mirror of
https://github.com/seigler/webgl-threejs-hello
synced 2025-07-27 01:36:14 +00:00
52 lines
No EOL
1.7 MiB
52 lines
No EOL
1.7 MiB
!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;o<s;o++)r=n[o],".."===r?i.pop():"."!==r&&""!==r&&i.push(r);return i.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},l=function(t){return function(r){var i=o(s(t),r);return e.require(i,t)}},c=function(e,t){var i=v&&v.createHot(e),n={id:e,exports:{},hot:i};return r[e]=n,t(n.exports,l(e),n),n.exports},u=function(e){return i[e]?u(i[e]):e},h=function(e,t){return u(o(s(e),t))},d=function(e,i){null==i&&(i="/");var a=u(e);if(n.call(r,a))return r[a].exports;if(n.call(t,a))return c(a,t[a]);throw new Error("Cannot find module '"+e+"' from '"+i+"'")};d.alias=function(e,t){i[t]=e};var p=/\.[^.\/]+$/,f=/\/index(\.[^\/]+)?$/,m=function(e){if(p.test(e)){var t=e.replace(p,"");n.call(i,t)&&i[t].replace(p,"")!==t+"/index"||(i[t]=e)}if(f.test(e)){var r=e.replace(f,"");n.call(i,r)||(i[r]=e)}};d.register=d.define=function(e,i){if(e&&"object"==typeof e)for(var a in e)n.call(e,a)&&d.register(a,e[a]);else t[e]=i,delete r[e],m(e)},d.list=function(){var e=[];for(var r in t)n.call(t,r)&&e.push(r);return e};var v=e._hmr&&new e._hmr(h,d,t,r);d._cache=r,d.hmr=v&&v.wrap,d.brunch=!0,e.require=d}}(),function(){var e,t="undefined"==typeof window?this:window,r=function(e,t,r){var i={},n=function(t,r){var a;try{return a=e(r+"/node_modules/"+t)}catch(o){if(o.toString().indexOf("Cannot find module")===-1)throw o;if(r.indexOf("node_modules")!==-1){var s=r.split("/"),l=s.lastIndexOf("node_modules"),c=s.slice(0,l).join("/");return n(t,c)}}return i};return function(a){if(a in t&&(a=t[a]),a){if("."!==a[0]&&r){var o=n(a,r);if(o!==i)return o}return e(a)}}};require.register("base64-js/index.js",function(e,t,i){t=r(t,{},"base64-js"),function(){"use strict";function t(e){var t=e.length;if(t%4>0)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<h;d+=4)r=c[e.charCodeAt(d)]<<18|c[e.charCodeAt(d+1)]<<12|c[e.charCodeAt(d+2)]<<6|c[e.charCodeAt(d+3)],s[l++]=r>>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;o<r;o+=3)i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),n.push(a(i));return n.join("")}function s(e){for(var t,r=e.length,i=r%3,n=[],a=16383,s=0,c=r-i;s<c;s+=a)n.push(o(e,s,s+a>c?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;d<p;++d)l[d]=h[d],c[h.charCodeAt(d)]=d;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}()}),require.register("buffer/index.js",function(e,i,n){i=r(i,{},"buffer");var a=i("buffer");a&&a.Buffer;!function(){"use strict";function r(){try{var e=new Uint8Array(1);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(t){return!1}}function n(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e){return this instanceof a?(a.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof e?o(this,e):"string"==typeof e?s(this,e,arguments.length>1?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<t;r++)e[r]=0;return e}function s(e,t,r){"string"==typeof r&&""!==r||(r="utf8");var i=0|y(t,r);return e=m(e,i),e.write(t,r),e}function l(e,t){if(a.isBuffer(t))return c(e,t);if(J(t))return u(e,t);if(null==t)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(t.buffer instanceof ArrayBuffer)return h(e,t);if(t instanceof ArrayBuffer)return d(e,t)}return t.length?p(e,t):f(e,t)}function c(e,t){var r=0|v(t.length);return e=m(e,r),t.copy(e,0,0,r),e}function u(e,t){var r=0|v(t.length);e=m(e,r);for(var i=0;i<r;i+=1)e[i]=255&t[i];return e}function h(e,t){var r=0|v(t.length);e=m(e,r);for(var i=0;i<r;i+=1)e[i]=255&t[i];return e}function d(e,t){return t.byteLength,a.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=a.prototype):e=h(e,new Uint8Array(t)),e}function p(e,t){var r=0|v(t.length);e=m(e,r);for(var i=0;i<r;i+=1)e[i]=255&t[i];return e}function f(e,t){var r,i=0;"Buffer"===t.type&&J(t.data)&&(r=t.data,i=0|v(r.length)),e=m(e,i);for(var n=0;n<i;n+=1)e[n]=255&r[n];return e}function m(e,t){a.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=a.prototype):e.length=t;var r=0!==t&&t<=a.poolSize>>>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;o<i;o++){var s=parseInt(t.substr(2*o,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[r+o]=s}return o}function w(e,t,r,i){return Y(G(t,e.length-r),e,r,i)}function _(e,t,r,i){return Y(W(t),e,r,i)}function S(e,t,r,i){return _(e,t,r,i)}function A(e,t,r,i){return Y(H(t),e,r,i)}function M(e,t,r,i){return Y(X(t,e.length-r),e,r,i)}function T(e,t,r){return 0===t&&r===e.length?q.fromByteArray(e):q.fromByteArray(e.slice(t,r))}function E(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var a=e[n],o=null,s=a>239?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;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=K));return r}function L(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;n++)i+=String.fromCharCode(127&e[n]);return i}function P(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;n++)i+=String.fromCharCode(e[n]);return i}function N(e,t,r){var i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var n="",a=t;a<r;a++)n+=V(e[a]);return n}function O(e,t,r){for(var i=e.slice(t,r),n="",a=0;a<i.length;a+=2)n+=String.fromCharCode(i[a]+256*i[a+1]);return n}function D(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)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||t<o)throw new RangeError("value is out of bounds");if(r+i>e.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<a;n++)e[r+n]=(t&255<<8*(i?n:1-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<a;n++)e[r+n]=t>>>8*(i?n:3-n)&255}function U(e,t,r,i,n,a){if(t>n||t<a)throw new RangeError("value is out of bounds");if(r+i>e.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;o<i;o++){if(r=e.charCodeAt(o),r>55295&&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<e.length;r++)t.push(255&e.charCodeAt(r));return t}function X(e,t){for(var r,i,n,a=[],o=0;o<e.length&&!((t-=2)<0);o++)r=e.charCodeAt(o),i=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<i&&!(n+r>=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);n<o&&e[n]===t[n];)++n;return n!==o&&(r=e[n],i=t[n]),r<i?-1:i<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!J(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new a(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;r++)t+=e[r].length;var i=new a(t),n=0;for(r=0;r<e.length;r++){var o=e[r];o.copy(i,n),n+=o.length}return i},a.byteLength=y,a.prototype._isBuffer=!0,a.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?E(this,0,e):x.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+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+n<e.length;n++)if(e[r+n]===t[i===-1?0:n-i]){if(i===-1&&(i=n),n-i+1===t.length)return r+i}else i=-1;return-1}if(t>2147483647?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),t<e&&(t=e);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(e,t),i.__proto__=a.prototype;else{var n=t-e;i=new a(n,(void 0));for(var o=0;o<n;o++)i[o]=this[o+e]}return i.length&&(i.parent=this.parent||this),i},a.prototype.readUIntLE=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<t&&(n*=256);)i+=this[e+a]*n;return i},a.prototype.readUIntBE=function(e,t,r){e=0|e,t=0|t,r||D(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(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<t&&(n*=256);)i+=this[e+a]*n;return n*=128,i>=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<r&&(n*=256);)this[t+a]=e/n&255;return t+r},a.prototype.writeUIntBE=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=r-1,a=1;for(this[t+n]=255&e;--n>=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<r&&(o*=256);)this[t+a]=(e/o>>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<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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<i-r&&(i=e.length-t+r);var n,o=i-r;if(this===e&&r<t&&t<i)for(n=o-1;n>=0;n--)e[n+t]=this[n+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(n=0;n<o;n++)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},a.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),r<t)throw new RangeError("end < start");if(r!==t&&0!==this.length){if(t<0||t>=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<r;i++)this[i]=e;else{var n=G(e.toString()),a=n.length;for(i=t;i<r;i++)this[i]=n[i%a]}return this}};var $=/[^+\/0-9A-Za-z-_]/g}()}),require.register("dat-gui/index.js",function(e,t,i){t=r(t,{},"dat-gui"),function(){i.exports=t("./vendor/dat.gui"),i.exports.color=t("./vendor/dat.color")}()}),require.register("dat-gui/vendor/dat.color.js",function(e,t,i){t=r(t,{},"dat-gui"),function(){var e=i.exports=e||{};e.color=e.color||{},e.utils=e.utils||{},e.utils.common=function(){var e=Array.prototype.forEach,t=Array.prototype.slice;return{BREAK:{},extend:function(e){return this.each(t.call(arguments,1),function(t){for(var r in t)this.isUndefined(t[r])||(e[r]=t[r])},this),e},defaults:function(e){return this.each(t.call(arguments,1),function(t){for(var r in t)this.isUndefined(e[r])&&(e[r]=t[r])},this),e},compose:function(){var e=t.call(arguments);return function(){for(var r=t.call(arguments),i=e.length-1;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;n<a;n++)if(n in t&&r.call(i,t[n],n)===this.BREAK)return}else for(var n in t)if(r.call(i,t[n],n)===this.BREAK)return},defer:function(e){setTimeout(e,0)},toArray:function(e){return e.toArray?e.toArray():t.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){return e!==e},isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return e===!1||e===!0},isFunction:function(e){return"[object Function]"===Object.prototype.toString.call(e)}}}(),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=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=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.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<<e)}}}(),e.color.toString,e.utils.common)}()}),require.register("dat-gui/vendor/dat.gui.js",function(e,t,i){t=r(t,{},"dat-gui"),function(){var e=i.exports=e||{};e.gui=e.gui||{},e.utils=e.utils||{},e.controllers=e.controllers||{},e.dom=e.dom||{},e.color=e.color||{},e.utils.css=function(){return{load:function(e,t){t=t||document;var r=t.createElement("link");r.type="text/css",r.rel="stylesheet",r.href=e,t.getElementsByTagName("head")[0].appendChild(r)},inject:function(e,t){t=t||document;var r=document.createElement("style");r.type="text/css",r.innerHTML=e,t.getElementsByTagName("head")[0].appendChild(r)}}}(),e.utils.common=function(){var e=Array.prototype.forEach,t=Array.prototype.slice;return{BREAK:{},extend:function(e){return this.each(t.call(arguments,1),function(t){for(var r in t)this.isUndefined(t[r])||(e[r]=t[r])},this),e},defaults:function(e){return this.each(t.call(arguments,1),function(t){for(var r in t)this.isUndefined(e[r])&&(e[r]=t[r])},this),e},compose:function(){var e=t.call(arguments);return function(){for(var r=t.call(arguments),i=e.length-1;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;n<a;n++)if(n in t&&r.call(i,t[n],n)===this.BREAK)return}else for(var n in t)if(r.call(i,t[n],n)===this.BREAK)return},defer:function(e){setTimeout(e,0)},toArray:function(e){return e.toArray?e.toArray():t.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){return e!==e},isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return e===!1||e===!0},isFunction:function(e){return"[object Function]"===Object.prototype.toString.call(e)}}}(),e.controllers.Controller=function(e){var t=function(e,t){this.initialValue=e[t],this.domElement=document.createElement("div"),this.object=e,this.property=t,this.__onChange=void 0,this.__onFinishChange=void 0};return e.extend(t.prototype,{onChange:function(e){return this.__onChange=e,this},onFinishChange:function(e){return this.__onFinishChange=e,this},setValue:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this},getValue:function(){return this.object[this.property]},updateDisplay:function(){return this},isModified:function(){return this.initialValue!==this.getValue()}}),t}(e.utils.common),e.dom.dom=function(e){function t(t){if("0"===t||e.isUndefined(t))return 0;var r=t.match(n);return e.isNull(r)?0:parseFloat(r[1])}var r={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},i={};e.each(r,function(t,r){e.each(t,function(e){i[e]=r})});var n=/(\d+(\.\d+)?)px/,a={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(t,r,i){e.isUndefined(r)&&(r=!0),e.isUndefined(i)&&(i=!0),t.style.position="absolute",r&&(t.style.left=0,t.style.right=0),i&&(t.style.top=0,t.style.bottom=0)},fakeEvent:function(t,r,n,a){n=n||{};var o=i[r];if(!o)throw new Error("Event type "+r+" not supported.");var s=document.createEvent(o);switch(o){case"MouseEvents":var l=n.x||n.clientX||0,c=n.y||n.clientY||0;s.initMouseEvent(r,n.bubbles||!1,n.cancelable||!0,window,n.clickCount||1,0,0,l,c,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var u=s.initKeyboardEvent||s.initKeyEvent;e.defaults(n,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),u(r,n.bubbles||!1,n.cancelable,window,n.ctrlKey,n.altKey,n.shiftKey,n.metaKey,n.keyCode,n.charCode);break;default:s.initEvent(r,n.bubbles||!1,n.cancelable||!0)}e.defaults(s,a),t.dispatchEvent(s)},bind:function(e,t,r,i){return i=i||!1,e.addEventListener?e.addEventListener(t,r,i):e.attachEvent&&e.attachEvent("on"+t,r),a},unbind:function(e,t,r,i){return i=i||!1,e.removeEventListener?e.removeEventListener(t,r,i):e.detachEvent&&e.detachEvent("on"+t,r),a},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var r=e.className.split(/ +/);r.indexOf(t)==-1&&(r.push(t),e.className=r.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return a},removeClass:function(e,t){if(t)if(void 0===e.className);else if(e.className===t)e.removeAttribute("class");else{var r=e.className.split(/ +/),i=r.indexOf(t);i!=-1&&(r.splice(i,1),e.className=r.join(" "))}else e.className=void 0;return a},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var r=getComputedStyle(e);return t(r["border-left-width"])+t(r["border-right-width"])+t(r["padding-left"])+t(r["padding-right"])+t(r.width)},getHeight:function(e){var r=getComputedStyle(e);return t(r["border-top-width"])+t(r["border-bottom-width"])+t(r["padding-top"])+t(r["padding-bottom"])+t(r.height)},getOffset:function(e){var t={left:0,top:0};if(e.offsetParent)do t.left+=e.offsetLeft,t.top+=e.offsetTop;while(e=e.offsetParent);return t},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}};return a}(e.utils.common),e.controllers.OptionController=function(e,t,r){
|
|
var i=function(e,n,a){i.superclass.call(this,e,n);var o=this;if(this.__select=document.createElement("select"),r.isArray(a)){var s={};r.each(a,function(e){s[e]=e}),a=s}r.each(a,function(e,t){var r=document.createElement("option");r.innerHTML=t,r.setAttribute("value",e),o.__select.appendChild(r)}),this.updateDisplay(),t.bind(this.__select,"change",function(){var e=this.options[this.selectedIndex].value;o.setValue(e)}),this.domElement.appendChild(this.__select)};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()),t},updateDisplay:function(){return this.__select.value=this.getValue(),i.superclass.prototype.updateDisplay.call(this)}}),i}(e.controllers.Controller,e.dom.dom,e.utils.common),e.controllers.NumberController=function(e,t){function r(e){return e=e.toString(),e.indexOf(".")>-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&&e<this.__min?e=this.__min:void 0!==this.__max&&e>this.__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;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value}),r.appendChild(s),r.appendChild(i),r.appendChild(n),r.appendChild(a),r.appendChild(o),F){var l=document.getElementById("dg-save-locally"),c=document.getElementById("dg-local-explain");l.style.display="block";var u=document.getElementById("dg-local-storage");"true"===localStorage.getItem(x(e,"isLocal"))&&u.setAttribute("checked","checked"),t(),p.bind(u,"change",function(){e.useLocalStorage=!e.useLocalStorage,t()})}var h=document.getElementById("dg-new-constructor");p.bind(h,"keydown",function(e){!e.metaKey||67!==e.which&&67!=e.keyCode||C.hide()}),p.bind(i,"click",function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),C.show(),h.focus(),h.select()}),p.bind(n,"click",function(){e.save()}),p.bind(a,"click",function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)}),p.bind(o,"click",function(){e.revert()})}function w(e){function t(t){return t.preventDefault(),n=t.clientX,p.addClass(e.__closeButton,k.CLASS_DRAG),p.bind(window,"mousemove",r),p.bind(window,"mouseup",i),!1}function r(t){return t.preventDefault(),e.width+=n-t.clientX,e.onResize(),n=t.clientX,!1}function i(){p.removeClass(e.__closeButton,k.CLASS_DRAG),p.unbind(window,"mousemove",r),p.unbind(window,"mouseup",i)}e.__resize_handle=document.createElement("div"),f.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"});var n;p.bind(e.__resize_handle,"mousedown",t),p.bind(e.__closeButton,"mousedown",t),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function _(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function S(e,t){var r={};return f.each(e.__rememberedObjects,function(i,n){var a={},o=e.__rememberedObjectIndecesToControllers[n];f.each(o,function(e,r){a[r]=t?e.initialValue:e.getValue()}),r[n]=a}),r}function A(e,t,r){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),r&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function M(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value==e.preset&&(e.__preset_select.selectedIndex=t)}function T(e,t){var r=e.__preset_select[e.__preset_select.selectedIndex];t?r.innerHTML=r.value+"*":r.innerHTML=r.value}function E(e){0!=e.length&&h(function(){E(e)}),f.each(e,function(e){e.updateDisplay()})}e.inject(r);var C,L,P="dg",N=72,O=20,D="Default",F=function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}(),R=!0,I=!1,U=[],k=function(e){function t(){localStorage.setItem(x(i,"gui"),JSON.stringify(i.getSaveObject()))}function r(){var e=i.getRoot();e.width+=1,f.defer(function(){e.width-=1})}var i=this;this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),p.addClass(this.domElement,P),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],e=e||{},e=f.defaults(e,{autoPlace:!0,width:k.DEFAULT_WIDTH}),e=f.defaults(e,{resizable:e.autoPlace,hideable:e.autoPlace}),f.isUndefined(e.load)?e.load={preset:D}:e.preset&&(e.load.preset=e.preset),f.isUndefined(e.parent)&&e.hideable&&U.push(this),e.resizable=f.isUndefined(e.parent)&&e.resizable,e.autoPlace&&f.isUndefined(e.scrollable)&&(e.scrollable=!0);var n=F&&"true"===localStorage.getItem(x(this,"isLocal"));if(Object.defineProperties(this,{parent:{get:function(){return e.parent}},scrollable:{get:function(){return e.scrollable}},autoPlace:{get:function(){return e.autoPlace}},preset:{get:function(){return i.parent?i.getRoot().preset:e.load.preset},set:function(t){i.parent?i.getRoot().preset=t:e.load.preset=t,M(this),i.revert()}},width:{get:function(){return e.width},set:function(t){e.width=t,_(i,t)}},name:{get:function(){return e.name},set:function(t){e.name=t,o&&(o.innerHTML=e.name)}},closed:{get:function(){return e.closed},set:function(t){e.closed=t,e.closed?p.addClass(i.__ul,k.CLASS_CLOSED):p.removeClass(i.__ul,k.CLASS_CLOSED),this.onResize(),i.__closeButton&&(i.__closeButton.innerHTML=t?k.TEXT_OPEN:k.TEXT_CLOSED)}},load:{get:function(){return e.load}},useLocalStorage:{get:function(){return n},set:function(e){F&&(n=e,e?p.bind(window,"unload",t):p.unbind(window,"unload",t),localStorage.setItem(x(i,"isLocal"),e))}}}),f.isUndefined(e.parent)){if(e.closed=!1,p.addClass(this.domElement,k.CLASS_MAIN),p.makeSelectable(this.domElement,!1),F&&n){i.useLocalStorage=!0;var a=localStorage.getItem(x(this,"gui"));a&&(e.load=JSON.parse(a))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=k.TEXT_CLOSED,p.addClass(this.__closeButton,k.CLASS_CLOSE_BUTTON),this.domElement.appendChild(this.__closeButton),p.bind(this.__closeButton,"click",function(){i.closed=!i.closed})}else{void 0===e.closed&&(e.closed=!0);var o=document.createTextNode(e.name);p.addClass(o,"controller-name");var s=v(i,o),l=function(e){return e.preventDefault(),i.closed=!i.closed,!1};p.addClass(this.__ul,k.CLASS_CLOSED),p.addClass(s,"title"),p.bind(s,"click",l),e.closed||(this.closed=!1)}e.autoPlace&&(f.isUndefined(e.parent)&&(R&&(L=document.createElement("div"),p.addClass(L,P),p.addClass(L,k.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(L),R=!1),L.appendChild(this.domElement),p.addClass(this.domElement,k.CLASS_AUTO_PLACE)),this.parent||_(i,e.width)),p.bind(window,"resize",function(){i.onResize()}),p.bind(this.__ul,"webkitTransitionEnd",function(){i.onResize()}),p.bind(this.__ul,"transitionend",function(){i.onResize()}),p.bind(this.__ul,"oTransitionEnd",function(){i.onResize()}),this.onResize(),e.resizable&&w(this);i.getRoot();e.parent||r()};return k.toggleHide=function(){I=!I,f.each(U,function(e){e.domElement.style.zIndex=I?-999:999,e.domElement.style.opacity=I?0:1})},k.CLASS_AUTO_PLACE="a",k.CLASS_AUTO_PLACE_CONTAINER="ac",k.CLASS_MAIN="main",k.CLASS_CONTROLLER_ROW="cr",k.CLASS_TOO_TALL="taller-than-window",k.CLASS_CLOSED="closed",k.CLASS_CLOSE_BUTTON="close-button",k.CLASS_DRAG="drag",k.DEFAULT_WIDTH=245,k.TEXT_CLOSED="Close Controls",k.TEXT_OPEN="Open Controls",p.bind(window,"keydown",function(e){"text"===document.activeElement.type||e.which!==N&&e.keyCode!=N||k.toggleHide()},!1),f.extend(k.prototype,{add:function(e,t){return m(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return m(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.slice(this.__controllers.indexOf(e),1);var t=this;f.defer(function(){t.onResize()})},destroy:function(){this.autoPlace&&L.removeChild(this.domElement)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var r=new k(t);this.__folders[e]=r;var i=v(this,r.domElement);return p.addClass(i,"folder"),r},open:function(){this.closed=!1},close:function(){this.closed=!0},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=p.getOffset(e.__ul).top,r=0;f.each(e.__ul.childNodes,function(t){e.autoPlace&&t===e.__save_row||(r+=p.getHeight(t))}),window.innerHeight-t-O<r?(p.addClass(e.domElement,k.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-O+"px"):(p.removeClass(e.domElement,k.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&f.defer(function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"}),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},remember:function(){if(f.isUndefined(C)&&(C=new d,C.domElement.innerHTML=t),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;f.each(Array.prototype.slice.call(arguments),function(t){0==e.__rememberedObjects.length&&b(e),e.__rememberedObjects.indexOf(t)==-1&&e.__rememberedObjects.push(t)}),this.autoPlace&&_(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(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,'<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox"/> Automatically save\n values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n easier to work incrementally, but <code>localStorage</code> is fragile,\n and your friends may not see the same values you do.\n \n </div>\n \n </div>\n\n</div>',".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<<e)}}}(),e.color.toString,e.utils.common),e.color.interpret,e.utils.common),e.utils.requestAnimationFrame=function(){return window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e,t){window.setTimeout(e,1e3/60)}}(),e.dom.CenteredDiv=function(e,t){var r=function(){this.backgroundElement=document.createElement("div"),t.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear"}),e.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),t.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var r=this;e.bind(this.backgroundElement,"click",function(){r.hide()})};return r.prototype.show=function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),t.defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})},r.prototype.hide=function(){var t=this,r=function(){t.domElement.style.display="none",t.backgroundElement.style.display="none",e.unbind(t.domElement,"webkitTransitionEnd",r),e.unbind(t.domElement,"transitionend",r),e.unbind(t.domElement,"oTransitionEnd",r)};e.bind(this.domElement,"webkitTransitionEnd",r),e.bind(this.domElement,"transitionend",r),e.bind(this.domElement,"oTransitionEnd",r),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"},r.prototype.layout=function(){this.domElement.style.left=window.innerWidth/2-e.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-e.getHeight(this.domElement)/2+"px"},r}(e.dom.dom,e.utils.common),e.dom.dom,e.utils.common)}()}),require.register("ieee754/index.js",function(e,t,i){t=r(t,{},"ieee754"),function(){e.read=function(e,t,r,i,n){var a,o,s=8*n-i-1,l=(1<<s)-1,c=l>>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<<c)-1,h=u>>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<<n|s,c+=n;c>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=[];++m<t;)d&&d[m].run();m=-1,t=p.length}d=null,f=!1,n(e)}}function s(e,t){this.fun=e,this.array=t}function l(){}var c,u,h=i.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:e}catch(r){c=e}try{u="function"==typeof clearTimeout?clearTimeout:t}catch(r){u=t}}();var d,p=[],f=!1,m=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];p.push(new s(e,t)),1!==p.length||f||r(o)},s.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}}()}),require.register("three-full/builds/Three.cjs.js",function(e,i,n){i=r(i,{},"three-full");var a=i("buffer");a&&a.Buffer;!function(){function r(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&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;r<i;++r)e[r]<t&&(t=e[r]);return t}function L(e){if(0===e.length)return-(1/0);for(var t=e[0],r=1,i=e.length;r<i;++r)e[r]>t&&(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;c<r;c++)for(l=0;l<t;l++){var _=d[c][l+1],S=d[c][l],A=d[c+1][l],T=d[c+1][l+1];(0!==c||o>0)&&m.push(_,S,T),(c!==r-1||u<Math.PI)&&m.push(S,A,T)}this.setIndex(m),this.addAttribute("position",new M(v,3)),this.addAttribute("normal",new M(g,3)),this.addAttribute("uv",new M(y,2))}function D(){Object.defineProperty(this,"id",{value:yu++}),this.uuid=Fs.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=al,this.side=Js,this.flatShading=!1,this.vertexColors=tl,this.opacity=1,this.transparent=!1,this.blendSrc=xl,this.blendDst=bl,this.blendEquation=ul,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Ll,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function F(e){D.call(this),this.type="MeshBasicMaterial",this.color=new u(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Fl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(e)}function R(e){D.call(this),this.type="LineBasicMaterial",this.color=new u(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.lights=!1,this.setValues(e)}function I(e,t){this.origin=void 0!==e?e:new i,this.direction=void 0!==t?t:new i}function U(e,t,r){this.a=void 0!==e?e:new i,this.b=void 0!==t?t:new i,this.c=void 0!==r?r:new i}function k(e,t){c.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new P,this.material=void 0!==t?t:new F({color:16777215*Math.random()}),this.drawMode=iu,this.updateMorphTargets()}function B(e,t,r){1===r&&console.error("Line: parameter LinePieces no longer supported. Use LineSegments instead."),c.call(this),this.type="Line",this.geometry=void 0!==e?e:new P,this.material=void 0!==t?t:new R({color:16777215*Math.random()})}function z(e,t,r){this._mixer=e,this._clip=t,this._localRoot=r||null;for(var i=t.tracks,n=i.length,a=new Array(n),o={endingStart:eu,endingEnd:eu},s=0;s!==n;++s){var l=i[s].createInterpolant(null);a[s]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Qc,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function j(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r}function V(e,t,r,i){j.call(this,e,t,r,i)}function G(e,t,r){var i=r||W.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}function W(e,t,r){this.path=t,this.parsedPath=r||W.parseTrackName(t),this.node=W.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function X(e,t,r){this.binding=e,this.valueSize=r;var i,n=Float64Array;switch(t){case"quaternion":i=this._slerp;break;case"string":case"bool":n=Array,i=this._select;break;default:i=this._lerp}this.buffer=new n(4*r),this._mixBufferRegion=i,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function H(e,t,r,i){j.call(this,e,t,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Y(e,t,r,i){j.call(this,e,t,r,i)}function q(e,t,r,i){if(void 0===e)throw new Error("KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=wu.convertArray(t,this.TimeBufferType),this.values=wu.convertArray(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}function Q(e,t,r){q.call(this,e,t,r)}function J(e,t,r,i){q.call(this,e,t,r,i)}function Z(e,t,r,i){q.call(this,e,t,r,i)}function K(e,t,r,i){j.call(this,e,t,r,i)}function $(e,t,r,i){q.call(this,e,t,r,i)}function ee(e,t,r,i){q.call(this,e,t,r,i)}function te(e,t,r,i){q.call(this,e,t,r,i)}function re(e,t,r){this.name=e,this.tracks=r,this.duration=void 0!==t?t:-1,this.uuid=Fs.generateUUID(),this.duration<0&&this.resetDuration()}function ie(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Z;case"vector":case"vector2":case"vector3":case"vector4":return te;case"color":return J;case"quaternion":return $;case"bool":case"boolean":return Q;case"string":return ee}throw new Error("KeyframeTrack: Unsupported typeName: "+e)}function ne(e){if(void 0===e.type)throw new Error("KeyframeTrack: track type undefined, can not parse");var t=ie(e.type);if(void 0===e.times){var r=[],i=[];wu.flattenJSON(e.keys,r,i,"value"),e.times=r,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}function ae(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function oe(){c.call(this),this.type="Bone"}function se(e,t,r,i,n,a){m.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:n,depthSegments:a},this.fromBufferGeometry(new le(e,t,r,i,n,a)),this.mergeVertices()}function le(e,t,r,n,a,o){function s(e,t,r,n,a,o,s,m,v,g,y){var x,b,w=o/v,_=s/g,S=o/2,A=s/2,M=m/2,T=v+1,E=g+1,C=0,L=0,P=new i;for(b=0;b<E;b++){var N=b*_-A;for(x=0;x<T;x++){var O=x*w-S;P[e]=O*n,P[t]=N*a,P[r]=M,u.push(P.x,P.y,P.z),P[e]=0,P[t]=0,P[r]=m>0?1:-1,h.push(P.x,P.y,P.z),d.push(x/v),d.push(1-b/g),C+=1}}for(b=0;b<g;b++)for(x=0;x<v;x++){var D=p+x+T*b,F=p+x+T*(b+1),R=p+(x+1)+T*(b+1),I=p+(x+1)+T*b;c.push(D,F,I),c.push(F,R,I),L+=6}l.addGroup(f,L,y),f+=L,p+=C}P.call(this),this.type="BoxBufferGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:n,heightSegments:a,depthSegments:o};var l=this;e=e||1,t=t||1,r=r||1,n=Math.floor(n)||1,a=Math.floor(a)||1,o=Math.floor(o)||1;var c=[],u=[],h=[],d=[],p=0,f=0;s("z","y","x",-1,-1,r,t,e,o,a,0),s("z","y","x",1,-1,r,t,-e,o,a,1),s("x","z","y",1,1,e,r,t,n,o,2),s("x","z","y",1,-1,e,r,-t,n,o,3),s("x","y","z",1,-1,e,t,r,n,a,4),s("x","y","z",-1,-1,e,t,-r,n,a,5),this.setIndex(c),this.addAttribute("position",new M(u,3)),this.addAttribute("normal",new M(h,3)),this.addAttribute("uv",new M(d,2))}function ce(e,t,r,i,n,a,o,s){m.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:s},this.fromBufferGeometry(new ue(e,t,r,i,n,a,o,s)),this.mergeVertices()}function ue(e,t,r,n,a,o,s,l){function c(){var o,c,u=new i,f=new i,w=0,_=(t-e)/r;for(c=0;c<=a;c++){var S=[],A=c/a,M=A*(t-e)+e;for(o=0;o<=n;o++){var T=o/n,E=T*l+s,C=Math.sin(E),L=Math.cos(E);f.x=M*C,f.y=-A*r+x,f.z=M*L,p.push(f.x,f.y,f.z),u.set(C,_,L).normalize(),m.push(u.x,u.y,u.z),v.push(T,1-A),S.push(g++)}y.push(S)}for(o=0;o<n;o++)for(c=0;c<a;c++){var P=y[c][o],N=y[c+1][o],O=y[c+1][o+1],D=y[c][o+1];d.push(P,N,D),d.push(N,O,D),w+=6}h.addGroup(b,w,0),b+=w}function u(r){var a,o,c,u=new f,y=new i,w=0,_=r===!0?e:t,S=r===!0?1:-1;for(o=g,a=1;a<=n;a++)p.push(0,x*S,0),m.push(0,S,0),v.push(.5,.5),g++;for(c=g,a=0;a<=n;a++){var A=a/n,M=A*l+s,T=Math.cos(M),E=Math.sin(M);y.x=_*E,y.y=x*S,y.z=_*T,p.push(y.x,y.y,y.z),m.push(0,S,0),u.x=.5*T+.5,u.y=.5*E*S+.5,v.push(u.x,u.y),g++}for(a=0;a<n;a++){var C=o+a,L=c+a;r===!0?d.push(L,L+1,C):d.push(L+1,L,C),w+=3}h.addGroup(b,w,r===!0?1:2),b+=w}P.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:n,heightSegments:a,openEnded:o,thetaStart:s,thetaLength:l};var h=this;e=void 0!==e?e:1,t=void 0!==t?t:1,r=r||1,n=Math.floor(n)||8,a=Math.floor(a)||1,o=void 0!==o&&o,s=void 0!==s?s:0,l=void 0!==l?l:2*Math.PI;var d=[],p=[],m=[],v=[],g=0,y=[],x=r/2,b=0;c(),o===!1&&(e>0&&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<h;a++){var y=a*p-s;for(n=0;n<u;n++){var x=n*d-o;m.push(x,-y,0),v.push(0,0,1),g.push(n/l),g.push(1-a/c)}}for(a=0;a<c;a++)for(n=0;n<l;n++){var b=n+u*a,w=n+u*(a+1),_=n+1+u*(a+1),S=n+1+u*a;f.push(b,w,S),f.push(w,_,S)}this.setIndex(f),this.addAttribute("position",new M(m,3)),this.addAttribute("normal",new M(v,3)),this.addAttribute("uv",new M(g,2))}function be(e,t,r){var i=this,n=!1,a=0,o=0,s=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){o++,n===!1&&void 0!==i.onStart&&i.onStart(e,a,o),n=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,o),a===o&&(n=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this}}function we(e){this.manager=void 0!==e?e:Du}function _e(e){R.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function Se(e){D.call(this),this.type="MeshDepthMaterial",this.depthPacking=fu,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(e)}function Ae(e){D.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new i,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(e)}function Me(e){D.call(this),this.type="MeshLambertMaterial",this.color=new u(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new u(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Fl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Te(e){D.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new f(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ee(e){D.call(this),this.type="MeshPhongMaterial",this.color=new u(16777215),this.specular=new u(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new u(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new f(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Fl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ce(e){D.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new u(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new u(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=vu,this.normalScale=new f(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Le(e){Ce.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)}function Pe(e){Ee.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function Ne(e){D.call(this),this.type="PointsMaterial",this.color=new u(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.lights=!1,
|
|
this.setValues(e)}function Oe(e){pe.call(this,e),this.type="RawShaderMaterial"}function De(e){D.call(this),this.type="ShadowMaterial",this.color=new u(0),this.transparent=!0,this.setValues(e)}function Fe(e){D.call(this),this.type="SpriteMaterial",this.color=new u(16777215),this.map=null,this.rotation=0,this.sizeAttenuation=!0,this.lights=!1,this.transparent=!0,this.setValues(e)}function Re(e){this.manager=void 0!==e?e:Du,this.textures={}}function Ie(e){this.manager=void 0!==e?e:Du}function Ue(e){this.manager=void 0!==e?e:Du}function ke(){}function Be(e){"boolean"==typeof e&&(console.warn("JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:Du,this.withCredentials=!1}function ze(e,t){this.normal=void 0!==e?e:new i(1,0,0),this.constant=void 0!==t?t:0}function je(e,t,r,i){this.ray=new I(e,t),this.near=r||0,this.far=i||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Ve(e,t){return e.distance-t.distance}function Ge(e,t,r,i){if(e.visible!==!1&&(e.raycast(t,r),i===!0))for(var n=e.children,a=0,o=n.length;a<o;a++)Ge(n[a],t,r,!0)}function We(e,t,r){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==r?r:0,this}function Xe(e,t,r,i){m.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:i},this.fromBufferGeometry(new He(e,t,r,i)),this.mergeVertices()}function He(e,t,r,n){function a(e){for(var r=new i,n=new i,a=new i,s=0;s<t.length;s+=3)h(t[s+0],r),h(t[s+1],n),h(t[s+2],a),o(r,n,a,e)}function o(e,t,r,i){var n,a,o=Math.pow(2,i),s=[];for(n=0;n<=o;n++){s[n]=[];var l=e.clone().lerp(r,n/o),c=t.clone().lerp(r,n/o),h=o-n;for(a=0;a<=h;a++)0===a&&n===o?s[n][a]=l:s[n][a]=l.clone().lerp(c,a/h)}for(n=0;n<o;n++)for(a=0;a<2*(o-n)-1;a++){var d=Math.floor(a/2);a%2===0?(u(s[n][d+1]),u(s[n+1][d]),u(s[n][d])):(u(s[n][d+1]),u(s[n+1][d+1]),u(s[n+1][d]))}}function s(e){for(var t=new i,r=0;r<g.length;r+=3)t.x=g[r+0],t.y=g[r+1],t.z=g[r+2],t.normalize().multiplyScalar(e),g[r+0]=t.x,g[r+1]=t.y,g[r+2]=t.z}function l(){for(var e=new i,t=0;t<g.length;t+=3){e.x=g[t+0],e.y=g[t+1],e.z=g[t+2];var r=m(e)/2/Math.PI+.5,n=v(e)/Math.PI+.5;y.push(r,1-n)}d(),c()}function c(){for(var e=0;e<y.length;e+=6){var t=y[e+0],r=y[e+2],i=y[e+4],n=Math.max(t,r,i),a=Math.min(t,r,i);n>.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;l<g.length;l+=9,c+=6){e.set(g[l+0],g[l+1],g[l+2]),t.set(g[l+3],g[l+4],g[l+5]),r.set(g[l+6],g[l+7],g[l+8]),a.set(y[c+0],y[c+1]),o.set(y[c+2],y[c+3]),s.set(y[c+4],y[c+5]),n.copy(e).add(t).add(r).divideScalar(3);var u=m(n);p(a,c+0,e,u),p(o,c+2,t,u),p(s,c+4,r,u)}}function p(e,t,r,i){i<0&&1===e.x&&(y[t]=e.x-1),0===r.x&&0===r.z&&(y[t]=i/2/Math.PI+.5)}function m(e){return Math.atan2(e.z,-e.x)}function v(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}P.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:n},r=r||1,n=n||0;var g=[],y=[];a(n),s(r),l(),this.addAttribute("position",new M(g,3)),this.addAttribute("normal",new M(g.slice(),3)),this.addAttribute("uv",new M(y,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}function Ye(e,t){m.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new qe(e,t)),this.mergeVertices()}function qe(e,t){var r=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];He.call(this,r,i,e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Qe(e,t,r,i,n){m.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:i,arc:n},this.fromBufferGeometry(new Je(e,t,r,i,n)),this.mergeVertices()}function Je(e,t,r,n,a){P.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:n,arc:a},e=e||1,t=t||.4,r=Math.floor(r)||8,n=Math.floor(n)||6,a=a||2*Math.PI;var o,s,l=[],c=[],u=[],h=[],d=new i,p=new i,f=new i;for(o=0;o<=r;o++)for(s=0;s<=n;s++){var m=s/n*a,v=o/r*Math.PI*2;p.x=(e+t*Math.cos(v))*Math.cos(m),p.y=(e+t*Math.cos(v))*Math.sin(m),p.z=t*Math.sin(v),c.push(p.x,p.y,p.z),d.x=e*Math.cos(m),d.y=e*Math.sin(m),f.subVectors(p,d).normalize(),u.push(f.x,f.y,f.z),h.push(s/n),h.push(o/r)}for(o=1;o<=r;o++)for(s=1;s<=n;s++){var g=(n+1)*o+s-1,y=(n+1)*(o-1)+s-1,x=(n+1)*(o-1)+s,b=(n+1)*o+s;l.push(g,y,b),l.push(y,x,b)}this.setIndex(l),this.addAttribute("position",new M(c,3)),this.addAttribute("normal",new M(u,3)),this.addAttribute("uv",new M(h,2))}function Ze(e,t){this.start=void 0!==e?e:new i,this.end=void 0!==t?t:new i}function Ke(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new rt,this.unassigned=new rt,this.vertices=[]}function $e(){this.normal=new i,this.midpoint=new i,this.area=0,this.constant=0,this.outside=null,this.mark=Zu,this.edge=null}function et(e,t){this.vertex=e,this.prev=null,this.next=null,this.twin=null,this.face=t}function tt(e){this.point=e,this.prev=null,this.next=null,this.face=null}function rt(){this.head=null,this.tail=null}function it(e){m.call(this),this.fromBufferGeometry(new nt(e)),this.mergeVertices()}function nt(e){P.call(this);var t=[],r=[];void 0===Ke&&console.error("ConvexBufferGeometry: ConvexBufferGeometry relies on QuickHull");for(var i=(new Ke).setFromPoints(e),n=i.faces,a=0;a<n.length;a++){var o=n[a],s=o.edge;do{var l=s.head().point;t.push(l.x,l.y,l.z),r.push(o.normal.x,o.normal.y,o.normal.z),s=s.next}while(s!==o.edge)}this.addAttribute("position",new M(t,3)),this.addAttribute("normal",new M(r,3))}function at(){this.type="Curve",this.arcLengthDivisions=200}function ot(){at.call(this)}function st(e){at.call(this),this.scale=void 0===e?5:e}function lt(e){at.call(this),this.scale=void 0===e?70:e}function ct(){at.call(this)}function ut(){at.call(this)}function ht(e){at.call(this),this.scale=void 0===e?10:e}function dt(e){at.call(this),this.scale=void 0===e?10:e}function pt(e){at.call(this),this.scale=void 0===e?10:e}function ft(e){at.call(this),this.scale=void 0===e?10:e}function mt(e){at.call(this),this.scale=void 0===e?1:e}function vt(e){at.call(this),this.scale=void 0===e?40:e}function gt(e){at.call(this),this.scale=void 0===e?40:e}function yt(e){at.call(this),this.scale=void 0===e?40:e}function xt(e){at.call(this),this.scale=void 0===e?40:e}function bt(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new de,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new de,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function wt(e,t,n,a){function o(){var t,r=new P,n=[],o=new i,c=new i;e.geometry.isGeometry?r.fromGeometry(e.geometry):r.copy(e.geometry);var m=r.attributes.position,v=r.attributes.normal;if(null!==r.index){var g=r.index;for(t=0;t<g.count;t++)o.fromBufferAttribute(m,g.getX(t)),c.fromBufferAttribute(v,g.getX(t)),s(n,o,c)}else for(t=0;t<m.count;t++)o.fromBufferAttribute(m,t),c.fromBufferAttribute(v,t),s(n,o,c);for(n=l(n,p.set(1,0,0)),n=l(n,p.set(-1,0,0)),n=l(n,p.set(0,1,0)),n=l(n,p.set(0,-1,0)),n=l(n,p.set(0,0,1)),n=l(n,p.set(0,0,-1)),t=0;t<n.length;t++){var y=n[t];d.push(.5+y.position.x/a.x,.5+y.position.y/a.y),y.position.applyMatrix4(f),u.push(y.position.x,y.position.y,y.position.z),h.push(y.normal.x,y.normal.y,y.normal.z)}}function s(t,r,i){r.applyMatrix4(e.matrixWorld),r.applyMatrix4(m),t.push(new _t(r.clone(),i.clone()))}function l(e,t){for(var r=[],i=.5*Math.abs(a.dot(t)),n=0;n<e.length;n+=3){var o,s,l,u,h,d,p,f=0,m=e[n+0].position.dot(t)-i,v=e[n+1].position.dot(t)-i,g=e[n+2].position.dot(t)-i;switch(o=m>0,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<this.variables.length;n++){var a=i.variables[n];a.renderTargets[0]=i.createRenderTarget(e,t,a.wrapS,a.wrapT,a.minFilter,a.magFilter),a.renderTargets[1]=i.createRenderTarget(e,t,a.wrapS,a.wrapT,a.minFilter,a.magFilter),i.renderTexture(a.initialValueTexture,a.renderTargets[0]),i.renderTexture(a.initialValueTexture,a.renderTargets[1]);var o=a.material,s=o.uniforms;if(null!==a.dependencies)for(var l=0;l<a.dependencies.length;l++){var c=a.dependencies[l];if(c.name!==a.name){for(var u=!1,h=0;h<this.variables.length;h++)if(c.name===i.variables[h].name){u=!0;break}if(!u)return"Variable dependency not found. Variable="+a.name+", dependency="+c.name}s[c.name]={value:null},o.fragmentShader="\nuniform sampler2D "+c.name+";\n"+o.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){for(var e=this,t=this.currentTextureIndex,r=0===this.currentTextureIndex?1:0,i=0,n=this.variables.length;i<n;i++){var a=e.variables[i];if(null!==a.dependencies)for(var o=a.material.uniforms,s=0,l=a.dependencies.length;s<l;s++){var c=a.dependencies[s];o[c.name].value=c.renderTargets[t].texture}e.doRenderTarget(a.material,a.renderTargets[r])}this.currentTextureIndex=r},this.getCurrentRenderTarget=function(e){return e.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(e){return e.renderTargets[0===this.currentTextureIndex?1:0]},this.addResolutionDefine=i,this.createShaderMaterial=n,this.createRenderTarget=function(r,i,n,a,o,s){r=r||e,i=i||t,n=n||Zl,a=a||Zl,o=o||$l,s=s||$l;var l=new ge(r,i,{wrapS:n,wrapT:a,minFilter:o,magFilter:s,format:xc,type:/(iPad|iPhone|iPod)/g.test(navigator.userAgent)?dc:hc,stencilBuffer:!1,depthBuffer:!1});return l},this.createTexture=function(){var r=new Float32Array(e*t*4),i=new Mt(r,e,t,xc,hc);return i.needsUpdate=!0,i},this.renderTexture=function(e,t){c.texture.value=e,this.doRenderTarget(u,t),c.texture.value=null},this.doRenderTarget=function(e,t){h.material=e,r.render(s,l,t),h.material=u}}function Et(e,t){c.call(this),this.type="Points",this.geometry=void 0!==e?e:new P,this.material=void 0!==t?t:new Ne({color:16777215*Math.random()})}function Ct(){P.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Lt(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Pt(e,t,r){Lt.call(this,e,t),this.meshPerAttribute=r||1}function Nt(e,t,r,i){this.data=e,this.itemSize=t,this.offset=r,this.normalized=i===!0}function Ot(e){P.call(this),this.type="WireframeGeometry";var t,r,n,a,o,s,l,c,u,h,d=[],p=[0,0],f={},m=["a","b","c"];if(e&&e.isGeometry){var v=e.faces;for(t=0,n=v.length;t<n;t++){var g=v[t];for(r=0;r<3;r++)l=g[m[r]],c=g[m[(r+1)%3]],p[0]=Math.min(l,c),p[1]=Math.max(l,c),u=p[0]+","+p[1],void 0===f[u]&&(f[u]={index1:p[0],index2:p[1]})}for(u in f)s=f[u],h=e.vertices[s.index1],d.push(h.x,h.y,h.z),h=e.vertices[s.index2],d.push(h.x,h.y,h.z)}else if(e&&e.isBufferGeometry){var y,x,b,w,_,S,A,T;if(h=new i,null!==e.index){for(y=e.attributes.position,x=e.index,b=e.groups,0===b.length&&(b=[{start:0,count:x.count,materialIndex:0}]),a=0,o=b.length;a<o;++a)for(w=b[a],_=w.start,S=w.count,t=_,n=_+S;t<n;t+=3)for(r=0;r<3;r++)l=x.getX(t+r),c=x.getX(t+(r+1)%3),p[0]=Math.min(l,c),p[1]=Math.max(l,c),u=p[0]+","+p[1],void 0===f[u]&&(f[u]={index1:p[0],index2:p[1]});for(u in f)s=f[u],h.fromBufferAttribute(y,s.index1),d.push(h.x,h.y,h.z),h.fromBufferAttribute(y,s.index2),d.push(h.x,h.y,h.z)}else for(y=e.attributes.position,t=0,n=y.count/3;t<n;t++)for(r=0;r<3;r++)A=3*t+r,h.fromBufferAttribute(y,A),d.push(h.x,h.y,h.z),T=3*t+(r+1)%3,h.fromBufferAttribute(y,T),d.push(h.x,h.y,h.z)}this.addAttribute("position",new M(d,3))}function Dt(){c.call(this),this.type="Group"}function Ft(e,t){var i=this;if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,a=this.bones.length;n<a;n++)i.boneInverses.push(new r)}}function Rt(e,t){k.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new r,this.bindMatrixInverse=new r;var i=this.initBones(),n=new Ft(i);this.bind(n,this.matrixWorld),this.normalizeSkinWeights()}function It(){this.id=0,this.data=null}function Ut(){}function kt(e,t){c.call(this),this.type="Light",this.color=new u(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function Bt(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new f(512,512),this.map=null,this.matrix=new r}function zt(e,t,r,i){kt.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==r?r:0,this.decay=void 0!==i?i:1,this.shadow=new Bt(new de(90,1,.5,500))}function jt(){Bt.call(this,new me((-5),5,5,(-5),.5,500))}function Vt(e,t){kt.call(this,e,t),this.type="DirectionalLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.target=new c,this.shadow=new jt}function Gt(){Bt.call(this,new de(50,1,.5,500))}function Wt(e,t,r,i,n,a){kt.call(this,e,t),this.type="SpotLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.target=new c,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==r?r:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==n?n:0,this.decay=void 0!==a?a:1,this.shadow=new Gt}function Xt(e,t,r){kt.call(this,e,r),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(c.DefaultUp),this.updateMatrix(),this.groundColor=new u(t)}function Ht(e,t){kt.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function Yt(e,t){B.call(this,e,t),this.type="LineSegments"}function qt(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={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Qt(e){this.manager=void 0!==e?e:Du,this._parser=null}function Jt(e,t){B.call(this,e,t),this.type="LineLoop"}function Zt(e,t,r){ge.call(this,e,t,r),this.activeCubeFace=0,this.activeMipMapLevel=0}function Kt(e){this.manager=void 0!==e?e:Du,this._parser=null}function $t(e,t,r,i,n,a,o,s,l,c){e=void 0!==e?e:[],t=void 0!==t?t:Gl,ve.call(this,e,t,r,i,n,a,o,s,l,c),this.flipY=!1}function er(e){this.uuid=Fs.generateUUID(),this.name="",this.type=e,this.userData={}}function tr(e,t){er.call(this,e),t=t||{},this.shared=void 0===t.shared||t.shared,this.unique=void 0!==t.unique&&t.unique}function rr(e){tr.call(this,"v2",{shared:!1}),this.index=e||0}function ir(e){tr.call(this,"v3"),this.scope=e||ir.LOCAL}function nr(e){tr.call(this,"v3"),this.scope=e||nr.LOCAL}function ar(e,t){t=t||{},t.shared=void 0!==t.shared&&t.shared,tr.call(this,e,t),this.readonly=!1}function or(e){ar.call(this,"f"),this.value=e||0}function sr(e,t,r){or.call(this),this.scale=void 0!==e?e:1,this.scope=t||sr.GLOBAL,this.timeScale=void 0!==r?r:1!==this.scale}function lr(e,t){tr.call(this),this.eval(e||lr.PI,t)}function cr(e,t){tr.call(this,"v3"),this.setScope(e||cr.POSITION),this.setCamera(t)}function ur(){if(null===em){var e=new ArrayBuffer(2),t=new Uint8Array(e),r=new Uint16Array(e);t[0]=170,t[1]=187,em=43707===r[0]}return em}function hr(e,t,r,i,n){var a,o=t.BYTES_PER_ELEMENT;if(n===ur()||1===o)a=new t(e,r,i);else{var s=new DataView(e,r,i*o),l=rm[t.name],c=!n,u=0;for(a=new t(i);u<i;u++)a[u]=s[l](u*o,c)}return a}function dr(e){var t=new Uint8Array(e),r=t[0],i=t[1],n=!!(i>>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<s;y++){for(u="";x<t.length&&(h=t[x],x++,0!==h);)u+=String.fromCharCode(h);i=t[x],d=i>>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<r;a+=i)o=si(a,e[a],e[a+1],o);else for(a=r-i;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.x<a.x?n.x<o.x?n.x:o.x:a.x<o.x?a.x:o.x,l=n.y<a.y?n.y<o.y?n.y:o.y:a.y<o.y?a.y:o.y,c=n.x>a.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<a;n++)o=t[n]*i,s=n<a-1?t[n+1]*i:e.length,l=Ur(e,o,s,i,!1),l===l.next&&(l.steiner=!0),c.push(Zr(l));for(c.sort(Xr),n=0;n<c.length;n++)Hr(c[n],r),r=kr(r,r.next);return r}function Xr(e,t){return e.x-t.x}function Hr(e,t){if(t=Yr(e,t)){var r=oi(t,e);kr(r,r.next)}}function Yr(e,t){var r,i=t,n=e.x,a=e.y,o=-(1/0);do{if(a<=i.y&&a>=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.next.x?i:i.next}}i=i.next}while(i!==t);if(!r)return null;if(n===o)return r.prev;var l,c=r,u=r.x,h=r.y,d=1/0;for(i=r.next;i!==c;)n>=i.x&&i.x>=u&&n!==i.x&&Kr(a<h?n:o,a,u,h,a<h?o:n,a,i.x,i.y)&&(l=Math.abs(a-i.y)/(n-i.x),(l<d||l===d&&i.x>r.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;t<c&&(s++,i=i.nextZ,i);t++);for(l=c;s>0||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<r.x&&(r=t),t=t.next;while(t!==e);return r}function Kr(e,t,r,i,n,a,o,s){return(n-o)*(t-s)-(e-o)*(a-s)>=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;a<r;a+=i)n+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return n}function hi(e){var t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function di(e,t){for(var r=0;r<t.length;r++)e.push(t[r].x),e.push(t[r].y)}function pi(){this.type="ShapePath",this.color=new u,this.subPaths=[],this.currentPath=null}function fi(e){c.call(this),this.material=e,this.render=function(){}}function mi(e,t,r,i,n,a,o,s,l){ve.call(this,e,t,r,i,n,a,o,s,l),this.needsUpdate=!0}function vi(e){if(c.call(this),this.type="Sprite",void 0===ov){ov=new P;var t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),r=new Lt(t,5);ov.setIndex([0,1,2,0,2,3]),ov.addAttribute("position",new Nt(r,3,0,(!1))),ov.addAttribute("uv",new Nt(r,2,3,(!1)))}this.geometry=ov,this.material=void 0!==e?e:new Fe,this.center=new f(.5,.5)}function gi(e){tr.call(this,"v4",{shared:!1}),this.index=e||0}function yi(e){tr.call(this,"v3",{shared:!1}),this.scope=e||yi.TOTAL}function xi(e){tr.call(this,"v3",{unique:!0}),this.scope=e||xi.CUBE}function bi(e){e=e||{},this.name=e.name,this.type=e.type,this.node=e.node,this.needsUpdate=e.needsUpdate}function wi(e){tr.call(this),this.eval(e)}function _i(e,t,r){ar.call(this,"v3"),this.value=e instanceof i?e:new i(e,t,r)}function Si(e,t,r,i){ar.call(this,"v4"),this.value=e instanceof v?e:new v(e,t,r,i)}function Ai(e,t){tr.call(this,"v4"),this.input=e,this.method=t||Ai.LINEAR}function Mi(e,t,r,i){ar.call(this,"v4",{shared:!0}),this.value=e,this.uv=t||new rr,this.bias=r,this.project=void 0!==i&&i}function Ti(e,t,r){ar.call(this,"v4",{shared:!0}),this.value=e,this.uv=t||new xi,this.bias=r}function Ei(){tr.call(this,"f")}function Ci(e){tr.call(this,"f"),this.blinnExponent=e||new Ei}function Li(e,t,r){tr.call(this,"TextureCubeUVData"),this.uv=e||new xi(xi.VECTOR),this.textureSize=t||new or(1024),this.blinnExponentToRoughness=r||new Ci}function Pi(e,t){tr.call(this,"v4"),this.value=e,this.uv=t||new Li}function Ni(){this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.requires={uv:[],color:[],lights:!1,fog:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCube(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2D(a, b, c)","#endif","#include <packing>","#include <common>"].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;r<i;r++)if(e[r]===t)return r;return-1}function Fn(e,t,r){for(var i=0,n=e.length;i<n;i++)if(e[i][t]===r)return i;return-1}function Rn(e,t,r,i,n,a,o,s,l,c){if(c=void 0!==c?c:Sc,c!==Sc&&c!==Ac)throw new Error("DepthTexture format must be either DepthFormat or DepthStencilFormat");void 0===r&&c===Sc&&(r=lc),void 0===r&&c===Ac&&(r=vc),ve.call(this,null,i,n,a,o,s,c,r,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:$l,this.minFilter=void 0!==s?s:$l,this.flipY=!1,this.generateMipmaps=!1}function In(e,t,r,i,n,a){this.planes=[void 0!==e?e:new ze,void 0!==t?t:new ze,void 0!==r?r:new ze,void 0!==i?i:new ze,void 0!==n?n:new ze,void 0!==a?a:new ze]}function Un(){function e(n,a){r!==!1&&(i(n,a),t.requestAnimationFrame(e))}var t=null,r=!1,i=null;return{start:function(){r!==!0&&null!==i&&(t.requestAnimationFrame(e),r=!0)},stop:function(){r=!1},setAnimationLoop:function(e){i=e},setContext:function(e){t=e}}}function kn(e){function t(t,r){var i=t.array,n=t.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,a=e.createBuffer();e.bindBuffer(r,a),e.bufferData(r,i,n),t.onUploadCallback();var o=e.FLOAT;return i instanceof Float32Array?o=e.FLOAT:i instanceof Float64Array?console.warn("WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=e.UNSIGNED_SHORT:i instanceof Int16Array?o=e.SHORT:i instanceof Uint32Array?o=e.UNSIGNED_INT:i instanceof Int32Array?o=e.INT:i instanceof Int8Array?o=e.BYTE:i instanceof Uint8Array&&(o=e.UNSIGNED_BYTE),{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}function r(t,r,i){var n=r.array,a=r.updateRange;e.bindBuffer(i,t),r.dynamic===!1?e.bufferData(i,n,e.STATIC_DRAW):a.count===-1?e.bufferSubData(i,0,n):0===a.count?console.error("WebGLObjects.updateBuffer: dynamic BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(i,a.offset*n.BYTES_PER_ELEMENT,n.subarray(a.offset,a.offset+a.count)),a.count=-1)}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),o.get(e)}function n(t){t.isInterleavedBufferAttribute&&(t=t.data);var r=o.get(t);r&&(e.deleteBuffer(r.buffer),o["delete"](t))}function a(e,i){e.isInterleavedBufferAttribute&&(e=e.data);var n=o.get(e);void 0===n?o.set(e,t(e,i)):n.version<e.version&&(r(n.buffer,e,i),n.version=e.version)}var o=new WeakMap;return{get:i,remove:n,update:a}}function Bn(e,t,r,i){function n(t,i,n,u){var d=i.background;null===d?a(c,h):d&&d.isColor&&(a(d,1),u=!0),(e.autoClear||u)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),d&&d.isCubeTexture?(void 0===l&&(l=new k(new le(1,1,1),new pe({uniforms:vp.cube.uniforms,vertexShader:vp.cube.vertexShader,fragmentShader:vp.cube.fragmentShader,side:Zs,depthTest:!0,depthWrite:!1,fog:!1})),l.geometry.removeAttribute("normal"),l.geometry.removeAttribute("uv"),l.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},r.update(l)),l.material.uniforms.tCube.value=d,t.push(l,l.geometry,l.material,0,null)):d&&d.isTexture&&(void 0===o&&(o=new me((-1),1,1,(-1),0,1),s=new k(new xe(2,2),new F({depthTest:!1,depthWrite:!1,fog:!1})),r.update(s)),s.material.map=d,e.renderBufferDirect(o,null,s.geometry,s.material,s,null))}function a(e,r){t.buffers.color.setClear(e.r,e.g,e.b,r,i)}var o,s,l,c=new u(0),h=0;return{getClearColor:function(){return c},setClearColor:function(e,t){c.set(e),h=void 0!==t?t:1,a(c,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,a(c,h)},render:n}}function zn(e,t,r,i){function n(e){s=e}function a(t,i){e.drawArrays(s,t,i),r.update(i,s)}function o(n,a,o){var l;if(i.isWebGL2)l=e;else if(l=t.get("ANGLE_instanced_arrays"),null===l)return void console.error("WebGLBufferRenderer: using InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[i.isWebGL2?"drawArraysInstanced":"drawArraysInstancedANGLE"](s,a,o,n.maxInstancedCount),r.update(o,s,n.maxInstancedCount)}var s;this.setMode=n,this.render=a,this.renderInstances=o}function jn(e,t,r){function i(){if(void 0!==a)return a;var r=t.get("EXT_texture_filter_anisotropic");return a=null!==r?e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}function n(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a,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.length<l)&&(o=new Float32Array(l));for(var d=0,p=i;d!==a;++d,p+=4)s.copy(e[d]).applyMatrix4(h,c),s.normal.toArray(o,p),o[p+3]=s.constant}u.value=o,u.needsUpdate=!0}return r.numPlanes=a,o}var r=this,i=null,n=0,a=!1,o=!1,s=new ze,c=new l,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(e,r,o){var s=0!==e.length||r||0!==n||a;return a=r,i=t(e,o,0),n=e.length,s},this.beginShadows=function(){o=!0,t(null)},this.endShadows=function(){o=!1,e()},this.setState=function(r,s,l,c,h,d){if(!a||null===r||0===r.length||o&&!l)o?t(null):e();else{var p=o?0:n,f=4*p,m=h.clippingState||null;u.value=m,m=t(r,c,f,d);for(var v=0;v!==f;++v)m[v]=i[v];h.clippingState=m,this.numIntersection=s?this.numPlanes:0,this.numPlanes+=p}}}function Gn(e){var t={};return{get:function(r){if(void 0!==t[r])return t[r];var i;switch(r){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(r)}return null===i&&console.warn("WebGLRenderer: "+r+" extension not supported."),t[r]=i,i}}}function Wn(e,t,r){function i(e){var n=e.target,a=s[n.id];null!==a.index&&t.remove(a.index);for(var o in a.attributes)t.remove(a.attributes[o]);n.removeEventListener("dispose",i),delete s[n.id];var c=l[a.id];c&&(t.remove(c),delete l[a.id]),r.memory.geometries--}function n(e,t){var n=s[t.id];return n?n:(t.addEventListener("dispose",i),t.isBufferGeometry?n=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new P).setFromObject(e)),n=t._bufferGeometry),s[t.id]=n,r.memory.geometries++,n)}function a(r){var i=r.index,n=r.attributes;null!==i&&t.update(i,e.ELEMENT_ARRAY_BUFFER);for(var a in n)t.update(n[a],e.ARRAY_BUFFER);var o=r.morphAttributes;for(var a in o)for(var s=o[a],l=0,c=s.length;l<c;l++)t.update(s[l],e.ARRAY_BUFFER)}function o(r){var i=l[r.id];if(i)return i;var n=[],a=r.index,o=r.attributes;if(null!==a)for(var s=a.array,c=0,u=s.length;c<u;c+=3){var h=s[c+0],d=s[c+1],p=s[c+2];n.push(h,d,d,p,p,h)}else for(var s=o.position.array,c=0,u=s.length/3-1;c<u;c+=3){var h=c+0,d=c+1,p=c+2;n.push(h,d,d,p,p,h)}return i=new(L(n)>65535?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;u<l;u++)c[u]=[u,0];r[n.id]=c}for(var h=a.morphTargets&&n.morphAttributes.position,d=a.morphNormals&&n.morphAttributes.normal,u=0;u<l;u++){var p=c[u];0!==p[1]&&(h&&n.removeAttribute("morphTarget"+u),d&&n.removeAttribute("morphNormal"+u))}for(var u=0;u<l;u++){var p=c[u];p[0]=u,p[1]=s[u]}c.sort(Yn);for(var u=0;u<8;u++){var p=c[u];if(p){var f=p[0],m=p[1];if(m){h&&n.addAttribute("morphTarget"+u,h[f]),d&&n.addAttribute("morphNormal"+u,d[f]),i[u]=m;continue}}i[u]=0}o.getUniforms().setValue(e,"morphTargetInfluences",i)}var r={},i=new Float32Array(8);return{update:t}}function Qn(e,t){function r(r){var i=t.render.frame,a=r.geometry,o=e.get(r,a);return n[o.id]!==i&&(a.isGeometry&&o.updateFromObject(r),e.update(o),n[o.id]=i),o}function i(){n={}}var n={};return{update:r,dispose:i}}function Jn(){this.seq=[],this.map={}}function Zn(e,t,r){var i=e[0];if(i<=0||i>0)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<i;r++)if(e[r]!==t[r])return!1;return!0}function $n(e,t){for(var r=0,i=t.length;r<i;r++)e[r]=t[r]}function ea(e,t){var r=Qg[t];void 0===r&&(r=new Int32Array(t),Qg[t]=r);for(var i=0;i!==t;++i)r[i]=e.allocTextureUnit();return r}function ta(e,t){var r=this.cache;r[0]!==t&&(e.uniform1f(this.addr,t),r[0]=t)}function ra(e,t){var r=this.cache;r[0]!==t&&(e.uniform1i(this.addr,t),r[0]=t)}function ia(e,t){var r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y);else{if(Kn(r,t))return;e.uniform2fv(this.addr,t),$n(r,t)}}function na(e,t){var r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z);else if(void 0!==t.r)r[0]===t.r&&r[1]===t.g&&r[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),r[0]=t.r,r[1]=t.g,r[2]=t.b);else{if(Kn(r,t))return;e.uniform3fv(this.addr,t),$n(r,t)}}function aa(e,t){var r=this.cache;if(void 0!==t.x)r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w);else{if(Kn(r,t))return;e.uniform4fv(this.addr,t),$n(r,t)}}function oa(e,t){var r=this.cache,i=t.elements;if(void 0===i){if(Kn(r,t))return;e.uniformMatrix2fv(this.addr,!1,t),$n(r,t)}else{if(Kn(r,i))return;Kg.set(i),e.uniformMatrix2fv(this.addr,!1,Kg),$n(r,i)}}function sa(e,t){var r=this.cache,i=t.elements;if(void 0===i){if(Kn(r,t))return;e.uniformMatrix3fv(this.addr,!1,t),$n(r,t)}else{if(Kn(r,i))return;Zg.set(i),e.uniformMatrix3fv(this.addr,!1,Zg),$n(r,i)}}function la(e,t){var r=this.cache,i=t.elements;if(void 0===i){if(Kn(r,t))return;e.uniformMatrix4fv(this.addr,!1,t),$n(r,t)}else{if(Kn(r,i))return;Jg.set(i),e.uniformMatrix4fv(this.addr,!1,Jg),$n(r,i)}}function ca(e,t,r){var i=this.cache,n=r.allocTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.setTexture2D(t||Hg,n)}function ua(e,t,r){var i=this.cache,n=r.allocTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.setTextureCube(t||Yg,n)}function ha(e,t){var r=this.cache;Kn(r,t)||(e.uniform2iv(this.addr,t),$n(r,t))}function da(e,t){var r=this.cache;Kn(r,t)||(e.uniform3iv(this.addr,t),$n(r,t))}function pa(e,t){var r=this.cache;Kn(r,t)||(e.uniform4iv(this.addr,t),$n(r,t))}function fa(e){switch(e){case 5126:return ta;case 35664:return ia;case 35665:return na;case 35666:return aa;case 35674:return oa;case 35675:return sa;case 35676:return la;case 35678:case 36198:return ca;case 35680:return ua;case 5124:case 35670:return ra;case 35667:case 35671:return ha;case 35668:case 35672:return da;case 35669:case 35673:return pa}}function ma(e,t){var r=this.cache;Kn(r,t)||(e.uniform1fv(this.addr,t),$n(r,t))}function va(e,t){var r=this.cache;Kn(r,t)||(e.uniform1iv(this.addr,t),$n(r,t))}function ga(e,t){var r=this.cache,i=Zn(t,this.size,2);Kn(r,i)||(e.uniform2fv(this.addr,i),this.updateCache(i))}function ya(e,t){var r=this.cache,i=Zn(t,this.size,3);Kn(r,i)||(e.uniform3fv(this.addr,i),this.updateCache(i))}function xa(e,t){var r=this.cache,i=Zn(t,this.size,4);Kn(r,i)||(e.uniform4fv(this.addr,i),this.updateCache(i))}function ba(e,t){var r=this.cache,i=Zn(t,this.size,4);Kn(r,i)||(e.uniformMatrix2fv(this.addr,!1,i),this.updateCache(i))}function wa(e,t){var r=this.cache,i=Zn(t,this.size,9);Kn(r,i)||(e.uniformMatrix3fv(this.addr,!1,i),this.updateCache(i))}function _a(e,t){var r=this.cache,i=Zn(t,this.size,16);Kn(r,i)||(e.uniformMatrix4fv(this.addr,!1,i),this.updateCache(i))}function Sa(e,t,r){var i=this.cache,n=t.length,a=ea(r,n);Kn(i,a)===!1&&(e.uniform1iv(this.addr,a),$n(i,a));for(var o=0;o!==n;++o)r.setTexture2D(t[o]||Hg,a[o])}function Aa(e,t,r){var i=this.cache,n=t.length,a=ea(r,n);Kn(i,a)===!1&&(e.uniform1iv(this.addr,a),$n(i,a));for(var o=0;o!==n;++o)r.setTextureCube(t[o]||Yg,a[o])}function Ma(e){switch(e){case 5126:return ma;case 35664:return ga;case 35665:return ya;case 35666:return xa;case 35674:return ba;case 35675:return wa;case 35676:return _a;case 35678:return Sa;case 35680:return Aa;case 5124:case 35670:return va;case 35667:case 35671:return ha;case 35668:case 35672:return da;case 35669:case 35673:return pa}}function Ta(e,t,r){this.id=e,this.addr=r,this.cache=[],this.setValue=fa(t.type)}function Ea(e,t,r){this.id=e,this.addr=r,this.cache=[],this.size=t.size,this.setValue=Ma(t.type)}function Ca(e){this.id=e,Jn.call(this)}function La(e,t){e.seq.push(t),e.map[t.id]=t}function Pa(e,t,r){var i=e.name,n=i.length;for($g.lastIndex=0;;){var a=$g.exec(i),o=$g.lastIndex,s=a[1],l="]"===a[2],c=a[3];if(l&&(s=0|s),void 0===c||"["===c&&o+2===n){La(r,void 0===c?new Ta(s,e,t):new Ea(s,e,t));break}var u=r.map,h=u[s];void 0===h&&(h=new Ca(s),La(r,h)),r=h}}function Na(e,t,r){var i=this;Jn.call(this),this.renderer=r;for(var n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),a=0;a<n;++a){var o=e.getActiveUniform(t,a),s=e.getUniformLocation(t,o.name);Pa(o,s,i)}}function Oa(e){for(var t=e.split("\n"),r=0;r<t.length;r++)t[r]=r+1+": "+t[r];return t.join("\n")}function Da(e,t,r){var i=e.createShader(t);return e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)===!1&&console.error("WebGLShader: Shader couldn't compile."),""!==e.getShaderInfoLog(i)&&console.warn("WebGLShader: gl.getShaderInfoLog()",t===e.VERTEX_SHADER?"vertex":"fragment",e.getShaderInfoLog(i),Oa(r)),i}function Fa(e){switch(e){case ou:return["Linear","( value )"];case su:return["sRGB","( value )"];case cu:return["RGBE","( value )"];case hu:return["RGBM","( value, 7.0 )"];case du:return["RGBM","( value, 16.0 )"];case pu:return["RGBD","( value, 256.0 )"];case lu:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+e)}}function Ra(e,t){var r=Fa(t);return"vec4 "+e+"( vec4 value ) { return "+r[0]+"ToLinear"+r[1]+"; }"}function Ia(e,t){var r=Fa(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}function Ua(e,t){var r;switch(t){case kl:r="Linear";break;case Bl:r="Reinhard";break;case zl:r="Uncharted2";break;case jl:r="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}function ka(e,t,r){e=e||{};var i=[e.derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap&&!t.objectSpaceNormalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&r.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&r.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&r.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""];return i.filter(ja).join("\n")}function Ba(e){var t=[];for(var r in e){var i=e[r];i!==!1&&t.push("#define "+r+" "+i)}return t.join("\n")}function za(e,t){for(var r={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),n=0;n<i;n++){var a=e.getActiveAttrib(t,n),o=a.name;r[o]=e.getAttribLocation(t,o)}return r}function ja(e){return""!==e}function Va(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights)}function Ga(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Wa(e){function t(e,t){var r=fp[t];if(void 0===r)throw new Error("Can not resolve #include <"+t+">");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);a<parseInt(r);a++)n+=i.replace(/\[ i \]/g,"[ "+a+" ]");return n}var r=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;return e.replace(r,t)}function Ha(e,t,r,i,n,a,o){var s=e.context,l=i.defines,c=n.vertexShader,u=n.fragmentShader,h="SHADOWMAP_TYPE_BASIC";a.shadowMapType===qs?h="SHADOWMAP_TYPE_PCF":a.shadowMapType===Qs&&(h="SHADOWMAP_TYPE_PCF_SOFT");var d="ENVMAP_TYPE_CUBE",p="ENVMAP_MODE_REFLECTION",f="ENVMAP_BLENDING_MULTIPLY";if(a.envMap){switch(i.envMap.mapping){case Gl:case Wl:d="ENVMAP_TYPE_CUBE";break;case ql:case Ql:d="ENVMAP_TYPE_CUBE_UV";break;case Xl:case Hl:d="ENVMAP_TYPE_EQUIREC";break;case Yl:d="ENVMAP_TYPE_SPHERE"}switch(i.envMap.mapping){case Wl:case Hl:p="ENVMAP_MODE_REFRACTION"}switch(i.combine){case Fl:f="ENVMAP_BLENDING_MULTIPLY";break;case Rl:f="ENVMAP_BLENDING_MIX";break;case Il:f="ENVMAP_BLENDING_ADD"}}var m,v,g=e.gammaFactor>0?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 o<i.length?(console.warn("WebGLRenderer: Skeleton has "+i.length+" bones. This GPU supports "+o+"."),0):o}function n(e,t){var r;return e?e.isTexture?r=e.encoding:e.isWebGLRenderTarget&&(console.warn("WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),r=e.texture.encoding):r=ou,r===ou&&t&&(r=lu),r}var a=[],o={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},s=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering"];this.getParameters=function(t,a,s,l,c,u,h){var d=o[t.type],p=h.isSkinnedMesh?i(h):0,f=r.precision;null!==t.precision&&(f=r.getMaxPrecision(t.precision),f!==t.precision&&console.warn("WebGLProgram.getParameters:",t.precision,"not supported, using",f,"instead."));var m=e.getRenderTarget(),v={shaderID:d,precision:f,supportsVertexTextures:r.vertexTextures,outputEncoding:n(m?m.texture:null,e.gammaOutput),map:!!t.map,mapEncoding:n(t.map,e.gammaInput),envMap:!!t.envMap,envMapMode:t.envMap&&t.envMap.mapping,envMapEncoding:n(t.envMap,e.gammaInput),envMapCubeUV:!!t.envMap&&(t.envMap.mapping===ql||t.envMap.mapping===Ql),lightMap:!!t.lightMap,aoMap:!!t.aoMap,emissiveMap:!!t.emissiveMap,emissiveMapEncoding:n(t.emissiveMap,e.gammaInput),bumpMap:!!t.bumpMap,normalMap:!!t.normalMap,objectSpaceNormalMap:t.normalMapType===gu,displacementMap:!!t.displacementMap,roughnessMap:!!t.roughnessMap,metalnessMap:!!t.metalnessMap,specularMap:!!t.specularMap,alphaMap:!!t.alphaMap,gradientMap:!!t.gradientMap,combine:t.combine,vertexColors:t.vertexColors,fog:!!l,useFog:t.fog,fogExp:l&&l.isFogExp2,flatShading:t.flatShading,sizeAttenuation:t.sizeAttenuation,logarithmicDepthBuffer:r.logarithmicDepthBuffer,skinning:t.skinning&&p>0,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;a<s.length;a++)i.push(r[s[a]]);return i.push(t.onBeforeCompile.toString()),i.push(e.gammaOutput),i.join()},this.acquireProgram=function(i,n,o,s){for(var l,c=0,u=a.length;c<u;c++){var h=a[c];if(h.code===s){l=h,++l.usedTimes;break}}return void 0===l&&(l=new Ha(e,t,s,i,n,o,r),a.push(l)),l},this.releaseProgram=function(e){if(0===--e.usedTimes){var t=a.indexOf(e);a[t]=a[a.length-1],a.pop(),e.destroy()}},this.programs=a}function qa(){function e(e){var t=n.get(e);return void 0===t&&(t={},n.set(e,t)),t}function t(e){n["delete"](e)}function r(e,t,r){n.get(e)[t]=r}function i(){n=new WeakMap}var n=new WeakMap;return{get:e,remove:t,update:r,dispose:i}}function Qa(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program&&t.program&&e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Ja(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Za(){function e(){n=0,a.length=0,o.length=0}function t(e,t,r,s,l){var c=i[n];void 0===c?(c={id:e.id,object:e,geometry:t,material:r,program:r.program,renderOrder:e.renderOrder,z:s,group:l},i[n]=c):(c.id=e.id,c.object=e,c.geometry=t,c.material=r,c.program=r.program,c.renderOrder=e.renderOrder,c.z=s,c.group=l),(r.transparent===!0?o:a).push(c),n++}function r(){a.length>1&&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;g<y;g++){var x=e[g],b=x.color,w=x.intensity,_=x.distance,S=x.shadow&&x.shadow.map?x.shadow.map.texture:null;if(x.isAmbientLight)l+=b.r*w,c+=b.g*w,u+=b.b*w;else if(x.isDirectionalLight){var A=t.get(x);if(A.color.copy(x.color).multiplyScalar(x.intensity),A.direction.setFromMatrixPosition(x.matrixWorld),a.setFromMatrixPosition(x.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),A.shadow=x.castShadow,x.castShadow){var M=x.shadow;A.shadowBias=M.bias,A.shadowRadius=M.radius,A.shadowMapSize=M.mapSize}n.directionalShadowMap[h]=S,n.directionalShadowMatrix[h]=x.shadow.matrix,n.directional[h]=A,h++}else if(x.isSpotLight){var A=t.get(x);if(A.position.setFromMatrixPosition(x.matrixWorld),A.position.applyMatrix4(v),A.color.copy(b).multiplyScalar(w),A.distance=_,A.direction.setFromMatrixPosition(x.matrixWorld),a.setFromMatrixPosition(x.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),A.coneCos=Math.cos(x.angle),A.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),A.decay=0===x.distance?0:x.decay,A.shadow=x.castShadow,x.castShadow){var M=x.shadow;A.shadowBias=M.bias,A.shadowRadius=M.radius,A.shadowMapSize=M.mapSize}n.spotShadowMap[p]=S,n.spotShadowMatrix[p]=x.shadow.matrix,n.spot[p]=A,p++}else if(x.isRectAreaLight){var A=t.get(x);A.color.copy(b).multiplyScalar(w),A.position.setFromMatrixPosition(x.matrixWorld),A.position.applyMatrix4(v),s.identity(),o.copy(x.matrixWorld),o.premultiply(v),s.extractRotation(o),A.halfWidth.set(.5*x.width,0,0),A.halfHeight.set(0,.5*x.height,0),A.halfWidth.applyMatrix4(s),A.halfHeight.applyMatrix4(s),n.rectArea[f]=A,f++}else if(x.isPointLight){var A=t.get(x);if(A.position.setFromMatrixPosition(x.matrixWorld),A.position.applyMatrix4(v),A.color.copy(x.color).multiplyScalar(x.intensity),A.distance=x.distance,A.decay=0===x.distance?0:x.decay,A.shadow=x.castShadow,x.castShadow){var M=x.shadow;A.shadowBias=M.bias,A.shadowRadius=M.radius,A.shadowMapSize=M.mapSize,A.shadowCameraNear=M.camera.near,A.shadowCameraFar=M.camera.far}n.pointShadowMap[d]=S,n.pointShadowMatrix[d]=x.shadow.matrix,n.point[d]=A,d++}else if(x.isHemisphereLight){var A=t.get(x);A.direction.setFromMatrixPosition(x.matrixWorld),A.direction.transformDirection(v),A.direction.normalize(),A.skyColor.copy(x.color).multiplyScalar(w),A.groundColor.copy(x.groundColor).multiplyScalar(w),n.hemi[m]=A,m++}}n.ambient[0]=l,n.ambient[1]=c,n.ambient[2]=u,n.directional.length=h,n.spot.length=p,n.rectArea.length=f,n.point.length=d,n.hemi.length=m,n.hash.stateID=n.id,n.hash.directionalLength=h,n.hash.pointLength=d,n.hash.spotLength=p,n.hash.rectAreaLength=f,n.hash.hemiLength=m,n.hash.shadowsLength=r.length}var t=new $a,n={id:ty++,hash:{stateID:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,shadowsLength:-1},ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},a=new i,o=new r,s=new r;return{setup:e,state:n}}function to(){function e(){a.length=0,o.length=0}function t(e){a.push(e)}function r(e){o.push(e)}function i(e){n.setup(a,o,e)}var n=new eo,a=[],o=[],s={lightsArray:a,shadowsArray:o,lights:n};return{init:e,state:s,setupLights:i,pushLight:t,pushShadow:r}}function ro(){function e(e,t){var i;return void 0===r[e.id]?(i=new to,r[e.id]={},r[e.id][t.id]=i):void 0===r[e.id][t.id]?(i=new to,r[e.id][t.id]=i):i=r[e.id][t.id],i}function t(){r={}}var r={};return{get:e,dispose:t}}function io(e,t,n){function a(t,r,i,n,a,o){var s=t.geometry,l=null,c=y,u=t.customDepthMaterial;if(i&&(c=x,u=t.customDistanceMaterial),u)l=u;else{var h=!1;r.morphTargets&&(s&&s.isBufferGeometry?h=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0: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<m;f++){var v=p[f],g=h[v.materialIndex];if(g&&g.visible){var y=a(r,g,l,d,n.near,n.far);e.renderBufferDirect(n,null,u,y,r,v)}}else if(h.visible){var y=a(r,h,l,d,n.near,n.far);e.renderBufferDirect(n,null,u,y,r,null)}}for(var x=r.children,b=0,w=x.length;b<w;b++)o(x[b],i,n,l)}}for(var s=new In,l=new r,c=new f,u=new f(n,n),h=new i,d=new i,p=1,m=2,g=(p|m)+1,y=new Array(g),x=new Array(g),b={},w={0:Zs,1:Js,2:Ks},_=[new i(1,0,0),new i((-1),0,0),new i(0,0,1),new i(0,0,(-1)),new i(0,1,0),new i(0,(-1),0)],S=[new i(0,1,0),new i(0,1,0),new i(0,1,0),new i(0,1,0),new i(0,0,1),new i(0,0,(-1))],A=[new v,new v,new v,new v,new v,new v],M=0;M!==g;++M){var T=0!==(M&p),E=0!==(M&m),C=new Se({depthPacking:mu,morphTargets:T,skinning:E});y[M]=C;var L=new Ae({morphTargets:T,skinning:E});x[M]=L}var P=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=qs,this.render=function(t,r,i){if(P.enabled!==!1&&(P.autoUpdate!==!1||P.needsUpdate!==!1)&&0!==t.length){var n=e.context,a=e.state;a.disable(n.BLEND),a.buffers.color.setClear(1,1,1,1),a.buffers.depth.setTest(!0),a.setScissorTest(!1);for(var p,f=0,m=t.length;f<m;f++){var v=t[f],g=v.shadow,y=v&&v.isPointLight;if(void 0!==g){var x=g.camera;if(c.copy(g.mapSize),c.min(u),y){var b=c.x,w=c.y;A[0].set(2*b,w,b,w),A[1].set(0,w,b,w),A[2].set(3*b,w,b,w),A[3].set(b,w,b,w),A[4].set(3*b,0,b,w),A[5].set(b,0,b,w),c.x*=4,c.y*=2}if(null===g.map){var M={minFilter:$l,magFilter:$l,format:xc};g.map=new ge(c.x,c.y,M),g.map.texture.name=v.name+".shadowMap",x.updateProjectionMatrix()}g.isSpotLightShadow&&g.update(v);var T=g.map,E=g.matrix;d.setFromMatrixPosition(v.matrixWorld),x.position.copy(d),y?(p=6,E.makeTranslation(-d.x,-d.y,-d.z)):(p=1,h.setFromMatrixPosition(v.target.matrixWorld),x.lookAt(h),x.updateMatrixWorld(),E.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),E.multiply(x.projectionMatrix),E.multiply(x.matrixWorldInverse)),e.setRenderTarget(T),e.clear();for(var C=0;C<p;C++){if(y){h.copy(x.position),h.add(_[C]),x.up.copy(S[C]),x.lookAt(h),x.updateMatrixWorld();var L=A[C];a.viewport(L)}l.multiplyMatrices(x.projectionMatrix,x.matrixWorldInverse),s.setFromMatrix(l),o(r,i,x,y)}}else console.warn("WebGLShadowMap:",v,"has no shadow.")}P.needsUpdate=!1}}}function no(e,t,r,i){function n(){var t=!1,r=new v,i=null,n=new v(0,0,0,0);return{setMask:function(r){i===r||t||(e.colorMask(r,r,r,r),i=r)},setLocked:function(e){t=e},setClear:function(t,i,a,o,s){s===!0&&(t*=o,i*=o,a*=o),r.set(t,i,a,o),n.equals(r)===!1&&(e.clearColor(t,i,a,o),n.copy(r))},reset:function(){t=!1,i=null,n.set(-1,0,0,0)}}}function a(){var t=!1,r=null,i=null,n=null;return{setTest:function(t){t?d(e.DEPTH_TEST):p(e.DEPTH_TEST)},setMask:function(i){r===i||t||(e.depthMask(i),r=i)},setFunc:function(t){if(i!==t){if(t)switch(t){case Tl:e.depthFunc(e.NEVER);break;case El:e.depthFunc(e.ALWAYS);break;case Cl:e.depthFunc(e.LESS);break;case Ll:e.depthFunc(e.LEQUAL);break;case Pl:e.depthFunc(e.EQUAL);break;case Nl:e.depthFunc(e.GEQUAL);break;case Ol:e.depthFunc(e.GREATER);break;case Dl:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);i=t}},setLocked:function(e){t=e},setClear:function(t){n!==t&&(e.clearDepth(t),n=t)},reset:function(){t=!1,r=null,i=null,n=null}}}function o(){var t=!1,r=null,i=null,n=null,a=null,o=null,s=null,l=null,c=null;return{setTest:function(t){t?d(e.STENCIL_TEST):p(e.STENCIL_TEST)},setMask:function(i){r===i||t||(e.stencilMask(i),r=i)},setFunc:function(t,r,o){i===t&&n===r&&a===o||(e.stencilFunc(t,r,o),i=t,n=r,a=o)},setOp:function(t,r,i){o===t&&s===r&&l===i||(e.stencilOp(t,r,i),o=t,s=r,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,r=null,i=null,n=null,a=null,o=null,s=null,l=null,c=null}}}function s(t,r,i){var n=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var o=0;o<i;o++)e.texImage2D(r+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,n);return a}function l(){for(var e=0,t=R.length;e<t;e++)R[e]=0}function c(e){u(e,0)}function u(r,n){if(R[r]=1,0===I[r]&&(e.enableVertexAttribArray(r),I[r]=1),U[r]!==n){var a=i.isWebGL2?e:t.get("ANGLE_instanced_arrays");a[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](r,n),U[r]=n}}function h(){for(var t=0,r=I.length;t!==r;++t)I[t]!==R[t]&&(e.disableVertexAttribArray(t),I[t]=0)}function d(t){k[t]!==!0&&(e.enable(t),k[t]=!0)}function p(t){k[t]!==!1&&(e.disable(t),k[t]=!1)}function f(){if(null===B&&(B=[],t.get("WEBGL_compressed_texture_pvrtc")||t.get("WEBGL_compressed_texture_s3tc")||t.get("WEBGL_compressed_texture_etc1")||t.get("WEBGL_compressed_texture_astc")))for(var r=e.getParameter(e.COMPRESSED_TEXTURE_FORMATS),i=0;i<r.length;i++)B.push(r[i]);return B}function m(t){return z!==t&&(e.useProgram(t),z=t,!0)}function g(t,i,n,a,o,s,l,c){if(t===nl)return void(j&&(p(e.BLEND),j=!1));if(j||(d(e.BLEND),j=!0),t===cl)o=o||i,s=s||n,l=l||a,i===G&&o===H||(e.blendEquationSeparate(r.convert(i),r.convert(o)),G=i,H=o),n===W&&a===X&&s===Y&&l===q||(e.blendFuncSeparate(r.convert(n),r.convert(a),r.convert(s),r.convert(l)),W=n,X=a,Y=s,q=l),V=t,Q=null;else if(t!==V||c!==Q){if(G===ul&&H===ul||(e.blendEquation(e.FUNC_ADD),G=ul,H=ul),c)switch(t){case al:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ol:e.blendFunc(e.ONE,e.ONE);break;case sl:e.blendFuncSeparate(e.ZERO,e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ONE_MINUS_SRC_ALPHA);break;case ll:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("WebGLState: Invalid blending: ",t)}else switch(t){case al:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case ol:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case sl:e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case ll:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("WebGLState: Invalid blending: ",t)}W=null,X=null,Y=null,q=null,V=t,Q=c}}function y(t,r){t.side===Ks?p(e.CULL_FACE):d(e.CULL_FACE);var i=t.side===Zs;r&&(i=!i),x(i),t.blending===al&&t.transparent===!1?g(nl):g(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),O.setFunc(t.depthFunc),O.setTest(t.depthTest),O.setMask(t.depthWrite),N.setMask(t.colorWrite),_(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)}function x(t){J!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),J=t)}function b(t){t!==js?(d(e.CULL_FACE),t!==Z&&(t===Vs?e.cullFace(e.BACK):t===Gs?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):p(e.CULL_FACE),Z=t}function w(t){t!==K&&(re&&e.lineWidth(t),K=t)}function _(t,r,i){t?(d(e.POLYGON_OFFSET_FILL),$===r&&ee===i||(e.polygonOffset(r,i),$=r,ee=i)):p(e.POLYGON_OFFSET_FILL)}function S(t){t?d(e.SCISSOR_TEST):p(e.SCISSOR_TEST)}function A(t){void 0===t&&(t=e.TEXTURE0+te-1),ae!==t&&(e.activeTexture(t),ae=t)}function M(t,r){null===ae&&A();var i=oe[ae];void 0===i&&(i={type:void 0,texture:void 0},oe[ae]=i),i.type===t&&i.texture===r||(e.bindTexture(t,r||ce[t]),i.type=t,i.texture=r)}function T(){try{e.compressedTexImage2D.apply(e,arguments)}catch(t){console.error("WebGLState:",t)}}function E(){try{e.texImage2D.apply(e,arguments)}catch(t){console.error("WebGLState:",t)}}function C(t){se.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),se.copy(t))}function L(t){le.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),le.copy(t))}function P(){for(var t=0;t<I.length;t++)1===I[t]&&(e.disableVertexAttribArray(t),I[t]=0);k={},B=null,ae=null,oe={},z=null,V=null,J=null,Z=null,N.reset(),O.reset(),D.reset()}var N=new n,O=new a,D=new o,F=e.getParameter(e.MAX_VERTEX_ATTRIBS),R=new Uint8Array(F),I=new Uint8Array(F),U=new Uint8Array(F),k={},B=null,z=null,j=null,V=null,G=null,W=null,X=null,H=null,Y=null,q=null,Q=!1,J=null,Z=null,K=null,$=null,ee=null,te=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),re=!1,ie=0,ne=e.getParameter(e.VERSION);ne.indexOf("WebGL")!==-1?(ie=parseFloat(/^WebGL\ ([0-9])/.exec(ne)[1]),re=ie>=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<C;E++)M=T[E],t.format!==xc&&t.format!==yc?r.getCompressedTextureFormats().indexOf(w)>-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<M;A++)w=S[A],r.texImage2D(e.TEXTURE_2D,A,b,w.width,w.height,0,y,x,w.data);i.generateMipmaps=!1,t.__maxMipLevel=S.length-1}else r.texImage2D(e.TEXTURE_2D,0,b,v.width,v.height,0,y,x,v.data),t.__maxMipLevel=0;else if(i.isCompressedTexture){for(var A=0,M=S.length;A<M;A++)w=S[A],i.format!==xc&&i.format!==yc?r.getCompressedTextureFormats().indexOf(y)>-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<M;A++)w=S[A],r.texImage2D(e.TEXTURE_2D,A,b,y,x,w);i.generateMipmaps=!1,t.__maxMipLevel=S.length-1}else r.texImage2D(e.TEXTURE_2D,0,b,y,x,v),t.__maxMipLevel=0;h(i,g)&&d(e.TEXTURE_2D,i,v.width,v.height),t.__version=i.version,i.onUpdate&&i.onUpdate(i)}function A(t,n,o,s){var l=a.convert(n.texture.format),c=a.convert(n.texture.type),u=p(l,c);r.texImage2D(s,0,u,n.width,n.height,0,l,c,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,o,s,i.get(n.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function M(t,r){e.bindRenderbuffer(e.RENDERBUFFER,t),r.depthBuffer&&!r.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,r.width,r.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):r.depthBuffer&&r.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,r.width,r.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,r.width,r.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}function T(t,r){var n=r&&r.isWebGLRenderTargetCube;if(n)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),x(r.depthTexture,0);var a=i.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===Sc)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==Ac)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0)}}function E(t){var r=i.get(t),n=t.isWebGLRenderTargetCube===!0;if(t.depthTexture){if(n)throw new Error("target.depthTexture not supported in Cube render targets");T(r.__webglFramebuffer,t)}else if(n){r.__webglDepthbuffer=[];for(var a=0;a<6;a++)e.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[a]),r.__webglDepthbuffer[a]=e.createRenderbuffer(),M(r.__webglDepthbuffer[a],t)}else e.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),M(r.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}function C(t){var n=i.get(t),a=i.get(t.texture);t.addEventListener("dispose",v),a.__webglTexture=e.createTexture(),o.memory.textures++;var s=t.isWebGLRenderTargetCube===!0,c=l(t);if(s){n.__webglFramebuffer=[];for(var u=0;u<6;u++)n.__webglFramebuffer[u]=e.createFramebuffer()}else n.__webglFramebuffer=e.createFramebuffer();if(s){r.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture),_(e.TEXTURE_CUBE_MAP,t.texture,c);for(var u=0;u<6;u++)A(n.__webglFramebuffer[u],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+u);h(t.texture,c)&&d(e.TEXTURE_CUBE_MAP,t.texture,t.width,t.height),r.bindTexture(e.TEXTURE_CUBE_MAP,null)}else r.bindTexture(e.TEXTURE_2D,a.__webglTexture),_(e.TEXTURE_2D,t.texture,c),A(n.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),h(t.texture,c)&&d(e.TEXTURE_2D,t.texture,t.width,t.height),r.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&E(t)}function L(t){var n=t.texture,a=l(t);if(h(n,a)){var o=t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,s=i.get(n).__webglTexture;r.bindTexture(o,s),d(o,n,t.width,t.height),r.bindTexture(o,null)}}function P(e){var t=e.id,r=o.render.frame;O[t]!==r&&(O[t]=r,e.update());
|
|
}var N,O={};this.setTexture2D=x,this.setTextureCube=b,this.setTextureCubeDynamic=w,this.setupRenderTarget=C,this.updateRenderTargetMipmap=L}function oo(e,t,r){function i(i){var n;if(i===Jl)return e.REPEAT;if(i===Zl)return e.CLAMP_TO_EDGE;if(i===Kl)return e.MIRRORED_REPEAT;if(i===$l)return e.NEAREST;if(i===ec)return e.NEAREST_MIPMAP_NEAREST;if(i===tc)return e.NEAREST_MIPMAP_LINEAR;if(i===rc)return e.LINEAR;if(i===ic)return e.LINEAR_MIPMAP_NEAREST;if(i===nc)return e.LINEAR_MIPMAP_LINEAR;if(i===ac)return e.UNSIGNED_BYTE;if(i===pc)return e.UNSIGNED_SHORT_4_4_4_4;if(i===fc)return e.UNSIGNED_SHORT_5_5_5_1;if(i===mc)return e.UNSIGNED_SHORT_5_6_5;if(i===oc)return e.BYTE;if(i===sc)return e.SHORT;if(i===lc)return e.UNSIGNED_SHORT;if(i===cc)return e.INT;if(i===uc)return e.UNSIGNED_INT;if(i===hc)return e.FLOAT;if(i===dc){if(r.isWebGL2)return e.HALF_FLOAT;if(n=t.get("OES_texture_half_float"),null!==n)return n.HALF_FLOAT_OES}if(i===gc)return e.ALPHA;if(i===yc)return e.RGB;if(i===xc)return e.RGBA;if(i===bc)return e.LUMINANCE;if(i===wc)return e.LUMINANCE_ALPHA;if(i===Sc)return e.DEPTH_COMPONENT;if(i===Ac)return e.DEPTH_STENCIL;if(i===ul)return e.FUNC_ADD;if(i===hl)return e.FUNC_SUBTRACT;if(i===dl)return e.FUNC_REVERSE_SUBTRACT;if(i===ml)return e.ZERO;if(i===vl)return e.ONE;if(i===gl)return e.SRC_COLOR;if(i===yl)return e.ONE_MINUS_SRC_COLOR;if(i===xl)return e.SRC_ALPHA;if(i===bl)return e.ONE_MINUS_SRC_ALPHA;if(i===wl)return e.DST_ALPHA;if(i===_l)return e.ONE_MINUS_DST_ALPHA;if(i===Sl)return e.DST_COLOR;if(i===Al)return e.ONE_MINUS_DST_COLOR;if(i===Ml)return e.SRC_ALPHA_SATURATE;if((i===Mc||i===Tc||i===Ec||i===Cc)&&(n=t.get("WEBGL_compressed_texture_s3tc"),null!==n)){if(i===Mc)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Tc)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ec)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Cc)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((i===Lc||i===Pc||i===Nc||i===Oc)&&(n=t.get("WEBGL_compressed_texture_pvrtc"),null!==n)){if(i===Lc)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Pc)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Nc)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Oc)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===Dc&&(n=t.get("WEBGL_compressed_texture_etc1"),null!==n))return n.COMPRESSED_RGB_ETC1_WEBGL;if((i===Fc||i===Rc||i===Ic||i===Uc||i===kc||i===Bc||i===zc||i===jc||i===Vc||i===Gc||i===Wc||i===Xc||i===Hc||i===Yc)&&(n=t.get("WEBGL_compressed_texture_astc"),null!==n))return i;if(i===pl||i===fl){if(r.isWebGL2){if(i===pl)return e.MIN;if(i===fl)return e.MAX}if(n=t.get("EXT_blend_minmax"),null!==n){if(i===pl)return n.MIN_EXT;if(i===fl)return n.MAX_EXT}}if(i===vc){if(r.isWebGL2)return e.UNSIGNED_INT_24_8;if(n=t.get("WEBGL_depth_texture"),null!==n)return n.UNSIGNED_INT_24_8_WEBGL}return 0}return{convert:i}}function so(e){de.call(this),this.cameras=e||[]}function lo(e){function t(){return null!==c&&c.isPresenting===!0}function a(){if(t()){var r=c.getEyeParameters("left"),i=r.renderWidth,n=r.renderHeight;A=e.getPixelRatio(),S=e.getSize(),e.setDrawingBufferSize(2*i,n,1),T.start()}else l.enabled&&e.setDrawingBufferSize(S.width,S.height,A),T.stop()}function o(e){for(var t=navigator.getGamepads&&navigator.getGamepads(),r=0,i=0,n=t.length;r<n;r++){var a=t[r];if(a&&("Daydream Controller"===a.id||"Gear VR Controller"===a.id||"Oculus Go Controller"===a.id||"OpenVR Gamepad"===a.id||a.id.startsWith("Oculus Touch")||a.id.startsWith("Spatial Controller"))){if(i===e)return a;i++}}}function s(){for(var e=0;e<d.length;e++){var t=d[e],r=o(e);if(void 0!==r&&void 0!==r.pose){if(null===r.pose)return;var i=r.pose;i.hasPosition===!1&&t.position.set(.2,-.6,-.05),null!==i.position&&t.position.fromArray(i.position),null!==i.orientation&&t.quaternion.fromArray(i.orientation),t.matrix.compose(t.position,t.quaternion,t.scale),t.matrix.premultiply(p),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixWorldNeedsUpdate=!0,t.visible=!0;var n="Daydream Controller"===r.id?0:1;M[e]!==r.buttons[n].pressed&&(M[e]=r.buttons[n].pressed,M[e]===!0?t.dispatchEvent({type:"selectstart"}):(t.dispatchEvent({type:"selectend"}),t.dispatchEvent({type:"select"})))}else t.visible=!1}}var l=this,c=null,u=null,h=null,d=[],p=new r,f=new r,m="stage";"undefined"!=typeof Ds&&"VRFrameData"in Ds&&(u=new Ds.VRFrameData,Ds.addEventListener("vrdisplaypresentchange",a,!1));var g=new r,y=new n,x=new i,b=new de;b.bounds=new v(0,0,.5,1),b.layers.enable(1);var w=new de;w.bounds=new v(.5,0,.5,1),w.layers.enable(2);var _=new so([b,w]);_.layers.enable(1),_.layers.enable(2);var S,A,M=[];this.enabled=!1,this.getController=function(e){var t=d[e];return void 0===t&&(t=new Dt,t.matrixAutoUpdate=!1,t.visible=!1,d[e]=t),t},this.getDevice=function(){return c},this.setDevice=function(e){void 0!==e&&(c=e),T.setContext(e)},this.setFrameOfReferenceType=function(e){m=e},this.setPoseTarget=function(e){void 0!==e&&(h=e)},this.getCamera=function(e){var t="stage"===m?1.6:0;if(null===c)return e.position.set(0,t,0),e;if(c.depthNear=e.near,c.depthFar=e.far,c.getFrameData(u),"stage"===m){var r=c.stageParameters;r?p.fromArray(r.sittingToStandingTransform):p.makeTranslation(0,t,0)}var i=u.pose,n=null!==h?h:e;if(n.matrix.copy(p),n.matrix.decompose(n.position,n.quaternion,n.scale),null!==i.orientation&&(y.fromArray(i.orientation),n.quaternion.multiply(y)),null!==i.position&&(y.setFromRotationMatrix(p),x.fromArray(i.position),x.applyQuaternion(y),n.position.add(x)),n.updateMatrixWorld(),c.isPresenting===!1)return e;b.near=e.near,w.near=e.near,b.far=e.far,w.far=e.far,_.matrixWorld.copy(e.matrixWorld),_.matrixWorldInverse.copy(e.matrixWorldInverse),b.matrixWorldInverse.fromArray(u.leftViewMatrix),w.matrixWorldInverse.fromArray(u.rightViewMatrix),f.getInverse(p),"stage"===m&&(b.matrixWorldInverse.multiply(f),w.matrixWorldInverse.multiply(f));var a=n.parent;null!==a&&(g.getInverse(a.matrixWorld),b.matrixWorldInverse.multiply(g),w.matrixWorldInverse.multiply(g)),b.matrixWorld.getInverse(b.matrixWorldInverse),w.matrixWorld.getInverse(w.matrixWorldInverse),b.projectionMatrix.fromArray(u.leftProjectionMatrix),w.projectionMatrix.fromArray(u.rightProjectionMatrix),_.projectionMatrix.copy(b.projectionMatrix);var o=c.getLayers();if(o.length){var l=o[0];null!==l.leftBounds&&4===l.leftBounds.length&&b.bounds.fromArray(l.leftBounds),null!==l.rightBounds&&4===l.rightBounds.length&&w.bounds.fromArray(l.rightBounds)}return s(),_},this.getStandingMatrix=function(){return p},this.isPresenting=t;var T=new Un;this.setAnimationLoop=function(e){T.setAnimationLoop(e)},this.submitFrame=function(){t()&&c.submitFrame()},this.dispose=function(){"undefined"!=typeof Ds&&Ds.removeEventListener("vrdisplaypresentchange",a)}}function co(e){function t(){return null!==c&&null!==u}function i(e){var t=p[f.indexOf(e.inputSource)];t&&t.dispatchEvent({type:e.type})}function n(){e.setFramebuffer(null),b.stop()}function a(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.getInverse(e.matrixWorld)}function o(e,t){if(d=t.getDevicePose(u),null!==d)for(var r=c.baseLayer,i=t.views,n=0;n<i.length;n++){var a=i[n],o=r.getViewport(a),s=d.getViewMatrix(a),l=y.cameras[n];l.matrix.fromArray(s).getInverse(l.matrix),l.projectionMatrix.fromArray(a.projectionMatrix),l.viewport.set(o.x,o.y,o.width,o.height),0===n&&(y.matrix.copy(l.matrix),y.projectionMatrix.copy(l.projectionMatrix))}for(var n=0;n<p.length;n++){var h=p[n],m=f[n];if(m){var v=t.getInputPose(m,u);if(null!==v){"targetRay"in v?h.matrix.elements=v.targetRay.transformMatrix:"pointerMatrix"in v&&(h.matrix.elements=v.pointerMatrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.visible=!0;continue}}h.visible=!1}x&&x(e)}var s=e.context,l=null,c=null,u=null,h="stage",d=null,p=[],f=[],m=new de;m.layers.enable(1),m.viewport=new v;var g=new de;g.layers.enable(2),g.viewport=new v;var y=new so([m,g]);y.layers.enable(1),y.layers.enable(2),this.enabled=!1,this.getController=function(e){var t=p[e];return void 0===t&&(t=new Dt,t.matrixAutoUpdate=!1,t.visible=!1,p[e]=t),t},this.getDevice=function(){return l},this.setDevice=function(e){void 0!==e&&(l=e),e instanceof XRDevice&&s.setCompatibleXRDevice(e)},this.setFrameOfReferenceType=function(e){h=e},this.setSession=function(t){c=t,null!==c&&(c.addEventListener("select",i),c.addEventListener("selectstart",i),c.addEventListener("selectend",i),c.addEventListener("end",n),c.baseLayer=new XRWebGLLayer(c,s),c.requestFrameOfReference(h).then(function(t){u=t,e.setFramebuffer(c.baseLayer.framebuffer),b.setContext(c),b.start()}),f=c.getInputSources(),c.addEventListener("inputsourceschange",function(){f=c.getInputSources(),console.log(f)}))},this.getCamera=function(e){if(t()){var r=e.parent,i=y.cameras;a(y,r);for(var n=0;n<i.length;n++)a(i[n],r);e.matrixWorld.copy(y.matrixWorld);for(var o=e.children,n=0,s=o.length;n<s;n++)o[n].updateMatrixWorld(!0);return y}return e},this.isPresenting=t;var x=null,b=new Un;b.setAnimationLoop(o),this.setAnimationLoop=function(e){x=e},this.dispose=function(){},this.getStandingMatrix=function(){return console.warn("WebXRManager: getStandingMatrix() is no longer needed."),new r},this.submitFrame=function(){}}function uo(e){function t(){return null===J?le:1}function n(){be=new Gn(H),we=new jn(H,be,e),we.isWebGL2||(be.get("WEBGL_depth_texture"),be.get("OES_texture_float"),be.get("OES_texture_half_float"),be.get("OES_texture_half_float_linear"),be.get("OES_standard_derivatives"),be.get("OES_element_index_uint"),be.get("ANGLE_instanced_arrays")),be.get("OES_texture_float_linear"),Ie=new oo(H,be,we),_e=new no(H,be,Ie,we),_e.scissor(ie.copy(ue).multiplyScalar(le)),_e.viewport(re.copy(ce).multiplyScalar(le)),Se=new Hn(H),Ae=new qa,Me=new ao(H,be,_e,Ae,we,Ie,Se),Te=new kn(H),Ee=new Wn(H,Te,Se),Ce=new Qn(Ee,Se),De=new qn(H),Le=new Ya(Y,be,we),Pe=new Ka,Ne=new ro,Oe=new Bn(Y,_e,Ce,j),Fe=new zn(H,be,Se,we),Re=new Xn(H,be,Se,we),Se.programs=Le.programs,Y.context=H,Y.capabilities=we,Y.extensions=be,Y.properties=Ae,Y.renderLists=Pe,Y.state=_e,Y.info=Se}function a(e){e.preventDefault(),console.log("WebGLRenderer: Context Lost."),q=!0}function o(){console.log("WebGLRenderer: Context Restored."),q=!1,n()}function s(e){var t=e.target;t.removeEventListener("dispose",s),l(t)}function l(e){c(e),Ae.remove(e)}function c(e){var t=Ae.get(e).program;e.program=void 0,void 0!==t&&Le.releaseProgram(t)}function u(e,t){e.render(function(e){Y.renderBufferImmediate(e,t)})}function h(e,t,r){if(r&&r.isInstancedBufferGeometry&!we.isWebGL2&&null===be.get("ANGLE_instanced_arrays"))return void console.error("WebGLRenderer.setupVertexAttributes: using InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");_e.initAttributes();var i=r.attributes,n=t.getAttributes(),a=e.defaultAttributeValues;for(var o in n){var s=n[o];if(s>=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<l;s++){var c=o[s],u=a[c.materialIndex];u&&u.visible&&W.push(e,n,u,ge.z,c)}else a.visible&&W.push(e,n,a,ge.z,null)}for(var h=e.children,s=0,l=h.length;s<l;s++)p(h[s],t,r)}}function f(e,t,r,i){for(var n=0,a=e.length;n<a;n++){var o=e[n],s=o.object,l=o.geometry,c=void 0===i?o.material:i,u=o.group;if(r.isArrayCamera){te=r;for(var h=r.cameras,d=0,p=h.length;d<p;d++){var f=h[d];if(s.layers.test(f.layers)){if("viewport"in f)_e.viewport(re.copy(f.viewport));else{var v=f.bounds,g=v.x*oe,y=v.y*se,x=v.z*oe,b=v.w*se;_e.viewport(re.set(g,y,x,b).multiplyScalar(le))}X.setupLights(f),m(s,t,f,l,c,u)}}}else te=null,m(s,t,r,l,c,u)}}function m(e,t,r,i,n,a){if(e.onBeforeRender(Y,t,r,i,n,a),X=Ne.get(t,te||r),e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),e.isImmediateRenderObject){_e.setMaterial(n);var o=y(r,t.fog,n,e);$.geometry=null,$.program=null,$.wireframe=!1,u(e,o)}else Y.renderBufferDirect(r,t.fog,i,n,e,a);e.onAfterRender(Y,t,r,i,n,a),X=Ne.get(t,te||r)}function g(e,t,r){var i=Ae.get(e),n=X.state.lights,a=X.state.shadowsArray,o=i.lightsHash,l=n.state.hash,u=Le.getParameters(e,n.state,a,t,pe.numPlanes,pe.numIntersection,r),h=Le.getProgramCode(e,u),d=i.program,p=!0;if(void 0===d)e.addEventListener("dispose",s);else if(d.code!==h)c(e);else if(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)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,p=!1;else{if(void 0!==u.shaderID)return;p=!1}if(p){if(u.shaderID){var f=vp[u.shaderID];i.shader={name:e.type,uniforms:Mu.clone(f.uniforms),vertexShader:f.vertexShader,fragmentShader:f.fragmentShader}}else i.shader={name:e.type,uniforms:e.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader};e.onBeforeCompile(i.shader,Y),h=Le.getProgramCode(e,u),d=Le.acquireProgram(e,i.shader,u,h),i.program=d,e.program=d}var m=d.getAttributes();if(e.morphTargets){e.numSupportedMorphTargets=0;for(var v=0;v<Y.maxMorphTargets;v++)m["morphTarget"+v]>=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var v=0;v<Y.maxMorphNormals;v++)m["morphNormal"+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<t.material.length;r++)g(t.material[r],e.fog,t);else g(t.material,e.fog,t)})};var Be=null,ze=new Un;ze.setAnimationLoop(d),"undefined"!=typeof Ds&&ze.setContext(Ds),this.setAnimationLoop=function(e){Be=e,Ue.setAnimationLoop(e),ze.start()},this.render=function(e,t,r,i){if(!t||!t.isCamera)return void console.error("WebGLRenderer.render: camera is not an instance of Camera.");if(!q){$.geometry=null,$.program=null,$.wireframe=!1,K=-1,ee=null,e.autoUpdate===!0&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Ue.enabled&&(t=Ue.getCamera(t)),X=Ne.get(e,t),X.init(),e.onBeforeRender(Y,e,t,r),ve.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),de.setFromMatrix(ve),me=this.localClippingEnabled,fe=pe.init(this.clippingPlanes,me,t),W=Pe.get(e,t),W.init(),p(e,t,Y.sortObjects),Y.sortObjects===!0&&W.sort(),fe&&pe.beginShadows();var n=X.state.shadowsArray;ke.render(n,e,t),X.setupLights(t),fe&&pe.endShadows(),this.info.autoReset&&this.info.reset(),void 0===r&&(r=null),this.setRenderTarget(r),Oe.render(W,e,t,i);var a=W.opaque,o=W.transparent;if(e.overrideMaterial){var s=e.overrideMaterial;a.length&&f(a,e,t,s),o.length&&f(o,e,t,s)}else a.length&&f(a,e,t),o.length&&f(o,e,t);r&&Me.updateRenderTargetMipmap(r),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1),e.onAfterRender(Y,e,t),Ue.enabled&&Ue.submitFrame(),W=null,X=null}},this.allocTextureUnit=F,this.setTexture2D=function(){var e=!1;return function(t,r){t&&t.isWebGLRenderTarget&&(e||(console.warn("WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),Me.setTexture2D(t,r)}}(),this.setTexture=function(){var e=!1;return function(t,r){e||(console.warn("WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),
|
|
e=!0),Me.setTexture2D(t,r)}}(),this.setTextureCube=function(){var e=!1;return function(t,r){t&&t.isWebGLRenderTargetCube&&(e||(console.warn("WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?Me.setTextureCube(t,r):Me.setTextureCubeDynamic(t,r)}}(),this.setFramebuffer=function(e){Q=e},this.getRenderTarget=function(){return J},this.setRenderTarget=function(e){J=e,e&&void 0===Ae.get(e).__webglFramebuffer&&Me.setupRenderTarget(e);var t=Q,r=!1;if(e){var i=Ae.get(e).__webglFramebuffer;e.isWebGLRenderTargetCube?(t=i[e.activeCubeFace],r=!0):t=i,re.copy(e.viewport),ie.copy(e.scissor),ne=e.scissorTest}else re.copy(ce).multiplyScalar(le),ie.copy(ue).multiplyScalar(le),ne=he;if(Z!==t&&(H.bindFramebuffer(H.FRAMEBUFFER,t),Z=t),_e.viewport(re),_e.scissor(ie),_e.setScissorTest(ne),r){var n=Ae.get(e.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,n.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,r,i,n,a){if(!e||!e.isWebGLRenderTarget)return void console.error("WebGLRenderer.readRenderTargetPixels: renderTarget is not WebGLRenderTarget.");var o=Ae.get(e).__webglFramebuffer;if(o){var s=!1;o!==Z&&(H.bindFramebuffer(H.FRAMEBUFFER,o),s=!0);try{var l=e.texture,c=l.format,u=l.type;if(c!==xc&&Ie.convert(c)!==H.getParameter(H.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(u===ac||Ie.convert(u)===H.getParameter(H.IMPLEMENTATION_COLOR_READ_TYPE)||u===hc&&(we.isWebGL2||be.get("OES_texture_float")||be.get("WEBGL_color_buffer_float"))||u===dc&&(we.isWebGL2?be.get("EXT_color_buffer_float"):be.get("EXT_color_buffer_half_float"))))return void console.error("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");H.checkFramebufferStatus(H.FRAMEBUFFER)===H.FRAMEBUFFER_COMPLETE?t>=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<e.length;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]);E.set(0,0,1).applyQuaternion(f);for(var r=e.length-1;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;i<n;i++){var a=e[i],c=e[(i+1)%n];C.copy(a).add(t),C.applyQuaternion(f),C.add(v),L.copy(c).add(t),L.applyQuaternion(f),L.add(v),N.copy(c).add(t),N.applyQuaternion(m),N.add(y),O.copy(a).add(t),O.applyQuaternion(m),O.add(y),o.push(C.x,C.y,C.z),o.push(L.x,L.y,L.z),o.push(O.x,O.y,O.z),o.push(L.x,L.y,L.z),o.push(N.x,N.y,N.z),o.push(O.x,O.y,O.z),D.copy(a),D.applyQuaternion(f),D.normalize(),F.copy(c),F.applyQuaternion(f),F.normalize(),R.copy(c),R.applyQuaternion(m),R.normalize(),I.copy(a),I.applyQuaternion(m),I.normalize(),s.push(D.x,D.y,D.z),s.push(F.x,F.y,F.z),s.push(I.x,I.y,I.z),s.push(F.x,F.y,F.z),s.push(R.x,R.y,R.z),s.push(I.x,I.y,I.z),l.push(r[0],r[1],r[2]),l.push(r[0],r[1],r[2]),l.push(r[0],r[1],r[2]),l.push(r[0],r[1],r[2]),l.push(r[0],r[1],r[2]),l.push(r[0],r[1],r[2])}}P.call(this);var o=[],s=[],l=[],c=[1,1,1],u=[1,1,0],h=new i(0,1,0),d=new i,p=new i,f=new n,m=new n;m.setFromAxisAngle(h,Math.PI/2);var v=new i,y=new i;y.copy(e.getPointAt(0));for(var x=[new i((-.225),0,0),new i(0,(-.05),0),new i(0,(-.175),0),new i(0,(-.05),0),new i(.225,0,0),new i(0,(-.175),0)],b=2*Math.PI,w=5,_=[],S=0;S<w;S++){var A=S/w*b;_.push(new i(.06*Math.sin(A),.06*Math.cos(A),0))}for(var w=6,M=[],S=0;S<w;S++){var A=S/w*b;M.push(new i(.025*Math.sin(A),.025*Math.cos(A),0))}for(var T=new i,E=new i,C=new i,L=new i,N=new i,O=new i,D=new i,F=new i,R=new i,I=new i,U=new i,S=1;S<=t;S++){v.copy(e.getPointAt(S/t)),h.set(0,1,0),d.subVectors(v,y).normalize(),p.crossVectors(h,d).normalize(),h.crossVectors(d,p);var A=Math.atan2(d.x,d.z);f.setFromAxisAngle(h,A),S%2===0&&r(x,u),a(_,U.set(0,-.125,0),u),a(M,U.set(.2,0,0),c),a(M,U.set(-.2,0,0),c),y.copy(v),m.copy(f)}this.addAttribute("position",new g(new Float32Array(o),3)),this.addAttribute("normal",new g(new Float32Array(s),3)),this.addAttribute("color",new g(new Float32Array(l),3))}function fo(e,t){function r(e,t,r){for(var i=0,n=e.length;i<n;i++){var l=e[i],c=e[(i+1)%n];f.copy(l),f.applyQuaternion(s),f.add(t),m.copy(c),m.applyQuaternion(s),m.add(t),v.copy(c),v.applyQuaternion(s),v.add(r),y.copy(l),y.applyQuaternion(s),y.add(r),a.push(f.x,f.y,f.z),a.push(m.x,m.y,m.z),a.push(y.x,y.y,y.z),a.push(m.x,m.y,m.z),a.push(v.x,v.y,v.z),a.push(y.x,y.y,y.z),x.copy(l),x.applyQuaternion(s),x.normalize(),b.copy(c),b.applyQuaternion(s),b.normalize(),w.copy(c),w.applyQuaternion(s),w.normalize(),_.copy(l),_.applyQuaternion(s),_.normalize(),o.push(x.x,x.y,x.z),o.push(b.x,b.y,b.z),o.push(_.x,_.y,_.z),o.push(b.x,b.y,b.z),o.push(w.x,w.y,w.z),o.push(_.x,_.y,_.z)}}P.call(this);for(var a=[],o=[],s=new n,l=new i(0,1,0),c=new i,u=new i,h=[new i(0,.05,(-.05)),new i(0,.05,.05),new i(0,(-.05),0)],d=[new i((-.05),0,.05),new i((-.05),0,(-.05)),new i(.05,0,0)],p=[new i(.05,0,(-.05)),new i(.05,0,.05),new i((-.05),0,0)],f=new i,m=new i,v=new i,y=new i,x=new i,b=new i,w=new i,_=new i,S=new i,A=new i,M=1;M<=t;M++){c.copy(e.getPointAt(M/t)),u.copy(e.getTangentAt(M/t));var T=Math.atan2(u.x,u.z);s.setFromAxisAngle(l,T),c.y>10?(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;r<e.children.length;r++)t.push.apply(t,yo(e.children[r]));return t}function xo(e){for(var t=yo(e),r=new P,i=[],n=[],a=new u(0,0,1),o=new u(0,1,0),s=0;s<t.length;s++){var l=t[s];l.parent&&l.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),n.push(a.r,a.g,a.b),n.push(o.r,o.g,o.b))}r.addAttribute("position",new M(i,3)),r.addAttribute("color",new M(n,3));var c=new R({vertexColors:il,depthTest:!1,depthWrite:!1,transparent:!0});Yt.call(this,r,c),this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}function bo(e,t,r,i){m.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:r,thetaLength:i},this.fromBufferGeometry(new wo(e,t,r,i)),this.mergeVertices()}function wo(e,t,r,n){P.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:r,thetaLength:n},e=e||1,t=void 0!==t?Math.max(3,t):8,r=void 0!==r?r:0,n=void 0!==n?n:2*Math.PI;var a,o,s=[],l=[],c=[],u=[],h=new i,d=new f;for(l.push(0,0,0),c.push(0,0,1),u.push(.5,.5),o=0,a=3;o<=t;o++,a+=3){var p=r+o/t*n;h.x=e*Math.cos(p),h.y=e*Math.sin(p),l.push(h.x,h.y,h.z),c.push(0,0,1),d.x=(l[a]/e+1)/2,d.y=(l[a+1]/e+1)/2,u.push(d.x,d.y)}for(a=1;a<=t;a++)s.push(a,a+1,0);this.setIndex(s),this.addAttribute("position",new M(l,3)),this.addAttribute("normal",new M(c,3)),this.addAttribute("uv",new M(u,2))}function _o(e,t){m.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new So(e,t)),this.mergeVertices()}function So(e,t){var r=(1+Math.sqrt(5))/2,i=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];He.call(this,i,n,e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Ao(e,t){m.call(this),this.type="ShapeGeometry","object"==typeof t&&(console.warn("ShapeGeometry: Options parameter has been removed."),t=t.curveSegments),this.parameters={shapes:e,curveSegments:t},this.fromBufferGeometry(new Mo(e,t)),this.mergeVertices()}function Mo(e,t){function r(e){var r,i,l,u=a.length/3,h=e.extractPoints(t),d=h.shape,p=h.holes;if(dm.isClockWise(d)===!1)for(d=d.reverse(),r=0,i=p.length;r<i;r++)l=p[r],dm.isClockWise(l)===!0&&(p[r]=l.reverse());var f=dm.triangulateShape(d,p);for(r=0,i=p.length;r<i;r++)l=p[r],d=d.concat(l);for(r=0,i=d.length;r<i;r++){var m=d[r];a.push(m.x,m.y,0),o.push(0,0,1),s.push(m.x,m.y)}for(r=0,i=f.length;r<i;r++){var v=f[r],g=v[0]+u,y=v[1]+u,x=v[2]+u;n.push(g,y,x),c+=3}}var i=this;P.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:e,curveSegments:t},t=t||12;var n=[],a=[],o=[],s=[],l=0,c=0;if(Array.isArray(e)===!1)r(e);else for(var u=0;u<e.length;u++)r(e[u]),i.addGroup(l,c,u),l+=c,c=0;this.setIndex(n),this.addAttribute("position",new M(a,3)),this.addAttribute("normal",new M(o,3)),this.addAttribute("uv",new M(s,2))}function To(e,t){if(t.shapes=[],Array.isArray(e))for(var r=0,i=e.length;r<i;r++){var n=e[r];t.shapes.push(n.uuid)}else t.shapes.push(e.uuid);return t}function Eo(){var e=arguments;this.uuid=Fs.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var r=0,i=arguments.length;r!==i;++r)t[e[r].uuid]=r;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var n=this;this.stats={objects:{get total(){return n._objects.length},get inUse(){return this.total-n.nCachedObjects_}},get bindingsPerObject(){return n._bindings.length}}}function Co(e){c.call(this),this.type="Audio",this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.offset=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Lo(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=void 0!==t?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}function Po(){c.call(this),this.type="AudioListener",this.context=ix.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function No(e){Co.call(this,e),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Oo(e,t,r){c.call(this),this.type="CubeCamera";var n=90,a=1,o=new de(n,a,e,t);o.up.set(0,-1,0),o.lookAt(new i(1,0,0)),this.add(o);var s=new de(n,a,e,t);s.up.set(0,-1,0),s.lookAt(new i((-1),0,0)),this.add(s);var l=new de(n,a,e,t);l.up.set(0,0,1),l.lookAt(new i(0,1,0)),this.add(l);var u=new de(n,a,e,t);u.up.set(0,0,-1),u.lookAt(new i(0,(-1),0)),this.add(u);var h=new de(n,a,e,t);h.up.set(0,-1,0),h.lookAt(new i(0,0,1)),this.add(h);var d=new de(n,a,e,t);d.up.set(0,-1,0),d.lookAt(new i(0,0,(-1))),this.add(d);var p={format:yc,magFilter:rc,minFilter:rc};this.renderTarget=new Zt(r,r,p),this.renderTarget.texture.name="CubeCamera",this.update=function(e,t){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,i=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,r.activeCubeFace=0,e.render(t,o,r),r.activeCubeFace=1,e.render(t,s,r),r.activeCubeFace=2,e.render(t,l,r),r.activeCubeFace=3,e.render(t,u,r),r.activeCubeFace=4,e.render(t,h,r),r.texture.generateMipmaps=i,r.activeCubeFace=5,e.render(t,d,r),e.setRenderTarget(null)},this.clear=function(e,t,r,i){for(var n=this.renderTarget,a=0;a<6;a++)n.activeCubeFace=a,e.setRenderTarget(n),e.clear(t,r,i);e.setRenderTarget(null)}}function Do(e,t,r,i){"number"==typeof r&&(i=r,r=!1,console.error("InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),g.call(this,e,t,r),this.meshPerAttribute=i||1}function Fo(e){this.type="Font",this.data=e}function Ro(e,t,r){for(var i=Array.from?Array.from(e):String(e).split(""),n=t/r.resolution,a=(r.boundingBox.yMax-r.boundingBox.yMin+r.underlineThickness)*n,o=[],s=0,l=0,c=0;c<i.length;c++){var u=i[c];if("\n"===u)s=0,l-=a;else{var h=Io(u,n,s,l,r);s+=h.offsetX,o.push(h.path)}}return o}function Io(e,t,r,i,n){var a=n.glyphs[e]||n.glyphs["?"];if(a){var o,s,l,c,u,h,d,p,f=new pi;if(a.o)for(var m=a._cachedOutline||(a._cachedOutline=a.o.split(" ")),v=0,g=m.length;v<g;){var y=m[v++];switch(y){case"m":o=m[v++]*t+r,s=m[v++]*t+i,f.moveTo(o,s);break;case"l":o=m[v++]*t+r,s=m[v++]*t+i,f.lineTo(o,s);break;case"q":l=m[v++]*t+r,c=m[v++]*t+i,u=m[v++]*t+r,h=m[v++]*t+i,f.quadraticCurveTo(u,h,l,c);break;case"b":l=m[v++]*t+r,c=m[v++]*t+i,u=m[v++]*t+r,h=m[v++]*t+i,d=m[v++]*t+r,p=m[v++]*t+i,f.bezierCurveTo(u,h,d,p,l,c)}}return{offsetX:a.ha*t,path:f}}}function Uo(e,t,r,i,n,a,o){ce.call(this,0,e,t,r,i,n,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:a,thetaLength:o}}function ko(e,t,r,i,n,a,o){ue.call(this,0,e,t,r,i,n,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:a,thetaLength:o}}function Bo(e,t){m.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new zo(e,t)),this.mergeVertices()}function zo(e,t){var r=(1+Math.sqrt(5))/2,i=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];He.call(this,n,a,e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function jo(e,t){P.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1;var r,i,n,a,o=[],s=Math.cos(Fs.DEG2RAD*t),l=[0,0],c={},u=["a","b","c"];e.isBufferGeometry?(a=new m,a.fromBufferGeometry(e)):a=e.clone(),a.mergeVertices(),a.computeFaceNormals();for(var h=a.vertices,d=a.faces,p=0,f=d.length;p<f;p++)for(var v=d[p],g=0;g<3;g++)r=v[u[g]],i=v[u[(g+1)%3]],l[0]=Math.min(r,i),l[1]=Math.max(r,i),n=l[0]+","+l[1],void 0===c[n]?c[n]={index1:l[0],index2:l[1],face1:p,face2:void 0}:c[n].face2=p;for(n in c){var y=c[n];if(void 0===y.face2||d[y.face1].normal.dot(d[y.face2].normal)<=s){var x=h[y.index1];o.push(x.x,x.y,x.z),x=h[y.index2],o.push(x.x,x.y,x.z)}}this.addAttribute("position",new M(o,3))}function Vo(e,t){m.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},this.fromBufferGeometry(new Go(e,t)),this.mergeVertices()}function Go(e,t){function r(e){function r(e,t,r){return t||console.error("ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(r).add(e)}function s(e,t,r){var i,n,a,o=e.x-t.x,s=e.y-t.y,l=r.x-e.x,c=r.y-e.y,u=o*o+s*s,h=o*c-s*l;if(Math.abs(h)>Number.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<Q;Z++)Y=z[Z],d(Y[2]+r,Y[1]+r,Y[0]+r);for(t=x+2*A,r=q*t,Z=0;Z<Q;Z++)Y=z[Z],d(Y[0]+r,Y[1]+r,Y[2]+r)}else{for(Z=0;Z<Q;Z++)Y=z[Z],d(Y[2],Y[1],Y[0]);for(Z=0;Z<Q;Z++)Y=z[Z],d(Y[0]+q*x,Y[1]+q*x,Y[2]+q*x)}n.addGroup(e,a.length/3-e,0)}function c(){var e=a.length/3,t=0;for(u(j,t),t+=j.length,F=0,R=k.length;F<R;F++)D=k[F],u(D,t),t+=D.length;n.addGroup(e,a.length/3-e,1)}function u(e,t){var r,i;for(Z=e.length;--Z>=0;){r=Z,i=Z-1,i<0&&(i=e.length-1);var n=0,a=x+2*A;for(n=0;n<a;n++){var o=q*n,s=q*(n+1),l=t+r+o,c=t+i+o,u=t+i+s,h=t+r+s;p(l,c,u,h)}}}function h(e,t,r){g.push(e),g.push(t),g.push(r)}function d(e,t,r){m(e),m(t),m(r);var i=a.length/3,o=T.generateTopUV(n,a,i-3,i-2,i-1);v(o[0]),v(o[1]),v(o[2])}function p(e,t,r,i){m(e),m(t),m(i),m(t),m(r),m(i);var o=a.length/3,s=T.generateSideWallUV(n,a,o-6,o-3,o-2,o-1);v(s[0]),v(s[1]),v(s[3]),v(s[1]),v(s[2]),v(s[3])}function m(e){a.push(g[3*e+0]),a.push(g[3*e+1]),a.push(g[3*e+2])}function v(e){o.push(e.x),o.push(e.y)}var g=[],y=void 0!==t.curveSegments?t.curveSegments:12,x=void 0!==t.steps?t.steps:1,b=void 0!==t.depth?t.depth:100,w=void 0===t.bevelEnabled||t.bevelEnabled,_=void 0!==t.bevelThickness?t.bevelThickness:6,S=void 0!==t.bevelSize?t.bevelSize:_-2,A=void 0!==t.bevelSegments?t.bevelSegments:3,M=t.extrudePath,T=void 0!==t.UVGenerator?t.UVGenerator:nx;void 0!==t.amount&&(console.warn("ExtrudeBufferGeometry: amount has been renamed to depth."),b=t.amount);var E,C,L,P,N,O=!1;M&&(E=M.getSpacedPoints(x),O=!0,w=!1,C=M.computeFrenetFrames(x,!1),L=new i,P=new i,N=new i),w||(A=0,_=0,S=0);var D,F,R,I=e.extractPoints(y),U=I.shape,k=I.holes,B=!dm.isClockWise(U);if(B)for(U=U.reverse(),F=0,R=k.length;F<R;F++)D=k[F],dm.isClockWise(D)&&(k[F]=D.reverse());var z=dm.triangulateShape(U,k),j=U;for(F=0,R=k.length;F<R;F++)D=k[F],U=U.concat(D);for(var V,G,W,X,H,Y,q=U.length,Q=z.length,J=[],Z=0,K=j.length,$=K-1,ee=Z+1;Z<K;Z++,$++,ee++)$===K&&($=0),ee===K&&(ee=0),J[Z]=s(j[Z],j[$],j[ee]);var te,re=[],ie=J.concat();for(F=0,R=k.length;F<R;F++){for(D=k[F],te=[],Z=0,K=D.length,$=K-1,ee=Z+1;Z<K;Z++,$++,ee++)$===K&&($=0),ee===K&&(ee=0),te[Z]=s(D[Z],D[$],D[ee]);re.push(te),ie=ie.concat(te)}for(V=0;V<A;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<K;Z++)H=r(j[Z],J[Z],G),h(H.x,H.y,-X);for(F=0,R=k.length;F<R;F++)for(D=k[F],te=re[F],Z=0,K=D.length;Z<K;Z++)H=r(D[Z],te[Z],G),h(H.x,H.y,-X)}for(G=S,Z=0;Z<q;Z++)H=w?r(U[Z],ie[Z],G):U[Z],O?(P.copy(C.normals[0]).multiplyScalar(H.x),L.copy(C.binormals[0]).multiplyScalar(H.y),N.copy(E[0]).add(P).add(L),h(N.x,N.y,N.z)):h(H.x,H.y,0);var ne;for(ne=1;ne<=x;ne++)for(Z=0;Z<q;Z++)H=w?r(U[Z],ie[Z],G):U[Z],O?(P.copy(C.normals[ne]).multiplyScalar(H.x),L.copy(C.binormals[ne]).multiplyScalar(H.y),N.copy(E[ne]).add(P).add(L),h(N.x,N.y,N.z)):h(H.x,H.y,b/x*ne);for(V=A-1;V>=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<K;Z++)H=r(j[Z],J[Z],G),h(H.x,H.y,b+X);for(F=0,R=k.length;F<R;F++)for(D=k[F],te=re[F],Z=0,K=D.length;Z<K;Z++)H=r(D[Z],te[Z],G),O?h(H.x,H.y+E[x-1].y,E[x-1].x+X):h(H.x,H.y,b+X)}l(),c()}P.call(this),this.type="ExtrudeBufferGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];for(var n=this,a=[],o=[],s=0,l=e.length;s<l;s++){var c=e[s];r(c)}this.addAttribute("position",new M(a,3)),this.addAttribute("uv",new M(o,2)),this.computeVertexNormals()}function Wo(e,t,r){if(r.shapes=[],Array.isArray(e))for(var i=0,n=e.length;i<n;i++){var a=e[i];r.shapes.push(a.uuid)}else r.shapes.push(e.uuid);return void 0!==t.extrudePath&&(r.options.extrudePath=t.extrudePath.toJSON()),r}function Xo(e,t,r,i){m.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:i},this.fromBufferGeometry(new Ho(e,t,r,i)),this.mergeVertices()}function Ho(e,t,r,n){P.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:n},t=Math.floor(t)||12,r=r||0,n=n||2*Math.PI,n=Fs.clamp(n,0,2*Math.PI);var a,o,s,l=[],c=[],u=[],h=1/t,d=new i,p=new f;for(o=0;o<=t;o++){var m=r+o*h*n,v=Math.sin(m),g=Math.cos(m);for(s=0;s<=e.length-1;s++)d.x=e[s].x*v,d.y=e[s].y,d.z=e[s].x*g,c.push(d.x,d.y,d.z),p.x=o/t,p.y=s/(e.length-1),u.push(p.x,p.y)}for(o=0;o<t;o++)for(s=0;s<e.length-1;s++){a=s+o*e.length;var y=a,x=a+e.length,b=a+e.length+1,w=a+1;l.push(y,x,w),l.push(x,b,w)}if(this.setIndex(l),this.addAttribute("position",new M(c,3)),this.addAttribute("uv",new M(u,2)),this.computeVertexNormals(),n===2*Math.PI){var _=this.attributes.normal.array,S=new i,A=new i,T=new i;for(a=t*e.length*3,o=0,s=0;o<e.length;o++,s+=3)S.x=_[s+0],S.y=_[s+1],S.z=_[s+2],A.x=_[a+s+0],A.y=_[a+s+1],A.z=_[a+s+2],T.addVectors(S,A).normalize(),_[s+0]=_[a+s+0]=T.x,_[s+1]=_[a+s+1]=T.y,_[s+2]=_[a+s+2]=T.z}}function Yo(e,t,r){m.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:r},this.fromBufferGeometry(new qo(e,t,r)),this.mergeVertices()}function qo(e,t,r){P.call(this),this.type="ParametricBufferGeometry",this.parameters={func:e,slices:t,stacks:r};var n,a,o=[],s=[],l=[],c=[],u=1e-5,h=new i,d=new i,p=new i,f=new i,m=new i;e.length<3&&console.error("ParametricGeometry: Function must now modify a Vector3 as third parameter.");var v=t+1;for(n=0;n<=r;n++){var g=n/r;for(a=0;a<=t;a++){var y=a/t;e(y,g,d),s.push(d.x,d.y,d.z),y-u>=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;n<r;n++)for(a=0;a<t;a++){var x=n*v+a,b=n*v+a+1,w=(n+1)*v+a+1,_=(n+1)*v+a;o.push(x,b,_),o.push(b,w,_)}this.setIndex(o),this.addAttribute("position",new M(s,3)),this.addAttribute("normal",new M(l,3)),this.addAttribute("uv",new M(c,2))}function Qo(e,t,r,i,n,a){m.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:r,phiSegments:i,thetaStart:n,thetaLength:a},this.fromBufferGeometry(new Jo(e,t,r,i,n,a)),this.mergeVertices()}function Jo(e,t,r,n,a,o){P.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:r,phiSegments:n,thetaStart:a,thetaLength:o},e=e||.5,t=t||1,a=void 0!==a?a:0,o=void 0!==o?o:2*Math.PI,r=void 0!==r?Math.max(3,r):8,n=void 0!==n?Math.max(1,n):1;var s,l,c,u=[],h=[],d=[],p=[],m=e,v=(t-e)/n,g=new i,y=new f;for(l=0;l<=n;l++){for(c=0;c<=r;c++)s=a+c/r*o,g.x=m*Math.cos(s),g.y=m*Math.sin(s),h.push(g.x,g.y,g.z),d.push(0,0,1),y.x=(g.x/t+1)/2,y.y=(g.y/t+1)/2,p.push(y.x,y.y);m+=v}for(l=0;l<n;l++){var x=l*(r+1);for(c=0;c<r;c++){s=c+x;var b=s,w=s+r+1,_=s+r+2,S=s+1;u.push(b,w,S),u.push(w,_,S)}}this.setIndex(u),this.addAttribute("position",new M(h,3)),this.addAttribute("normal",new M(d,3)),this.addAttribute("uv",new M(p,2))}function Zo(e,t){m.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Ko(e,t)),this.mergeVertices()}function Ko(e,t){var r=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];He.call(this,r,i,e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function $o(e,t){m.call(this),this.type="TextGeometry",this.parameters={text:e,parameters:t},this.fromBufferGeometry(new es(e,t)),this.mergeVertices()}function es(e,t){t=t||{};var r=t.font;if(!r||!r.isFont)return console.error("TextGeometry: font parameter is not an instance of Font."),new m;var i=r.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),Go.call(this,i,t),this.type="TextBufferGeometry"}function ts(e,t,r,i,n,a,o){m.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:r,radialSegments:i,p:n,q:a},void 0!==o&&console.warn("TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new rs(e,t,r,i,n,a)),this.mergeVertices()}function rs(e,t,r,n,a,o){function s(e,t,r,i,n){var a=Math.cos(e),o=Math.sin(e),s=r/t*e,l=Math.cos(s);n.x=i*(2+l)*.5*a,n.y=i*(2+l)*o*.5,n.z=i*Math.sin(s)*.5}P.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:r,radialSegments:n,p:a,q:o},e=e||1,t=t||.4,r=Math.floor(r)||64,n=Math.floor(n)||8,a=a||2,o=o||3;var l,c,u=[],h=[],d=[],p=[],f=new i,m=new i,v=new i,g=new i,y=new i,x=new i,b=new i;for(l=0;l<=r;++l){var w=l/r*a*Math.PI*2;for(s(w,a,o,e,v),s(w+.01,a,o,e,g),x.subVectors(g,v),b.addVectors(g,v),y.crossVectors(x,b),b.crossVectors(y,x),y.normalize(),b.normalize(),c=0;c<=n;++c){var _=c/n*Math.PI*2,S=-t*Math.cos(_),A=t*Math.sin(_);f.x=v.x+(S*b.x+A*y.x),f.y=v.y+(S*b.y+A*y.y),f.z=v.z+(S*b.z+A*y.z),h.push(f.x,f.y,f.z),m.subVectors(f,v).normalize(),d.push(m.x,m.y,m.z),p.push(l/r),p.push(c/n)}}for(c=1;c<=r;c++)for(l=1;l<=n;l++){var T=(n+1)*(c-1)+(l-1),E=(n+1)*c+(l-1),C=(n+1)*c+l,L=(n+1)*(c-1)+l;u.push(T,E,L),u.push(E,C,L)}this.setIndex(u),this.addAttribute("position",new M(h,3)),this.addAttribute("normal",new M(d,3)),this.addAttribute("uv",new M(p,2))}function is(e,t,r,i,n,a){m.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:r,radialSegments:i,closed:n},void 0!==a&&console.warn("TubeGeometry: taper has been removed.");var o=new ns(e,t,r,i,n);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function ns(e,t,r,n,a){function o(){for(h=0;h<t;h++)s(h);s(a===!1?t:0),c(),l()}function s(i){g=e.getPointAt(i/t,g);var a=u.normals[i],o=u.binormals[i];for(d=0;d<=n;d++){var s=d/n*Math.PI*2,l=Math.sin(s),c=-Math.cos(s);m.x=c*a.x+l*o.x,m.y=c*a.y+l*o.y,m.z=c*a.z+l*o.z,m.normalize(),x.push(m.x,m.y,m.z),p.x=g.x+r*m.x,p.y=g.y+r*m.y,p.z=g.z+r*m.z,y.push(p.x,p.y,p.z)}}function l(){for(d=1;d<=t;d++)for(h=1;h<=n;h++){var e=(n+1)*(d-1)+(h-1),r=(n+1)*d+(h-1),i=(n+1)*d+h,a=(n+1)*(d-1)+h;w.push(e,r,a),w.push(r,i,a)}}function c(){for(h=0;h<=t;h++)for(d=0;d<=n;d++)v.x=h/t,v.y=d/n,b.push(v.x,v.y)}P.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:r,radialSegments:n,closed:a},t=t||64,r=r||1,n=n||8,a=a||!1;var u=e.computeFrenetFrames(t,a);this.tangents=u.tangents,this.normals=u.normals,this.binormals=u.binormals;var h,d,p=new i,m=new i,v=new f,g=new i,y=[],x=[],b=[],w=[];o(),this.setIndex(w),this.addAttribute("position",new M(y,3)),this.addAttribute("normal",new M(x,3)),this.addAttribute("uv",new M(b,2))}function as(e,t,r,i,n,a){c.call(this),void 0===i&&(i=16776960),void 0===r&&(r=1),void 0===n&&(n=.2*r),void 0===a&&(a=.2*n),void 0===ax&&(ax=new P,ax.addAttribute("position",new M([0,0,0,0,1,0],3)),ox=new ue(0,.5,1,5,1),ox.translate(0,-.5,0)),this.position.copy(t),this.line=new B(ax,new R({color:i})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new k(ox,new F({color:i})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(r,n,a)}function os(e){e=e||1;var t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new P;i.addAttribute("position",new M(t,3)),i.addAttribute("color",new M(r,3));var n=new R({vertexColors:il});Yt.call(this,i,n)}function ss(e,t){this.type="Box3Helper",this.box=e;var r=void 0!==t?t:16776960,i=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]),n=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],a=new P;a.setIndex(new g(i,1)),a.addAttribute("position",new M(n,3)),Yt.call(this,a,new R({color:r})),this.geometry.computeBoundingSphere()}function ls(e){function t(e,t,i){r(e,i),r(t,i)}function r(e,t){a.push(0,0,0),o.push(t.r,t.g,t.b),void 0===s[e]&&(s[e]=[]),s[e].push(a.length/3-1)}var i=new P,n=new R({color:16777215,vertexColors:rl}),a=[],o=[],s={},l=new u(16755200),c=new u(16711680),h=new u(43775),d=new u(16777215),p=new u(3355443);t("n1","n2",l),t("n2","n4",l),t("n4","n3",l),t("n3","n1",l),t("f1","f2",l),t("f2","f4",l),t("f4","f3",l),t("f3","f1",l),t("n1","f1",l),t("n2","f2",l),t("n3","f3",l),t("n4","f4",l),t("p","n1",c),t("p","n2",c),t("p","n3",c),t("p","n4",c),t("u1","u2",h),t("u2","u3",h),t("u3","u1",h),t("c","t",d),t("p","c",p),t("cn1","cn2",p),t("cn3","cn4",p),t("cf1","cf2",p),t("cf3","cf4",p),i.addAttribute("position",new M(a,3)),i.addAttribute("color",new M(o,3)),Yt.call(this,i,n),this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}function cs(e,t,r){c.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,void 0===t&&(t=1);var i=new P;i.addAttribute("position",new M([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));var n=new R({fog:!1});this.lightPlane=new B(i,n),this.add(this.lightPlane),i=new P,i.addAttribute("position",new M([0,0,0,0,0,1],3)),this.targetLine=new B(i,n),this.add(this.targetLine),this.update()}function us(e,t,r,i){this.object=e,this.size=void 0!==t?t:1;var n=void 0!==r?r:16776960,a=void 0!==i?i:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=s.faces.length:console.warn("FaceNormalsHelper: only Geometry is supported. Use VertexNormalsHelper, instead.");var l=new P,c=new M(2*o*3,3);l.addAttribute("position",c),Yt.call(this,l,new R({color:n,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}function hs(e,t,r,i){e=e||10,t=t||10,r=new u(void 0!==r?r:4473924),i=new u(void 0!==i?i:8947848);for(var n=t/2,a=e/t,o=e/2,s=[],l=[],c=0,h=0,d=-o;c<=t;c++,d+=a){s.push(-o,0,d,o,0,d),s.push(d,0,-o,d,0,o);var p=c===n?r:i;p.toArray(l,h),h+=3,p.toArray(l,h),h+=3,p.toArray(l,h),h+=3,p.toArray(l,h),h+=3}var f=new P;f.addAttribute("position",new M(s,3)),f.addAttribute("color",new M(l,3));var m=new R({vertexColors:il});Yt.call(this,f,m)}function ds(e,t,r){c.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r;var i=new qe(t);i.rotateY(.5*Math.PI),this.material=new F({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=il);var n=i.getAttribute("position"),a=new Float32Array(3*n.count);i.addAttribute("color",new g(a,3)),this.add(new k(i,this.material)),
|
|
this.update()}function ps(e,t,r){this.type="PlaneHelper",this.plane=e,this.size=void 0===t?1:t;var i=void 0!==r?r:16776960,n=[1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],a=new P;a.addAttribute("position",new M(n,3)),a.computeBoundingSphere(),B.call(this,a,new R({color:i}));var o=[1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],s=new P;s.addAttribute("position",new M(o,3)),s.computeBoundingSphere(),this.add(new k(s,new F({color:i,opacity:.2,transparent:!0,depthWrite:!1})))}function fs(e,t,r){this.light=e,this.light.updateMatrixWorld(),this.color=r;var i=new O(t,4,2),n=new F({wireframe:!0,fog:!1});k.call(this,i,n),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}function ms(e,t,r,i,n,a){e=e||10,t=t||16,r=r||8,i=i||64,n=new u(void 0!==n?n:4473924),a=new u(void 0!==a?a:8947848);var o,s,l,c,h,d,p,f=[],m=[];for(c=0;c<=t;c++)l=c/t*(2*Math.PI),o=Math.sin(l)*e,s=Math.cos(l)*e,f.push(0,0,0),f.push(o,0,s),p=1&c?n:a,m.push(p.r,p.g,p.b),m.push(p.r,p.g,p.b);for(c=0;c<=r;c++)for(p=1&c?n:a,d=e-e/r*c,h=0;h<i;h++)l=h/i*(2*Math.PI),o=Math.sin(l)*d,s=Math.cos(l)*d,f.push(o,0,s),m.push(p.r,p.g,p.b),l=(h+1)/i*(2*Math.PI),o=Math.sin(l)*d,s=Math.cos(l)*d,f.push(o,0,s),m.push(p.r,p.g,p.b);var v=new P;v.addAttribute("position",new M(f,3)),v.addAttribute("color",new M(m,3));var g=new R({vertexColors:il});Yt.call(this,v,g)}function vs(e,t){c.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;var r=new R({fog:!1}),i=new P;i.addAttribute("position",new g(new Float32Array(15),3)),this.line=new B(i,r),this.add(this.line),this.update()}function gs(e,t){c.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;for(var r=new P,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],n=0,a=1,o=32;n<o;n++,a++){var s=n/o*Math.PI*2,l=a/o*Math.PI*2;i.push(Math.cos(s),Math.sin(s),1,Math.cos(l),Math.sin(l),1)}r.addAttribute("position",new M(i,3));var u=new R({fog:!1});this.cone=new Yt(r,u),this.add(this.cone),this.update()}function ys(e,t,r,i){this.object=e,this.size=void 0!==t?t:1;var n=void 0!==r?r:16711680,a=void 0!==i?i:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var l=new P,c=new M(2*o*3,3);l.addAttribute("position",c),Yt.call(this,l,new R({color:n,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}function xs(e,t,r,i){kt.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==r?r:10,this.height=void 0!==i?i:10}function bs(e){this.manager=void 0!==e?e:Du}function ws(e){this.manager=void 0!==e?e:Du}function _s(e){this.manager=void 0!==e?e:Du}function Ss(e){this.manager=void 0!==e?e:Du}function As(e){this.manager=void 0!==e?e:Du}function Ms(e){"undefined"==typeof createImageBitmap&&console.warn("ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("ImageBitmapLoader: fetch() not supported."),this.manager=void 0!==e?e:Du,this.options=void 0}function Ts(){c.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Es(e,t,r){this.name="",this.color=new u(e),this.near=void 0!==t?t:1,this.far=void 0!==r?r:1e3}function Cs(e,t){this.name="",this.color=new u(e),this.density=void 0!==t?t:25e-5}function Ls(e){this.manager=void 0!==e?e:Du,this.texturePath=""}function Ps(e,t,r){return this.radius=void 0!==e?e:1,this.theta=void 0!==t?t:0,this.y=void 0!==r?r:0,this}function Ns(e){function t(e,t,r){var i=0;(void 0===e||e)&&(i|=s.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=s.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=s.STENCIL_BUFFER_BIT),s.clear(i)}function r(e){void 0!==e&&(C=e,i(L.z,L.w,!1))}function i(e,t,r){T=e,E=t,l.width=e*C,l.height=t*C,r!==!1&&(l.style.width=e+"px",l.style.height=t+"px"),n(0,0,e,t)}function n(e,t,r,i){N.viewport(L.set(e,t,r,i))}function a(e,t){if(void 0!==t&&t.isCamera!==!0)return void console.error("WebGL2Renderer.render: camera is not an instance of Camera.");var r=e.background;null===r?N.buffers.color.setClear(A.r,A.g,A.b,M,m):r&&r.isColor&&N.buffers.color.setClear(r.r,r.g,r.b,1,m),this.clear(w,_,S)}function o(e){e.preventDefault()}console.log("WebGL2Renderer",Bs),e=e||{};var s,l=void 0!==e.canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),c=void 0!==e.context?e.context:null,h=void 0!==e.alpha&&e.alpha,d=void 0===e.depth||e.depth,p=void 0===e.stencil||e.stencil,f=void 0!==e.antialias&&e.antialias,m=void 0===e.premultipliedAlpha||e.premultipliedAlpha,g=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,y=void 0!==e.powerPreference?e.powerPreference:"default";try{var x={alpha:h,depth:d,stencil:p,antialias:f,premultipliedAlpha:m,preserveDrawingBuffer:g,powerPreference:y};if(l.addEventListener("webglcontextlost",o,!1),l.addEventListener("webglcontextrestored",function(){}),s=c||l.getContext("webgl2",x),null===s)throw null!==l.getContext("webgl2")?new Error("Error creating WebGL2 context with your selected attributes."):new Error("Error creating WebGL2 context.")}catch(b){console.error("WebGL2Renderer: "+b.message)}var w=!0,_=!0,S=!0,A=new u(0),M=0,T=l.width,E=l.height,C=1,L=new v(0,0,T,E),P=new Gn(s),N=new no(s,P,function(){});return{domElement:l,clear:t,setPixelRatio:r,setSize:i,render:a}}function Os(e,t,r,i,n,a,o,s,l){ve.call(this,e,t,r,i,n,a,o,s,l),this.generateMipmaps=!1}var Ds={};"undefined"!=typeof Window?Ds&&Ds instanceof Window?Ds=Ds:t&&t instanceof Window?Ds=t:GLOBAL&&GLOBAL instanceof Window?Ds=GLOBAL:console.warn("Unable to find classic window global variable declaration. Some dependencies that depending on global window variable could not work properly."):console.warn("It seems you are using this package in a non-browser environment. Some dependencies that depending on global window variable could not work properly."),Object.defineProperty(e,"__esModule",{value:!0}),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:e>0?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<arguments.length;i++){var n=t[i];if(void 0!==n&&null!==n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r}}();var Fs={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){for(var e=[],t=0;t<256;t++)e[t]=(t<16?"0":"")+t.toString(16);return function(){var t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0,a=e[255&t]+e[t>>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<n;i++)e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.applyMatrix4(r),t.setXYZ(i,e.x,e.y,e.z);return t}}(),determinant:function(){var e=this.elements,t=e[0],r=e[4],i=e[8],n=e[12],a=e[1],o=e[5],s=e[9],l=e[13],c=e[2],u=e[6],h=e[10],d=e[14],p=e[3],f=e[7],m=e[11],v=e[15];return p*(+n*s*u-i*l*u-n*o*h+r*l*h+i*o*d-r*s*d)+f*(+t*s*d-t*l*h+n*a*h-i*a*d+i*l*c-n*s*c)+m*(+t*l*u-t*o*d-n*a*u+r*a*d+n*o*c-r*l*c)+v*(-i*o*c-t*s*u+t*o*h+i*a*u-r*a*h+r*s*c)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},setPosition:function(e){var t=this.elements;return t[12]=e.x,t[13]=e.y,t[14]=e.z,this},getInverse:function(e,t){var r=this.elements,i=e.elements,n=i[0],a=i[1],o=i[2],s=i[3],l=i[4],c=i[5],u=i[6],h=i[7],d=i[8],p=i[9],f=i[10],m=i[11],v=i[12],g=i[13],y=i[14],x=i[15],b=p*y*h-g*f*h+g*u*m-c*y*m-p*u*x+c*f*x,w=v*f*h-d*y*h-v*u*m+l*y*m+d*u*x-l*f*x,_=d*g*h-v*p*h+v*c*m-l*g*m-d*c*x+l*p*x,S=v*p*u-d*g*u-v*c*f+l*g*f+d*c*y-l*p*y,A=n*b+a*w+o*_+s*S;if(0===A){var M="Matrix4: .getInverse() can't invert matrix, determinant is 0";if(t===!0)throw new Error(M);return console.warn(M),this.identity()}var T=1/A;return r[0]=b*T,r[1]=(g*f*s-p*y*s-g*o*m+a*y*m+p*o*x-a*f*x)*T,r[2]=(c*y*s-g*u*s+g*o*h-a*y*h-c*o*x+a*u*x)*T,r[3]=(p*u*s-c*f*s-p*o*h+a*f*h+c*o*m-a*u*m)*T,r[4]=w*T,r[5]=(d*y*s-v*f*s+v*o*m-n*y*m-d*o*x+n*f*x)*T,r[6]=(v*u*s-l*y*s-v*o*h+n*y*h+l*o*x-n*u*x)*T,r[7]=(l*f*s-d*u*s+d*o*h-n*f*h-l*o*m+n*u*m)*T,r[8]=_*T,r[9]=(v*p*s-d*g*s-v*a*m+n*g*m+d*a*x-n*p*x)*T,r[10]=(l*g*s-v*c*s+v*a*h-n*g*h-l*a*x+n*c*x)*T,r[11]=(d*c*s-l*p*s-d*a*h+n*p*h+l*a*m-n*c*m)*T,r[12]=S*T,r[13]=(d*g*o-v*p*o+v*a*f-n*g*f-d*a*y+n*p*y)*T,r[14]=(v*c*o-l*g*o-v*a*u+n*g*u+l*a*y-n*c*y)*T,r[15]=(l*p*o-d*c*o+d*a*u-n*p*u-l*a*f+n*c*f)*T,this},scale:function(e){var t=this.elements,r=e.x,i=e.y,n=e.z;return t[0]*=r,t[4]*=i,t[8]*=n,t[1]*=r,t[5]*=i,t[9]*=n,t[2]*=r,t[6]*=i,t[10]*=n,t[3]*=r,t[7]*=i,t[11]*=n,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,i))},makeTranslation:function(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var r=Math.cos(t),i=Math.sin(t),n=1-r,a=e.x,o=e.y,s=e.z,l=n*a,c=n*o;return this.set(l*a+r,l*o-i*s,l*s+i*o,0,l*o+i*s,c*o+r,c*s-i*a,0,l*s-i*o,c*s+i*a,n*s*s+r,0,0,0,0,1),this},makeScale:function(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this},makeShear:function(e,t,r){return this.set(1,t,r,0,e,1,r,0,e,t,1,0,0,0,0,1),this},compose:function(e,t,r){var i=this.elements,n=t._x,a=t._y,o=t._z,s=t._w,l=n+n,c=a+a,u=o+o,h=n*l,d=n*c,p=n*u,f=a*c,m=a*u,v=o*u,g=s*l,y=s*c,x=s*u,b=r.x,w=r.y,_=r.z;return i[0]=(1-(f+v))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*w,i[5]=(1-(h+v))*w,i[6]=(m+g)*w,i[7]=0,i[8]=(p+y)*_,i[9]=(m-g)*_,i[10]=(1-(h+f))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},decompose:function(){var e=new i,t=new r;return function(r,i,n){var a=this.elements,o=e.set(a[0],a[1],a[2]).length(),s=e.set(a[4],a[5],a[6]).length(),l=e.set(a[8],a[9],a[10]).length(),c=this.determinant();c<0&&(o=-o),r.x=a[12],r.y=a[13],r.z=a[14],t.copy(this);var u=1/o,h=1/s,d=1/l;return t.elements[0]*=u,t.elements[1]*=u,t.elements[2]*=u,t.elements[4]*=h,t.elements[5]*=h,t.elements[6]*=h,t.elements[8]*=d,t.elements[9]*=d,t.elements[10]*=d,i.setFromRotationMatrix(t),n.x=o,n.y=s,n.z=l,this}}(),makePerspective:function(e,t,r,i,n,a){void 0===a&&console.warn("Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var o=this.elements,s=2*n/(t-e),l=2*n/(r-i),c=(t+e)/(t-e),u=(r+i)/(r-i),h=-(a+n)/(a-n),d=-2*a*n/(a-n);return o[0]=s,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makeOrthographic:function(e,t,r,i,n,a){var o=this.elements,s=1/(t-e),l=1/(r-i),c=1/(a-n),u=(t+e)*s,h=(r+i)*l,d=(a+n)*c;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(e){for(var t=this.elements,r=e.elements,i=0;i<16;i++)if(t[i]!==r[i])return!1;return!0},fromArray:function(e,t){var r=this;void 0===t&&(t=0);for(var i=0;i<16;i++)r.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}),Object.assign(i.prototype,{isVector3:!0,set:function(e,t,r){return this.x=e,this.y=t,this.z=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e=new n;return function(t){return t&&t.isEuler||console.error("Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e=new n;return function(t,r){return this.applyQuaternion(e.setFromAxisAngle(t,r))}}(),applyMatrix3:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[3]*r+n[6]*i,this.y=n[1]*t+n[4]*r+n[7]*i,this.z=n[2]*t+n[5]*r+n[8]*i,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements,a=1/(n[3]*t+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*t+n[4]*r+n[8]*i+n[12])*a,this.y=(n[1]*t+n[5]*r+n[9]*i+n[13])*a,this.z=(n[2]*t+n[6]*r+n[10]*i+n[14])*a,this},applyQuaternion:function(e){var t=this.x,r=this.y,i=this.z,n=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*i-o*r,c=s*r+o*t-n*i,u=s*i+n*r-a*t,h=-n*t-a*r-o*i;return this.x=l*s+h*-n+c*-o-u*-a,this.y=c*s+h*-a+u*-n-l*-o,this.z=u*s+h*-o+l*-a-c*-n,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(){var e=new r;return function(t){return this.applyMatrix4(e.getInverse(t.projectionMatrix)).applyMatrix4(t.matrixWorld)}}(),transformDirection:function(e){var t=this.x,r=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*r+n[8]*i,this.y=n[1]*t+n[5]*r+n[9]*i,this.z=n[2]*t+n[6]*r+n[10]*i,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},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.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new i,t=new i;return function(r,i){return e.set(r,r,r),t.set(i,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.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),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.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},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.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},cross:function(e,t){return void 0!==t?(console.warn("Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var r=e.x,i=e.y,n=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-n*o,this.y=n*a-r*s,this.z=r*o-i*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new i;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new i;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(Fs.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,r){var i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},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},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},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(n,{slerp:function(e,t,r,i){return r.copy(e).slerp(t,i)},slerpFlat:function(e,t,r,i,n,a,o){var s=r[i+0],l=r[i+1],c=r[i+2],u=r[i+3],h=n[a+0],d=n[a+1],p=n[a+2],f=n[a+3];if(u!==f||s!==h||l!==d||c!==p){var m=1-o,v=s*h+l*d+c*p+u*f,g=v>=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,e<r?(e=0,Math.abs(n.x)>Math.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;a<o;a++)n[a].call(t,e)}}}}),o.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],o.DefaultOrder="XYZ",Object.defineProperties(o.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()}},order:{get:function(){return this._order},set:function(e){this._order=e,this.onChangeCallback()}}}),Object.assign(o.prototype,{isEuler:!0,set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._order=i||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,r){var i=Fs.clamp,n=e.elements,a=n[0],o=n[4],s=n[8],l=n[1],c=n[5],u=n[9],h=n[2],d=n[6],p=n[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(d,c),this._z=0)):"YXZ"===t?(this._x=Math.asin(-i(u,-1,1)),
|
|
Math.abs(u)<.99999?(this._y=Math.atan2(s,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(i(d,-1,1)),Math.abs(d)<.99999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,a))):"ZYX"===t?(this._y=Math.asin(-i(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-o,c))):"YZX"===t?(this._z=Math.asin(i(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(s,p))):"XZY"===t?(this._z=Math.asin(-i(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(d,c),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-u,p),this._y=0)):console.warn("Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,r!==!1&&this.onChangeCallback(),this},setFromQuaternion:function(){var e=new r;return function(t,r,i){return e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,r,i)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new n;return function(t){return e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},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._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new i(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(s.prototype,{set:function(e){this.mask=1<<e|0},enable:function(e){this.mask|=1<<e|0},toggle:function(e){this.mask^=1<<e|0},disable:function(e){this.mask&=~(1<<e|0)},test:function(e){return 0!==(this.mask&e.mask)}}),Object.assign(l.prototype,{isMatrix3:!0,set:function(e,t,r,i,n,a,o,s,l){var c=this.elements;return c[0]=e,c[1]=i,c[2]=o,c[3]=t,c[4]=n,c[5]=s,c[6]=r,c[7]=a,c[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).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],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(){var e=new i;return function(t){for(var r=this,i=0,n=t.count;i<n;i++)e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.applyMatrix3(r),t.setXYZ(i,e.x,e.y,e.z);return t}}(),multiply:function(e){return 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[3],s=r[6],l=r[1],c=r[4],u=r[7],h=r[2],d=r[5],p=r[8],f=i[0],m=i[3],v=i[6],g=i[1],y=i[4],x=i[7],b=i[2],w=i[5],_=i[8];return n[0]=a*f+o*g+s*b,n[3]=a*m+o*y+s*w,n[6]=a*v+o*x+s*_,n[1]=l*f+c*g+u*b,n[4]=l*m+c*y+u*w,n[7]=l*v+c*x+u*_,n[2]=h*f+d*g+p*b,n[5]=h*m+d*y+p*w,n[8]=h*v+d*x+p*_,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*a*c-t*o*l-r*n*c+r*o*s+i*n*l-i*a*s},getInverse:function(e,t){e&&e.isMatrix4&&console.error("Matrix3: .getInverse() no longer takes a Matrix4 argument.");var r=e.elements,i=this.elements,n=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],h=r[7],d=r[8],p=d*l-c*h,f=c*u-d*s,m=h*s-l*u,v=n*p+a*f+o*m;if(0===v){var g="Matrix3: .getInverse() can't invert matrix, determinant is 0";if(t===!0)throw new Error(g);return console.warn(g),this.identity()}var y=1/v;return i[0]=p*y,i[1]=(o*h-d*a)*y,i[2]=(c*a-o*l)*y,i[3]=f*y,i[4]=(d*n-o*u)*y,i[5]=(o*s-c*n)*y,i[6]=m*y,i[7]=(a*u-h*n)*y,i[8]=(l*n-a*s)*y,this},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},setUvTransform:function(e,t,r,i,n,a,o){var s=Math.cos(n),l=Math.sin(n);this.set(r*s,r*l,-r*(s*a+l*o)+a+e,-i*l,i*s,-i*(-l*a+s*o)+o+t,0,0,1)},scale:function(e,t){var r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=t,r[4]*=t,r[7]*=t,this},rotate:function(e){var t=Math.cos(e),r=Math.sin(e),i=this.elements,n=i[0],a=i[3],o=i[6],s=i[1],l=i[4],c=i[7];return i[0]=t*n+r*s,i[3]=t*a+r*l,i[6]=t*o+r*c,i[1]=-r*n+t*s,i[4]=-r*a+t*l,i[7]=-r*o+t*c,this},translate:function(e,t){var r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=t*r[2],r[4]+=t*r[5],r[7]+=t*r[8],this},equals:function(e){for(var t=this.elements,r=e.elements,i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0},fromArray:function(e,t){var r=this;void 0===t&&(t=0);for(var i=0;i<9;i++)r.elements[i]=e[i+t];return this},toArray:function(e,t){void 0===e&&(e=[]),void 0===t&&(t=0);var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}});var Rs=0;c.DefaultUp=new i(0,1,0),c.DefaultMatrixAutoUpdate=!0,c.prototype=Object.assign(Object.create(a.prototype),{constructor:c,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(e){return this.quaternion.premultiply(e),this},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(){var e=new n;return function(t,r){return e.setFromAxisAngle(t,r),this.quaternion.multiply(e),this}}(),rotateOnWorldAxis:function(){var e=new n;return function(t,r){return e.setFromAxisAngle(t,r),this.quaternion.premultiply(e),this}}(),rotateX:function(){var e=new i(1,0,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateY:function(){var e=new i(0,1,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateZ:function(){var e=new i(0,0,1);return function(t){return this.rotateOnAxis(e,t)}}(),translateOnAxis:function(){var e=new i;return function(t,r){return e.copy(t).applyQuaternion(this.quaternion),this.position.add(e.multiplyScalar(r)),this}}(),translateX:function(){var e=new i(1,0,0);return function(t){return this.translateOnAxis(e,t)}}(),translateY:function(){var e=new i(0,1,0);return function(t){return this.translateOnAxis(e,t)}}(),translateZ:function(){var e=new i(0,0,1);return function(t){return this.translateOnAxis(e,t)}}(),localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var e=new r;return function(t){return t.applyMatrix4(e.getInverse(this.matrixWorld))}}(),lookAt:function(){var e=new n,t=new r,a=new i,o=new i;return function(r,i,n){r.isVector3?a.copy(r):a.set(r,i,n);var s=this.parent;this.updateWorldMatrix(!0,!1),o.setFromMatrixPosition(this.matrixWorld),this.isCamera?t.lookAt(o,a,this.up):t.lookAt(a,o,this.up),this.quaternion.setFromRotationMatrix(t),s&&(t.extractRotation(s.matrixWorld),e.setFromRotationMatrix(t),this.quaternion.premultiply(e.inverse()))}}(),add:function(e){var t=arguments,r=this;if(arguments.length>1){for(var i=0;i<arguments.length;i++)r.add(t[i]);return this}return e===this?(console.error("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,e.dispatchEvent({type:"added"}),this.children.push(e)):console.error("Object3D.add: object not an instance of Object3D.",e),this)},remove:function(e){var t=arguments,r=this;if(arguments.length>1){for(var i=0;i<arguments.length;i++)r.remove(t[i]);return this}var n=this.children.indexOf(e);return n!==-1&&(e.parent=null,e.dispatchEvent({type:"removed"}),this.children.splice(n,1)),this},getObjectById:function(e){return this.getObjectByProperty("id",e)},getObjectByName:function(e){return this.getObjectByProperty("name",e)},getObjectByProperty:function(e,t){var r=this;if(this[e]===t)return this;for(var i=0,n=this.children.length;i<n;i++){var a=r.children[i],o=a.getObjectByProperty(e,t);if(void 0!==o)return o}},getWorldPosition:function(e){return void 0===e&&(console.warn("Object3D: .getWorldPosition() target is now required"),e=new i),this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var e=new i,t=new i;return function(r){return void 0===r&&(console.warn("Object3D: .getWorldQuaternion() target is now required"),r=new n),this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,r,t),r}}(),getWorldScale:function(){var e=new i,t=new n;return function(r){return void 0===r&&(console.warn("Object3D: .getWorldScale() target is now required"),r=new i),this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,t,r),r}}(),getWorldDirection:function(e){void 0===e&&(console.warn("Object3D: .getWorldDirection() target is now required"),e=new i),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()},raycast:function(){},traverse:function(e){e(this);for(var t=this.children,r=0,i=t.length;r<i;r++)t[r].traverse(e)},traverseVisible:function(e){if(this.visible!==!1){e(this);for(var t=this.children,r=0,i=t.length;r<i;r++)t[r].traverseVisible(e)}},traverseAncestors:function(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=this.children,r=0,i=t.length;r<i;r++)t[r].updateMatrixWorld(e)},updateWorldMatrix:function(e,t){var r=this.parent;if(e===!0&&null!==r&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0)for(var i=this.children,n=0,a=i.length;n<a;n++)i[n].updateWorldMatrix(!1,!0)},toJSON:function(e){function t(t,r){return void 0===t[r.uuid]&&(t[r.uuid]=r.toJSON(e)),r.uuid}function r(e){var t=[];for(var r in e){var i=e[r];delete i.metadata,t.push(i)}return t}var i=this,n=void 0===e||"string"==typeof e,a={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{}},a.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var o={};if(o.uuid=this.uuid,o.type=this.type,""!==this.name&&(o.name=this.name),this.castShadow===!0&&(o.castShadow=!0),this.receiveShadow===!0&&(o.receiveShadow=!0),this.visible===!1&&(o.visible=!1),this.frustumCulled===!1&&(o.frustumCulled=!1),0!==this.renderOrder&&(o.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(o.userData=this.userData),o.layers=this.layers.mask,o.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(o.matrixAutoUpdate=!1),this.isMesh||this.isLine||this.isPoints){o.geometry=t(e.geometries,this.geometry);var s=this.geometry.parameters;if(void 0!==s&&void 0!==s.shapes){var l=s.shapes;if(Array.isArray(l))for(var c=0,u=l.length;c<u;c++){var h=l[c];t(e.shapes,h)}else t(e.shapes,l)}}if(void 0!==this.material)if(Array.isArray(this.material)){for(var d=[],c=0,u=this.material.length;c<u;c++)d.push(t(e.materials,i.material[c]));o.material=d}else o.material=t(e.materials,this.material);if(this.children.length>0){o.children=[];for(var c=0;c<this.children.length;c++)o.children.push(i.children[c].toJSON(e).object)}if(n){var p=r(e.geometries),f=r(e.materials),m=r(e.textures),v=r(e.images),l=r(e.shapes);p.length>0&&(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<e.children.length;i++){var n=e.children[i];r.add(n.clone())}return this}});var Is={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(u.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>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+(n<a?6:0);break;case n:t=(a-i)/c+2;break;case a:t=(i-n)/c+4}t/=6}return e.h=t,e.s=r,e.l=l,e},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(){var e={};return function(t,r,i){return this.getHSL(e),e.h+=t,e.s+=r,e.l+=i,this.setHSL(e.h,e.s,e.l),this}}(),add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},sub:function(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},lerpHSL:function(){var e={h:0,s:0,l:0},t={h:0,s:0,l:0};return function(r,i){this.getHSL(e),r.getHSL(t);var n=Fs.lerp(e.h,t.h,i),a=Fs.lerp(e.s,t.s,i),o=Fs.lerp(e.l,t.l,i);return this.setHSL(n,a,o),this}}(),equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e},toJSON:function(){return this.getHex()}}),Object.assign(h.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(e){var t=this;this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(var r=0,i=e.vertexNormals.length;r<i;r++)t.vertexNormals[r]=e.vertexNormals[r].clone();for(var r=0,i=e.vertexColors.length;r<i;r++)t.vertexColors[r]=e.vertexColors[r].clone();return this}}),Object.assign(d.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray: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.length;s<l;s+=3){var c=e[s],u=e[s+1],h=e[s+2];c<t&&(t=c),u<r&&(r=u),h<i&&(i=h),c>n&&(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;s<l;s++){var c=e.getX(s),u=e.getY(s),h=e.getZ(s);c<t&&(t=c),u<r&&(r=u),h<i&&(i=h),c>n&&(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;r<i;r++)t.expandByPoint(e[r]);return this},setFromCenterAndSize:function(){var e=new i;return function(t,r){var i=e.copy(r).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}}(),setFromObject:function(e){return this.makeEmpty(),this.expandByObject(e)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=+(1/0),this.max.x=this.max.y=this.max.z=-(1/0),this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(e){return void 0===e&&(console.warn("Box3: .getCenter() target is now required"),e=new i),this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("Box3: .getSize() target is now required"),e=new i),this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},expandByObject:function(){function e(e){var i=e.geometry;if(void 0!==i)if(i.isGeometry){var o=i.vertices;for(r=0,n=o.length;r<n;r++)a.copy(o[r]),a.applyMatrix4(e.matrixWorld),t.expandByPoint(a)}else if(i.isBufferGeometry){var s=i.attributes.position;if(void 0!==s)for(r=0,n=s.count;r<n;r++)a.fromBufferAttribute(s,r).applyMatrix4(e.matrixWorld),t.expandByPoint(a)}}var t,r,n,a=new i;return function(r){return t=this,r.updateMatrixWorld(!0),r.traverse(e),this}}(),containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)},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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)},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;a<o;a++)n=Math.max(n,i.distanceToSquared(t[a]));return this.radius=Math.sqrt(n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return this.radius<=0},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius},clampPoint:function(e,t){var r=this.center.distanceToSquared(e);return void 0===t&&(console.warn("Sphere: .clampPoint() target is now required"),t=new i),t.copy(e),r>this.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;i<n;i++){var a=t.vertices[i];a.applyMatrix4(e)}for(var i=0,n=this.faces.length;i<n;i++){var o=t.faces[i];o.normal.applyMatrix3(r).normalize();for(var s=0,c=o.vertexNormals.length;s<c;s++)o.vertexNormals[s].applyMatrix3(r).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,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)}}(),fromBufferGeometry:function(e){function t(e,t,i,n){var a=void 0!==s?[p[e].clone(),p[t].clone(),p[i].clone()]:[],o=void 0!==l?[r.colors[e].clone(),r.colors[t].clone(),r.colors[i].clone()]:[],u=new h(e,t,i,a,o,n);r.faces.push(u),void 0!==c&&r.faceVertexUvs[0].push([m[e].clone(),m[t].clone(),m[i].clone()]),void 0!==d&&r.faceVertexUvs[1].push([v[e].clone(),v[t].clone(),v[i].clone()])}var r=this,n=null!==e.index?e.index.array:void 0,a=e.attributes,o=a.position.array,s=void 0!==a.normal?a.normal.array:void 0,l=void 0!==a.color?a.color.array:void 0,c=void 0!==a.uv?a.uv.array:void 0,d=void 0!==a.uv2?a.uv2.array:void 0;void 0!==d&&(this.faceVertexUvs[1]=[]);for(var p=[],m=[],v=[],g=0,y=0;g<o.length;g+=3,y+=2)r.vertices.push(new i(o[g],o[g+1],o[g+2])),void 0!==s&&p.push(new i(s[g],s[g+1],s[g+2])),void 0!==l&&r.colors.push(new u(l[g],l[g+1],l[g+2])),void 0!==c&&m.push(new f(c[y],c[y+1])),void 0!==d&&v.push(new f(d[y],d[y+1]));var x=e.groups;if(x.length>0)for(var g=0;g<x.length;g++)for(var b=x[g],w=b.start,_=b.count,y=w,S=w+_;y<S;y+=3)void 0!==n?t(n[y],n[y+1],n[y+2],b.materialIndex):t(y,y+1,y+2,b.materialIndex);else if(void 0!==n)for(var g=0;g<n.length;g+=3)t(n[g],n[g+1],n[g+2]);else for(var g=0;g<o.length/3;g+=3)t(g,g+1,g+2);return this.computeFaceNormals(),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this},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}}(),normalize:function(){this.computeBoundingSphere();var e=this.boundingSphere.center,t=this.boundingSphere.radius,i=0===t?1:1/t,n=new r;return n.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix(n),this},computeFaceNormals:function(){for(var e=this,t=new i,r=new i,n=0,a=this.faces.length;n<a;n++){var o=e.faces[n],s=e.vertices[o.a],l=e.vertices[o.b],c=e.vertices[o.c];t.subVectors(c,l),r.subVectors(s,l),t.cross(r),t.normalize(),o.normal.copy(t)}},computeVertexNormals:function(e){var t=this;void 0===e&&(e=!0);var r,n,a,o,s,l;for(l=new Array(this.vertices.length),r=0,n=this.vertices.length;r<n;r++)l[r]=new i;if(e){var c,u,h,d=new i,p=new i;for(a=0,o=this.faces.length;a<o;a++)s=t.faces[a],c=t.vertices[s.a],u=t.vertices[s.b],h=t.vertices[s.c],d.subVectors(h,u),p.subVectors(c,u),d.cross(p),l[s.a].add(d),l[s.b].add(d),l[s.c].add(d)}else for(this.computeFaceNormals(),a=0,o=this.faces.length;a<o;a++)s=t.faces[a],l[s.a].add(s.normal),l[s.b].add(s.normal),l[s.c].add(s.normal);for(r=0,n=this.vertices.length;r<n;r++)l[r].normalize();for(a=0,o=this.faces.length;a<o;a++){s=t.faces[a];var f=s.vertexNormals;3===f.length?(f[0].copy(l[s.a]),f[1].copy(l[s.b]),f[2].copy(l[s.c])):(f[0]=l[s.a].clone(),f[1]=l[s.b].clone(),f[2]=l[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,r,i=this;for(this.computeFaceNormals(),e=0,t=this.faces.length;e<t;e++){r=i.faces[e];var n=r.vertexNormals;3===n.length?(n[0].copy(r.normal),n[1].copy(r.normal),n[2].copy(r.normal)):(n[0]=r.normal.clone(),n[1]=r.normal.clone(),n[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,r,n,a,o=this;for(r=0,n=this.faces.length;r<n;r++)for(a=o.faces[r],a.__originalFaceNormal?a.__originalFaceNormal.copy(a.normal):a.__originalFaceNormal=a.normal.clone(),a.__originalVertexNormals||(a.__originalVertexNormals=[]),e=0,t=a.vertexNormals.length;e<t;e++)a.__originalVertexNormals[e]?a.__originalVertexNormals[e].copy(a.vertexNormals[e]):a.__originalVertexNormals[e]=a.vertexNormals[e].clone();var s=new m;for(s.faces=this.faces,e=0,t=this.morphTargets.length;e<t;e++){if(!o.morphNormals[e]){o.morphNormals[e]={},o.morphNormals[e].faceNormals=[],o.morphNormals[e].vertexNormals=[];var l,c,u=o.morphNormals[e].faceNormals,h=o.morphNormals[e].vertexNormals;for(r=0,n=this.faces.length;r<n;r++)l=new i,c={a:new i,b:new i,c:new i},u.push(l),h.push(c)}var d=o.morphNormals[e];s.vertices=o.morphTargets[e].vertices,s.computeFaceNormals(),s.computeVertexNormals();var l,c;for(r=0,n=this.faces.length;r<n;r++)a=o.faces[r],l=d.faceNormals[r],c=d.vertexNormals[r],l.copy(a.normal),c.a.copy(a.vertexNormals[0]),c.b.copy(a.vertexNormals[1]),c.c.copy(a.vertexNormals[2])}for(r=0,n=this.faces.length;r<n;r++)a=o.faces[r],a.normal=a.__originalFaceNormal,a.vertexNormals=a.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new d),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new p),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,r){if(!e||!e.isGeometry)return void console.error("Geometry.merge(): geometry not an instance of Geometry.",e);var i,n=this.vertices.length,a=this.vertices,o=e.vertices,s=this.faces,c=e.faces,u=this.faceVertexUvs[0],d=e.faceVertexUvs[0],p=this.colors,f=e.colors;void 0===r&&(r=0),void 0!==t&&(i=(new l).getNormalMatrix(t));for(var m=0,v=o.length;m<v;m++){var g=o[m],y=g.clone();void 0!==t&&y.applyMatrix4(t),a.push(y)}for(var m=0,v=f.length;m<v;m++)p.push(f[m].clone());for(m=0,v=c.length;m<v;m++){var x,b,w,_=c[m],S=_.vertexNormals,A=_.vertexColors;x=new h(_.a+n,_.b+n,_.c+n),x.normal.copy(_.normal),void 0!==i&&x.normal.applyMatrix3(i).normalize();for(var M=0,T=S.length;M<T;M++)b=S[M].clone(),void 0!==i&&b.applyMatrix3(i).normalize(),x.vertexNormals.push(b);x.color.copy(_.color);for(var M=0,T=A.length;M<T;M++)w=A[M],x.vertexColors.push(w.clone());x.materialIndex=_.materialIndex+r,s.push(x)}for(m=0,v=d.length;m<v;m++){var E=d[m],C=[];if(void 0!==E){for(var M=0,T=E.length;M<T;M++)C.push(E[M].clone());u.push(C)}}},mergeMesh:function(e){return e&&e.isMesh?(e.matrixAutoUpdate&&e.updateMatrix(),void this.merge(e.geometry,e.matrix)):void console.error("Geometry.mergeMesh(): mesh not an instance of Mesh.",e)},mergeVertices:function(){var e,t,r,i,n,a,o,s,l=this,c={},u=[],h=[],d=4,p=Math.pow(10,d);for(r=0,i=this.vertices.length;r<i;r++)e=l.vertices[r],t=Math.round(e.x*p)+"_"+Math.round(e.y*p)+"_"+Math.round(e.z*p),void 0===c[t]?(c[t]=r,u.push(l.vertices[r]),h[r]=u.length-1):h[r]=h[c[t]];var f=[];for(r=0,i=this.faces.length;r<i;r++){n=l.faces[r],n.a=h[n.a],n.b=h[n.b],n.c=h[n.c],a=[n.a,n.b,n.c];for(var m=0;m<3;m++)if(a[m]===a[(m+1)%3]){f.push(r);break}}for(r=f.length-1;r>=0;r--){var v=f[r];for(l.faces.splice(v,1),o=0,s=this.faceVertexUvs.length;o<s;o++)l.faceVertexUvs[o].splice(v,1)}var g=this.vertices.length-u.length;return this.vertices=u,g},setFromPoints:function(e){var t=this;this.vertices=[];for(var r=0,n=e.length;r<n;r++){var a=e[r];t.vertices.push(new i(a.x,a.y,a.z||0))}return this},sortFacesByMaterialIndex:function(){function e(e,t){return e.materialIndex-t.materialIndex}for(var t=this.faces,r=t.length,i=0;i<r;i++)t[i]._id=i;t.sort(e);var n,a,o=this.faceVertexUvs[0],s=this.faceVertexUvs[1];o&&o.length===r&&(n=[]),s&&s.length===r&&(a=[]);for(var i=0;i<r;i++){var l=t[i]._id;n&&n.push(o[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)},toJSON:function(){function e(e,t,r){return r?e|1<<t:e&~(1<<t)}function t(e){var t=e.x.toString()+e.y.toString()+e.z.toString();return void 0!==p[t]?p[t]:(p[t]=d.length/3,d.push(e.x,e.y,e.z),p[t])}function r(e){var t=e.r.toString()+e.g.toString()+e.b.toString();return void 0!==m[t]?m[t]:(m[t]=f.length,f.push(e.getHex()),m[t])}function i(e){var t=e.x.toString()+e.y.toString();return void 0!==g[t]?g[t]:(g[t]=v.length/2,v.push(e.x,e.y),g[t])}var n=this,a={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(a.uuid=this.uuid,a.type=this.type,""!==this.name&&(a.name=this.name),void 0!==this.parameters){var o=this.parameters;for(var s in o)void 0!==o[s]&&(a[s]=o[s]);return a}for(var l=[],c=0;c<this.vertices.length;c++){var u=n.vertices[c];l.push(u.x,u.y,u.z)}for(var h=[],d=[],p={},f=[],m={},v=[],g={},c=0;c<this.faces.length;c++){var y=n.faces[c],x=!0,b=!1,w=void 0!==n.faceVertexUvs[0][c],_=y.normal.length()>0,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;t<r;t++)s.vertices.push(l[t].clone());var c=e.colors;for(t=0,r=c.length;t<r;t++)s.colors.push(c[t].clone());var u=e.faces;for(t=0,r=u.length;t<r;t++)s.faces.push(u[t].clone());for(t=0,r=e.faceVertexUvs.length;t<r;t++){var h=e.faceVertexUvs[t];for(void 0===s.faceVertexUvs[t]&&(s.faceVertexUvs[t]=[]),i=0,n=h.length;i<n;i++){var d=h[i],p=[];for(a=0,o=d.length;a<o;a++){var f=d[a];p.push(f.clone())}s.faceVertexUvs[t].push(p)}}var m=e.morphTargets;for(t=0,r=m.length;t<r;t++){var v={};if(v.name=m[t].name,void 0!==m[t].vertices)for(v.vertices=[],i=0,n=m[t].vertices.length;i<n;i++)v.vertices.push(m[t].vertices[i].clone());if(void 0!==m[t].normals)for(v.normals=[],i=0,n=m[t].normals.length;i<n;i++)v.normals.push(m[t].normals[i].clone());s.morphTargets.push(v)}var g=e.morphNormals;for(t=0,r=g.length;t<r;t++){var y={};if(void 0!==g[t].vertexNormals)for(y.vertexNormals=[],i=0,n=g[t].vertexNormals.length;i<n;i++){var x=g[t].vertexNormals[i],b={};b.a=x.a.clone(),b.b=x.b.clone(),b.c=x.c.clone(),y.vertexNormals.push(b)}if(void 0!==g[t].faceNormals)for(y.faceNormals=[],i=0,n=g[t].faceNormals.length;i<n;i++)y.faceNormals.push(g[t].faceNormals[i].clone());s.morphNormals.push(y)}var w=e.skinWeights;for(t=0,r=w.length;t<r;t++)s.skinWeights.push(w[t].clone());var _=e.skinIndices;for(t=0,r=_.length;t<r;t++)s.skinIndices.push(_[t].clone());var S=e.lineDistances;for(t=0,r=S.length;t<r;t++)s.lineDistances.push(S[t]);var A=e.boundingBox;null!==A&&(this.boundingBox=A.clone());var M=e.boundingSphere;return null!==M&&(this.boundingSphere=M.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.assign(v.prototype,{isVector4:!0,set:function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},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=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*i+a[12]*n,this.y=a[1]*t+a[5]*r+a[9]*i+a[13]*n,this.z=a[2]*t+a[6]*r+a[10]*i+a[14]*n,this.w=a[3]*t+a[7]*r+a[11]*i+a[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,r,i,n,a=.01,o=.1,s=e.elements,l=s[0],c=s[4],u=s[8],h=s[1],d=s[5],p=s[9],f=s[2],m=s[6],v=s[10];if(Math.abs(c-h)<a&&Math.abs(u-f)<a&&Math.abs(p-m)<a){if(Math.abs(c+h)<o&&Math.abs(u+f)<o&&Math.abs(p+m)<o&&Math.abs(l+d+v-3)<o)return this.set(1,0,0,0),this;t=Math.PI;var g=(l+1)/2,y=(d+1)/2,x=(v+1)/2,b=(c+h)/4,w=(u+f)/4,_=(p+m)/4;return g>y&&g>x?g<a?(r=0,i=.707106781,n=.707106781):(r=Math.sqrt(g),i=b/r,n=w/r):y>x?y<a?(r=.707106781,i=0,n=.707106781):(i=Math.sqrt(y),r=b/i,n=_/i):x<a?(r=.707106781,i=.707106781,n=0):(n=Math.sqrt(x),r=w/n,i=_/n),this.set(r,i,n,t),this}var S=Math.sqrt((m-p)*(m-p)+(u-f)*(u-f)+(h-c)*(h-c));return Math.abs(S)<.001&&(S=1),this.x=(m-p)/S,this.y=(u-f)/S,this.z=(h-c)/S,this.w=Math.acos((l+d+v-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},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.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(r,i){return void 0===e&&(e=new v,t=new v),e.set(r,r,r,r),t.set(i,i,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.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},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.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},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.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*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&&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},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},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),Object.defineProperty(g.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(g.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setArray:function(e){if(Array.isArray(e))throw new TypeError("BufferAttribute: array should be a Typed Array.");return this.count=void 0!==e?e.length/this.itemSize:0,this.array=e,this},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.dynamic=e.dynamic,this},copyAt:function(e,t,r){var i=this;e*=this.itemSize,r*=t.itemSize;for(var n=0,a=this.itemSize;n<a;n++)i.array[e+n]=t.array[r+n];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var t=this.array,r=0,i=0,n=e.length;i<n;i++){var a=e[i];void 0===a&&(console.warn("BufferAttribute.copyColorsArray(): color is undefined",i),a=new u),t[r++]=a.r,t[r++]=a.g,t[r++]=a.b}return this},copyVector2sArray:function(e){for(var t=this.array,r=0,i=0,n=e.length;i<n;i++){var a=e[i];void 0===a&&(console.warn("BufferAttribute.copyVector2sArray(): vector is undefined",i),a=new f),t[r++]=a.x,t[r++]=a.y}return this},copyVector3sArray:function(e){for(var t=this.array,r=0,n=0,a=e.length;n<a;n++){var o=e[n];void 0===o&&(console.warn("BufferAttribute.copyVector3sArray(): vector is undefined",n),o=new i),t[r++]=o.x,t[r++]=o.y,t[r++]=o.z}return this},copyVector4sArray:function(e){for(var t=this.array,r=0,i=0,n=e.length;i<n;i++){var a=e[i];void 0===a&&(console.warn("BufferAttribute.copyVector4sArray(): vector is undefined",i),a=new v),t[r++]=a.x,t[r++]=a.y,t[r++]=a.z,t[r++]=a.w}return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this},setXYZ:function(e,t,r,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this},setXYZW:function(e,t,r,i,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=n,this},onUpload:function(e){return this.onUploadCallback=e,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),y.prototype=Object.create(g.prototype),y.prototype.constructor=y,x.prototype=Object.create(g.prototype),x.prototype.constructor=x,b.prototype=Object.create(g.prototype),b.prototype.constructor=b,w.prototype=Object.create(g.prototype),w.prototype.constructor=w,_.prototype=Object.create(g.prototype),_.prototype.constructor=_,S.prototype=Object.create(g.prototype),S.prototype.constructor=S,A.prototype=Object.create(g.prototype),A.prototype.constructor=A,M.prototype=Object.create(g.prototype),M.prototype.constructor=M,T.prototype=Object.create(g.prototype),T.prototype.constructor=T,Object.assign(E.prototype,{computeGroups:function(e){for(var t,r=[],i=void 0,n=e.faces,a=0;a<n.length;a++){var o=n[a];o.materialIndex!==i&&(i=o.materialIndex,void 0!==t&&(t.count=3*a-t.start,r.push(t)),t={start:3*a,materialIndex:i})}void 0!==t&&(t.count=3*a-t.start,r.push(t)),this.groups=r},fromGeometry:function(e){var t,r=this,i=e.faces,n=e.vertices,a=e.faceVertexUvs,o=a[0]&&a[0].length>0,s=a[1]&&a[1].length>0,l=e.morphTargets,c=l.length;if(c>0){t=[];for(var u=0;u<c;u++)t[u]={name:l[u].name,data:[]};this.morphTargets.position=t}var h,d=e.morphNormals,p=d.length;if(p>0){h=[];for(var u=0;u<p;u++)h[u]={name:d[u].name,data:[]};this.morphTargets.normal=h}var m=e.skinIndices,v=e.skinWeights,g=m.length===n.length,y=v.length===n.length;n.length>0&&0===i.length&&console.error("DirectGeometry: Faceless geometries are not supported.");for(var u=0;u<i.length;u++){var x=i[u];r.vertices.push(n[x.a],n[x.b],n[x.c]);var b=x.vertexNormals;if(3===b.length)r.normals.push(b[0],b[1],b[2]);else{var w=x.normal;r.normals.push(w,w,w)}var _=x.vertexColors;if(3===_.length)r.colors.push(_[0],_[1],_[2]);else{var S=x.color;r.colors.push(S,S,S)}if(o===!0){var A=a[0][u];void 0!==A?r.uvs.push(A[0],A[1],A[2]):(console.warn("DirectGeometry.fromGeometry(): Undefined vertexUv ",u),r.uvs.push(new f,new f,new f))}if(s===!0){var A=a[1][u];void 0!==A?r.uvs2.push(A[0],A[1],A[2]):(console.warn("DirectGeometry.fromGeometry(): Undefined vertexUv2 ",u),r.uvs2.push(new f,new f,new f))}for(var M=0;M<c;M++){var T=l[M].vertices;t[M].data.push(T[x.a],T[x.b],T[x.c])}for(var M=0;M<p;M++){var E=d[M].vertexNormals[u];h[M].data.push(E.a,E.b,E.c)}g&&r.skinIndices.push(m[x.a],m[x.b],m[x.c]),y&&r.skinWeights.push(v[x.a],v[x.b],v[x.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}});var ks=1;P.prototype=Object.assign(Object.create(a.prototype),{constructor:P,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(e){Array.isArray(e)?this.index=new(L(e)>65535?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;r<i;r++){var n=e[r];t.push(n.x,n.y,n.z||0)}return this.addAttribute("position",new M(t,3)),this},updateFromObject:function(e){var t=e.geometry;if(e.isMesh){var r=t.__directGeometry;if(t.elementsNeedUpdate===!0&&(r=void 0,t.elementsNeedUpdate=!1),void 0===r)return this.fromGeometry(t);r.verticesNeedUpdate=t.verticesNeedUpdate,r.normalsNeedUpdate=t.normalsNeedUpdate,r.colorsNeedUpdate=t.colorsNeedUpdate,r.uvsNeedUpdate=t.uvsNeedUpdate,r.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=r}var i;return t.verticesNeedUpdate===!0&&(i=this.attributes.position,void 0!==i&&(i.copyVector3sArray(t.vertices),i.needsUpdate=!0),t.verticesNeedUpdate=!1),t.normalsNeedUpdate===!0&&(i=this.attributes.normal,void 0!==i&&(i.copyVector3sArray(t.normals),i.needsUpdate=!0),t.normalsNeedUpdate=!1),t.colorsNeedUpdate===!0&&(i=this.attributes.color,void 0!==i&&(i.copyColorsArray(t.colors),i.needsUpdate=!0),t.colorsNeedUpdate=!1),t.uvsNeedUpdate&&(i=this.attributes.uv,void 0!==i&&(i.copyVector2sArray(t.uvs),i.needsUpdate=!0),t.uvsNeedUpdate=!1),t.lineDistancesNeedUpdate&&(i=this.attributes.lineDistance,void 0!==i&&(i.copyArray(t.lineDistances),i.needsUpdate=!0),t.lineDistancesNeedUpdate=!1),t.groupsNeedUpdate&&(t.computeGroups(e.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new E).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=this,r=new Float32Array(3*e.vertices.length);if(this.addAttribute("position",new g(r,3).copyVector3sArray(e.vertices)),e.normals.length>0){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;u<h;u++){var d=c[u],p=new M(3*d.data.length,3);p.name=d.name,l.push(p.copyVector3sArray(d.data))}t.morphAttributes[s]=l}if(e.skinIndices.length>0){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;a<o;a++)t.x=r.getX(a),t.y=r.getY(a),t.z=r.getZ(a),n=Math.max(n,i.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,t=this.attributes;if(t.position){var r=t.position.array;if(void 0===t.normal)this.addAttribute("normal",new g(new Float32Array(r.length),3));else for(var n=t.normal.array,a=0,o=n.length;a<o;a++)n[a]=0;var s,l,c,u=t.normal.array,h=new i,d=new i,p=new i,f=new i,m=new i;if(e)for(var v=e.array,a=0,o=e.count;a<o;a+=3)s=3*v[a+0],l=3*v[a+1],c=3*v[a+2],h.fromArray(r,s),d.fromArray(r,l),p.fromArray(r,c),f.subVectors(p,d),m.subVectors(h,d),f.cross(m),u[s]+=f.x,u[s+1]+=f.y,u[s+2]+=f.z,u[l]+=f.x,u[l+1]+=f.y,u[l+2]+=f.z,u[c]+=f.x,u[c+1]+=f.y,u[c+2]+=f.z;else for(var a=0,o=r.length;a<o;a+=9)h.fromArray(r,a),d.fromArray(r,a+3),p.fromArray(r,a+6),f.subVectors(p,d),m.subVectors(h,d),f.cross(m),u[a]=f.x,u[a+1]=f.y,u[a+2]=f.z,u[a+3]=f.x,u[a+4]=f.y,u[a+5]=f.z,u[a+6]=f.x,u[a+7]=f.y,u[a+8]=f.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},merge:function(e,t){if(!e||!e.isBufferGeometry)return void console.error("BufferGeometry.merge(): geometry not an instance of BufferGeometry.",e);void 0===t&&(t=0,console.warn("BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var r=this.attributes;for(var i in r)if(void 0!==e.attributes[i])for(var n=r[i],a=n.array,o=e.attributes[i],s=o.array,l=o.itemSize,c=0,u=l*t;c<s.length;c++,
|
|
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;r<i;r++)e.x=t.getX(r),e.y=t.getY(r),e.z=t.getZ(r),e.normalize(),t.setXYZ(r,e.x,e.y,e.z)}}(),toNonIndexed:function(){if(null===this.index)return console.warn("BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var e=new P,t=this.index.array,r=this.attributes;for(var i in r){for(var n=r[i],a=n.array,o=n.itemSize,s=new a.constructor(t.length*o),l=0,c=0,u=0,h=t.length;u<h;u++){l=t[u]*o;for(var d=0;d<o;d++)s[c++]=a[l++]}e.addAttribute(i,new g(s,o))}for(var p=this.groups,u=0,h=p.length;u<h;u++){var f=p[u];e.addGroup(f.start,f.count,f.materialIndex)}return e},toJSON:function(){var e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var 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;r<i;r++)c.push(u[r].clone());n.morphAttributes[t]=c}var h=e.groups;for(r=0,i=h.length;r<i;r++){var d=h[r];n.addGroup(d.start,d.count,d.materialIndex)}var p=e.boundingBox;null!==p&&(this.boundingBox=p.clone());var f=e.boundingSphere;return null!==f&&(this.boundingSphere=f.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),N.prototype=Object.create(m.prototype),N.prototype.constructor=N,O.prototype=Object.create(P.prototype),O.prototype.constructor=O;var Bs="96",zs={LEFT:0,MIDDLE:1,RIGHT:2},js=0,Vs=1,Gs=2,Ws=3,Xs=0,Hs=1,Ys=0,qs=1,Qs=2,Js=0,Zs=1,Ks=2,$s=1,el=2,tl=0,rl=1,il=2,nl=0,al=1,ol=2,sl=3,ll=4,cl=5,ul=100,hl=101,dl=102,pl=103,fl=104,ml=200,vl=201,gl=202,yl=203,xl=204,bl=205,wl=206,_l=207,Sl=208,Al=209,Ml=210,Tl=0,El=1,Cl=2,Ll=3,Pl=4,Nl=5,Ol=6,Dl=7,Fl=0,Rl=1,Il=2,Ul=0,kl=1,Bl=2,zl=3,jl=4,Vl=300,Gl=301,Wl=302,Xl=303,Hl=304,Yl=305,ql=306,Ql=307,Jl=1e3,Zl=1001,Kl=1002,$l=1003,ec=1004,tc=1005,rc=1006,ic=1007,nc=1008,ac=1009,oc=1010,sc=1011,lc=1012,cc=1013,uc=1014,hc=1015,dc=1016,pc=1017,fc=1018,mc=1019,vc=1020,gc=1021,yc=1022,xc=1023,bc=1024,wc=1025,_c=xc,Sc=1026,Ac=1027,Mc=33776,Tc=33777,Ec=33778,Cc=33779,Lc=35840,Pc=35841,Nc=35842,Oc=35843,Dc=36196,Fc=37808,Rc=37809,Ic=37810,Uc=37811,kc=37812,Bc=37813,zc=37814,jc=37815,Vc=37816,Gc=37817,Wc=37818,Xc=37819,Hc=37820,Yc=37821,qc=2200,Qc=2201,Jc=2202,Zc=2300,Kc=2301,$c=2302,eu=2400,tu=2401,ru=2402,iu=0,nu=1,au=2,ou=3e3,su=3001,lu=3007,cu=3002,uu=3003,hu=3004,du=3005,pu=3006,fu=3200,mu=3201,vu=0,gu=1,yu=0;D.prototype=Object.assign(Object.create(a.prototype),{constructor:D,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){var t=this;if(void 0!==e)for(var r in e){var i=e[r];if(void 0!==i)if("shading"!==r){var n=t[r];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):"overdraw"===r?t[r]=Number(i):t[r]=i:console.warn(""+t.type+": '"+r+"' is not a property of this material.")}else console.warn(""+t.type+": .shading has been removed. Use the boolean .flatShading instead."),t.flatShading=i===$s;else console.warn("Material: '"+r+"' parameter is undefined.")}},toJSON:function(e){function t(e){var t=[];for(var r in e){var i=e[r];delete i.metadata,t.push(i)}return t}var r=void 0===e||"string"==typeof e;r&&(e={textures:{},images:{}});var i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearCoat&&(i.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(i.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,i.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==al&&(i.blending=this.blending),this.flatShading===!0&&(i.flatShading=this.flatShading),this.side!==Js&&(i.side=this.side),this.vertexColors!==tl&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,0!==this.rotation&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(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<i||i!==i)&&(i=a),u>=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<i||i!==i)&&(i=s),i<0?null:this.at(r>=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;e<t;e++)r=s[e].name||String(e),i.morphTargetInfluences.push(0),i.morphTargetDictionary[r]=e}}else{var l=n.morphTargets;if(void 0!==l&&l.length>0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=l.length;e<t;e++)r=l[e].name||String(e),i.morphTargetInfluences.push(0),i.morphTargetDictionary[r]=e}},raycast:function(){function e(e,t,r,i,n,a,o,s){var l;if(l=t.side===Zs?i.intersectTriangle(o,a,n,!0,s):i.intersectTriangle(n,a,o,t.side!==Ks,s),null===l)return null;b.copy(s),b.applyMatrix4(e.matrixWorld);var c=r.ray.origin.distanceTo(b);return c<r.near||c>r.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;T<C;T++)for(P=k[T],N=b[P.materialIndex],O=Math.max(P.start,B.start),D=Math.min(P.start+P.count,B.start+B.count),E=O,L=D;E<L;E+=3)S=F.getX(E),A=F.getX(E+1),M=F.getX(E+2),_=t(h,N,r,a,R,I,S,A,M),_&&(_.faceIndex=Math.floor(E/3),i.push(_));else for(O=Math.max(0,B.start),D=Math.min(F.count,B.start+B.count),T=O,C=D;T<C;T+=3)S=F.getX(T),A=F.getX(T+1),M=F.getX(T+2),_=t(h,b,r,a,R,I,S,A,M),_&&(_.faceIndex=Math.floor(T/3),i.push(_));else if(void 0!==R)if(Array.isArray(b))for(T=0,C=k.length;T<C;T++)for(P=k[T],N=b[P.materialIndex],O=Math.max(P.start,B.start),D=Math.min(P.start+P.count,B.start+B.count),E=O,L=D;E<L;E+=3)S=E,A=E+1,M=E+2,_=t(h,N,r,a,R,I,S,A,M),_&&(_.faceIndex=Math.floor(E/3),i.push(_));else for(O=Math.max(0,B.start),D=Math.min(R.count,B.start+B.count),T=O,C=D;T<C;T+=3)S=T,A=T+1,M=T+2,_=t(h,b,r,a,R,I,S,A,M),_&&(_.faceIndex=Math.floor(T/3),i.push(_))}else if(p.isGeometry){var z,j,V,G,W=Array.isArray(b),X=p.vertices,H=p.faces,Y=p.faceVertexUvs[0];Y.length>0&&(G=Y);for(var q=0,Q=H.length;q<Q;q++){var J=H[q],Z=W?b[J.materialIndex]:b;if(void 0!==Z){if(z=X[J.a],j=X[J.b],V=X[J.c],Z.morphTargets===!0){var K=p.morphTargets,$=h.morphTargetInfluences;s.set(0,0,0),l.set(0,0,0),c.set(0,0,0);for(var ee=0,te=K.length;ee<te;ee++){var re=$[ee];if(0!==re){var ie=K[ee].vertices;s.addScaledVector(u.subVectors(ie[J.a],z),re),l.addScaledVector(d.subVectors(ie[J.b],j),re),c.addScaledVector(m.subVectors(ie[J.c],V),re)}}s.add(z),l.add(j),c.add(V),z=s,j=l,V=c}if(_=e(h,Z,r,a,z,j,V,x)){if(G&&G[q]){var ne=G[q];v.copy(ne[0]),g.copy(ne[1]),y.copy(ne[2]),_.uv=U.getUV(x,z,j,V,v,g,y,new f)}_.face=J,_.faceIndex=q,i.push(_)}}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),B.prototype=Object.assign(Object.create(c.prototype),{constructor:B,isLine:!0,computeLineDistances:function(){var e=new i,t=new i;return function(){var r=this.geometry;if(r.isBufferGeometry)if(null===r.index){for(var i=r.attributes.position,n=[0],a=1,o=i.count;a<o;a++)e.fromBufferAttribute(i,a-1),t.fromBufferAttribute(i,a),n[a]=n[a-1],n[a]+=e.distanceTo(t);r.addAttribute("lineDistance",new M(n,1))}else console.error("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(r.isGeometry){var s=r.vertices,n=r.lineDistances;n[0]=0;for(var a=1,o=s.length;a<o;a++)n[a]=n[a-1],n[a]+=s[a-1].distanceTo(s[a])}return this}}(),raycast:function(){var e=new r,t=new I,n=new p;return function(r,a){var o=this,s=r.linePrecision,l=this.geometry,c=this.matrixWorld;if(null===l.boundingSphere&&l.computeBoundingSphere(),n.copy(l.boundingSphere),n.applyMatrix4(c),n.radius+=s,r.ray.intersectsSphere(n)!==!1){e.getInverse(c),t.copy(r.ray).applyMatrix4(e);var u=s/((this.scale.x+this.scale.y+this.scale.z)/3),h=u*u,d=new i,p=new i,f=new i,m=new i,v=this&&this.isLineSegments?2:1;if(l.isBufferGeometry){var g=l.index,y=l.attributes,x=y.position.array;if(null!==g)for(var b=g.array,w=0,_=b.length-1;w<_;w+=v){var S=b[w],A=b[w+1];d.fromArray(x,3*S),p.fromArray(x,3*A);var M=t.distanceSqToSegment(d,p,m,f);if(!(M>h)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);T<r.near||T>r.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);T<r.near||T>r.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;w<C-1;w+=v){var M=t.distanceSqToSegment(E[w],E[w+1],m,f);if(!(M>h)){m.applyMatrix4(o.matrixWorld);var T=r.ray.origin.distanceTo(m);T<r.near||T>r.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;p<f;p++){var m=n[p],v=i[m.effector],g=i[m.target];t.setFromMatrixPosition(g.matrixWorld);for(var y=m.links,x=void 0!==m.iteration?m.iteration:1,b=0;b<x;b++){for(var w=!1,_=0,S=y.length;_<S;_++){var A=i[y[_].index];if(y[_].enabled===!1)break;var M=y[_].limitation,T=y[_].rotationMin,E=y[_].rotationMax;A.matrixWorld.decompose(s,l,c),l.inverse(),a.setFromMatrixPosition(v.matrixWorld),o.subVectors(a,s),o.applyQuaternion(l),o.normalize(),r.subVectors(t,s),r.applyQuaternion(l),r.normalize();var C=r.dot(o);if(C>1?C=1:C<-1&&(C=-1),C=d.acos(C),!(C<1e-5)){if(void 0!==m.minAngle&&C<m.minAngle&&(C=m.minAngle),void 0!==m.maxAngle&&C>m.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;r<i;r++){var n,a,o=e[r],s=t[o.effector],l=o.links;n=s;for(var c=0,u=l.length;c<u;c++)a=t[l[c].index],n.parent!==a&&console.warn("CCDIKSolver: bone "+n.name+" is not the child of bone "+a.name),n=a}}},t.prototype=Object.assign(Object.create(c.prototype),{constructor:t,updateMatrixWorld:function(){function e(e,t){return a.setFromMatrixPosition(e.matrixWorld).applyMatrix4(t)}function t(t,r,i,n){var a=e(i,n);t[3*r+0]=a.x,t[3*r+1]=a.y,t[3*r+2]=a.z}var n=new r,a=new i;return function(r){var i=this,a=this.root;if(this.visible){var o=0,s=this.iks,l=a.skeleton.bones;n.getInverse(a.matrixWorld);for(var u=0,h=s.length;u<h;u++){var d=s[u],p=l[d.target],f=l[d.effector],m=i.children[o++],v=i.children[o++];m.position.copy(e(p,n)),v.position.copy(e(f,n));for(var g=0,y=d.links.length;g<y;g++){var x=d.links[g],b=l[x.index],w=i.children[o++];w.position.copy(e(b,n))}var _=i.children[o++],S=_.geometry.attributes.position.array;t(S,0,p,n),t(S,1,f,n);for(var g=0,y=d.links.length;g<y;g++){var x=d.links[g],b=l[x.index];t(S,g+2,b,n)}_.geometry.attributes.position.needsUpdate=!0}}this.matrix.copy(a.matrixWorld),c.prototype.updateMatrixWorld.call(this,r)}}(),_init:function(){function e(e){var t=new P,r=new Float32Array(3*(2+e.links.length));return t.addAttribute("position",new g(r,3)),t}function t(){return new k(o.sphereGeometry,o.targetSphereMaterial)}function r(){return new k(o.sphereGeometry,o.effectorSphereMaterial)}function i(){return new k(o.sphereGeometry,o.linkSphereMaterial)}function n(t){return new B(e(t),o.lineMaterial)}for(var a=this,o=this,s=this.iks,l=0,c=s.length;l<c;l++){var u=s[l];a.add(t()),a.add(r());for(var h=0,d=u.links.length;h<d;h++)a.add(i());a.add(n(u))}}}),e}();Object.assign(z.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(e){return this._startTime=e,this},setLoop:function(e,t){return this.loop=e,this.repetitions=t,this},setEffectiveWeight:function(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(e){return this._scheduleFading(e,0,1)},fadeOut:function(e){return this._scheduleFading(e,1,0)},crossFadeFrom:function(e,t,r){if(e.fadeOut(t),this.fadeIn(t),r){var i=this._clip.duration,n=e._clip.duration,a=n/i,o=i/n;e.warp(1,a,t),this.warp(o,1,t)}return this},crossFadeTo:function(e,t,r){return e.crossFadeFrom(this,t,r)},stopFading:function(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},setEffectiveTimeScale:function(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(e){return this.timeScale=this._clip.duration/e,this.stopWarping()},syncWith:function(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()},halt:function(e){return this.warp(this._effectiveTimeScale,0,e)},warp:function(e,t,r){var i=this._mixer,n=i.time,a=this._timeScaleInterpolant,o=this.timeScale;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);var s=a.parameterPositions,l=a.sampleValues;return s[0]=n,s[1]=n+r,l[0]=e/o,l[1]=t/o,this},stopWarping:function(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(e,t,r,i){if(!this.enabled)return void this._updateWeight(e);var n=this._startTime;if(null!==n){var a=(e-n)*r;if(a<0||0===r)return;this._startTime=null,t=r*a}t*=this._updateTimeScale(e);var o=this._updateTime(t),s=this._updateWeight(e);if(s>0)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<n)){for(var s=i+2;;){if(void 0===n){if(e<a)break i;return i=r.length,t._cachedIndex=i,t.afterEnd_(i-1,e,a)}if(i===s)break;if(a=n,n=r[++i],e<n)break t}o=r.length;break r}{if(e>=a)break e;var l=r[1];e<l&&(i=2,a=l);for(var s=i-2;;){if(void 0===a)return t._cachedIndex=0,t.beforeStart_(0,e,n);if(i===s)break;if(n=a,a=r[--i-1],e>=a)break t}o=i,i=0}}for(;i<o;){var c=i+o>>>1;e<r[c]?o=c:i=c+1}if(n=r[i],a=r[i-1],void 0===a)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(void 0===n)return i=r.length,this._cachedIndex=i,this.afterEnd_(i-1,a,e)}this._cachedIndex=i,this.intervalChanged_(i,a,n)}return this.interpolate_(i,a,e,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(e){for(var t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,n=e*i,a=0;a!==i;++a)t[a]=r[n+a];return t},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(j.prototype,{beforeStart_:j.prototype.copySampleValue_,afterEnd_:j.prototype.copySampleValue_}),V.prototype=Object.assign(Object.create(j.prototype),{constructor:V,interpolate_:function(e,t,r,i){for(var n=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,l=s-o,c=(r-t)/(i-t),u=1-c,h=0;h!==o;++h)n[h]=a[l+h]*u+a[s+h]*c;return n}});var bu="\\[\\]\\.:\\/";Object.assign(G.prototype,{getValue:function(e,t){this.bind();var r=this._targetGroup.nCachedObjects_,i=this._bindings[r];void 0!==i&&i.getValue(e,t)},setValue:function(e,t){for(var r=this._bindings,i=this._targetGroup.nCachedObjects_,n=r.length;i!==n;++i)r[i].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}),Object.assign(W,{Composite:G,create:function(e,t,r){return e&&e.isAnimationObjectGroup?new W.Composite(e,t,r):new W(e,t,r)},sanitizeNodeName:function(){var e=new RegExp("["+bu+"]","g");return function(t){return t.replace(/\s/g,"_").replace(e,"")}}(),parseTrackName:function(){var e="[^"+bu+"]",t="[^"+bu.replace("\\.","")+"]",r=/((?:WC+[\/:])*)/.source.replace("WC",e),i=/(WCOD+)?/.source.replace("WCOD",t),n=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",e),a=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",e),o=new RegExp("^"+r+i+n+a+"$"),s=["material","materials","bones"];return function(e){var t=o.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==i&&i!==-1){var n=r.nodeName.substring(i+1);s.indexOf(n)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=n)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}}(),findNode:function(e,t){if(!t||""===t||"root"===t||"."===t||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){var r=e.skeleton.getBoneByName(t);if(void 0!==r)return r}if(e.children){var i=function(e){for(var r=0;r<e.length;r++){var n=e[r];if(n.name===t||n.uuid===t)return n;var a=i(n.children);if(a)return a}return null},n=i(e.children);if(n)return n}return null}}),Object.assign(W.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(e,t){e[t]=this.node[this.propertyName]},function(e,t){for(var r=this.resolvedProperty,i=0,n=r.length;i!==n;++i)e[t++]=r[i]},function(e,t){e[t]=this.resolvedProperty[this.propertyIndex]},function(e,t){this.resolvedProperty.toArray(e,t)}],SetterByBindingTypeAndVersioning:[[function(e,t){this.targetObject[this.propertyName]=e[t]},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){for(var r=this.resolvedProperty,i=0,n=r.length;i!==n;++i)r[i]=e[t++]},function(e,t){for(var r=this.resolvedProperty,i=0,n=r.length;i!==n;++i)r[i]=e[t++];this.targetObject.needsUpdate=!0},function(e,t){for(var r=this.resolvedProperty,i=0,n=r.length;i!==n;++i)r[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty[this.propertyIndex]=e[t]},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(e,t){this.resolvedProperty.fromArray(e,t)},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0},function(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){var e=this.node,t=this.parsedPath,r=t.objectName,i=t.propertyName,n=t.propertyIndex;if(e||(e=W.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(r){var a=t.objectIndex;switch(r){case"materials":if(!e.material)return void console.error("PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(var o=0;o<e.length;o++)if(e[o].name===a){a=o;break}break;default:if(void 0===e[r])return void console.error("PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[r]}if(void 0!==a){if(void 0===e[a])return void console.error("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[a]}}var s=e[i];if(void 0===s){var l=t.nodeName;return void console.error("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e)}var c=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?c=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate);var u=this.BindingType.Direct;if(void 0!==n){if("morphTargetInfluences"===i){if(!e.geometry)return void console.error("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes)return void console.error("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(var o=0;o<this.node.geometry.morphAttributes.position.length;o++)if(e.geometry.morphAttributes.position[o].name===n){n=o;break}}else{if(!e.geometry.morphTargets)return void console.error("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(var o=0;o<this.node.geometry.morphTargets.length;o++)if(e.geometry.morphTargets[o].name===n){n=o;break}}}u=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=n}else void 0!==s.fromArray&&void 0!==s.toArray?(u=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(u=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][c]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(W.prototype,{_getValue_unbound:W.prototype.getValue,_setValue_unbound:W.prototype.setValue}),Object.assign(X.prototype,{accumulate:function(e,t){var r=this.buffer,i=this.valueSize,n=e*i+i,a=this.cumulativeWeight;if(0===a){for(var o=0;o!==i;++o)r[n+o]=r[o];a=t}else{a+=t;var s=t/a;this._mixBufferRegion(r,n,0,s,i)}this.cumulativeWeight=a},apply:function(e){var t=this.valueSize,r=this.buffer,i=e*t+t,n=this.cumulativeWeight,a=this.binding;if(this.cumulativeWeight=0,n<1){var o=3*t;this._mixBufferRegion(r,i,o,1-n,t)}for(var s=t,l=t+t;s!==l;++s)if(r[s]!==r[s+t]){a.setValue(r,i);break}},saveOriginalState:function(){var e=this.binding,t=this.buffer,r=this.valueSize,i=3*r;e.getValue(t,i);for(var n=r,a=i;n!==a;++n)t[n]=t[i+n%r];this.cumulativeWeight=0},restoreOriginalState:function(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)},_select:function(e,t,r,i,n){if(i>=.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]<e;)++n;for(;a!==-1&&r[a]>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;o<a;++o){var s=!1,l=e[o],c=e[o+1];if(l!==c&&(1!==o||l!==l[0]))if(i)s=!0;else for(var u=o*r,h=u-r,d=u+r,p=0;p!==r;++p){var f=t[u+p];if(f!==t[h+p]||f!==t[d+p]){s=!0;break}}if(s){if(o!==n){e[n]=e[o];for(var m=o*r,v=n*r,p=0;p!==r;++p)t[v+p]=t[m+p]}++n}}if(a>0){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;o<n;o++){var s=[],l=[];s.push((o+n-1)%n,o,(o+1)%n),l.push(0,1,0);var c=wu.getKeyframeOrder(s);s=wu.sortedArray(s,1,c),l=wu.sortedArray(l,1,c),i||0!==s[0]||(s.push(n),l.push(l[0])),a.push(new Z(".morphTargetInfluences["+t[o].name+"]",s,l).scale(1/r))}return new re(e,(-1),a)},findByName:function(e,t){var r=e;if(!Array.isArray(e)){var i=e;r=i.geometry&&i.geometry.animations||i.animations}for(var n=0;n<r.length;n++)if(r[n].name===t)return r[n];return null},CreateClipsFromMorphTargetSequences:function(e,t,r){for(var i={},n=/^([\w-]*?)([\d]+)$/,a=0,o=e.length;a<o;a++){var s=e[a],l=s.name.match(n);if(l&&l.length>1){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;l<s.length;l++){var c=s[l].keys;if(c&&0!==c.length)if(c[0].morphTargets){for(var u={},h=0;h<c.length;h++)if(c[h].morphTargets)for(var d=0;d<c[h].morphTargets.length;d++)u[c[h].morphTargets[d]]=-1;for(var p in u){for(var f=[],m=[],d=0;d!==c[h].morphTargets.length;++d){var v=c[h];f.push(v.time),m.push(v.morphTarget===p?1:0)}i.push(new Z(".morphTargetInfluence["+p+"]",f,m))}a=u.length*(o||1)}else{var g=".bones["+t[l].name+"]";r(te,g+".position",c,"pos",i),r($,g+".quaternion",c,"rot",i),r(te,g+".scale",c,"scl",i)}}if(0===i.length)return null;var y=new re(n,a,i);return y}}),Object.assign(re.prototype,{resetDuration:function(){for(var e=this,t=this.tracks,r=0,i=0,n=t.length;i!==n;++i){var a=e.tracks[i];r=Math.max(r,a.times[a.times.length-1])}return this.duration=r,this},trim:function(){for(var e=this,t=0;t<this.tracks.length;t++)e.tracks[t].trim(0,e.duration);return this},validate:function(){for(var e=this,t=!0,r=0;r<this.tracks.length;r++)t=t&&e.tracks[r].validate();return t},optimize:function(){for(var e=this,t=0;t<this.tracks.length;t++)e.tracks[t].optimize();return this}}),ae.prototype=Object.assign(Object.create(a.prototype),{constructor:ae,_bindAction:function(e,t){var r=this,i=e._localRoot||this._root,n=e._clip.tracks,a=n.length,o=e._propertyBindings,s=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName,u=c[l];void 0===u&&(u={},c[l]=u);for(var h=0;h!==a;++h){var d=n[h],p=d.name,f=u[p];if(void 0!==f)o[h]=f;else{if(f=o[h],void 0!==f){null===f._cacheIndex&&(++f.referenceCount,r._addInactiveBinding(f,l,p));continue}var m=t&&t._propertyBindings[h].binding.parsedPath;f=new X(W.create(i,p,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,r._addInactiveBinding(f,l,p),o[h]=f}s[h].resultBuffer=f.buffer}},_activateAction:function(e){var t=this;if(!this._isActiveAction(e)){if(null===e._cacheIndex){var r=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,r)}for(var a=e._propertyBindings,o=0,s=a.length;o!==s;++o){var l=a[o];0===l.useCount++&&(t._lendBinding(l),l.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){var t=this;if(this._isActiveAction(e)){for(var r=e._propertyBindings,i=0,n=r.length;i!==n;++i){var a=r[i];0===--a.useCount&&(a.restoreOriginalState(),t._takeBackBinding(a))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&t<this._nActiveActions},_addInactiveAction:function(e,t,r){var i=this._actions,n=this._actionsByClip,a=n[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=a;else{var o=a.knownActions;e._byClipCacheIndex=o.length,o.push(e)}e._cacheIndex=i.length,i.push(e),a.actionByRoot[r]=e},_removeInactiveAction:function(e){var t=this._actions,r=t[t.length-1],i=e._cacheIndex;r._cacheIndex=i,t[i]=r,t.pop(),e._cacheIndex=null;var n=e._clip.uuid,a=this._actionsByClip,o=a[n],s=o.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null;var u=o.actionByRoot,h=(e._localRoot||this._root).uuid;delete u[h],0===s.length&&delete a[n],this._removeInactiveBindingsForAction(e)},_removeInactiveBindingsForAction:function(e){for(var t=this,r=e._propertyBindings,i=0,n=r.length;i!==n;++i){var a=r[i];0===--a.referenceCount&&t._removeInactiveBinding(a)}},_lendAction:function(e){var t=this._actions,r=e._cacheIndex,i=this._nActiveActions++,n=t[i];e._cacheIndex=i,t[i]=e,n._cacheIndex=r,t[r]=n},_takeBackAction:function(e){var t=this._actions,r=e._cacheIndex,i=--this._nActiveActions,n=t[i];e._cacheIndex=i,t[i]=e,n._cacheIndex=r,t[r]=n},_addInactiveBinding:function(e,t,r){var i=this._bindingsByRootAndName,n=i[t],a=this._bindings;void 0===n&&(n={},i[t]=n),n[r]=e,e._cacheIndex=a.length,a.push(e)},_removeInactiveBinding:function(e){var t=this._bindings,r=e.binding,i=r.rootNode.uuid,n=r.path,a=this._bindingsByRootAndName,o=a[i],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete o[n];e:{for(var c in o)break e;delete a[i]}},_lendBinding:function(e){var t=this._bindings,r=e._cacheIndex,i=this._nActiveBindings++,n=t[i];e._cacheIndex=i,t[i]=e,n._cacheIndex=r,t[r]=n},_takeBackBinding:function(e){var t=this._bindings,r=e._cacheIndex,i=--this._nActiveBindings,n=t[i];e._cacheIndex=i,t[i]=e,n._cacheIndex=r,t[r]=n},_lendControlInterpolant:function(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++,r=e[t];return void 0===r&&(r=new V(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),r.__cacheIndex=t,e[t]=r),r},_takeBackControlInterpolant:function(e){var t=this._controlInterpolants,r=e.__cacheIndex,i=--this._nActiveControlInterpolants,n=t[i];e.__cacheIndex=i,t[i]=e,n.__cacheIndex=r,t[r]=n},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(e,t){var r=t||this._root,i=r.uuid,n="string"==typeof e?re.findByName(r,e):e,a=null!==n?n.uuid:e,o=this._actionsByClip[a],s=null;if(void 0!==o){var l=o.actionByRoot[i];if(void 0!==l)return l;s=o.knownActions[0],null===n&&(n=s._clip)}if(null===n)return null;var c=new z(this,n,t);return this._bindAction(c,s),this._addInactiveAction(c,a,i),c},existingAction:function(e,t){var r=t||this._root,i=r.uuid,n="string"==typeof e?re.findByName(r,e):e,a=n?n.uuid:e,o=this._actionsByClip[a];return void 0!==o?o.actionByRoot[i]||null:null},stopAllAction:function(){var e=this._actions,t=this._nActiveActions,r=this._bindings,i=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var n=0;n!==t;++n)e[n].reset();for(var n=0;n!==i;++n)r[n].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,r=this._nActiveActions,i=this.time+=e,n=Math.sign(e),a=this._accuIndex^=1,o=0;o!==r;++o){var s=t[o];s._update(i,e,n,a)}for(var l=this._bindings,c=this._nActiveBindings,o=0;o!==c;++o)l[o].apply(a);return this},getRoot:function(){return this._root},uncacheClip:function(e){var t=this,r=this._actions,i=e.uuid,n=this._actionsByClip,a=n[i];if(void 0!==a){for(var o=a.knownActions,s=0,l=o.length;s!==l;++s){var c=o[s];t._deactivateAction(c);var u=c._cacheIndex,h=r[r.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=u,r[u]=h,r.pop(),t._removeInactiveBindingsForAction(c)}delete n[i]}},uncacheRoot:function(e){var t=this,r=e.uuid,i=this._actionsByClip;for(var n in i){var a=i[n].actionByRoot,o=a[r];void 0!==o&&(t._deactivateAction(o),t._removeInactiveAction(o))}var s=this._bindingsByRootAndName,l=s[r];if(void 0!==l)for(var c in l){var u=l[c];u.restoreOriginalState(),t._removeInactiveBinding(u)}},uncacheAction:function(e,t){var r=this.existingAction(e,t);null!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}}),oe.prototype=Object.assign(Object.create(c.prototype),{constructor:oe,isBone:!0}),se.prototype=Object.create(m.prototype),se.prototype.constructor=se,le.prototype=Object.create(P.prototype),le.prototype.constructor=le,ce.prototype=Object.create(m.prototype),ce.prototype.constructor=ce,ue.prototype=Object.create(P.prototype),ue.prototype.constructor=ue;var _u=function(){function e(e,r,n,a){if("undefined"==typeof Ammo)throw new Error("MMDPhysics: Import ammo.js https://github.com/kripken/ammo.js");n=n||[],a=a||{},this.manager=new t,this.mesh=e,this.unitStep=void 0!==a.unitStep?a.unitStep:1/65,this.maxStepNum=void 0!==a.maxStepNum?a.maxStepNum:3,this.gravity=new i(0,(-98),0),void 0!==a.gravity&&this.gravity.copy(gravity),this.world=void 0!==a.world?a.world:null,this.bodies=[],this.constraints=[],this._init(e,r,n)}function t(){this.threeVector3s=[],this.threeMatrix4s=[],this.threeQuaternions=[],this.threeEulers=[],this.transforms=[],this.quaternions=[],this.vector3s=[]}function a(e,t,r,i){this.mesh=e,this.world=t,this.params=r,this.manager=i,this.body=null,this.bone=null,this.boneOffsetForm=null,this.boneOffsetFormInverse=null,this._init()}function s(e,t,r,i,n,a){this.mesh=e,this.world=t,this.bodyA=r,this.bodyB=i,this.params=n,this.manager=a,this.constraint=null,this._init()}function l(e,t){c.call(this),this.root=e,this.physics=t,this.matrix.copy(e.matrixWorld),this.matrixAutoUpdate=!1,this.materials=[],this.materials.push(new F({color:new u(16746632),wireframe:!0,depthTest:!1,depthWrite:!1,opacity:.25,transparent:!0})),this.materials.push(new F({color:new u(8978312),wireframe:!0,depthTest:!1,depthWrite:!1,opacity:.25,transparent:!0})),this.materials.push(new F({color:new u(8947967),wireframe:!0,depthTest:!1,depthWrite:!1,opacity:.25,transparent:!0})),this._init()}return e.prototype={constructor:e,update:function(e){var t=this.manager,r=this.mesh,i=!1,n=t.allocThreeVector3(),a=t.allocThreeQuaternion(),o=t.allocThreeVector3();r.matrixWorld.decompose(n,a,o),1===o.x&&1===o.y&&1===o.z||(i=!0);var s;return i&&(s=r.parent,null!==s&&(r.parent=null),o.copy(this.mesh.scale),r.scale.set(1,1,1),r.updateMatrixWorld(!0)),this._updateRigidBodies(),this._stepSimulation(e),this._updateBones(),i&&(null!==s&&(s.parent=s),r.scale.copy(o)),t.freeThreeVector3(o),t.freeThreeQuaternion(a),t.freeThreeVector3(n),this},reset:function(){for(var e=this,t=0,r=this.bodies.length;t<r;t++)e.bodies[t].reset();return this},warmup:function(e){for(var t=this,r=0;r<e;r++)t.update(1/60);return this},setGravity:function(e){return this.world.setGravity(new Ammo.btVector3(e.x,e.y,e.z)),this.gravity.copy(e),this},createHelper:function(){return new l(this.mesh,this)},_init:function(e,t,r){var i=this.manager,n=e.parent;null!==n&&(n=null);var a=i.allocThreeVector3(),o=i.allocThreeQuaternion(),s=i.allocThreeVector3();a.copy(e.position),o.copy(e.quaternion),s.copy(e.scale),e.position.set(0,0,0),e.quaternion.set(0,0,0,1),e.scale.set(1,1,1),e.updateMatrixWorld(!0),null===this.world&&(this.world=this._createWorld(),this.setGravity(this.gravity)),this._initRigidBodies(t),this._initConstraints(r),null!==n&&(e.parent=n),e.position.copy(a),e.quaternion.copy(o),e.scale.copy(s),e.updateMatrixWorld(!0),this.reset(),i.freeThreeVector3(a),i.freeThreeQuaternion(o),i.freeThreeVector3(s)},_createWorld:function(){var e=new Ammo.btDefaultCollisionConfiguration,t=new Ammo.btCollisionDispatcher(e),r=new Ammo.btDbvtBroadphase,i=new Ammo.btSequentialImpulseConstraintSolver,n=new Ammo.btDiscreteDynamicsWorld(t,r,i,e);return n},_initRigidBodies:function(e){for(var t=this,r=0,i=e.length;r<i;r++)t.bodies.push(new a(t.mesh,t.world,e[r],t.manager))},_initConstraints:function(e){for(var t=this,r=0,i=e.length;r<i;r++){var n=e[r],a=t.bodies[n.rigidBodyIndex1],o=t.bodies[n.rigidBodyIndex2];t.constraints.push(new s(t.mesh,t.world,a,o,n,t.manager))}},_stepSimulation:function(e){var t=this.unitStep,r=e,i=(e/t|0)+1;r<t&&(r=t,i=1),i>this.maxStepNum&&(i=this.maxStepNum),this.world.stepSimulation(r,i,t)},_updateRigidBodies:function(){for(var e=this,t=0,r=this.bodies.length;t<r;t++)e.bodies[t].updateFromBone()},_updateBones:function(){for(var e=this,t=0,r=this.bodies.length;t<r;t++)e.bodies[t].updateBone()}},t.prototype={constructor:t,allocThreeVector3:function(){return this.threeVector3s.length>0?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<<r.groupIndex,r.groupTarget),this.body=f,this.bone=n,this.boneOffsetForm=l,this.boneOffsetFormInverse=t.inverseTransform(l),t.freeVector3(s),t.freeTransform(h),t.freeTransform(u),t.freeThreeVector3(c)},_getBoneTransform:function(){var e=this.manager,t=e.allocThreeVector3(),r=e.allocThreeQuaternion(),i=e.allocThreeVector3();this.bone.matrixWorld.decompose(t,r,i);var n=e.allocTransform();e.setOriginFromThreeVector3(n,t),e.setBasisFromThreeQuaternion(n,r);var a=e.multiplyTransforms(n,this.boneOffsetForm);return e.freeTransform(n),e.freeThreeVector3(i),e.freeThreeQuaternion(r),e.freeThreeVector3(t),a},_getWorldTransformForBone:function(){var e=this.manager,t=e.allocTransform();this.body.getMotionState().getWorldTransform(t);var r=e.multiplyTransforms(t,this.boneOffsetFormInverse);return e.freeTransform(t),r},_setTransformFromBone:function(){var e=this.manager,t=this._getBoneTransform();this.body.setCenterOfMassTransform(t),this.body.getMotionState().setWorldTransform(t),e.freeTransform(t)},_setPositionFromBone:function(){var e=this.manager,t=this._getBoneTransform(),r=e.allocTransform();this.body.getMotionState().getWorldTransform(r),e.copyOrigin(r,t),this.body.setCenterOfMassTransform(r),this.body.getMotionState().setWorldTransform(r),e.freeTransform(r),e.freeTransform(t)},_updateBoneRotation:function(){var e=this.manager,t=this._getWorldTransformForBone(),r=e.getBasis(t),i=e.allocThreeQuaternion(),n=e.allocThreeQuaternion(),a=e.allocThreeQuaternion();i.set(r.x(),r.y(),r.z(),r.w()),n.setFromRotationMatrix(this.bone.matrixWorld),n.conjugate(),n.multiply(i),a.setFromRotationMatrix(this.bone.matrix),this.bone.quaternion.copy(n.multiply(a)),e.freeThreeQuaternion(i),e.freeThreeQuaternion(n),e.freeThreeQuaternion(a),e.freeQuaternion(r),e.freeTransform(t)},_updateBonePosition:function(){var e=this.manager,t=this._getWorldTransformForBone(),r=e.allocThreeVector3(),i=e.getOrigin(t);r.set(i.x(),i.y(),i.z());var n=this.bone.worldToLocal(r);this.bone.position.add(n),e.freeThreeVector3(r),e.freeTransform(t)}},s.prototype={constructor:s,_init:function(){var e=this.manager,t=this.params,r=this.bodyA,i=this.bodyB,n=e.allocTransform();e.setIdentity(n),e.setOriginFromArray3(n,t.position),e.setBasisFromArray3(n,t.rotation);var a=e.allocTransform(),o=e.allocTransform();r.body.getMotionState().getWorldTransform(a),i.body.getMotionState().getWorldTransform(o);var s=e.inverseTransform(a),l=e.inverseTransform(o),c=e.multiplyTransforms(s,n),u=e.multiplyTransforms(l,n),h=new Ammo.btGeneric6DofSpringConstraint(r.body,i.body,c,u,(!0)),d=e.allocVector3(),p=e.allocVector3(),f=e.allocVector3(),m=e.allocVector3();d.setValue(t.translationLimitation1[0],t.translationLimitation1[1],t.translationLimitation1[2]),p.setValue(t.translationLimitation2[0],t.translationLimitation2[1],t.translationLimitation2[2]),f.setValue(t.rotationLimitation1[0],t.rotationLimitation1[1],t.rotationLimitation1[2]),m.setValue(t.rotationLimitation2[0],t.rotationLimitation2[1],t.rotationLimitation2[2]),h.setLinearLowerLimit(d),h.setLinearUpperLimit(p),h.setAngularLowerLimit(f),h.setAngularUpperLimit(m);for(var v=0;v<3;v++)0!==t.springPosition[v]&&(h.enableSpring(v,!0),h.setStiffness(v,t.springPosition[v]));for(var v=0;v<3;v++)0!==t.springRotation[v]&&(h.enableSpring(v+3,!0),h.setStiffness(v+3,t.springRotation[v]));if(void 0!==h.setParam)for(var v=0;v<6;v++)h.setParam(2,.475,v);this.world.addConstraint(h,!0),this.constraint=h,e.freeTransform(n),e.freeTransform(a),e.freeTransform(o),e.freeTransform(s),e.freeTransform(l),e.freeTransform(c),e.freeTransform(u),e.freeVector3(d),e.freeVector3(p),e.freeVector3(f),e.freeVector3(m)}},l.prototype=Object.assign(Object.create(c.prototype),{constructor:l,updateMatrixWorld:function(){var e=new i,t=new n,a=new i,o=new r;return function(r){var i=this,n=this.root;if(this.visible){var s=this.physics.bodies;o.copy(n.matrixWorld).decompose(e,t,a).compose(e,t,a.set(1,1,1)).getInverse(o);for(var l=0,u=s.length;l<u;l++){var h=s[l].body,d=i.children[l],p=h.getCenterOfMassTransform(),f=p.getOrigin(),m=p.getRotation();d.position.set(f.x(),f.y(),f.z()).applyMatrix4(o),d.quaternion.setFromRotationMatrix(o).multiply(t.set(m.x(),m.y(),m.z(),m.w()))}}this.matrix.copy(n.matrixWorld).decompose(e,t,a).compose(e,t,a.set(1,1,1)),c.prototype.updateMatrixWorld.call(this,r)}}(),_init:function(){function e(e){switch(e.shapeType){case 0:return new O(e.width,16,8);case 1:return new le(2*e.width,2*e.height,2*e.depth,8,8,8);case 2:return new t(e.width,e.height,16,8);default:return null}}function t(e,t,r,i){var n=new ue(e,e,t,r,i,(!0)),a=new k(new O(e,r,i,0,2*Math.PI,0,Math.PI/2)),o=new k(new O(e,r,i,0,2*Math.PI,Math.PI/2,Math.PI/2));return a.position.set(0,t/2,0),o.position.set(0,-t/2,0),a.updateMatrix(),o.updateMatrix(),n.merge(a.geometry,a.matrix),n.merge(o.geometry,o.matrix),n}for(var r=this,i=this.physics.bodies,n=0,a=i.length;n<a;n++){var o=i[n].params;r.add(new k(e(o),r.materials[o.type]))}}}),e}(),Su=function(){function e(e){e=e||{},this.meshes=[],this.camera=null,this.cameraTarget=new c,this.cameraTarget.name="target",this.audio=null,this.audioManager=null,this.objects=new WeakMap,this.configuration={sync:void 0===e.sync||e.sync,afterglow:void 0!==e.afterglow?e.afterglow:0,resetPhysicsOnLoop:void 0===e.resetPhysicsOnLoop||e.resetPhysicsOnLoop},this.enabled={animation:!0,ik:!0,grant:!0,physics:!0,cameraAnimation:!0},this.onBeforePhysics=function(e){},this.sharedPhysics=!1,this.masterPhysics=null}function t(e,t){t=t||{},this.audio=e,this.elapsedTime=0,this.currentTime=0,this.delayTime=void 0!==t.delayTime?t.delayTime:0,this.audioDuration=this.audio.buffer.duration,this.duration=this.audioDuration+this.delayTime}function r(e,t){this.mesh=e,this.grants=t||[]}return e.prototype={constructor:e,add:function(e,t){if(t=t||{},e.isSkinnedMesh)this._addMesh(e,t);else if(e.isCamera)this._setupCamera(e,t);else{if("Audio"!==e.type)throw new Error("MMDAnimationHelper.add: accepts only SkinnedMesh or Camera or Audio instance.");this._setupAudio(e,t)}return this.configuration.sync&&this._syncDuration(),this},remove:function(e){if(e.isSkinnedMesh)this._removeMesh(e);else if(e.isCamera)this._clearCamera(e);else{if("Audio"!==e.type)throw new Error("MMDAnimationHelper.remove: accepts only SkinnedMesh or Camera or Audio instance.");this._clearAudio(e)}return this.configuration.sync&&this._syncDuration(),this},update:function(e){var t=this;null!==this.audioManager&&this.audioManager.control(e);for(var r=0;r<this.meshes.length;r++)t._animateMesh(t.meshes[r],e);return this.sharedPhysics&&this._updateSharedPhysics(e),null!==this.camera&&this._animateCamera(this.camera,e),this},pose:function(e,t,r){r=r||{},r.resetPose!==!1&&e.pose();for(var a=e.skeleton.bones,o=t.bones,s={},l=0,c=a.length;l<c;l++)s[a[l].name]=l;for(var u=new i,h=new n,l=0,c=o.length;l<c;l++){var d=o[l],p=s[d.name];if(void 0!==p){var f=a[p];f.position.add(u.fromArray(d.translation)),f.quaternion.multiply(h.fromArray(d.quaternion))}}return e.updateMatrixWorld(!0),r.ik!==!1&&this._createCCDIKSolver(e).update(r.saveOriginalBonesBeforeIK),r.grant!==!1&&this.createGrantSolver(e).update(),this},enable:function(e,t){var r=this;if(void 0===this.enabled[e])throw new Error("MMDAnimationHelper.enable: unknown key "+e);if(this.enabled[e]=t,"physics"===e)for(var i=0,n=this.meshes.length;i<n;i++)r._optimizeIK(r.meshes[i],t);return this},createGrantSolver:function(e){return new r(e,e.geometry.userData.MMD.grants)},_addMesh:function(e,t){if(this.meshes.indexOf(e)>=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;n<a;n++)t.meshes[n]!==e?t.meshes[i++]=t.meshes[n]:(t.objects["delete"](e),r=!0);if(!r)throw new Error("MMDAnimationHelper._removeMesh: SkinnedMesh '"+e.name+"' has not been added yet.");return this.meshes.length=i,this},_clearCamera:function(e){if(e!==this.camera)throw new Error("MMDAnimationHelper._clearCamera: Camera '"+e.name+"' has not been set yet.");return this.camera.remove(this.cameraTarget),this.objects["delete"](this.camera),this.camera=null,this},_clearAudio:function(e){if(e!==this.audio)throw new Error("MMDAnimationHelper._clearAudio: Audio '"+e.name+"' has not been set yet.");return this.objects["delete"](this.audioManager),this.audio=null,this.audioManager=null,this},_setupMeshAnimation:function(e,t){var r=this.objects.get(e);if(void 0!==t){var i=Array.isArray(t)?t:[t];r.mixer=new ae(e);for(var n=0,a=i.length;n<a;n++)r.mixer.clipAction(i[n]).play();r.mixer.addEventListener("loop",function(e){var t=e.action._clip.tracks;t.length>0&&".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;n<a;n++)i.mixer.clipAction(r[n]).play()},_setupMeshPhysics:function(e,t){var r=this.objects.get(e);if(void 0===t.world&&this.sharedPhysics){var i=this._getMasterPhysics();null!==i&&(world=i.world)}r.physics=this._createMMDPhysics(e,t),r.mixer&&t.animationWarmup!==!1&&(this._animateMesh(e,0),r.physics.reset()),r.physics.warmup(void 0!==t.warmup?t.warmup:60),this._optimizeIK(e,!0)},_animateMesh:function(e,t){var r=this.objects.get(e),i=r.mixer,n=r.ikSolver,a=r.grantSolver,o=r.physics,s=r.looped;i&&this.enabled.animation&&(this._restoreBones(e),i.update(t),this._saveBones(e),n&&this.enabled.ik&&(e.updateMatrixWorld(!0),n.update()),a&&this.enabled.grant&&a.update()),s===!0&&this.enabled.physics&&(o&&this.configuration.resetPhysicsOnLoop&&o.reset(),r.looped=!1),o&&this.enabled.physics&&!this.sharedPhysics&&(this.onBeforePhysics(e),o.update(t))},_animateCamera:function(e,t){var r=this.objects.get(e).mixer;r&&this.enabled.cameraAnimation&&(r.update(t),e.updateProjectionMatrix(),e.up.set(0,1,0),e.up.applyQuaternion(e.quaternion),e.lookAt(this.cameraTarget.position))},_optimizeIK:function(e,t){for(var r=e.geometry.userData.MMD.iks,i=e.geometry.userData.MMD.bones,n=0,a=r.length;n<a;n++)for(var o=r[n],s=o.links,l=0,c=s.length;l<c;l++){var u=s[l];t===!0?u.enabled=!(i[u.index].rigidBodyType>0):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<s;o++){var l=e.objects.get(i[o]).mixer;if(void 0!==l)for(var c=0;c<l._actions.length;c++){var u=l._actions[c]._clip;r.has(u)||r.set(u,{duration:u.duration}),t=Math.max(t,r.get(u).duration)}}if(null!==n){var l=this.objects.get(n).mixer;if(void 0!==l)for(var o=0,s=l._actions.length;o<s;o++){var u=l._actions[o]._clip;r.has(u)||r.set(u,{duration:u.duration}),t=Math.max(t,r.get(u).duration)}}null!==a&&(t=Math.max(t,r.get(a).duration)),t+=this.configuration.afterglow;for(var o=0,s=this.meshes.length;o<s;o++){var l=e.objects.get(e.meshes[o]).mixer;if(void 0!==l)for(var c=0,h=l._actions.length;c<h;c++)l._actions[c]._clip.duration=t}if(null!==n){var l=this.objects.get(n).mixer;if(void 0!==l)for(var o=0,s=l._actions.length;o<s;o++)l._actions[o]._clip.duration=t}null!==a&&(a.duration=t)},_updatePropertyMixersBuffer:function(e){for(var t=this.objects.get(e).mixer,r=t._bindings,i=t._accuIndex,n=0,a=r.length;n<a;n++){var o=r[n],s=o.buffer,l=o.valueSize,c=(i+1)*l;o.binding.getValue(s,c)}},_saveBones:function(e){var t=this.objects.get(e),r=e.skeleton.bones,i=t.backupBones;void 0===i&&(i=new Float32Array(7*r.length),t.backupBones=i);for(var n=0,a=r.length;n<a;n++){var o=r[n];o.position.toArray(i,7*n),o.quaternion.toArray(i,7*n+3)}},_restoreBones:function(e){var t=this.objects.get(e),r=t.backupBones;if(void 0!==r)for(var i=e.skeleton.bones,n=0,a=i.length;n<a;n++){var o=i[n];o.position.fromArray(r,7*n),o.quaternion.fromArray(r,7*n+3)}},_getMasterPhysics:function(){var e=this;if(null!==this.masterPhysics)return this.masterPhysics;for(var t=0,r=this.meshes.length;t<r;t++){var i=e.meshes[t].physics;if(void 0!==i&&null!==i)return e.masterPhysics=i,e.masterPhysics}return null},_updateSharedPhysics:function(e){var t=this;if(0!==this.meshes.length&&this.enabled.physics&&this.sharedPhysics){var r=this._getMasterPhysics();if(null!==r){for(var i=0,n=this.meshes.length;i<n;i++){var a=t.meshes[i].physics;null!==a&&void 0!==a&&a.updateRigidBodies()}r.stepSimulation(e);for(var i=0,n=this.meshes.length;i<n;i++){var a=t.meshes[i].physics;null!==a&&void 0!==a&&a.updateBones()}}}}},t.prototype={constructor:t,control:function(e){return this.elapsed+=e,this.currentTime+=e,this._shouldStopAudio()&&this.audio.stop(),this._shouldStartAudio()&&this.audio.play(),this},_shouldStartAudio:function(){var e=this;if(this.audio.isPlaying)return!1;for(;this.currentTime>=this.duration;)e.currentTime-=e.duration;return!(this.currentTime<this.delayTime)&&(this.audio.startTime=this.currentTime-this.delayTime,!0)},_shouldStopAudio:function(){return this.audio.isPlaying&&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;i<n;i++){var a=r[i],o=t[a.index],s=t[a.parentIndex];a.isLocal?(a.affectPosition,a.affectRotation):(a.affectPosition,a.affectRotation&&(e.set(0,0,0,1),e.slerp(s.quaternion,a.ratio),o.quaternion.multiply(e)))}return this}}()},e}(),Au=function(){};Au.CreateRotationAnimation=function(e,t){var r=[0,e],i=[0,360];t=t||"x";var n=".rotation["+t+"]",a=new Z(n,r,i);return new re(null,e,[a])},Au.CreateScaleAxisAnimation=function(e,t){var r=[0,e],i=[0,1];t=t||"x";var n=".scale["+t+"]",a=new Z(n,r,i);return new re(null,e,[a])},Au.CreateShakeAnimation=function(e,t){for(var r=[],n=[],a=new i,o=0;o<10*e;o++)r.push(o/10),a.set(2*Math.random()-1,2*Math.random()-1,2*Math.random()-1).multiply(t).toArray(n,n.length);var s=".position",l=new te(s,r,n);return new re(null,e,[l])},Au.CreatePulsationAnimation=function(e,t){for(var r=[],n=[],a=new i,o=0;o<10*e;o++){r.push(o/10);var s=Math.random()*t;a.set(s,s,s).toArray(n,n.length)}var l=".scale",c=new te(l,r,n);return new re(null,e,[c])},Au.CreateVisibilityAnimation=function(e){var t=[0,e/2,e],r=[!0,!1,!0],i=".visible",n=new Q(i,t,r);return new re(null,e,[n])},Au.CreateMaterialColorAnimation=function(e,t){for(var r=[],i=[],n=e/t.length,a=0;a<=t.length;a++)r.push(a*n),i.push(t[a%t.length]);var o=".material[0].color",s=new J(o,r,i);return new re(null,e,[s])},he.prototype=Object.assign(Object.create(c.prototype),{constructor:he,isCamera:!0,copy:function(e,t){return c.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("Camera: .getWorldDirection() target is now required"),e=new i),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){c.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),de.prototype=Object.assign(Object.create(he.prototype),{constructor:de,isPerspectiveCamera:!0,copy:function(e,t){return he.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*Fs.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*Fs.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*Fs.RAD2DEG*Math.atan(Math.tan(.5*Fs.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,r,i,n,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=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.near,t=e*Math.tan(.5*Fs.DEG2RAD*this.fov)/this.zoom,r=2*t,i=this.aspect*r,n=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;n+=a.offsetX*i/o,t-=a.offsetY*r/s,i*=a.width/o,r*=a.height/s}var l=this.filmOffset;0!==l&&(n+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,t,t-r,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=c.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});var Mu={merge:function(e){for(var t=this,r={},i=0;i<e.length;i++){var n=t.clone(e[i]);for(var a in n)r[a]=n[a]}return r},clone:function(e){var t={};for(var r in e){t[r]={};for(var i in e[r]){var n=e[r][i];n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture)?t[r][i]=n.clone():Array.isArray(n)?t[r][i]=n.slice():t[r][i]=n}}return t}};pe.prototype=Object.create(D.prototype),pe.prototype.constructor=pe,pe.prototype.isShaderMaterial=!0,pe.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Mu.clone(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},pe.prototype.toJSON=function(e){var t=this,r=D.prototype.toJSON.call(this,e);r.uniforms={};for(var i in t.uniforms){var n=t.uniforms[i],a=n.value;a.isTexture?r.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a.isColor?r.uniforms[i]={type:"c",value:a.getHex()}:a.isVector2?r.uniforms[i]={type:"v2",value:a.toArray()}:a.isVector3?r.uniforms[i]={type:"v3",value:a.toArray()}:a.isVector4?r.uniforms[i]={type:"v4",value:a.toArray()}:a.isMatrix4?r.uniforms[i]={type:"m4",value:a.toArray()}:r.uniforms[i]={value:a}}return Object.keys(this.defines).length>0&&(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;a<o;a++)n.push(Tu.getDataURL(i[a]))}else n=Tu.getDataURL(i);e.images[i.uuid]={uuid:i.uuid,url:n}}r.image=i.uuid}return t||(e.textures[this.uuid]=r),r},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping!==Vl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)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 <common>","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 <packing>","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 <common>","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 <begin_vertex>","\t#include <project_vertex>","\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;m<h.length;m++)f[m]=h.charCodeAt(m);d="blob"===p?new Blob([f.buffer],{type:c}):f.buffer;break;case"document":var v=new DOMParser;d=v.parseFromString(h,c);break;case"json":d=JSON.parse(h);break;default:d=h}Ds.setTimeout(function(){t&&t(d),a.manager.itemEnd(e)},0)}catch(g){Ds.setTimeout(function(){i&&i(g),a.manager.itemEnd(e),a.manager.itemError(e)},0)}}else{Fu[e]=[],Fu[e].push({onLoad:t,onProgress:r,onError:i});var y=new XMLHttpRequest;y.open("GET",e,!0),y.addEventListener("load",function(t){var r=this.response;Ou.add(e,r);var i=Fu[e];if(delete Fu[e],200===this.status||0===this.status){0===this.status&&console.warn("FileLoader: HTTP Status 0 received.");for(var n=0,o=i.length;n<o;n++){var s=i[n];s.onLoad&&s.onLoad(r)}a.manager.itemEnd(e)}else{for(var n=0,o=i.length;n<o;n++){var s=i[n];s.onError&&s.onError(t)}a.manager.itemEnd(e),a.manager.itemError(e)}},!1),y.addEventListener("progress",function(t){for(var r=Fu[e],i=0,n=r.length;i<n;i++){var a=r[i];a.onProgress&&a.onProgress(t)}},!1),y.addEventListener("error",function(t){var r=Fu[e];delete Fu[e];for(var i=0,n=r.length;i<n;i++){var o=r[i];o.onError&&o.onError(t)}a.manager.itemEnd(e),a.manager.itemError(e)},!1),y.addEventListener("abort",function(t){var r=Fu[e];delete Fu[e];for(var i=0,n=r.length;i<n;i++){var o=r[i];o.onError&&o.onError(t)}a.manager.itemEnd(e),a.manager.itemError(e)},!1),void 0!==this.responseType&&(y.responseType=this.responseType),void 0!==this.withCredentials&&(y.withCredentials=this.withCredentials),y.overrideMimeType&&y.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(var x in n.requestHeader)y.setRequestHeader(x,n.requestHeader[x]);y.send(null)}return a.manager.itemStart(e),y},setPath:function(e){return this.path=e,this},setResponseType:function(e){return this.responseType=e,this},setWithCredentials:function(e){return this.withCredentials=e,this},setMimeType:function(e){return this.mimeType=e,this},setRequestHeader:function(e){return this.requestHeader=e,this}}),_e.prototype=Object.create(R.prototype),_e.prototype.constructor=_e,_e.prototype.isLineDashedMaterial=!0,_e.prototype.copy=function(e){return R.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this},Se.prototype=Object.create(D.prototype),Se.prototype.constructor=Se,Se.prototype.isMeshDepthMaterial=!0,Se.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},Ae.prototype=Object.create(D.prototype),Ae.prototype.constructor=Ae,Ae.prototype.isMeshDistanceMaterial=!0,Ae.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this},Me.prototype=Object.create(D.prototype),Me.prototype.constructor=Me,Me.prototype.isMeshLambertMaterial=!0,Me.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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,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.morphNormals=e.morphNormals,this},Te.prototype=Object.create(D.prototype),Te.prototype.constructor=Te,Te.prototype.isMeshNormalMaterial=!0,Te.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Ee.prototype=Object.create(D.prototype),Ee.prototype.constructor=Ee,Ee.prototype.isMeshPhongMaterial=!0,Ee.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.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.morphNormals=e.morphNormals,this},Ce.prototype=Object.create(D.prototype),Ce.prototype.constructor=Ce,Ce.prototype.isMeshStandardMaterial=!0,Ce.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,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.morphNormals=e.morphNormals,this},Le.prototype=Object.create(Ce.prototype),Le.prototype.constructor=Le,Le.prototype.isMeshPhysicalMaterial=!0,Le.prototype.copy=function(e){return Ce.prototype.copy.call(this,e),this.defines={PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearCoat=e.clearCoat,this.clearCoatRoughness=e.clearCoatRoughness,this},Pe.prototype=Object.create(Ee.prototype),Pe.prototype.constructor=Pe,Pe.prototype.isMeshToonMaterial=!0,Pe.prototype.copy=function(e){return Ee.prototype.copy.call(this,e),this.gradientMap=e.gradientMap,this},Ne.prototype=Object.create(D.prototype),Ne.prototype.constructor=Ne,Ne.prototype.isPointsMaterial=!0,Ne.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this},Oe.prototype=Object.create(pe.prototype),Oe.prototype.constructor=Oe,Oe.prototype.isRawShaderMaterial=!0,De.prototype=Object.create(D.prototype),De.prototype.constructor=De,De.prototype.isShadowMaterial=!0,De.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.color.copy(e.color),this},Fe.prototype=Object.create(D.prototype),Fe.prototype.constructor=Fe,Fe.prototype.isSpriteMaterial=!0,Fe.prototype.copy=function(e){return D.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this},Object.assign(Re.prototype,{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)},setTextures:function(e){this.textures=e},parse:function(e){function t(e){return void 0===n[e]&&console.warn("MaterialLoader: Undefined texture",e),n[e]}var n=this.textures,a={LineBasicMaterial:R,LineDashedMaterial:_e,MeshBasicMaterial:F,MeshDepthMaterial:Se,MeshDistanceMaterial:Ae,MeshLambertMaterial:Me,MeshNormalMaterial:Te,MeshPhongMaterial:Ee,MeshPhysicalMaterial:Le,MeshStandardMaterial:Ce,MeshToonMaterial:Pe,PointsMaterial:Ne,RawShaderMaterial:Oe,ShaderMaterial:pe,ShadowMaterial:De,SpriteMaterial:Fe},o=new a[e.type];if(void 0!==e.uuid&&(o.uuid=e.uuid),void 0!==e.name&&(o.name=e.name),void 0!==e.color&&o.color.setHex(e.color),void 0!==e.roughness&&(o.roughness=e.roughness),void 0!==e.metalness&&(o.metalness=e.metalness),void 0!==e.emissive&&o.emissive.setHex(e.emissive),void 0!==e.specular&&o.specular.setHex(e.specular),void 0!==e.shininess&&(o.shininess=e.shininess),void 0!==e.clearCoat&&(o.clearCoat=e.clearCoat),void 0!==e.clearCoatRoughness&&(o.clearCoatRoughness=e.clearCoatRoughness),void 0!==e.vertexColors&&(o.vertexColors=e.vertexColors),void 0!==e.fog&&(o.fog=e.fog),void 0!==e.flatShading&&(o.flatShading=e.flatShading),void 0!==e.blending&&(o.blending=e.blending),void 0!==e.side&&(o.side=e.side),void 0!==e.opacity&&(o.opacity=e.opacity),void 0!==e.transparent&&(o.transparent=e.transparent),void 0!==e.alphaTest&&(o.alphaTest=e.alphaTest),void 0!==e.depthTest&&(o.depthTest=e.depthTest),void 0!==e.depthWrite&&(o.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(o.colorWrite=e.colorWrite),void 0!==e.wireframe&&(o.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(o.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(o.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(o.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(o.rotation=e.rotation),1!==e.linewidth&&(o.linewidth=e.linewidth),void 0!==e.dashSize&&(o.dashSize=e.dashSize),void 0!==e.gapSize&&(o.gapSize=e.gapSize),void 0!==e.scale&&(o.scale=e.scale),void 0!==e.polygonOffset&&(o.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(o.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(o.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.skinning&&(o.skinning=e.skinning),void 0!==e.morphTargets&&(o.morphTargets=e.morphTargets),void 0!==e.dithering&&(o.dithering=e.dithering),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.uniforms)for(var s in e.uniforms){var l=e.uniforms[s];switch(o.uniforms[s]={},l.type){case"t":o.uniforms[s].value=t(l.value);break;case"c":o.uniforms[s].value=(new u).setHex(l.value);break;case"v2":o.uniforms[s].value=(new f).fromArray(l.value);break;case"v3":o.uniforms[s].value=(new i).fromArray(l.value);break;case"v4":o.uniforms[s].value=(new v).fromArray(l.value);break;case"m4":o.uniforms[s].value=(new r).fromArray(l.value);break;default:o.uniforms[s].value=l.value}}if(void 0!==e.defines&&(o.defines=e.defines),void 0!==e.vertexShader&&(o.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(o.fragmentShader=e.fragmentShader),void 0!==e.shading&&(o.flatShading=1===e.shading),void 0!==e.size&&(o.size=e.size),void 0!==e.sizeAttenuation&&(o.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(o.map=t(e.map)),void 0!==e.alphaMap&&(o.alphaMap=t(e.alphaMap),o.transparent=!0),void 0!==e.bumpMap&&(o.bumpMap=t(e.bumpMap)),void 0!==e.bumpScale&&(o.bumpScale=e.bumpScale),void 0!==e.normalMap&&(o.normalMap=t(e.normalMap)),void 0!==e.normalMapType&&(o.normalMapType=e.normalMapType),void 0!==e.normalScale){var c=e.normalScale;Array.isArray(c)===!1&&(c=[c,c]),o.normalScale=(new f).fromArray(c)}return void 0!==e.displacementMap&&(o.displacementMap=t(e.displacementMap)),void 0!==e.displacementScale&&(o.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(o.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(o.roughnessMap=t(e.roughnessMap)),void 0!==e.metalnessMap&&(o.metalnessMap=t(e.metalnessMap)),void 0!==e.emissiveMap&&(o.emissiveMap=t(e.emissiveMap)),void 0!==e.emissiveIntensity&&(o.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(o.specularMap=t(e.specularMap)),void 0!==e.envMap&&(o.envMap=t(e.envMap)),void 0!==e.reflectivity&&(o.reflectivity=e.reflectivity),void 0!==e.lightMap&&(o.lightMap=t(e.lightMap)),void 0!==e.lightMapIntensity&&(o.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(o.aoMap=t(e.aoMap)),void 0!==e.aoMapIntensity&&(o.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(o.gradientMap=t(e.gradientMap)),o}}),Object.assign(Ie.prototype,{crossOrigin:"anonymous",load:function(e,t,r,i){function n(){l.removeEventListener("load",n,!1),l.removeEventListener("error",a,!1),Ou.add(e,this),t&&t(this),o.manager.itemEnd(e)}function a(t){l.removeEventListener("load",n,!1),l.removeEventListener("error",a,!1),i&&i(t),o.manager.itemEnd(e),o.manager.itemError(e)}void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var o=this,s=Ou.get(e);if(void 0!==s)return o.manager.itemStart(e),setTimeout(function(){t&&t(s),o.manager.itemEnd(e)},0),s;var l=document.createElementNS("http://www.w3.org/1999/xhtml","img");return l.addEventListener("load",n,!1),l.addEventListener("error",a,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(l.crossOrigin=this.crossOrigin),o.manager.itemStart(e),l.src=e,l},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Ue.prototype,{crossOrigin:"anonymous",load:function(e,t,r,i){var n=new ve,a=new Ie(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(r){n.image=r;var i=e.search(/\.jpe?g$/i)>0||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;r<i;r+=2){var n=t[r],a=t[r+1];if(n.test(e))return a}return null}},Object.assign(ke.prototype,{crossOrigin:"anonymous",onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(e,t,r){for(var i=this,n=[],a=0;a<e.length;++a)n[a]=i.createMaterial(e[a],t,r);return n},createMaterial:function(){var e={NoBlending:nl,NormalBlending:al,AdditiveBlending:ol,SubtractiveBlending:sl,MultiplyBlending:ll,CustomBlending:cl},t=new u,r=new Ue,i=new Re;return function(n,a,o){function s(e,t,i,n,s){var c,u=a+e,h=ke.Handlers.get(u);null!==h?c=h.load(u):(r.setCrossOrigin(o),c=r.load(u)),void 0!==t&&(c.repeat.fromArray(t),1!==t[0]&&(c.wrapS=Jl),1!==t[1]&&(c.wrapT=Jl)),void 0!==i&&c.offset.fromArray(i),void 0!==n&&("repeat"===n[0]&&(c.wrapS=Jl),"mirror"===n[0]&&(c.wrapS=Kl),"repeat"===n[1]&&(c.wrapT=Jl),"mirror"===n[1]&&(c.wrapT=Kl)),void 0!==s&&(c.anisotropy=s);var d=Fs.generateUUID();return l[d]=c,d}var l={},c={uuid:Fs.generateUUID(),type:"MeshLambertMaterial"};for(var u in n){var h=n[u];switch(u){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":c.name=h;break;case"blending":c.blending=e[h];break;case"colorAmbient":case"mapAmbient":console.warn("Loader.createMaterial:",u,"is no longer supported.");break;case"colorDiffuse":c.color=t.fromArray(h).getHex();break;case"colorSpecular":c.specular=t.fromArray(h).getHex();break;case"colorEmissive":c.emissive=t.fromArray(h).getHex();break;case"specularCoef":c.shininess=h;break;case"shading":"basic"===h.toLowerCase()&&(c.type="MeshBasicMaterial"),"phong"===h.toLowerCase()&&(c.type="MeshPhongMaterial"),"standard"===h.toLowerCase()&&(c.type="MeshStandardMaterial");break;case"mapDiffuse":c.map=s(h,n.mapDiffuseRepeat,n.mapDiffuseOffset,n.mapDiffuseWrap,n.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":c.emissiveMap=s(h,n.mapEmissiveRepeat,n.mapEmissiveOffset,n.mapEmissiveWrap,n.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":c.lightMap=s(h,n.mapLightRepeat,n.mapLightOffset,n.mapLightWrap,n.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":c.aoMap=s(h,n.mapAORepeat,n.mapAOOffset,n.mapAOWrap,n.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":c.bumpMap=s(h,n.mapBumpRepeat,n.mapBumpOffset,n.mapBumpWrap,n.mapBumpAnisotropy);break;case"mapBumpScale":c.bumpScale=h;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":c.normalMap=s(h,n.mapNormalRepeat,n.mapNormalOffset,n.mapNormalWrap,n.mapNormalAnisotropy);break;case"mapNormalFactor":c.normalScale=h;break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":c.specularMap=s(h,n.mapSpecularRepeat,n.mapSpecularOffset,n.mapSpecularWrap,n.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":c.metalnessMap=s(h,n.mapMetalnessRepeat,n.mapMetalnessOffset,n.mapMetalnessWrap,n.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":c.roughnessMap=s(h,n.mapRoughnessRepeat,n.mapRoughnessOffset,n.mapRoughnessWrap,n.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":c.alphaMap=s(h,n.mapAlphaRepeat,n.mapAlphaOffset,n.mapAlphaWrap,n.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":c.side=Zs;break;case"doubleSided":c.side=Ks;break;case"transparency":console.warn("Loader.createMaterial: transparency has been renamed to opacity"),c.opacity=h;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":c[u]=h;break;case"vertexColors":h===!0&&(c.vertexColors=il),"face"===h&&(c.vertexColors=rl);break;default:console.error("Loader.createMaterial: Unsupported",u,h)}}return"MeshBasicMaterial"===c.type&&delete c.emissive,"MeshPhongMaterial"!==c.type&&delete c.specular,c.opacity<1&&(c.transparent=!0),i.setTextures(l),i.parse(c)}}()});var Ru={decodeText:function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);
|
|
for(var t="",r=0,i=e.length;r<i;r++)t+=String.fromCharCode(e[r]);return decodeURIComponent(escape(t))},extractUrlBase:function(e){var t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}};Object.assign(Be.prototype,{crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:Ru.extractUrlBase(e),o=new we(this.manager);o.setWithCredentials(this.withCredentials),o.load(e,function(r){var i=JSON.parse(r),o=i.metadata;if(void 0!==o){var s=o.type;if(void 0!==s&&"object"===s.toLowerCase())return void console.error("JSONLoader: "+e+" should be loaded with ObjectLoader instead.")}var l=n.parse(i,a);t(l.geometry,l.materials)},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},setTexturePath:function(e){return this.texturePath=e,this},parse:function(){function e(e,t){function r(e,t){return e&1<<t}var n,a,o,s,l,c,d,p,m,v,g,y,x,b,w,_,S,A,M,T,E,C,L,P,N,O,D,F=e.faces,R=e.vertices,I=e.normals,U=e.colors,k=e.scale,B=0;if(void 0!==e.uvs){for(n=0;n<e.uvs.length;n++)e.uvs[n].length&&B++;for(n=0;n<B;n++)t.faceVertexUvs[n]=[]}for(s=0,l=R.length;s<l;)A=new i,A.x=R[s++]*k,A.y=R[s++]*k,A.z=R[s++]*k,t.vertices.push(A);for(s=0,l=F.length;s<l;)if(v=F[s++],g=r(v,0),y=r(v,1),x=r(v,3),b=r(v,4),w=r(v,5),_=r(v,6),S=r(v,7),g){if(T=new h,T.a=F[s],T.b=F[s+1],T.c=F[s+3],E=new h,E.a=F[s+1],E.b=F[s+2],E.c=F[s+3],s+=4,y&&(m=F[s++],T.materialIndex=m,E.materialIndex=m),o=t.faces.length,x)for(n=0;n<B;n++)for(P=e.uvs[n],t.faceVertexUvs[n][o]=[],t.faceVertexUvs[n][o+1]=[],a=0;a<4;a++)p=F[s++],O=P[2*p],D=P[2*p+1],N=new f(O,D),2!==a&&t.faceVertexUvs[n][o].push(N),0!==a&&t.faceVertexUvs[n][o+1].push(N);if(b&&(d=3*F[s++],T.normal.set(I[d++],I[d++],I[d]),E.normal.copy(T.normal)),w)for(n=0;n<4;n++)d=3*F[s++],L=new i(I[d++],I[d++],I[d]),2!==n&&T.vertexNormals.push(L),0!==n&&E.vertexNormals.push(L);if(_&&(c=F[s++],C=U[c],T.color.setHex(C),E.color.setHex(C)),S)for(n=0;n<4;n++)c=F[s++],C=U[c],2!==n&&T.vertexColors.push(new u(C)),0!==n&&E.vertexColors.push(new u(C));t.faces.push(T),t.faces.push(E)}else{if(M=new h,M.a=F[s++],M.b=F[s++],M.c=F[s++],y&&(m=F[s++],M.materialIndex=m),o=t.faces.length,x)for(n=0;n<B;n++)for(P=e.uvs[n],t.faceVertexUvs[n][o]=[],a=0;a<3;a++)p=F[s++],O=P[2*p],D=P[2*p+1],N=new f(O,D),t.faceVertexUvs[n][o].push(N);if(b&&(d=3*F[s++],M.normal.set(I[d++],I[d++],I[d])),w)for(n=0;n<3;n++)d=3*F[s++],L=new i(I[d++],I[d++],I[d]),M.vertexNormals.push(L);if(_&&(c=F[s++],M.color.setHex(U[c])),S)for(n=0;n<3;n++)c=F[s++],M.vertexColors.push(new u(U[c]));t.faces.push(M)}}function t(e,t){var r=void 0!==e.influencesPerVertex?e.influencesPerVertex:2;if(e.skinWeights)for(var i=0,n=e.skinWeights.length;i<n;i+=r){var a=e.skinWeights[i],o=r>1?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;i<n;i+=r){var c=e.skinIndices[i],u=r>1?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;n<a;n++){t.morphTargets[n]={},t.morphTargets[n].name=e.morphTargets[n].name,t.morphTargets[n].vertices=[];for(var o=t.morphTargets[n].vertices,s=e.morphTargets[n].vertices,l=0,c=s.length;l<c;l+=3){var u=new i;u.x=s[l]*r,u.y=s[l+1]*r,u.z=s[l+2]*r,o.push(u)}}if(void 0!==e.morphColors&&e.morphColors.length>0){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;n<a;n++)h[n].color.fromArray(d,3*n)}}function n(e,t){var r=[],i=[];void 0!==e.animation&&i.push(e.animation),void 0!==e.animations&&(e.animations.length?i=i.concat(e.animations):i.push(e.animations));for(var n=0;n<i.length;n++){var a=re.parseAnimation(i[n],t.bones);a&&r.push(a)}if(t.morphTargets){var o=re.CreateClipsFromMorphTargetSequences(t.morphTargets,10);r=r.concat(o)}r.length>0&&(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;r<s;r++)n=l[3*r],a=l[3*r+1],o=l[3*r+2],X.vertices.push(new i(n,a,o));return 3*s*Float32Array.BYTES_PER_ELEMENT}function l(t){var r=E.nnormals;if(r){var i,n,a,o,s=new Int8Array(e,t,3*r);for(i=0;i<r;i++)n=s[3*i],a=s[3*i+1],o=s[3*i+2],Y.push(n/127,a/127,o/127)}return 3*r*Int8Array.BYTES_PER_ELEMENT}function c(t){var r=E.nuvs;if(r){var i,n,a,o=new Float32Array(e,t,2*r);for(i=0;i<r;i++)n=o[2*i],a=o[2*i+1],q.push(n,a)}return 2*r*Float32Array.BYTES_PER_ELEMENT}function u(t,r){var i,n,a,o,s,l,c,u,h,d,p=new Uint32Array(e,r,3*t);for(i=0;i<t;i++)n=p[3*i],a=p[3*i+1],o=p[3*i+2],s=q[2*n],u=q[2*n+1],l=q[2*a],h=q[2*a+1],c=q[2*o],d=q[2*o+1],X.faceVertexUvs[0].push([new f(s,u),new f(l,h),new f(c,d)])}function d(t,r){var i,n,a,o,s,l,c,u,h,d,p,m,v,g=new Uint32Array(e,r,4*t);for(i=0;i<t;i++)n=g[4*i],a=g[4*i+1],o=g[4*i+2],s=g[4*i+3],l=q[2*n],d=q[2*n+1],c=q[2*a],p=q[2*a+1],u=q[2*o],m=q[2*o+1],h=q[2*s],v=q[2*s+1],X.faceVertexUvs[0].push([new f(l,d),new f(c,p),new f(h,v)]),X.faceVertexUvs[0].push([new f(c,p),new f(u,m),new f(h,v)])}function p(t,r,i){var n,a,o,s,l,c=new Uint32Array(e,r,3*t),u=new Uint16Array(e,i,t);for(n=0;n<t;n++)a=c[3*n],o=c[3*n+1],s=c[3*n+2],l=u[n],X.faces.push(new h(a,o,s,null,null,l))}function v(t,r,i){var n,a,o,s,l,c,u=new Uint32Array(e,r,4*t),d=new Uint16Array(e,i,t);for(n=0;n<t;n++)a=u[4*n],o=u[4*n+1],s=u[4*n+2],l=u[4*n+3],c=d[n],X.faces.push(new h(a,o,l,null,null,c)),X.faces.push(new h(o,s,l,null,null,c))}function g(t,r,n,a){var o,s,l,c,u,d,p,f,m=new Uint32Array(e,r,3*t),v=new Uint32Array(e,n,3*t),g=new Uint16Array(e,a,t);for(o=0;o<t;o++){s=m[3*o],l=m[3*o+1],c=m[3*o+2],d=v[3*o],p=v[3*o+1],f=v[3*o+2],u=g[o];var y=Y[3*d],x=Y[3*d+1],b=Y[3*d+2],w=Y[3*p],_=Y[3*p+1],S=Y[3*p+2],A=Y[3*f],M=Y[3*f+1],T=Y[3*f+2];X.faces.push(new h(s,l,c,[new i(y,x,b),new i(w,_,S),new i(A,M,T)],null,u))}}function y(t,r,n,a){var o,s,l,c,u,d,p,f,m,v,g=new Uint32Array(e,r,4*t),y=new Uint32Array(e,n,4*t),x=new Uint16Array(e,a,t);for(o=0;o<t;o++){s=g[4*o],l=g[4*o+1],c=g[4*o+2],u=g[4*o+3],p=y[4*o],f=y[4*o+1],m=y[4*o+2],v=y[4*o+3],d=x[o];var b=Y[3*p],w=Y[3*p+1],_=Y[3*p+2],S=Y[3*f],A=Y[3*f+1],M=Y[3*f+2],T=Y[3*m],E=Y[3*m+1],C=Y[3*m+2],L=Y[3*v],P=Y[3*v+1],N=Y[3*v+2];X.faces.push(new h(s,l,u,[new i(b,w,_),new i(S,A,M),new i(L,P,N)],null,d)),X.faces.push(new h(l,c,u,[new i(S,A,M),new i(T,E,C),new i(L,P,N)],null,d))}}function x(e){var t=E.ntri_flat;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*3;p(t,e,r)}}function b(e){var t=E.ntri_flat_uv;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*3,i=r+t*Uint32Array.BYTES_PER_ELEMENT*3;p(t,e,i),u(t,r)}}function w(e){var t=E.ntri_smooth;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*3,i=r+t*Uint32Array.BYTES_PER_ELEMENT*3;g(t,e,r,i)}}function _(e){var t=E.ntri_smooth_uv;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*3,i=r+t*Uint32Array.BYTES_PER_ELEMENT*3,n=i+t*Uint32Array.BYTES_PER_ELEMENT*3;g(t,e,r,n),u(t,i)}}function S(e){var t=E.nquad_flat;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*4;v(t,e,r)}}function A(e){var t=E.nquad_flat_uv;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*4,i=r+t*Uint32Array.BYTES_PER_ELEMENT*4;v(t,e,i),d(t,r)}}function M(e){var t=E.nquad_smooth;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*4,i=r+t*Uint32Array.BYTES_PER_ELEMENT*4;y(t,e,r,i)}}function T(e){var t=E.nquad_smooth_uv;if(t){var r=e+t*Uint32Array.BYTES_PER_ELEMENT*4,i=r+t*Uint32Array.BYTES_PER_ELEMENT*4,n=i+t*Uint32Array.BYTES_PER_ELEMENT*4;y(t,e,r,n),d(t,i)}}var E,C,L,P,N,O,D,F,R,I,U,k,B,z,j,V,G,W,X=this,H=0,Y=[],q=[];m.call(this),E=r(e,H),H+=E.header_bytes,I=3*E.vertex_index_bytes+E.material_index_bytes,U=4*E.vertex_index_bytes+E.material_index_bytes,k=E.ntri_flat*I,B=E.ntri_smooth*(I+3*E.normal_index_bytes),z=E.ntri_flat_uv*(I+3*E.uv_index_bytes),j=E.ntri_smooth_uv*(I+3*E.normal_index_bytes+3*E.uv_index_bytes),V=E.nquad_flat*U,G=E.nquad_smooth*(U+4*E.normal_index_bytes),W=E.nquad_flat_uv*(U+4*E.uv_index_bytes),H+=s(H),H+=l(H),H+=t(3*E.nnormals),H+=c(H),C=H,L=C+k+t(2*E.ntri_flat),P=L+B+t(2*E.ntri_smooth),N=P+z+t(2*E.ntri_flat_uv),O=N+j+t(2*E.ntri_smooth_uv),D=O+V+t(2*E.nquad_flat),F=D+G+t(2*E.nquad_smooth),R=F+W+t(2*E.nquad_flat_uv),b(P),_(N),A(F),T(R),x(C),w(L),S(O),M(D),this.computeFaceNormals()};a.prototype=Object.create(m.prototype),a.prototype.constructor=a;var o=new a,s=ke.prototype.initMaterials(n,r,this.crossOrigin);t(o,s)}};var Uu=function(){function e(e,t){a.bodyGeometry=e,a.bodyMaterials=t,r()}function t(e,t){a.wheelGeometry=e,a.wheelMaterials=t,r()}function r(){if(a.bodyGeometry&&a.wheelGeometry){if(a.autoWheelGeometry){a.wheelGeometry.computeBoundingBox();var e=a.wheelGeometry.boundingBox;a.wheelOffset.addVectors(e.min,e.max),a.wheelOffset.multiplyScalar(.5),a.wheelDiameter=e.max.y-e.min.y,a.wheelGeometry.center()}var t=a.modelScale,r=new i,n=a.bodyMaterials,o=a.wheelMaterials;a.bodyMesh=new k(a.bodyGeometry,n),a.bodyMesh.scale.set(t,t,t),a.root.add(a.bodyMesh),r.multiplyVectors(a.wheelOffset,new i(t,t,t)),a.frontLeftWheelRoot.position.add(r),a.frontLeftWheelMesh=new k(a.wheelGeometry,o),a.frontLeftWheelMesh.scale.set(t,t,t),a.frontLeftWheelRoot.add(a.frontLeftWheelMesh),a.root.add(a.frontLeftWheelRoot),r.multiplyVectors(a.wheelOffset,new i((-t),t,t)),a.frontRightWheelRoot.position.add(r),a.frontRightWheelMesh=new k(a.wheelGeometry,o),a.frontRightWheelMesh.scale.set(t,t,t),a.frontRightWheelMesh.rotation.z=Math.PI,a.frontRightWheelRoot.add(a.frontRightWheelMesh),a.root.add(a.frontRightWheelRoot),r.multiplyVectors(a.wheelOffset,new i(t,t,(-t))),r.z-=a.backWheelOffset,a.backLeftWheelMesh=new k(a.wheelGeometry,o),a.backLeftWheelMesh.position.add(r),a.backLeftWheelMesh.scale.set(t,t,t),a.root.add(a.backLeftWheelMesh),r.multiplyVectors(a.wheelOffset,new i((-t),t,(-t))),r.z-=a.backWheelOffset,a.backRightWheelMesh=new k(a.wheelGeometry,o),a.backRightWheelMesh.position.add(r),a.backRightWheelMesh.scale.set(t,t,t),a.backRightWheelMesh.rotation.z=Math.PI,a.root.add(a.backRightWheelMesh),a.meshes=[a.bodyMesh,a.frontLeftWheelMesh,a.frontRightWheelMesh,a.backLeftWheelMesh,a.backRightWheelMesh],a.loaded=!0,a.callback&&a.callback(a)}}function n(e){return 1===e?1:-Math.pow(2,-10*e)+1}var a=this;this.modelScale=1,this.backWheelOffset=2,this.autoWheelGeometry=!0,this.wheelOffset=new i,this.wheelDiameter=1,this.MAX_SPEED=2200,this.MAX_REVERSE_SPEED=-1500,this.MAX_WHEEL_ROTATION=.6,this.FRONT_ACCELERATION=1250,this.BACK_ACCELERATION=1500,this.WHEEL_ANGULAR_ACCELERATION=1.5,this.FRONT_DECCELERATION=750,this.WHEEL_ANGULAR_DECCELERATION=1,this.STEERING_RADIUS_RATIO=.0023,this.MAX_TILT_SIDES=.05,this.MAX_TILT_FRONTBACK=.015,this.speed=0,this.acceleration=0,this.wheelOrientation=0,this.carOrientation=0,this.root=new c,this.frontLeftWheelRoot=new c,this.frontRightWheelRoot=new c,this.bodyMesh=null,this.frontLeftWheelMesh=null,this.frontRightWheelMesh=null,this.backLeftWheelMesh=null,this.backRightWheelMesh=null,this.bodyGeometry=null,this.wheelGeometry=null,this.bodyMaterials=null,this.wheelMaterials=null,this.loaded=!1,this.meshes=[],this.enableShadows=function(e){for(var t=this,r=0;r<this.meshes.length;r++)t.meshes[r].castShadow=e,t.meshes[r].receiveShadow=e},this.setVisible=function(e){for(var t=this,r=0;r<this.meshes.length;r++)t.meshes[r].visible=e,t.meshes[r].visible=e},this.loadPartsJSON=function(r,i){var n=new Be;n.load(r,function(t,r){e(t,r)}),n.load(i,function(e,r){t(e,r)})},this.loadPartsBinary=function(r,i){var n=new Iu;n.load(r,function(t,r){e(t,r)}),n.load(i,function(e,r){t(e,r)})},this.updateCarModel=function(e,t){if(t.moveForward&&(this.speed=Fs.clamp(this.speed+e*this.FRONT_ACCELERATION,this.MAX_REVERSE_SPEED,this.MAX_SPEED),this.acceleration=Fs.clamp(this.acceleration+e,-1,1)),t.moveBackward&&(this.speed=Fs.clamp(this.speed-e*this.BACK_ACCELERATION,this.MAX_REVERSE_SPEED,this.MAX_SPEED),this.acceleration=Fs.clamp(this.acceleration-e,-1,1)),t.moveLeft&&(this.wheelOrientation=Fs.clamp(this.wheelOrientation+e*this.WHEEL_ANGULAR_ACCELERATION,-this.MAX_WHEEL_ROTATION,this.MAX_WHEEL_ROTATION)),t.moveRight&&(this.wheelOrientation=Fs.clamp(this.wheelOrientation-e*this.WHEEL_ANGULAR_ACCELERATION,-this.MAX_WHEEL_ROTATION,this.MAX_WHEEL_ROTATION)),!t.moveForward&&!t.moveBackward)if(this.speed>0){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;a<o;a++)Ge(e[a],i,n,t);return n.sort(Ve),n}});var Bu=function(e,t,r){function n(){r.addEventListener("mousemove",s,!1),r.addEventListener("mousedown",l,!1),r.addEventListener("mouseup",c,!1),r.addEventListener("mouseleave",c,!1),r.addEventListener("touchmove",u,!1),r.addEventListener("touchstart",h,!1),r.addEventListener("touchend",d,!1)}function a(){r.removeEventListener("mousemove",s,!1),r.removeEventListener("mousedown",l,!1),r.removeEventListener("mouseup",c,!1),r.removeEventListener("mouseleave",c,!1),r.removeEventListener("touchmove",u,!1),r.removeEventListener("touchstart",h,!1),r.removeEventListener("touchend",d,!1)}function o(){a()}function s(i){i.preventDefault();var n=r.getBoundingClientRect();if(g.x=(i.clientX-n.left)/n.width*2-1,g.y=2*-((i.clientY-n.top)/n.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});v.setFromCamera(g,t);var a=v.intersectObjects(e);if(a.length>0){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()))<e}}(),he=function(){var e=Math.cos(Math.PI/2-Math.PI/6);return function(t){return Math.abs(Math.cos(t.angle()))<e}}();R.domElement.addEventListener("contextmenu",F,!1),R.domElement.addEventListener("mousedown",T,!1),R.domElement.addEventListener("wheel",L,!1),R.domElement.addEventListener("touchstart",N,!1),R.domElement.addEventListener("touchend",D,!1),R.domElement.addEventListener("touchmove",O,!1),Ds.addEventListener("keydown",P,!1),this.update()};Gu.prototype=Object.create(a.prototype),Gu.prototype.constructor=Gu,Object.defineProperties(Gu.prototype,{center:{get:function(){return console.warn("MapControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("MapControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("MapControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("MapControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("MapControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("MapControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("MapControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("MapControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("MapControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("MapControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("MapControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn("MapControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(e){console.warn("MapControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=e}}});var Wu=function(e,t){function r(){return 2*Math.PI/60/60*O.autoRotateSpeed}function a(){return Math.pow(.95,O.zoomSpeed)}function o(e){z.theta-=e}function s(e){z.phi-=e}function l(e){O.object.isPerspectiveCamera?j/=e:O.object.isOrthographicCamera?(O.object.zoom=Math.max(O.minZoom,Math.min(O.maxZoom,O.object.zoom*e)),O.object.updateProjectionMatrix(),G=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),O.enableZoom=!1)}function c(e){O.object.isPerspectiveCamera?j*=e:O.object.isOrthographicCamera?(O.object.zoom=Math.max(O.minZoom,Math.min(O.maxZoom,O.object.zoom/e)),O.object.updateProjectionMatrix(),G=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),O.enableZoom=!1)}function u(e){W.set(e.clientX,e.clientY)}function h(e){J.set(e.clientX,e.clientY)}function d(e){Y.set(e.clientX,e.clientY)}function p(e){X.set(e.clientX,e.clientY),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 m(e){Z.set(e.clientX,e.clientY),K.subVectors(Z,J),K.y>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?a<Math.SQRT1_2?r.z=Math.sqrt(1-a*a):r.z=.5/a:a>1?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()<m.minDistance*m.minDistance&&(m.object.position.addVectors(m.target,w.setLength(m.minDistance)),T.copy(E)))},this.update=function(){w.subVectors(m.object.position,m.target),m.noRotate||m.rotateCamera(),m.noZoom||m.zoomCamera(),m.noPan||m.panCamera(),m.object.position.addVectors(m.target,w),m.checkDistances(),m.object.lookAt(m.target),y.distanceToSquared(m.object.position)>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;n<i.length;n++){var a=i[n];a.visible=!0,a.rotation.set(0,0,0),a.position.copy(e.worldPosition);var o=e.worldPosition.distanceTo(e.cameraPosition);if(a.scale.set(1,1,1).multiplyScalar(o*e.size/7),"helper"!==a.tag){if(a.quaternion.copy(r),"translate"===e.mode||"scale"===e.mode){var s=.99,l=.2,h=-.4;"X"!==a.name&&"XYZX"!==a.name||Math.abs(J.copy(re).applyQuaternion(r).dot(e.eye))>s&&(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))<l&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"YZ"===a.name&&Math.abs(J.copy(re).applyQuaternion(r).dot(e.eye))<l&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),"XZ"===a.name&&Math.abs(J.copy(ie).applyQuaternion(r).dot(e.eye))<l&&(a.scale.set(1e-10,1e-10,1e-10),a.visible=!1),a.name.search("X")!==-1&&(J.copy(re).applyQuaternion(r).dot(e.eye)<h?"fwd"===a.tag?a.visible=!1:a.scale.x*=-1:"bwd"===a.tag&&(a.visible=!1)),a.name.search("Y")!==-1&&(J.copy(ie).applyQuaternion(r).dot(e.eye)<h?"fwd"===a.tag?a.visible=!1:a.scale.y*=-1:"bwd"===a.tag&&(a.visible=!1)),a.name.search("Z")!==-1&&(J.copy(ne).applyQuaternion(r).dot(e.eye)<h?"fwd"===a.tag?a.visible=!1:a.scale.z*=-1:"bwd"===a.tag&&(a.visible=!1))}else"rotate"===e.mode&&(ee.copy(r),J.copy(e.eye).applyQuaternion($.copy(r).inverse()),a.name.search("E")!==-1&&a.quaternion.setFromRotationMatrix(K.lookAt(e.eye,Z,ie)),"X"===a.name&&($.setFromAxisAngle(re,Math.atan2(-J.y,J.z)),$.multiplyQuaternions(ee,$),a.quaternion.copy($)),"Y"===a.name&&($.setFromAxisAngle(ie,Math.atan2(J.x,J.z)),$.multiplyQuaternions(ee,$),a.quaternion.copy($)),"Z"===a.name&&($.setFromAxisAngle(ne,Math.atan2(J.y,J.x)),$.multiplyQuaternions(ee,$),a.quaternion.copy($)));a.visible=a.visible&&(a.name.indexOf("X")===-1||e.showX),a.visible=a.visible&&(a.name.indexOf("Y")===-1||e.showY),a.visible=a.visible&&(a.name.indexOf("Z")===-1||e.showZ),a.visible=a.visible&&(a.name.indexOf("E")===-1||e.showX&&e.showY&&e.showZ),a.material._opacity=a.material._opacity||a.material.opacity,a.material._color=a.material._color||a.material.color.clone(),a.material.color.copy(a.material._color),a.material.opacity=a.material._opacity,e.enabled?e.axis&&(a.name===e.axis?(a.material.opacity=1,a.material.color.lerp(new u(1,1,1),.5)):e.axis.split("").some(function(e){return a.name===e})?(a.material.opacity=1,a.material.color.lerp(new u(1,1,1),.5)):(a.material.opacity*=.25,a.material.color.lerp(new u(1,1,1),.5))):(a.material.opacity*=.5,a.material.color.lerp(new u(1,1,1),.5))}else a.visible=!1,"AXIS"===a.name?(a.position.copy(e.worldPositionStart),a.visible=!!e.axis,"X"===e.axis&&($.setFromEuler(Q.set(0,0,0)),a.quaternion.copy(r).multiply($),Math.abs(J.copy(re).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;r<i;r++)t.vertices.push(new tt(e[r]));return this.compute(),this},setFromObject:function(e){var t=[];return e.updateMatrixWorld(!0),e.traverse(function(e){var r,n,a,o=e.geometry;if(void 0!==o)if(o.isGeometry){var s=o.vertices;for(r=0,n=s.length;r<n;r++)a=s[r].clone(),a.applyMatrix4(e.matrixWorld),t.push(a)}else if(o.isBufferGeometry){var l=o.attributes.position;if(void 0!==l)for(r=0,n=l.count;r<n;r++)a=new i,a.fromBufferAttribute(l,r).applyMatrix4(e.matrixWorld),t.push(a)}}),this.setFromPoints(t)},makeEmpty:function(){return this.faces=[],this.vertices=[],this},addVertexToFace:function(e,t){return e.face=t,null===t.outside?this.assigned.append(e):this.assigned.insertBefore(t.outside,e),t.outside=e,this},removeVertexFromFace:function(e,t){return e===t.outside&&(null!==e.next&&e.next.face===t?t.outside=e.next:t.outside=null),this.assigned.remove(e),this},removeAllVerticesFromFace:function(e){if(null!==e.outside){for(var t=e.outside,r=e.outside;null!==r.next&&r.next.face===e;)r=r.next;return this.assigned.removeSubList(t,r),t.prev=r.next=null,e.outside=null,t}},deleteFaceVertices:function(e,t){var r=this,i=this.removeAllVerticesFromFace(e);if(void 0!==i)if(void 0===t)this.unassigned.appendChain(i);else{var n=i;do{var a=n.next,o=t.distanceToPoint(n.point);o>r.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;o<e.length;o++){var s=e[o];if(s.mark===Zu){var l=s.distanceToPoint(r.point);if(l>n&&(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;e<t;e++){var c=n.vertices[e],u=c.point;for(r=0;r<3;r++)u.getComponent(r)<a.getComponent(r)&&(a.setComponent(r,u.getComponent(r)),s[r]=c);for(r=0;r<3;r++)u.getComponent(r)>o.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;u<h;u++)a=f[u],a!==o&&a!==s&&(e.closestPointToPoint(a.point,!0,r),p=r.distanceToSquared(a.point),p>y&&(y=p,l=a));for(y=-1,t.setFromCoplanarPoints(o.point,s.point,l.point),u=0,h=this.vertices.length;u<h;u++)a=f[u],a!==o&&a!==s&&a!==l&&(p=Math.abs(t.distanceToPoint(a.point)),p>y&&(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;u<h;u++)if(a=f[u],a!==o&&a!==s&&a!==l&&a!==c){y=n.tolerance;var w=null;for(d=0;d<4;d++)p=n.faces[d].distanceToPoint(a.point),p>y&&(y=p,w=n.faces[d]);null!==w&&n.addVertexToFace(a,w)}return this}}(),reindexFaces:function(){for(var e=this,t=[],r=0;r<this.faces.length;r++){var i=e.faces[r];i.mark===Zu&&t.push(i)}return this.faces=t,this},nextVertexToAdd:function(){if(this.assigned.isEmpty()===!1){var e,t=0,r=this.assigned.first().face,i=r.outside;do{var n=r.distanceToPoint(i.point);n>t&&(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;a<t.length;a++){var o=t[a],s=r.addAdjoiningFace(e,o);null===i?i=s:s.next.setTwin(n),r.newFaces.push(s.face),n=s}return i.next.setTwin(n),this},addVertexToHull:function(e){var t=[];return this.unassigned.clear(),this.removeVertexFromFace(e,e.face),this.computeHorizon(e.point,null,e.face,t),this.addNewFaces(e,t),this.resolveUnassignedPoints(this.newFaces),this},cleanup:function(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this},compute:function(){var e,t=this;for(this.computeInitialHull();void 0!==(e=this.nextVertexToAdd());)t.addVertexToHull(e);return this.reindexFaces(),this.cleanup(),this}}),Object.assign($e,{create:function(e,t,r){var i=new $e,n=new et(e,i),a=new et(t,i),o=new et(r,i);return n.next=o.prev=a,a.next=n.prev=o,o.next=a.prev=n,i.edge=n,i.compute()}}),Object.assign($e.prototype,{getEdge:function(e){for(var t=this.edge;e>0;)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;a<n;a++)r.segments[a]=!1};$u.prototype={constructor:$u,prepareBreakableObject:function(e,t,r,i,n){e.geometry.isBufferGeometry||console.error("ConvexObjectBreaker.prepareBreakableObject(): Parameter object must have a BufferGeometry.");var a=e.userData;a.mass=t,a.velocity=r.clone(),a.angularVelocity=i.clone(),a.breakable=n},subdivideByImpact:function(e,t,r,i,n){function a(n,h,d,p){if(Math.random()<.05*p||p>c)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;v<m;v++)a.segments[v]=!1;for(var g=this.tempVector3_P0,y=this.tempVector3_P1,x=this.tempVector3_N0,b=this.tempVector3_N1,v=0;v<u-1;v++){var w=n(v,0),_=n(v,1),S=n(v,2);x.set(l[w],l[w]+1,l[w]+2);for(var A=v+1;A<u;A++){var M=n(A,0),T=n(A,1),E=n(A,2);b.set(l[M],l[M]+1,l[M]+2);var C=1-x.dot(b)<f;C&&(w===M||w===T||w===E?_===M||_===T||_===E?(a.segments[w*c+_]=!0,a.segments[_*c+w]=!0):(a.segments[S*c+w]=!0,a.segments[w*c+S]=!0):_!==M&&_!==T&&_!==E||(a.segments[S*c+_]=!0,a.segments[_*c+S]=!0))}}var L=this.tempPlane_Cut;e.updateMatrix(),$u.transformPlaneToLocalSpace(t,e.matrix,L);for(var v=0;v<u;v++)for(var P=n(v,0),N=n(v,1),O=n(v,2),D=0;D<3;D++){var F=0===D?P:1===D?N:O,R=0===D?N:1===D?O:P,I=a.segments[F*c+R];if(!I){a.segments[F*c+R]=!0,a.segments[R*c+F]=!0,g.set(s[3*F],s[3*F+1],s[3*F+2]),y.set(s[3*R],s[3*R+1],s[3*R+2]);var U=0,B=L.distanceToPoint(g);B>f?(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;v<W;v++)a.tempCM1.add(d[v]);this.tempCM1.divideScalar(W);for(var v=0;v<W;v++){var X=d[v];X.sub(a.tempCM1),G=Math.max(G,X.x,X.y,X.z)}this.tempCM1.add(e.position)}this.tempCM2.set(0,0,0);var H=0,Y=p.length;if(Y>0){for(var v=0;v<Y;v++)a.tempCM2.add(p[v]);this.tempCM2.divideScalar(Y);for(var v=0;v<Y;v++){var X=p[v];X.sub(a.tempCM2),H=Math.max(H,X.x,X.y,X.z)}this.tempCM2.add(e.position)}var q=null,Q=null,J=0;return W>4&&(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]||t>=r[o+1];)t<r[o]?a=o:n=o,o=Math.floor((n+a)/2);return o},calcBasisFunctions:function(e,t,r,i){var n=[],a=[],o=[];n[0]=1;for(var s=1;s<=r;++s){a[s]=t-i[e+1-s],o[s]=i[e+s]-t;for(var l=0,c=0;c<s;++c){var u=o[c+1],h=a[s-c],d=n[c]/(u+h);n[c]=l+u*d,l=h*d}n[s]=l}return n},calcBSplinePoint:function(e,t,r,i){for(var n=this.findSpan(e,i,t),a=this.calcBasisFunctions(n,i,e,t),o=new v(0,0,0,0),s=0;s<=e;++s){var l=r[n-e+s],c=a[s],u=l.w*c;o.x+=l.x*u,o.y+=l.y*u,o.z+=l.z*u,o.w+=l.w*c}return o},calcBasisFunctionDerivatives:function(e,t,r,i,n){for(var a=[],o=0;o<=r;++o)a[o]=0;for(var s=[],o=0;o<=i;++o)s[o]=a.slice(0);for(var l=[],o=0;o<=r;++o)l[o]=a.slice(0);l[0][0]=1;for(var c=a.slice(0),u=a.slice(0),h=1;h<=r;++h){c[h]=t-n[e+1-h],u[h]=n[e+h]-t;for(var d=0,p=0;p<h;++p){var f=u[p+1],m=c[h-p];l[h][p]=f+m;var v=l[p][h-1]/l[h][p];l[p][h]=d+f*v,d=m*v}l[h][h]=d}for(var h=0;h<=r;++h)s[0][h]=l[h][r];for(var p=0;p<=r;++p){for(var g=0,y=1,x=[],o=0;o<=r;++o)x[o]=a.slice(0);x[0][0]=1;for(var b=1;b<=i;++b){var w=0,_=p-b,S=r-b;p>=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=n<e?n:e,o=[],s=this.findSpan(e,i,t),l=this.calcBasisFunctionDerivatives(s,i,e,a,t),c=[],u=0;u<r.length;++u){var h=r[u].clone(),d=h.w;h.x*=d,h.y*=d,h.z*=d,c[u]=h}for(var p=0;p<=a;++p){for(var h=c[s-e].clone().multiplyScalar(l[p][0]),f=1;f<=e;++f)h.add(c[s-e+f].clone().multiplyScalar(l[p][f]));o[p]=h}for(var p=a+1;p<=n+1;++p)o[p]=new v(0,0,0);return o},calcKoverI:function(e,t){for(var r=1,i=2;i<=e;++i)r*=i;for(var n=1,i=2;i<=t;++i)n*=i;for(var i=2;i<=e-t;++i)n*=i;return r/n},calcRationalCurveDerivatives:function(e){for(var t=this,r=e.length,n=[],a=[],o=0;o<r;++o){var s=e[o];n[o]=new i(s.x,s.y,s.z),a[o]=s.w}for(var l=[],c=0;c<r;++c){for(var u=n[c].clone(),o=1;o<=c;++o)u.sub(l[c-o].clone().multiplyScalar(t.calcKoverI(c,o)*a[o]));l[c]=u.divideScalar(a[0])}return l},calcNURBSDerivatives:function(e,t,r,i,n){var a=this.calcBSplineDerivatives(e,t,r,i,n);return this.calcRationalCurveDerivatives(a)},calcSurfacePoint:function(e,t,r,i,n,a,o,s){for(var l=this.findSpan(e,a,r),c=this.findSpan(t,o,i),u=this.calcBasisFunctions(l,a,e,r),h=this.calcBasisFunctions(c,o,t,i),d=[],p=0;p<=t;++p){d[p]=new v(0,0,0,0);for(var f=0;f<=e;++f){var m=n[l-e+f][c-t+p].clone(),g=m.w;m.x*=g,m.y*=g,m.z*=g,d[p].add(m.multiplyScalar(u[f]))}}for(var y=new v(0,0,0,0),p=0;p<=t;++p)y.add(d[p].multiplyScalar(h[p]));y.divideScalar(y.w),s.set(y.x,y.y,y.z)}},rh=function(e,t,r,i,n){var a=this;at.call(this),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=n||this.knots.length-1;for(var o=0;o<r.length;++o){var s=r[o];a.controlPoints[o]=new v(s.x,s.y,s.z,s.w)}};rh.prototype=Object.create(at.prototype),rh.prototype.constructor=rh,rh.prototype.getPoint=function(e){var t=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=th.calcBSplinePoint(this.degree,this.knots,this.controlPoints,t);return 1!=r.w&&r.divideScalar(r.w),new i(r.x,r.y,r.z)},rh.prototype.getTangent=function(e){var t=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=th.calcNURBSDerivatives(this.degree,this.knots,this.controlPoints,t,1),i=r[1].clone();return i.normalize(),i};var ih=function(e,t,r,i,n){var a=this;this.degree1=e,this.degree2=t,this.knots1=r,this.knots2=i,this.controlPoints=[];for(var o=r.length-e-1,s=i.length-t-1,l=0;l<o;++l){a.controlPoints[l]=[];for(var c=0;c<s;++c){var u=n[l][c];a.controlPoints[l][c]=new v(u.x,u.y,u.z,u.w)}}};ih.prototype={constructor:ih,getPoint:function(e,t,r){var i=this.knots1[0]+e*(this.knots1[this.knots1.length-1]-this.knots1[0]),n=this.knots2[0]+t*(this.knots2[this.knots2.length-1]-this.knots2[0]);th.calcSurfacePoint(this.degree1,this.degree2,this.knots1,this.knots2,this.controlPoints,i,n,r)}};var nh={canvas:!!Ds.CanvasRenderingContext2D,webgl:function(){try{var e=document.createElement("canvas");return!(!Ds.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(t){return!1}}(),webgl2:function(){try{var e=document.createElement("canvas");return!(!Ds.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(t){return!1}}(),workers:!!Ds.Worker,fileapi:Ds.File&&Ds.FileReader&&Ds.FileList&&Ds.Blob,getWebGLErrorMessage:function(){var e=document.createElement("div");return e.id="webgl-error-message",e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.fontWeight="normal",e.style.textAlign="center",e.style.background="#fff",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",this.webgl||(e.innerHTML=Ds.WebGLRenderingContext?['Your graphics card does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br />','Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'].join("\n"):['Your browser does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">WebGL</a>.<br/>','Find out how to get it <a href="http://get.webgl.org/" style="color:#000">here</a>.'].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<g;n+=2){for(var a=0;a<v;a++){var o,s,l=4*(n*v+a),p=r[l],f=r[l+1],m=r[l+2],y=r[l+3];s=(.3*p+.59*f+.11*m)/255,0==y&&(s=1),o=Math.floor((1-s)*(M.length-1)),d&&(o=M.length-o-1);var x=M[o];void 0!==x&&" "!=x||(x=" "),i+=c?"<span style='color:rgb("+p+","+f+","+m+");"+(h?"background-color:rgb("+p+","+f+","+m+");":"")+(u?"opacity:"+y/255+";":"")+"'>"+x+"</span>":x}i+="<br/>"}t.innerHTML="<tr><td>"+i+"</td></tr>"}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 <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}\n",Wd="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",Hd="#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}\n",qd="uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include <common>\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 <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",Jd="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",Zd="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",Kd="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",$d="#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\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 <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",tp="#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",rp="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",ip="#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",ap="#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\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 <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n#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 <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",cp="uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}\n",up="uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}\n",hp="#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",dp="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",pp="uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( 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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\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+<begin_vertex>/.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;t<r;t++)e.material[t]=a(e.material[t]);else e.material=a(e.material);b[e.uuid]=e.onBeforeRender,e.onBeforeRender=l}}function s(e){if(void 0!==e.material){if(Array.isArray(e.material))for(var t=0,r=e.material.length;t<r;t++)e.material[t]=x[e.material[t].uuid];else e.material=x[e.material.uuid];e.onBeforeRender=b[e.uuid]}}function l(e,t,r,i,n,a){var o=x[n.uuid];void 0!==o&&c(n,o)}function c(e,t){var r=t.userData.outlineParameters;e.uniforms.outlineAlpha.value=t.opacity,void 0!==r&&(void 0!==r.thickness&&(e.uniforms.outlineThickness.value=r.thickness),void 0!==r.color&&e.uniforms.outlineColor.value.fromArray(r.color),void 0!==r.alpha&&(e.uniforms.outlineAlpha.value=r.alpha))}function h(e,t){if("invisible"!==e.name){var r=t.userData.outlineParameters;e.skinning=t.skinning,e.morphTargets=t.morphTargets,e.morphNormals=t.morphNormals,e.fog=t.fog,void 0!==r?(t.visible===!1?e.visible=!1:e.visible=void 0===r.visible||r.visible,e.transparent=void 0!==r.alpha&&r.alpha<1||t.transparent,void 0!==r.keepAlive&&(g[t.uuid].keepAlive=r.keepAlive)):(e.transparent=t.transparent,e.visible=t.visible),t.wireframe!==!0&&t.depthTest!==!1||(e.visible=!1)}}function d(){var e;e=Object.keys(x);for(var t=0,r=e.length;t<r;t++)x[e[t]]=void 0;e=Object.keys(b);for(var t=0,r=e.length;t<r;t++)b[e[t]]=void 0;e=Object.keys(g);for(var t=0,r=e.length;t<r;t++){var i=e[t];g[i].used===!1?(g[i].count++,g[i].keepAlive===!1&&g[i].count>y&&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 <fog_pars_vertex>","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 <fog_vertex>"].join("\n"),M=["#include <common>","#include <fog_pars_fragment>","uniform vec3 outlineColor;","uniform float outlineAlpha;","void main() {","\tgl_FragColor = vec4( outlineColor, outlineAlpha );","\t#include <fog_fragment>","}"].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?(a=t/3,o=t/3):(a=i/3,o=i/3),e.setSize(t,i)},this.render=function(i,n){i.updateMatrixWorld(),null===n.parent&&n.updateMatrixWorld(),n.matrixWorld.decompose(h,d,p),s.position.copy(h),s.quaternion.copy(d),s.translateZ(t.cameraDistance),s.lookAt(i.position),l.position.copy(h),l.quaternion.copy(d),l.translateZ(-t.cameraDistance),l.lookAt(i.position),l.rotation.z+=180*(Math.PI/180),c.position.copy(h),c.quaternion.copy(d),c.translateX(-t.cameraDistance),c.lookAt(i.position),c.rotation.x+=90*(Math.PI/180),u.position.copy(h),u.quaternion.copy(d),u.translateX(t.cameraDistance),u.lookAt(i.position),u.rotation.x+=90*(Math.PI/180),e.clear(),e.setScissorTest(!0),e.setScissor(r-a/2,2*o,a,o),e.setViewport(r-a/2,2*o,a,o),t.reflectFromAbove?e.render(i,l):e.render(i,s),e.setScissor(r-a/2,0,a,o),e.setViewport(r-a/2,0,a,o),t.reflectFromAbove?e.render(i,s):e.render(i,l),e.setScissor(r-a/2-a,o,a,o),e.setViewport(r-a/2-a,o,a,o),t.reflectFromAbove?e.render(i,u):e.render(i,c),e.setScissor(r+a/2,o,a,o),e.setViewport(r+a/2,o,a,o),t.reflectFromAbove?e.render(i,c):e.render(i,u),e.setScissorTest(!1)}},bp=function(e){var t=new bt;t.aspect=.5,this.setEyeSeparation=function(e){t.eyeSep=e},this.setSize=function(t,r){e.setSize(t,r)},this.render=function(r,i){r.updateMatrixWorld(),null===i.parent&&i.updateMatrixWorld(),t.update(i);var n=e.getSize();e.autoClear&&e.clear(),e.setScissorTest(!0),e.setScissor(0,0,n.width/2,n.height),e.setViewport(0,0,n.width/2,n.height),e.render(r,t.cameraL),e.setScissor(n.width/2,0,n.width/2,n.height),e.setViewport(n.width/2,0,n.width/2,n.height),e.render(r,t.cameraR),e.setScissorTest(!1)}},wp=function(){};wp.prototype={constructor:wp,parse:function(e,t,i){function n(e){var t=/^<\//,r=/(\?>$)|(\/>$)/,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;i++)r[i]=t.charCodeAt(i);return r}function o(e,t){y=y||document.createElement("canvas"),x=x||y.getContext("2d"),y.width=e.naturalWidth,y.height=e.naturalHeight,x.drawImage(e,0,0);var r=y.toDataURL("image/"+t,1).replace(/^data:image\/(png|jpg);base64,/,"");return a(r)}function s(e){if(e.isInterleavedBufferAttribute){for(var t=new e.array.constructor(e.count*e.itemSize),r=e.itemSize,i=0,n=e.count;i<n;i++)for(var a=0;a<r;a++)t[i*r+a]=e[w[a]](i);return t}return e.array}function l(e,t,r){return Array.isArray(e)?e.slice(t,t+r):new e.constructor(e.buffer,t*e.BYTES_PER_ELEMENT,r)}function c(e,t,r,i){var n=s(e),a='<source id="'+t+'"><float_array id="'+t+'-array" count="'+n.length+'">'+n.join(" ")+'</float_array><technique_common><accessor source="#'+t+'-array" count="'+Math.floor(n.length/e.itemSize)+'" stride="'+e.itemSize+'">'+r.map(function(e){return'<param name="'+e+'" type="'+i+'" />'}).join("")+"</accessor></technique_common></source>";return a}function h(e){return e.updateMatrix(),b=b||new r,b.copy(e.matrix),b.transpose(),"<matrix>"+b.toArray().join(" ")+"</matrix>"}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='<geometry id="'+i+'" name="'+e.name+'"><mesh>',u=i+"-position",h=i+"-vertices";o+=c(r.attributes.position,u,["X","Y","Z"],"float"),o+='<vertices id="'+h+'"><input semantic="POSITION" source="#'+u+'" /></vertices>';var d='<input semantic="VERTEX" source="#'+h+'" offset="0" />';if("normal"in r.attributes){var p=i+"-normal";o+=c(r.attributes.normal,p,["X","Y","Z"],"float"),d+='<input semantic="NORMAL" source="#'+p+'" offset="0" />'}if("uv"in r.attributes){var f=i+"-texcoord";o+=c(r.attributes.uv,f,["S","T"],"float"),d+='<input semantic="TEXCOORD" source="#'+f+'" offset="0" set="0" />'}if("color"in r.attributes){var v=i+"-color";o+=c(r.attributes.color,v,["X","Y","Z"],"uint8"),d+='<input semantic="COLOR" source="#'+v+'" offset="0" />'}var g=null;if(r.index)g=s(r.index);else{g=new Array(n);for(var y=0,x=g.length;y<x;y++)g[y]=y}for(var y=0,x=a.length;y<x;y++){var b=a[y],w=l(g,b.start,b.count),S=w.length/3;o+='<triangles material="MESH_MATERIAL_'+b.materialIndex+'" count="'+S+'">',o+=d,o+="<p>"+w.join(" ")+"</p>",o+="</triangles>"}o+="</mesh></geometry>",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='<image id="'+t+'" name="'+n+'">';a+="1.5.0"===g?"<init_from><ref>"+i.textureDirectory+n+"."+r+"</ref></init_from>":"<init_from>"+i.textureDirectory+n+"."+r+"</init_from>",a+="</image>",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+="<transparent>"+(e.map?'<texture texture="diffuse-sampler"></texture>':"<float>1</float>")+"</transparent>",e.opacity<1&&(l+="<transparency><float>"+e.opacity+"</float></transparency>"));var c='<technique sid="common"><'+r+"><emission>"+(e.emissiveMap?'<texture texture="emissive-sampler" texcoord="TEXCOORD" />':'<color sid="emission">'+i.r+" "+i.g+" "+i.b+" 1</color>")+"</emission><diffuse>"+(e.map?'<texture texture="diffuse-sampler" texcoord="TEXCOORD" />':'<color sid="diffuse">'+n.r+" "+n.g+" "+n.b+" 1</color>")+'</diffuse><specular><color sid="specular">'+a.r+" "+a.g+" "+a.b+" 1</color></specular><shininess>"+(e.specularMap?'<texture texture="specular-sampler" texcoord="TEXCOORD" />':'<float sid="shininess">'+o+"</float>")+"</shininess><reflective><color>"+n.r+" "+n.g+" "+n.b+" 1</color></reflective><reflectivity><float>"+s+"</float></reflectivity>"+l+"</"+r+"></technique>",h='<effect id="'+t+'-effect"><profile_COMMON>'+(e.map?'<newparam sid="diffuse-surface"><surface type="2D"><init_from>'+p(e.map)+'</init_from></surface></newparam><newparam sid="diffuse-sampler"><sampler2D><source>diffuse-surface</source></sampler2D></newparam>':"")+(e.specularMap?'<newparam sid="specular-surface"><surface type="2D"><init_from>'+p(e.specularMap)+'</init_from></surface></newparam><newparam sid="specular-sampler"><sampler2D><source>specular-surface</source></sampler2D></newparam>':"")+(e.emissiveMap?'<newparam sid="emissive-surface"><surface type="2D"><init_from>'+p(e.emissiveMap)+'</init_from></surface></newparam><newparam sid="emissive-sampler"><sampler2D><source>emissive-surface</source></sampler2D></newparam>':"")+c+(e.side===Ks?'<extra><technique><double_sided sid="double_sided" type="int">1</double_sided></technique></extra>':"")+"</profile_COMMON></effect>";L.push('<material id="'+t+'" name="'+e.name+'"><instance_effect url="#'+t+'-effect" /></material>'),C.push(h),S.set(e,t)}return t}function v(e){var t='<node name="'+e.name+'">';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+='<instance_geometry url="#'+i+'">'+(null!=a?"<bind_material><technique_common>"+a.map(function(e,t){return'<instance_material symbol="MESH_MATERIAL_'+t+'" target="#'+e+'" ><bind_vertex_input semantic="TEXCOORD" input_semantic="TEXCOORD" input_set="0" /></instance_material>'}).join("")+"</technique_common></bind_material>":"")+"</instance_geometry>"}return e.children.forEach(function(e){return t+=v(e)}),t+="</node>"}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='<?xml version="1.0" encoding="UTF-8" standalone="no" ?><COLLADA xmlns="'+O+'" version="'+g+'"><asset>'+("<contributor><authoring_tool>js Collada Exporter</authoring_tool>"+(null!==i.author?"<author>"+i.author+"</author>":"")+"</contributor><created>"+(new Date).toISOString()+"</created><modified>"+(new Date).toISOString()+"</modified><up_axis>Y_UP</up_axis>")+"</asset>";D+="<library_images>"+T.join("")+"</library_images>",D+="<library_effects>"+C.join("")+"</library_effects>",D+="<library_materials>"+L.join("")+"</library_materials>",D+="<library_geometries>"+E.join("")+"</library_geometries>",D+='<library_visual_scenes><visual_scene id="Scene" name="scene">'+N+"</visual_scene></library_visual_scenes>",D+='<scene><instance_visual_scene url="#Scene"/></scene>',D+="</COLLADA>";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;r<i;r++){var n=e.charCodeAt(r);t[r]=n>255?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;n<t+r;n++)for(var a=0;a<e.itemSize;a++){var o=e.array[n*e.itemSize+a];i.min[a]=Math.min(i.min[a],o),i.max[a]=Math.max(i.max[a],o)}return i}function s(e){return Fs.isPowerOfTwo(e.width)&&Fs.isPowerOfTwo(e.height)}function l(e){if(z.attributes.has(e))return!1;for(var t=new i,r=0,n=e.count;r<n;r++)if(Math.abs(t.fromArray(e.array,3*r).length()-1)>5e-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;n<a;n++)r.fromArray(t.array,3*n),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),r.toArray(t.array,3*n);return z.attributes.set(e,t),t}function u(e){return 4*Math.ceil(e/4)}function h(e,t){t=t||0;var r=u(e.byteLength);if(r!==e.byteLength){var i=new Uint8Array(r);if(i.set(new Uint8Array(e)),0!==t)for(var n=e.byteLength;n<r;n++)i[n]=t;return i.buffer}return e}function d(e){try{return JSON.parse(JSON.stringify(e.userData))}catch(t){return console.warn("GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message),{}}}function p(e){return D.buffers||(D.buffers=[{byteLength:0}]),R.push(e),0}function f(e,t,r,i,n){D.bufferViews||(D.bufferViews=[]);var a;a=t===_p.UNSIGNED_BYTE?1:t===_p.UNSIGNED_SHORT?2:4;for(var o=u(i*e.itemSize*a),s=new DataView(new ArrayBuffer(o)),l=0,c=r;c<r+i;c++)for(var h=0;h<e.itemSize;h++){var d=e.array[c*e.itemSize+h];t===_p.FLOAT?s.setFloat32(l,d,!0):t===_p.UNSIGNED_INT?s.setUint32(l,d,!0):t===_p.UNSIGNED_SHORT?s.setUint16(l,d,!0):t===_p.UNSIGNED_BYTE&&s.setUint8(l,d),l+=a}var f={buffer:p(s.buffer),byteOffset:F,byteLength:o};void 0!==n&&(f.target=n),n===_p.ARRAY_BUFFER&&(f.byteStride=e.itemSize*a),F+=o,D.bufferViews.push(f);var m={id:D.bufferViews.length-1,byteLength:0};return m}function m(e){return D.bufferViews||(D.bufferViews=[]),new Promise(function(t){var r=new Ds.FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){var e=h(r.result),i={buffer:p(e),byteOffset:F,byteLength:e.byteLength};F+=e.byteLength,D.bufferViews.push(i),t(D.bufferViews.length-1)}})}function v(e,t,i,n){var a,s={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"};if(e.array.constructor===Float32Array)a=_p.FLOAT;else if(e.array.constructor===Uint32Array)a=_p.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)a=_p.UNSIGNED_SHORT;else{if(e.array.constructor!==Uint8Array)throw new Error("GLTFExporter: Unsupported bufferAttribute component type.");a=_p.UNSIGNED_BYTE}if(void 0===i&&(i=0),void 0===n&&(n=e.count),r.truncateDrawRange&&void 0!==t&&null===t.index){var l=i+n,c=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;i=Math.max(i,t.drawRange.start),n=Math.min(l,c)-i,n<0&&(n=0)}if(0===n)return null;var u,h=o(e,i,n);void 0!==t&&(u=e===t.index?_p.ELEMENT_ARRAY_BUFFER:_p.ARRAY_BUFFER);var d=f(e,a,i,n,u),p={bufferView:d.id,byteOffset:d.byteOffset,componentType:a,count:n,max:h.max,min:h.min,type:s[e.itemSize]};return D.accessors||(D.accessors=[]),D.accessors.push(p),D.accessors.length-1}function y(e,t,i){z.images.has(e)||z.images.set(e,{});var n=z.images.get(e),a=t===xc?"image/png":"image/jpeg",o=a+":flipY/"+i.toString();if(void 0!==n[o])return n[o];D.images||(D.images=[]);var l={mimeType:a};if(r.embedImages){var c=O=O||document.createElement("canvas");c.width=e.width,c.height=e.height,r.forcePowerOfTwoTextures&&!s(e)&&(console.warn("GLTFExporter: Resized non-power-of-two image.",e),c.width=Fs.floorPowerOfTwo(c.width),c.height=Fs.floorPowerOfTwo(c.height));var u=c.getContext("2d");i===!0&&(u.translate(0,c.height),u.scale(1,-1)),u.drawImage(e,0,0,c.width,c.height),r.binary===!0?I.push(new Promise(function(e){c.toBlob(function(t){m(t).then(function(t){l.bufferView=t,e()})},a)})):l.uri=c.toDataURL(a)}else l.uri=e.src;D.images.push(l);var h=D.images.length-1;return n[o]=h,h}function x(e){D.samplers||(D.samplers=[]);var t={magFilter:Sp[e.magFilter],minFilter:Sp[e.minFilter],wrapS:Sp[e.wrapS],wrapT:Sp[e.wrapT]};return D.samplers.push(t),D.samplers.length-1}function b(e){if(z.textures.has(e))return z.textures.get(e);D.textures||(D.textures=[]);var t={sampler:x(e),source:y(e.image,e.format,e.flipY)};D.textures.push(t);var r=D.textures.length-1;return z.textures.set(e,r),r}function w(e){if(z.materials.has(e))return z.materials.get(e);if(D.materials||(D.materials=[]),e.isShaderMaterial)return console.warn("GLTFExporter: ShaderMaterial not supported."),null;var t={pbrMetallicRoughness:{}};e.isMeshBasicMaterial?(t.extensions={KHR_materials_unlit:{}},B.KHR_materials_unlit=!0):e.isMeshStandardMaterial||console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");var r=e.color.toArray().concat([e.opacity]);if(n(r,[1,1,1,1])||(t.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(t.pbrMetallicRoughness.metallicFactor=e.metalness,t.pbrMetallicRoughness.roughnessFactor=e.roughness):e.isMeshBasicMaterial?(t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9):(t.pbrMetallicRoughness.metallicFactor=.5,t.pbrMetallicRoughness.roughnessFactor=.5),(e.metalnessMap||e.roughnessMap)&&(e.metalnessMap===e.roughnessMap?t.pbrMetallicRoughness.metallicRoughnessTexture={index:b(e.metalnessMap)}:console.warn("GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.")),e.map&&(t.pbrMetallicRoughness.baseColorTexture={index:b(e.map)}),e.isMeshBasicMaterial||e.isLineBasicMaterial||e.isPointsMaterial);else{var i=e.emissive.clone().multiplyScalar(e.emissiveIntensity).toArray();n(i,[0,0,0])||(t.emissiveFactor=i),e.emissiveMap&&(t.emissiveTexture={index:b(e.emissiveMap)})}e.normalMap&&(t.normalTexture={index:b(e.normalMap)},e.normalScale.x!==-1&&(e.normalScale.x!==e.normalScale.y&&console.warn("GLTFExporter: Normal scale components are different, ignoring Y and exporting X."),t.normalTexture.scale=e.normalScale.x)),e.aoMap&&(t.occlusionTexture={index:b(e.aoMap)},1!==e.aoMapIntensity&&(t.occlusionTexture.strength=e.aoMapIntensity)),(e.transparent||e.alphaTest>0)&&(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;M<e.morphTargetInfluences.length;++M){var T={},E=!1;for(var f in i.morphAttributes)if("position"===f||"normal"===f){for(var m=i.morphAttributes[f][M],C=i.attributes[f],L=m.clone(),N=0,O=m.count;N<O;N++)L.setXYZ(N,m.getX(N)-C.getX(N),m.getY(N)-C.getY(N),m.getZ(N)-C.getZ(N));T[f.toUpperCase()]=v(L,i)}else E||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),E=!0);u.push(T),b.push(e.morphTargetInfluences[M]),void 0!==e.morphTargetDictionary&&_.push(S[M]);
|
|
}a.weights=b,_.length>0&&(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;M<B;M++)k[M]=M;i.setIndex(k),U=!0}for(var z=I?e.material:[e.material],j=I?i.groups:[{materialIndex:0,start:void 0,count:void 0}],M=0,B=j.length;M<B;M++){var V={mode:t,attributes:o};F&&(V.extras=F),u.length>0&&(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;n<e.tracks.length;++n){var a=e.tracks[n],o=W.parseTrackName(a.name),s=W.findNode(t,o.nodeName),l=Ap[o.propertyName];if("bones"===o.objectName&&(s=s.isSkinnedMesh===!0?s.skeleton.getBoneByName(o.objectIndex):void 0),!s||!l)return console.warn('GLTFExporter: Could not export animation track "%s".',a.name),null;var c=1,u=a.values.length/a.times.length;if(l===Ap.morphTargetInfluences){if(1!==s.morphTargetInfluences.length&&void 0!==o.propertyIndex){console.warn('GLTFExporter: Skipping animation track "%s". Morph target keyframe tracks must target all available morph targets for the given mesh.',a.name);continue}u/=s.morphTargetInfluences.length}var h;a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(h="CUBICSPLINE",u/=3):h=a.getInterpolation()===Zc?"STEP":"LINEAR",i.push({input:v(new g(a.times,c)),output:v(new g(a.values,u)),interpolation:h}),r.push({sampler:i.length-1,target:{node:U.get(s),path:l}})}return D.animations.push({name:e.name||"clip_"+D.animations.length,samplers:i,channels:r}),D.animations.length-1}function M(e){var t=D.nodes[U.get(e)],r=e.skeleton,i=e.skeleton.bones[0];if(void 0===i)return null;for(var n=[],a=new Float32Array(16*r.bones.length),o=0;o<r.bones.length;++o)n.push(U.get(r.bones[o])),r.boneInverses[o].toArray(a,16*o);void 0===D.skins&&(D.skins=[]),D.skins.push({inverseBindMatrices:v(new g(a,16)),joints:n,skeleton:U.get(i)});var s=t.skin=D.skins.length-1;return s}function T(e){if(e.isLight)return console.warn("GLTFExporter: Unsupported node type:",e.constructor.name),null;D.nodes||(D.nodes=[]);var t={};if(r.trs){var i=e.quaternion.toArray(),a=e.position.toArray(),o=e.scale.toArray();n(i,[0,0,0,1])||(t.rotation=i),n(a,[0,0,0])||(t.translation=a),n(o,[1,1,1])||(t.scale=o)}else e.updateMatrix(),n(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])||(t.matrix=e.matrix.elements);if(""!==e.name&&(t.name=String(e.name)),e.userData&&Object.keys(e.userData).length>0&&(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;c<u;c++){var h=e.children[c];if(h.visible||r.onlyVisible===!1){var p=T(h);null!==p&&l.push(p)}}l.length>0&&(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;n<a;n++){var o=e.children[n];if(o.visible||r.onlyVisible===!1){var s=T(o);null!==s&&i.push(s)}}i.length>0&&(t.nodes=i)}function C(e){var t=new fe;t.name="AuxScene";for(var r=0;r<e.length;r++)t.children.push(e[r]);E(t)}function L(e){e=e instanceof Array?e:[e];for(var t=[],i=0;i<e.length;i++)e[i]instanceof fe?E(e[i]):t.push(e[i]);t.length>0&&C(t);for(var i=0;i<k.length;++i)M(k[i]);for(var i=0;i<r.animations.length;++i)A(r.animations[i],e[0])}var N={binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,animations:[],forceIndices:!1,forcePowerOfTwoTextures:!1};r=Object.assign({},N,r),r.animations.length>0&&(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;n<o;n++){var s=i[n],l=r[s];s=parseInt(s),a[l]=s}}for(var c=[],n=0,o=e.length;n<o;n++){var u=e.charCodeAt(n),l=a[u];if(void 0===l)throw"cannot convert charcode 0x"+u.toString(16);l>255?(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;r<i;r++)t.push(l(e[r]));return t.join(",")}if(a.isSkinnedMesh!==!0)return console.warn("MMDExporter: parseVpd() requires SkinnedMesh instance."),null;a.updateMatrixWorld(!0);var u=a.skeleton.bones,h=t(a),d=new i,p=new n,f=new n,m=new r,v=[];v.push("Vocaloid Pose Data file"),v.push(""),v.push((""!==a.name?a.name.replace(/\s/g,"_"):"skin")+".osm;"),v.push(u.length+";"),v.push("");for(var g=0,y=u.length;g<y;g++){var x=u[g],b=h[g];s===!0&&void 0!==x.userData.ik&&void 0!==x.userData.ik.originalMatrix?m.fromArray(x.userData.ik.originalMatrix):m.copy(x.matrix),d.setFromMatrixPosition(m),p.setFromRotationMatrix(m);var w=d.sub(b.position).toArray(),_=f.copy(b.quaternion).conjugate().multiply(p).toArray();w[2]=-w[2],_[0]=-_[0],_[1]=-_[1],v.push("Bone"+g+"{"+x.name),v.push(" "+c(w)+";"),v.push(" "+c(_)+";"),v.push("}"),v.push("")}v.push("");var S=v.join("\n");return o===!0?e(S):S}},Ep=function(){};Ep.prototype={constructor:Ep,parse:function(e){var t,r,n,a,o,s="",c=0,u=0,h=0,d=new i,p=new i,v=new f,g=[],y=function(e){var i=0,n=0,f=0,y=e.geometry,x=new l;if(y instanceof m&&(y=(new P).setFromObject(e)),y instanceof P){var b=y.getAttribute("position"),w=y.getAttribute("normal"),_=y.getAttribute("uv"),S=y.getIndex();if(s+="o "+e.name+"\n",e.material&&e.material.name&&(s+="usemtl "+e.material.name+"\n"),void 0!==b)for(t=0,a=b.count;t<a;t++,i++)d.x=b.getX(t),d.y=b.getY(t),d.z=b.getZ(t),d.applyMatrix4(e.matrixWorld),s+="v "+d.x+" "+d.y+" "+d.z+"\n";if(void 0!==_)for(t=0,a=_.count;t<a;t++,f++)v.x=_.getX(t),v.y=_.getY(t),s+="vt "+v.x+" "+v.y+"\n";if(void 0!==w)for(x.getNormalMatrix(e.matrixWorld),t=0,a=w.count;t<a;t++,n++)p.x=w.getX(t),p.y=w.getY(t),p.z=w.getZ(t),p.applyMatrix3(x),s+="vn "+p.x+" "+p.y+" "+p.z+"\n";if(null!==S)for(t=0,a=S.count;t<a;t+=3){for(o=0;o<3;o++)r=S.getX(t+o)+1,g[o]=c+r+(w||_?"/"+(_?u+r:"")+(w?"/"+(h+r):""):"");s+="f "+g.join(" ")+"\n"}else for(t=0,a=b.count;t<a;t+=3){for(o=0;o<3;o++)r=t+o+1,g[o]=c+r+(w||_?"/"+(_?u+r:"")+(w?"/"+(h+r):""):"");s+="f "+g.join(" ")+"\n"}}else console.warn("OBJExporter.parseMesh(): geometry type unsupported",y);c+=i,u+=f,h+=n},x=function(e){var i=0,o=e.geometry,l=e.type;if(o instanceof m&&(o=(new P).setFromObject(e)),o instanceof P){var u=o.getAttribute("position");if(s+="o "+e.name+"\n",void 0!==u)for(t=0,a=u.count;t<a;t++,i++)d.x=u.getX(t),d.y=u.getY(t),d.z=u.getZ(t),d.applyMatrix4(e.matrixWorld),s+="v "+d.x+" "+d.y+" "+d.z+"\n";if("Line"===l){for(s+="l ",r=1,a=u.count;r<=a;r++)s+=c+r+" ";s+="\n"}if("LineSegments"===l)for(r=1,n=r+1,a=u.count;r<a;r+=2,n=r+1)s+="l "+(c+r)+" "+(c+n)+"\n"}else console.warn("OBJExporter.parseLine(): geometry type unsupported",o);c+=i};return e.traverse(function(e){e instanceof k&&y(e),e instanceof B&&x(e)}),s}};var Cp=function(){};Cp.prototype={constructor:Cp,parse:function(e,t,r){function n(t){e.traverse(function(e){if(e.isMesh===!0){var r=e,i=r.geometry;i.isGeometry===!0&&(i=s.get(i)),i.isBufferGeometry===!0&&void 0!==i.getAttribute("position")&&t(r,i)}})}t&&"object"==typeof t&&(console.warn('PLYExporter: The options parameter is now the third argument to the "parse" function. See the documentation for the new API.'),r=t,t=void 0);var a={binary:!1,excludeAttributes:[]};r=Object.assign(a,r);var o=r.excludeAttributes,s=new WeakMap,c=!1,u=!1,h=!1,d=0,p=0;e.traverse(function(e){if(e.isMesh===!0){var t=e,r=t.geometry;if(r.isGeometry===!0){var i=s.get(r)||(new P).setFromObject(t);s.set(r,i),r=i}if(r.isBufferGeometry===!0){var n=r.getAttribute("position"),a=r.getAttribute("normal"),o=r.getAttribute("uv"),l=r.getAttribute("color"),f=r.getIndex();if(void 0===n)return;d+=n.count,p+=f?f.count/3:n.count/3,void 0!==a&&(c=!0),void 0!==o&&(h=!0),void 0!==l&&(u=!0)}}});var f=o.indexOf("index")===-1;if(c=c&&o.indexOf("normal")===-1,u=u&&o.indexOf("color")===-1,h=h&&o.indexOf("uv")===-1,f&&p!==Math.floor(p))return console.error("PLYExporter: Failed to generate a valid PLY file with triangle indices because the number of indices is not divisible by 3."),null;var m=1;d>256&&(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<l;s++)g.x=r.getX(s),g.y=r.getY(s),g.z=r.getZ(s),g.applyMatrix4(e.matrixWorld),S.setFloat32(A,g.x),A+=4,S.setFloat32(A,g.y),A+=4,S.setFloat32(A,g.z),A+=4,c===!0&&(null!=i?(g.x=i.getX(s),g.y=i.getY(s),g.z=i.getZ(s),g.applyMatrix3(y),S.setFloat32(A,g.x),A+=4,S.setFloat32(A,g.y),A+=4,S.setFloat32(A,g.z),A+=4):(S.setFloat32(A,0),A+=4,S.setFloat32(A,0),A+=4,S.setFloat32(A,0),A+=4)),h===!0&&(null!=n?(S.setFloat32(A,n.getX(s)),A+=4,S.setFloat32(A,n.getY(s)),A+=4):h!==!1&&(S.setFloat32(A,0),A+=4,S.setFloat32(A,0),A+=4)),u===!0&&(null!=a?(S.setUint8(A,Math.floor(255*a.getX(s))),A+=1,S.setUint8(A,Math.floor(255*a.getY(s))),A+=1,S.setUint8(A,Math.floor(255*a.getZ(s))),A+=1):(S.setUint8(A,255),A+=1,S.setUint8(A,255),A+=1,S.setUint8(A,255),A+=1));if(f===!0){var d="setUint"+8*m;if(null!==o)for(var s=0,l=o.count;s<l;s+=3)S.setUint8(M,3),M+=1,S[d](M,o.getX(s+0)+T),M+=m,S[d](M,o.getX(s+1)+T),M+=m,S[d](M,o.getX(s+2)+T),M+=m;else for(var s=0,l=r.count;s<l;s+=3)S.setUint8(M,3),M+=1,S[d](M,T+s),M+=m,S[d](M,T+s+1),M+=m,S[d](M,T+s+2),M+=m}T+=r.count}),x=S.buffer}else{var T=0,E="",C="";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<l;s++){g.x=r.getX(s),g.y=r.getY(s),g.z=r.getZ(s),g.applyMatrix4(e.matrixWorld);var d=g.x+" "+g.y+" "+g.z;c===!0&&(null!=i?(g.x=i.getX(s),g.y=i.getY(s),g.z=i.getZ(s),g.applyMatrix3(y),d+=" "+g.x+" "+g.y+" "+g.z):d+=" 0 0 0"),h===!0&&(null!=n?d+=" "+n.getX(s)+" "+n.getY(s):h!==!1&&(d+=" 0 0")),u===!0&&(d+=null!=a?" "+Math.floor(255*a.getX(s))+" "+Math.floor(255*a.getY(s))+" "+Math.floor(255*a.getZ(s)):" 255 255 255"),E+=d+"\n"}if(f===!0){if(null!==o)for(var s=0,l=o.count;s<l;s+=3)C+="3 "+(o.getX(s+0)+T),C+=" "+(o.getX(s+1)+T),C+=" "+(o.getX(s+2)+T)+"\n";else for(var s=0,l=r.count;s<l;s+=3)C+="3 "+(T+s)+" "+(T+s+1)+" "+(T+s+2)+"\n";p+=o?o.count/3:r.count/3}T+=r.count}),x=""+v+E+"\n"+(f?C+"\n":"")}return"function"==typeof t&&requestAnimationFrame(function(){return t(x)}),x}};var Lp=function(){};Lp.prototype={constructor:Lp,parse:function(){var e=new i,t=new l;return function(r,i){void 0===i&&(i={});var n=void 0!==i.binary&&i.binary,a=[],o=0;if(r.traverse(function(e){if(e.isMesh){var t=e.geometry;t.isBufferGeometry&&(t=(new m).fromBufferGeometry(t)),t.isGeometry&&(o+=t.faces.length,a.push({geometry:t,matrixWorld:e.matrixWorld}))}}),n){var s=80,l=2*o+3*o*4*4+80+4,c=new ArrayBuffer(l),u=new DataView(c);u.setUint32(s,o,!0),s+=4;for(var h=0,d=a.length;h<d;h++){var p=a[h],f=p.geometry.vertices,v=p.geometry.faces,g=p.matrixWorld;t.getNormalMatrix(g);for(var y=0,x=v.length;y<x;y++){var b=v[y];e.copy(b.normal).applyMatrix3(t).normalize(),u.setFloat32(s,e.x,!0),s+=4,u.setFloat32(s,e.y,!0),s+=4,u.setFloat32(s,e.z,!0),s+=4;for(var w=[b.a,b.b,b.c],_=0;_<3;_++)e.copy(f[w[_]]).applyMatrix4(g),u.setFloat32(s,e.x,!0),s+=4,u.setFloat32(s,e.y,!0),s+=4,u.setFloat32(s,e.z,!0),s+=4;u.setUint16(s,0,!0),s+=2}}return u}var u="";u+="solid exported\n";for(var h=0,d=a.length;h<d;h++){var p=a[h],f=p.geometry.vertices,v=p.geometry.faces,g=p.matrixWorld;t.getNormalMatrix(g);for(var y=0,x=v.length;y<x;y++){var b=v[y];e.copy(b.normal).applyMatrix3(t).normalize(),u+="\tfacet normal "+e.x+" "+e.y+" "+e.z+"\n",u+="\t\touter loop\n";for(var w=[b.a,b.b,b.c],_=0;_<3;_++)e.copy(f[w[_]]).applyMatrix4(g),u+="\t\t\tvertex "+e.x+" "+e.y+" "+e.z+"\n";u+="\t\tendloop\n",u+="\tendfacet\n"}}return u+="endsolid exported\n"}}()};var Pp=function(){};Pp.prototype={constructor:Pp,parse:function(e){var t={metadata:{version:4,type:"TypedGeometry",generator:"TypedGeometryExporter"}},r=["vertices","normals","uvs"];for(var i in r){for(var n=r[i],a=e[n],o=[],s=0,l=a.length;s<l;s++)o[s]=a[s];t[n]=o}var c=e.boundingSphere;return null!==c&&(t.boundingSphere={center:c.center.toArray(),radius:c.radius}),t}},wt.prototype=Object.create(P.prototype),wt.prototype.constructor=wt,_t.prototype.clone=function(){return new _t(this.position.clone(),this.normal.clone())};var Np=function(e,t,n,a,o,s,l){var c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,3,16,17,18,7,19,20,21,11,22,23,24,15,25,26,27,18,28,29,30,21,31,32,33,24,34,35,36,27,37,38,39,30,40,41,0,33,42,43,4,36,44,45,8,39,46,47,12,12,13,14,15,48,49,50,51,52,53,54,55,56,57,58,59,15,25,26,27,51,60,61,62,55,63,64,65,59,66,67,68,27,37,38,39,62,69,70,71,65,72,73,74,68,75,76,77,39,46,47,12,71,78,79,48,74,80,81,52,77,82,83,56,56,57,58,59,84,85,86,87,88,89,90,91,92,93,94,95,59,66,67,68,87,96,97,98,91,99,100,101,95,102,103,104,68,75,76,77,98,105,106,107,101,108,109,110,104,111,112,113,77,82,83,56,107,114,115,84,110,116,117,88,113,118,119,92,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,123,136,137,120,127,138,139,124,131,140,141,128,135,142,143,132,132,133,134,135,144,145,146,147,148,149,150,151,68,152,153,154,135,142,143,132,147,155,156,144,151,157,158,148,154,159,160,68,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,164,177,178,161,168,179,180,165,172,181,182,169,176,183,184,173,173,174,175,176,185,186,187,188,189,190,191,192,193,194,195,196,176,183,184,173,188,197,198,185,192,199,200,189,196,201,202,193,203,203,203,203,204,205,206,207,208,208,208,208,209,210,211,212,203,203,203,203,207,213,214,215,208,208,208,208,212,216,217,218,203,203,203,203,215,219,220,221,208,208,208,208,218,222,223,224,203,203,203,203,221,225,226,204,208,208,208,208,224,227,228,209,209,210,211,212,229,230,231,232,233,234,235,236,237,238,239,240,212,216,217,218,232,241,242,243,236,244,245,246,240,247,248,249,218,222,223,224,243,250,251,252,246,253,254,255,249,256,257,258,224,227,228,209,252,259,260,229,255,261,262,233,258,263,264,237,265,265,265,265,266,267,268,269,270,271,272,273,92,119,118,113,265,265,265,265,269,274,275,276,273,277,278,279,113,112,111,104,265,265,265,265,276,280,281,282,279,283,284,285,104,103,102,95,265,265,265,265,282,286,287,266,285,288,289,270,95,94,93,92],u=[1.4,0,2.4,1.4,-.784,2.4,.784,-1.4,2.4,0,-1.4,2.4,1.3375,0,2.53125,1.3375,-.749,2.53125,.749,-1.3375,2.53125,0,-1.3375,2.53125,1.4375,0,2.53125,1.4375,-.805,2.53125,.805,-1.4375,2.53125,0,-1.4375,2.53125,1.5,0,2.4,1.5,-.84,2.4,.84,-1.5,2.4,0,-1.5,2.4,-.784,-1.4,2.4,-1.4,-.784,2.4,-1.4,0,2.4,-.749,-1.3375,2.53125,-1.3375,-.749,2.53125,-1.3375,0,2.53125,-.805,-1.4375,2.53125,-1.4375,-.805,2.53125,-1.4375,0,2.53125,-.84,-1.5,2.4,-1.5,-.84,2.4,-1.5,0,2.4,-1.4,.784,2.4,-.784,1.4,2.4,0,1.4,2.4,-1.3375,.749,2.53125,-.749,1.3375,2.53125,0,1.3375,2.53125,-1.4375,.805,2.53125,-.805,1.4375,2.53125,0,1.4375,2.53125,-1.5,.84,2.4,-.84,1.5,2.4,0,1.5,2.4,.784,1.4,2.4,1.4,.784,2.4,.749,1.3375,2.53125,1.3375,.749,2.53125,.805,1.4375,2.53125,1.4375,.805,2.53125,.84,1.5,2.4,1.5,.84,2.4,1.75,0,1.875,1.75,-.98,1.875,.98,-1.75,1.875,0,-1.75,1.875,2,0,1.35,2,-1.12,1.35,1.12,-2,1.35,0,-2,1.35,2,0,.9,2,-1.12,.9,1.12,-2,.9,0,-2,.9,-.98,-1.75,1.875,-1.75,-.98,1.875,-1.75,0,1.875,-1.12,-2,1.35,-2,-1.12,1.35,-2,0,1.35,-1.12,-2,.9,-2,-1.12,.9,-2,0,.9,-1.75,.98,1.875,-.98,1.75,1.875,0,1.75,1.875,-2,1.12,1.35,-1.12,2,1.35,0,2,1.35,-2,1.12,.9,-1.12,2,.9,0,2,.9,.98,1.75,1.875,1.75,.98,1.875,1.12,2,1.35,2,1.12,1.35,1.12,2,.9,2,1.12,.9,2,0,.45,2,-1.12,.45,1.12,-2,.45,0,-2,.45,1.5,0,.225,1.5,-.84,.225,.84,-1.5,.225,0,-1.5,.225,1.5,0,.15,1.5,-.84,.15,.84,-1.5,.15,0,-1.5,.15,-1.12,-2,.45,-2,-1.12,.45,-2,0,.45,-.84,-1.5,.225,-1.5,-.84,.225,-1.5,0,.225,-.84,-1.5,.15,-1.5,-.84,.15,-1.5,0,.15,-2,1.12,.45,-1.12,2,.45,0,2,.45,-1.5,.84,.225,-.84,1.5,.225,0,1.5,.225,-1.5,.84,.15,-.84,1.5,.15,0,1.5,.15,1.12,2,.45,2,1.12,.45,.84,1.5,.225,1.5,.84,.225,.84,1.5,.15,1.5,.84,.15,-1.6,0,2.025,-1.6,-.3,2.025,-1.5,-.3,2.25,-1.5,0,2.25,-2.3,0,2.025,-2.3,-.3,2.025,-2.5,-.3,2.25,-2.5,0,2.25,-2.7,0,2.025,-2.7,-.3,2.025,-3,-.3,2.25,-3,0,2.25,-2.7,0,1.8,-2.7,-.3,1.8,-3,-.3,1.8,-3,0,1.8,-1.5,.3,2.25,-1.6,.3,2.025,-2.5,.3,2.25,-2.3,.3,2.025,-3,.3,2.25,-2.7,.3,2.025,-3,.3,1.8,-2.7,.3,1.8,-2.7,0,1.575,-2.7,-.3,1.575,-3,-.3,1.35,-3,0,1.35,-2.5,0,1.125,-2.5,-.3,1.125,-2.65,-.3,.9375,-2.65,0,.9375,-2,-.3,.9,-1.9,-.3,.6,-1.9,0,.6,-3,.3,1.35,-2.7,.3,1.575,-2.65,.3,.9375,-2.5,.3,1.125,-1.9,.3,.6,-2,.3,.9,1.7,0,1.425,1.7,-.66,1.425,1.7,-.66,.6,1.7,0,.6,2.6,0,1.425,2.6,-.66,1.425,3.1,-.66,.825,3.1,0,.825,2.3,0,2.1,2.3,-.25,2.1,2.4,-.25,2.025,2.4,0,2.025,2.7,0,2.4,2.7,-.25,2.4,3.3,-.25,2.4,3.3,0,2.4,1.7,.66,.6,1.7,.66,1.425,3.1,.66,.825,2.6,.66,1.425,2.4,.25,2.025,2.3,.25,2.1,3.3,.25,2.4,2.7,.25,2.4,2.8,0,2.475,2.8,-.25,2.475,3.525,-.25,2.49375,3.525,0,2.49375,2.9,0,2.475,2.9,-.15,2.475,3.45,-.15,2.5125,3.45,0,2.5125,2.8,0,2.4,2.8,-.15,2.4,3.2,-.15,2.4,3.2,0,2.4,3.525,.25,2.49375,2.8,.25,2.475,3.45,.15,2.5125,2.9,.15,2.475,3.2,.15,2.4,2.8,.15,2.4,0,0,3.15,.8,0,3.15,.8,-.45,3.15,.45,-.8,3.15,0,-.8,3.15,0,0,2.85,.2,0,2.7,.2,-.112,2.7,.112,-.2,2.7,0,-.2,2.7,-.45,-.8,3.15,-.8,-.45,3.15,-.8,0,3.15,-.112,-.2,2.7,-.2,-.112,2.7,-.2,0,2.7,-.8,.45,3.15,-.45,.8,3.15,0,.8,3.15,-.2,.112,2.7,-.112,.2,2.7,0,.2,2.7,.45,.8,3.15,.8,.45,3.15,.112,.2,2.7,.2,.112,2.7,.4,0,2.55,.4,-.224,2.55,.224,-.4,2.55,0,-.4,2.55,1.3,0,2.55,1.3,-.728,2.55,.728,-1.3,2.55,0,-1.3,2.55,1.3,0,2.4,1.3,-.728,2.4,.728,-1.3,2.4,0,-1.3,2.4,-.224,-.4,2.55,-.4,-.224,2.55,-.4,0,2.55,-.728,-1.3,2.55,-1.3,-.728,2.55,-1.3,0,2.55,-.728,-1.3,2.4,-1.3,-.728,2.4,-1.3,0,2.4,-.4,.224,2.55,-.224,.4,2.55,0,.4,2.55,-1.3,.728,2.55,-.728,1.3,2.55,0,1.3,2.55,-1.3,.728,2.4,-.728,1.3,2.4,0,1.3,2.4,.224,.4,2.55,.4,.224,2.55,.728,1.3,2.55,1.3,.728,2.55,.728,1.3,2.4,1.3,.728,2.4,0,0,0,1.425,0,0,1.425,.798,0,.798,1.425,0,0,1.425,0,1.5,0,.075,1.5,.84,.075,.84,1.5,.075,0,1.5,.075,-.798,1.425,0,-1.425,.798,0,-1.425,0,0,-.84,1.5,.075,-1.5,.84,.075,-1.5,0,.075,-1.425,-.798,0,-.798,-1.425,0,0,-1.425,0,-1.5,-.84,.075,-.84,-1.5,.075,0,-1.5,.075,.798,-1.425,0,1.425,-.798,0,.84,-1.5,.075,1.5,-.84,.075];P.call(this),e=e||50,t=void 0!==t?Math.max(2,Math.floor(t)||10):10,n=void 0===n||n,a=void 0===a||a,o=void 0===o||o,s=void 0===s||s;var h=1.3;l=void 0===l||l;var d=3.15*(l?1:h),p=d/2,f=e/p,m=n?(8*t-4)*t:0;m+=a?(16*t-4)*t:0,m+=o?40*t*t:0;var y=new Uint32Array(3*m),x=n?4:0;x+=a?8:0,x+=o?20:0,x*=(t+1)*(t+1);var b=new Float32Array(3*x),w=new Float32Array(3*x),_=new Float32Array(2*x),S=new r;S.set(-1,3,-3,1,3,-6,3,0,-3,3,0,0,1,0,0,0);var A,M,T,E,C,L,N,O,D,F,R,I,U,k,B,z,j=[],V=[],G=[],W=[],X=[],H=[],Y=[],q=[],Q=[],J=new i,Z=0,K=0,$=new i,ee=new r,te=new r,re=new v,ie=new v,ne=new v,ae=new v,oe=new i,se=new i,le=S.clone();le.transpose();var ce=function(e,t,r){return!(b[3*e]===b[3*t]&&b[3*e+1]===b[3*t+1]&&b[3*e+2]===b[3*t+2]||b[3*e]===b[3*r]&&b[3*e+1]===b[3*r+1]&&b[3*e+2]===b[3*r+2]||b[3*t]===b[3*r]&&b[3*t+1]===b[3*r+1]&&b[3*t+2]===b[3*r+2])};for(A=0;A<3;A++)H[A]=new r;var ue=o?0:20,he=n?32:28;N=t+1;for(var de=0,pe=0,fe=0,me=0,ve=0,ge=ue;ge<he;ge++)if(a||ge<20||ge>=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;C<t;C++)for(L=0;L<t;L++)U=de*N*N+C*N+L,k=U+1,B=k+N,z=U+N,ce(U,k,B)&&(y[ve++]=U,y[ve++]=k,y[ve++]=B),ce(U,B,z)&&(y[ve++]=U,y[ve++]=B,y[ve++]=z);de++}this.setIndex(new g(y,1)),this.addAttribute("position",new g(b,3)),this.addAttribute("normal",new g(w,3)),this.addAttribute("uv",new g(_,2)),this.computeBoundingSphere()};Np.prototype=Object.create(P.prototype),Np.prototype.constructor=Np,Mt.prototype=Object.create(ve.prototype),Mt.prototype.constructor=Mt,Mt.prototype.isDataTexture=!0,Et.prototype=Object.assign(Object.create(c.prototype),{constructor:Et,isPoints:!0,raycast:function(){var e=new r,t=new I,n=new p;return function(r,a){function o(e,i){var n=t.distanceSqToPoint(e);if(n<d){t.closestPointToPoint(e,f),f.applyMatrix4(c);var o=r.ray.origin.distanceTo(f);if(o<r.near||o>r.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<b;x++){var w=y[x];p.fromArray(g,3*w),o(p,w)}else for(var x=0,_=g.length/3;x<_;x++)p.fromArray(g,3*x),o(p,x)}else for(var S=l.vertices,x=0,_=S.length;x<_;x++)o(S[x],x)}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Op=function(e){var t=this;c.apply(this,arguments),e=e||{},this.PARTICLE_COUNT=e.maxParticles||1e6,this.PARTICLE_CONTAINERS=e.containerCount||1,this.PARTICLE_NOISE_TEXTURE=e.particleNoiseTex||null,this.PARTICLE_SPRITE_TEXTURE=e.particleSpriteTex||null,this.PARTICLES_PER_CONTAINER=Math.ceil(this.PARTICLE_COUNT/this.PARTICLE_CONTAINERS),this.PARTICLE_CURSOR=0,this.time=0,this.particleContainers=[],this.rand=[];var r,i={vertexShader:["uniform float uTime;","uniform float uScale;","uniform sampler2D tNoise;","attribute vec3 positionStart;","attribute float startTime;","attribute vec3 velocity;","attribute float turbulence;","attribute vec3 color;","attribute float size;","attribute float lifeTime;","varying vec4 vColor;","varying float lifeLeft;","void main() {","\tvColor = vec4( color, 1.0 );","\tvec3 newPosition;","\tvec3 v;","\tfloat timeElapsed = uTime - startTime;","\tlifeLeft = 1.0 - ( timeElapsed / lifeTime );","\tgl_PointSize = ( uScale * size ) * lifeLeft;","\tv.x = ( velocity.x - 0.5 ) * 3.0;","\tv.y = ( velocity.y - 0.5 ) * 3.0;","\tv.z = ( velocity.z - 0.5 ) * 3.0;","\tnewPosition = positionStart + ( v * 10.0 ) * timeElapsed;","\tvec3 noise = texture2D( tNoise, vec2( newPosition.x * 0.015 + ( uTime * 0.05 ), newPosition.y * 0.02 + ( uTime * 0.015 ) ) ).rgb;","\tvec3 noiseVel = ( noise.rgb - 0.5 ) * 30.0;","\tnewPosition = mix( newPosition, newPosition + vec3( noiseVel * ( turbulence * 5.0 ) ), ( timeElapsed / lifeTime ) );","\tif( v.y > 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_CONTAINERS;t++){var r=new Dp(e.PARTICLES_PER_CONTAINER,e);e.particleContainers.push(r),e.add(r)}},this.spawnParticle=function(e){this.PARTICLE_CURSOR++,this.PARTICLE_CURSOR>=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_CONTAINERS;r++)t.particleContainers[r].update(e)},this.dispose=function(){var e=this;this.particleShaderMat.dispose(),this.particleNoiseTex.dispose(),this.particleSpriteTex.dispose();for(var t=0;t<this.PARTICLE_CONTAINERS;t++)e.particleContainers[t].dispose()},this.init()};Op.prototype=Object.create(c.prototype),Op.prototype.constructor=Op;var Dp=function(e,t){c.apply(this,arguments),this.PARTICLE_COUNT=e||1e5,this.PARTICLE_CURSOR=0,this.time=0,this.offset=0,this.count=0,this.DPR=Ds.devicePixelRatio,this.GPUParticleSystem=t,this.particleUpdate=!1,this.particleShaderGeo=new P,this.particleShaderGeo.addAttribute("position",new g(new Float32Array(3*this.PARTICLE_COUNT),3).setDynamic(!0)),this.particleShaderGeo.addAttribute("positionStart",new g(new Float32Array(3*this.PARTICLE_COUNT),3).setDynamic(!0)),this.particleShaderGeo.addAttribute("startTime",new g(new Float32Array(this.PARTICLE_COUNT),1).setDynamic(!0)),this.particleShaderGeo.addAttribute("velocity",new g(new Float32Array(3*this.PARTICLE_COUNT),3).setDynamic(!0)),this.particleShaderGeo.addAttribute("turbulence",new g(new Float32Array(this.PARTICLE_COUNT),1).setDynamic(!0)),this.particleShaderGeo.addAttribute("color",new g(new Float32Array(3*this.PARTICLE_COUNT),3).setDynamic(!0)),this.particleShaderGeo.addAttribute("size",new g(new Float32Array(this.PARTICLE_COUNT),1).setDynamic(!0)),this.particleShaderGeo.addAttribute("lifeTime",new g(new Float32Array(this.PARTICLE_COUNT),1).setDynamic(!0)),this.particleShaderMat=this.GPUParticleSystem.particleShaderMat;var r=new i,n=new i,a=new u;this.spawnParticle=function(e){var i=this.particleShaderGeo.getAttribute("positionStart"),o=this.particleShaderGeo.getAttribute("startTime"),s=this.particleShaderGeo.getAttribute("velocity"),l=this.particleShaderGeo.getAttribute("turbulence"),c=this.particleShaderGeo.getAttribute("color"),u=this.particleShaderGeo.getAttribute("size"),h=this.particleShaderGeo.getAttribute("lifeTime");e=e||{},r=void 0!==e.position?r.copy(e.position):r.set(0,0,0),n=void 0!==e.velocity?n.copy(e.velocity):n.set(0,0,0),a=void 0!==e.color?a.set(e.color):a.set(16777215);var d=void 0!==e.positionRandomness?e.positionRandomness:0,p=void 0!==e.velocityRandomness?e.velocityRandomness:0,f=void 0!==e.colorRandomness?e.colorRandomness:1,m=void 0!==e.turbulence?e.turbulence:1,v=void 0!==e.lifetime?e.lifetime:5,g=void 0!==e.size?e.size:10,y=void 0!==e.sizeRandomness?e.sizeRandomness:0,x=void 0!==e.smoothPosition&&e.smoothPosition;void 0!==this.DPR&&(g*=this.DPR);var b=this.PARTICLE_CURSOR;i.array[3*b+0]=r.x+t.random()*d,i.array[3*b+1]=r.y+t.random()*d,i.array[3*b+2]=r.z+t.random()*d,x===!0&&(i.array[3*b+0]+=-(n.x*t.random()),i.array[3*b+1]+=-(n.y*t.random()),i.array[3*b+2]+=-(n.z*t.random()));var w=2,_=n.x+t.random()*p,S=n.y+t.random()*p,A=n.z+t.random()*p;_=Fs.clamp((_- -w)/(w- -w),0,1),S=Fs.clamp((S- -w)/(w- -w),0,1),A=Fs.clamp((A- -w)/(w- -w),0,1),s.array[3*b+0]=_,s.array[3*b+1]=S,s.array[3*b+2]=A,a.r=Fs.clamp(a.r+t.random()*f,0,1),a.g=Fs.clamp(a.g+t.random()*f,0,1),a.b=Fs.clamp(a.b+t.random()*f,0,1),c.array[3*b+0]=a.r,c.array[3*b+1]=a.g,c.array[3*b+2]=a.b,l.array[b]=m,u.array[b]=g+t.random()*y,h.array[b]=v,o.array[b]=this.time+.02*t.random(),0===this.offset&&(this.offset=this.PARTICLE_CURSOR),this.count++,this.PARTICLE_CURSOR++,this.PARTICLE_CURSOR>=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<this.PARTICLE_COUNT?(e.updateRange.offset=this.offset*e.itemSize,t.updateRange.offset=this.offset*t.itemSize,r.updateRange.offset=this.offset*r.itemSize,i.updateRange.offset=this.offset*i.itemSize,n.updateRange.offset=this.offset*n.itemSize,a.updateRange.offset=this.offset*a.itemSize,o.updateRange.offset=this.offset*o.itemSize,e.updateRange.count=this.count*e.itemSize,t.updateRange.count=this.count*t.itemSize,r.updateRange.count=this.count*r.itemSize,i.updateRange.count=this.count*i.itemSize,n.updateRange.count=this.count*n.itemSize,a.updateRange.count=this.count*a.itemSize,o.updateRange.count=this.count*o.itemSize):(e.updateRange.offset=0,t.updateRange.offset=0,r.updateRange.offset=0,i.updateRange.offset=0,n.updateRange.offset=0,a.updateRange.offset=0,o.updateRange.offset=0,e.updateRange.count=-1,t.updateRange.count=-1,r.updateRange.count=-1,i.updateRange.count=-1,n.updateRange.count=-1,a.updateRange.count=-1,o.updateRange.count=-1),e.needsUpdate=!0,t.needsUpdate=!0,r.needsUpdate=!0,i.needsUpdate=!0,n.needsUpdate=!0,a.needsUpdate=!0,o.needsUpdate=!0,this.offset=0,this.count=0}},this.dispose=function(){this.particleShaderGeo.dispose()},this.init()};Dp.prototype=Object.create(c.prototype),Dp.prototype.constructor=Dp;var Fp=function(){c.call(this)};Fp.prototype=Object.create(c.prototype),Fp.prototype.constructor=Fp,Fp.prototype.updateMatrixWorld=function(){var e=new i,t=new n,r=new i,a=new i,o=new n,s=new i;return function(i){var n=this;this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(null!==this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(a,o,s),this.matrix.decompose(e,t,r),this.matrixWorld.compose(a,t,s)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,i=!0);for(var l=0,c=this.children.length;l<c;l++)n.children[l].updateMatrixWorld(i)}}();var Rp=function(){function e(e){return e*e*e*(e*(6*e-15)+10)}function t(e,t,r){return t+e*(r-t)}function r(e,t,r,i){var n=15&e,a=n<8?t:r,o=n<4?r:12==n||14==n?t:i;return(0==(1&n)?a:-a)+(0==(2&n)?o:-o)}for(var i=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],n=0;n<256;n++)i[256+n]=i[n];return{noise:function(n,a,o){var s=Math.floor(n),l=Math.floor(a),c=Math.floor(o),u=255&s,h=255&l,d=255&c;n-=s,a-=l,o-=c;var p=n-1,f=a-1,m=o-1,v=e(n),g=e(a),y=e(o),x=i[u]+h,b=i[x]+d,w=i[x+1]+d,_=i[u+1]+h,S=i[_]+d,A=i[_+1]+d;return t(y,t(g,t(v,r(i[b],n,a,o),r(i[S],p,a,o)),t(v,r(i[w],n,f,o),r(i[A],p,f,o))),t(g,t(v,r(i[b+1],n,a,m),r(i[S+1],p,a,o-1)),t(v,r(i[w+1],n,f,m),r(i[A+1],p,f,m))))}}};Ct.prototype=Object.assign(Object.create(P.prototype),{constructor:Ct,isInstancedBufferGeometry:!0,copy:function(e){return P.prototype.copy.call(this,e),this.maxInstancedCount=e.maxInstancedCount,this},clone:function(){return(new this.constructor).copy(this)}}),Object.defineProperty(Lt.prototype,"needsUpdate",{set:function(e){e===!0&&this.version++}}),Object.assign(Lt.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setArray:function(e){if(Array.isArray(e))throw new TypeError("BufferAttribute: array should be a Typed Array.");return this.count=void 0!==e?e.length/this.stride:0,this.array=e,this},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.dynamic=e.dynamic,this},copyAt:function(e,t,r){var i=this;e*=this.stride,r*=t.stride;for(var n=0,a=this.stride;n<a;n++)i.array[e+n]=t.array[r+n];return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(e){return this.onUploadCallback=e,this}}),Pt.prototype=Object.assign(Object.create(Lt.prototype),{constructor:Pt,isInstancedInterleavedBuffer:!0,copy:function(e){return Lt.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}}),Object.defineProperties(Nt.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(Nt.prototype,{isInterleavedBufferAttribute:!0,setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this},setXYZ:function(e,t,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this},setXYZW:function(e,t,r,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=n,this}}),Ot.prototype=Object.create(P.prototype),Ot.prototype.constructor=Ot;var Ip=function(){Ct.call(this),this.type="LineSegmentsGeometry";var e=(new P,[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0]),t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],r=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(r),this.addAttribute("position",new M(e,3)),this.addAttribute("uv",new M(t,2))};Ip.prototype=Object.assign(Object.create(Ct.prototype),{constructor:Ip,isLineSegmentsGeometry:!0,applyMatrix:function(e){var t=this.attributes.instanceStart,r=this.attributes.instanceEnd;return void 0!==t&&(e.applyToBufferAttribute(t),e.applyToBufferAttribute(r),t.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},setPositions:function(e){var t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var r=new Pt(t,6,1);return this.addAttribute("instanceStart",new Nt(r,3,0)),this.addAttribute("instanceEnd",new Nt(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},setColors:function(e){var t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var r=new Pt(t,6,1);return this.addAttribute("instanceColorStart",new Nt(r,3,0)),this.addAttribute("instanceColorEnd",new Nt(r,3,3)),this},fromWireframeGeometry:function(e){return this.setPositions(e.attributes.position.array),this},fromEdgesGeometry:function(e){return this.setPositions(e.attributes.position.array),this},fromMesh:function(e){return this.fromWireframeGeometry(new Ot(e.geometry)),this},fromLineSegements:function(e){var t=e.geometry;return t.isGeometry?this.setPositions(t.vertices):t.isBufferGeometry&&this.setPositions(t.position.array),this},computeBoundingBox:function(){var e=new d;return function(){null===this.boundingBox&&(this.boundingBox=new d);var t=this.attributes.instanceStart,r=this.attributes.instanceEnd;void 0!==t&&void 0!==r&&(this.boundingBox.setFromBufferAttribute(t),e.setFromBufferAttribute(r),this.boundingBox.union(e))}}(),computeBoundingSphere:function(){var e=new i;return function(){null===this.boundingSphere&&(this.boundingSphere=new p),null===this.boundingBox&&this.computeBoundingBox();var t=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(void 0!==t&&void 0!==r){var i=this.boundingSphere.center;this.boundingBox.getCenter(i);for(var n=0,a=0,o=t.count;a<o;a++)e.fromBufferAttribute(t,a),n=Math.max(n,i.distanceToSquared(e)),e.fromBufferAttribute(r,a),n=Math.max(n,i.distanceToSquared(e));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error("LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}}(),toJSON:function(){},clone:function(){},copy:function(e){return this}}),mp.line={linewidth:{value:1},resolution:{value:new f(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},vp.line={uniforms:Mu.merge([mp.common,mp.fog,mp.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\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 <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\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 <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\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<l;o++,s+=2)e.fromBufferAttribute(i,o),t.fromBufferAttribute(n,o),a[s]=0===s?0:a[s-1],a[s+1]=a[s]+e.distanceTo(t);var c=new Pt(a,2,1);return r.addAttribute("instanceDistanceStart",new Nt(c,1,0)),r.addAttribute("instanceDistanceEnd",new Nt(c,1,1)),this}}(),copy:function(e){return this}});var Bp=function(){Ip.call(this),this.type="LineGeometry"};Bp.prototype=Object.assign(Object.create(Ip.prototype),{constructor:Bp,isLineGeometry:!0,setPositions:function(e){for(var t=e.length-3,r=new Float32Array(2*t),i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return Ip.prototype.setPositions.call(this,r),this},setColors:function(e){for(var t=e.length-3,r=new Float32Array(2*t),i=0;i<t;i+=3)r[2*i]=e[i],r[2*i+1]=e[i+1],r[2*i+2]=e[i+2],r[2*i+3]=e[i+3],r[2*i+4]=e[i+4],r[2*i+5]=e[i+5];return Ip.prototype.setColors.call(this,r),this},fromLine:function(e){var t=e.geometry;return t.isGeometry?this.setPositions(t.vertices):t.isBufferGeometry&&this.setPositions(t.position.array),this},copy:function(e){return this}});var zp=function(e,t){kp.call(this),this.type="Line2",this.geometry=void 0!==e?e:new Bp,this.material=void 0!==t?t:new Up({color:16777215*Math.random()})};zp.prototype=Object.assign(Object.create(kp.prototype),{constructor:zp,isLine2:!0,copy:function(e){return this}});var jp=function(e,t){k.call(this),this.type="Wireframe",this.geometry=void 0!==e?e:new Ip,this.material=void 0!==t?t:new Up({color:16777215*Math.random()})};jp.prototype=Object.assign(Object.create(k.prototype),{constructor:jp,isWireframe:!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<l;o++,s+=2)e.fromBufferAttribute(i,o),t.fromBufferAttribute(n,o),a[s]=0===s?0:a[s-1],a[s+1]=a[s]+e.distanceTo(t);var c=new Pt(a,2,1);return r.addAttribute("instanceDistanceStart",new Nt(c,1,0)),r.addAttribute("instanceDistanceEnd",new Nt(c,1,1)),this}}(),copy:function(e){return this}});var Vp=function(e){Ip.call(this),this.type="WireframeGeometry2",this.fromWireframeGeometry(new Ot(e))};Vp.prototype=Object.assign(Object.create(Ip.prototype),{constructor:Vp,isWireframeGeometry2:!0,copy:function(e){return this}}),Dt.prototype=Object.assign(Object.create(c.prototype),{constructor:Dt,isGroup:!0});var Gp=function(e){this.manager=void 0!==e?e:Du,this.availableExtensions=[]};Gp.prototype={constructor:Gp,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,n=null,a=null,o=[],s=[],l={},c={},u={},d={};try{n=new JSZip(e)}catch(p){if(p instanceof ReferenceError)return console.error("ThreeMFLoader: jszip missing and file is compressed."),null}for(a in n.files)a.match(/\.rels$/)?t=a:a.match(/^3D\/.*\.model$/)?o.push(a):a.match(/^3D\/Metadata\/.*\.xml$/)||(a.match(/^3D\/Textures\/.*/)?s.push(a):a.match(/^3D\/Other\/.*/));var f=new Uint8Array(n.file(t).asArrayBuffer()),m=Ru.decodeText(f);r=i(m);for(var v=0;v<o.length;v++){var g=o[v],y=new Uint8Array(n.file(g).asArrayBuffer()),x=Ru.decodeText(y),b=(new DOMParser).parseFromString(x,"application/xml");"model"!==b.documentElement.nodeName.toLowerCase()&&console.error("ThreeMFLoader: Error loading 3MF - no 3MF document found: ",g);for(var w=b.querySelector("model"),_={},v=0;v<w.attributes.length;v++){var S=w.attributes[v];S.name.match(/^xmlns:(.+)$/)&&(_[S.value]=RegExp.$1)}var A=h(w);A.xml=w,0<Object.keys(_).length&&(A.extensions=_),l[g]=A}for(var v=0;v<s.length;v++){var M=s[v];u[M]=n.file(M).asBinary()}return{rels:r,model:l,printTicket:c,texture:u,other:d}}function i(e){var t=(new DOMParser).parseFromString(e,"application/xml"),r=t.querySelector("Relationship"),i=r.getAttribute("Target"),n=r.getAttribute("Id"),a=r.getAttribute("Type");return{target:i,id:n,type:a}}function n(e){for(var t={},r=0;r<e.length;r++){var i=e[r],n=i.getAttribute("name"),a=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate"];0<=a.indexOf(n)&&(t[n]=i.textContent)}return t}function a(e){}function o(e,t){for(var r={},i=[],n=e.querySelectorAll("vertices vertex"),a=0;a<n.length;a++){var o=n[a],s=o.getAttribute("x"),l=o.getAttribute("y"),c=o.getAttribute("z");i.push(parseFloat(s),parseFloat(l),parseFloat(c))}r.vertices=new Float32Array(i.length);for(var a=0;a<i.length;a++)r.vertices[a]=i[a];for(var u=[],h=[],d=e.querySelectorAll("triangles triangle"),a=0;a<d.length;a++){var p=d[a],f=p.getAttribute("v1"),m=p.getAttribute("v2"),v=p.getAttribute("v3"),g=p.getAttribute("p1"),y=p.getAttribute("p2"),x=p.getAttribute("p3"),b=p.getAttribute("pid");h.push(parseInt(f,10),parseInt(m,10),parseInt(v,10));var w={};g&&(w.p1=parseInt(g,10)),y&&(w.p2=parseInt(y,10)),x&&(w.p3=parseInt(x,10)),b&&(w.pid=b),0<Object.keys(w).length&&u.push(w)}r.triangleProperties=u,r.triangles=new Uint32Array(h.length);for(var a=0;a<h.length;a++)r.triangles[a]=h[a];return r}function s(e){}function l(e){var t={type:e.getAttribute("type")},r=e.getAttribute("id");r&&(t.id=r);var i=e.getAttribute("pid");i&&(t.pid=i);var n=e.getAttribute("pindex");n&&(t.pindex=n);var a=e.getAttribute("thumbnail");a&&(t.thumbnail=a);var l=e.getAttribute("partnumber");l&&(t.partnumber=l);var c=e.getAttribute("name");c&&(t.name=c);var u=e.querySelector("mesh");u&&(t.mesh=o(u));var h=e.querySelector("components");return h&&(t.components=s(h)),t}function c(e){var t={},r=e.querySelector("basematerials");r&&(t.basematerial=a(r)),t.object={};for(var i=e.querySelectorAll("object"),n=0;n<i.length;n++){var o=i[n],s=l(o);t.object[s.id]=s}return t}function u(e){for(var t=[],i=e.querySelectorAll("item"),n=0;n<i.length;n++){var a=i[n],o={objectid:a.getAttribute("objectid")},s=a.getAttribute("transform");if(s){var l=[];s.split(" ").forEach(function(e){l.push(parseFloat(e))});var c=new r;o.transform=c.set(l[0],l[3],l[6],l[9],l[1],l[4],l[7],l[10],l[2],l[5],l[8],l[11],0,0,0,1)}t.push(o)}return t}function h(e){var t={unit:e.getAttribute("unit")||"millimeter"},r=e.querySelectorAll("metadata");r&&(t.metadata=n(r));var i=e.querySelector("resources");i&&(t.resources=c(i));var a=e.querySelector("build");return a&&(t.build=u(a)),t}function d(e,t){var r=new P;r.setIndex(new g(e.triangles,1)),r.addAttribute("position",new g(e.vertices,3)),e.colors&&r.addAttribute("color",new g(e.colors,3)),r.computeBoundingSphere();var i={flatShading:!0};e.colors&&0<e.colors.length?i.vertexColors=il:i.color=11184895;var n=new Ee(i);return new k(r,n)}function p(e,t,r,i){if(e){for(var n=[],a=Object.keys(e),o=0;o<a.length;o++)for(var s=a[o],l=0;l<v.availableExtensions.length;l++){var c=v.availableExtensions[l];c.ns===s&&n.push(c)}for(var o=0;o<n.length;o++){var c=n[o];c.apply(r,e[c.ns],t)}}}function f(e){for(var t=e.model,r={},i=Object.keys(t),n=0;n<i.length;n++)for(var a=i[n],o=t[a],s=o.xml,l=o.extensions,c=Object.keys(o.resources.object),u=0;u<c.length;u++){var h=c[u],f=o.resources.object[h],m=f.mesh;p(l,m,s,e),r[h]=d(m,e)}return r}function m(e,t,r){for(var i=new Dt,n=r.model[t.target.substring(1)].build,a=0;a<n.length;a++){var o=n[a],s=e[o.objectid];o.transform&&s.geometry.applyMatrix(o.transform),i.add(s)}return i}var v=this,y=t(e),x=f(y);return m(x,y.rels,y)},addExtension:function(e){this.availableExtensions.push(e)}};var Wp=function(e){this.manager=void 0!==e?e:Du};Wp.prototype={constructor:Wp,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=new DataView(e),r=String.fromCharCode(t.getUint8(0),t.getUint8(1));if("PK"===r){var i=null,n=null;console.log("AMFLoader: Loading Zip");try{i=new JSZip(e)}catch(a){if(a instanceof ReferenceError)return console.log("AMFLoader: jszip missing and file is compressed."),null}for(n in i.files)if(".amf"===n.toLowerCase().substr(-4))break;console.log("AMFLoader: Trying to load file asset: "+n),t=new DataView(i.file(n).asArrayBuffer())}var o=Ru.decodeText(t),s=(new DOMParser).parseFromString(o,"application/xml");return"amf"!==s.documentElement.nodeName.toLowerCase()?(console.log("AMFLoader: Error loading AMF - no AMF document found."),null):s}function r(e){var t=1,r="millimeter";void 0!==e.documentElement.attributes.unit&&(r=e.documentElement.attributes.unit.value.toLowerCase());var i={millimeter:1,inch:25.4,feet:304.8,meter:1e3,micron:.001};return void 0!==i[r]&&(t=i[r]),console.log("AMFLoader: Unit scale: "+t),t}function i(e){for(var t="AMF Material",r=e.attributes.id.textContent,i={r:1,g:1,b:1,a:1},a=null,o=0;o<e.childNodes.length;o++){var s=e.childNodes[o];"metadata"===s.nodeName&&void 0!==s.attributes.type?"name"===s.attributes.type.value&&(t=s.textContent):"color"===s.nodeName&&(i=n(s))}return a=new Ee({flatShading:!0,color:new u(i.r,i.g,i.b),name:t}),1!==i.a&&(a.transparent=!0,a.opacity=i.a),{id:r,material:a}}function n(e){for(var t={r:1,g:1,b:1,a:1},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];"r"===i.nodeName?t.r=i.textContent:"g"===i.nodeName?t.g=i.textContent:"b"===i.nodeName?t.b=i.textContent:"a"===i.nodeName&&(t.a=i.textContent)}return t}function a(e){var t={name:"",triangles:[],materialid:null},r=e.firstElementChild;for(void 0!==e.attributes.materialid&&(t.materialId=e.attributes.materialid.nodeValue);r;){if("metadata"===r.nodeName)void 0!==r.attributes.type&&"name"===r.attributes.type.value&&(t.name=r.textContent);else if("triangle"===r.nodeName){var i=r.getElementsByTagName("v1")[0].textContent,n=r.getElementsByTagName("v2")[0].textContent,a=r.getElementsByTagName("v3")[0].textContent;t.triangles.push(i,n,a)}r=r.nextElementSibling}return t}function o(e){for(var t=[],r=[],i=e.firstElementChild;i;){if("vertex"===i.nodeName)for(var n=i.firstElementChild;n;){if("coordinates"===n.nodeName){var a=n.getElementsByTagName("x")[0].textContent,o=n.getElementsByTagName("y")[0].textContent,s=n.getElementsByTagName("z")[0].textContent;t.push(a,o,s)}else if("normal"===n.nodeName){var l=n.getElementsByTagName("nx")[0].textContent,c=n.getElementsByTagName("ny")[0].textContent,u=n.getElementsByTagName("nz")[0].textContent;r.push(l,c,u)}n=n.nextElementSibling}i=i.nextElementSibling}return{vertices:t,normals:r}}function s(e){for(var t=e.attributes.id.textContent,r={name:"amfobject",meshes:[]},i=null,s=e.firstElementChild;s;){if("metadata"===s.nodeName)void 0!==s.attributes.type&&"name"===s.attributes.type.value&&(r.name=s.textContent);else if("color"===s.nodeName)i=n(s);else if("mesh"===s.nodeName){for(var l=s.firstElementChild,c={vertices:[],normals:[],volumes:[],color:i};l;){if("vertices"===l.nodeName){var u=o(l);c.normals=c.normals.concat(u.normals),c.vertices=c.vertices.concat(u.vertices)}else"volume"===l.nodeName&&c.volumes.push(a(l));l=l.nextElementSibling}r.meshes.push(c)}s=s.nextElementSibling}return{id:t,obj:r}}var l,c,h=t(e),d="",p="",f=r(h),m={},v={},g=h.documentElement.childNodes;for(l=0;l<g.length;l++){var y=g[l];if("metadata"===y.nodeName)void 0!==y.attributes.type&&("name"===y.attributes.type.value?d=y.textContent:"author"===y.attributes.type.value&&(p=y.textContent));else if("material"===y.nodeName){var x=i(y);m[x.id]=x.material}else if("object"===y.nodeName){var b=s(y);v[b.id]=b.obj}}var w=new Dt,_=new Ee({color:11184895,flatShading:!0});w.name=d,w.userData.author=p,w.userData.loader="AMF";for(var S in v){var A=v[S],T=A.meshes,E=new Dt;for(E.name=A.name||"",l=0;l<T.length;l++){var C=_,L=T[l],N=new M(L.vertices,3),O=null;if(L.normals.length&&(O=new M(L.normals,3)),L.color){var D=L.color;C=_.clone(),C.color=new u(D.r,D.g,D.b),1!==D.a&&(C.transparent=!0,C.opacity=D.a)}var F=L.volumes;for(c=0;c<F.length;c++){var R=F[c],I=new P,U=C;I.setIndex(R.triangles),I.addAttribute("position",N.clone()),O&&I.addAttribute("normal",O.clone()),void 0!==m[R.materialId]&&(U=m[R.materialId]),I.scale(f,f,f),E.add(new k(I,U.clone()))}}w.add(E)}return w}};var Xp=function(e){this.manager=void 0!==e?e:Du};Xp.prototype={constructor:Xp,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=Ru.extractUrlBase(e),o=new we(this.manager);o.load(e,function(e){var r=JSON.parse(e),o=r.__metadata__;if("undefined"!=typeof o){if("assimp2json"!==o.format)return void i("AssimpJSONLoader: Not an assimp2json scene.");if(o.version<100&&o.version>=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;n<e.length;++n)i[n]=t.call(r,e[n]);return i}function n(e){var t,r,i,n=new P,a=[],o=e.vertices||[],s=e.normals||[],l=e.texturecoords||[],c=e.colors||[];for(l=l[0]||[],t=0,r=e.faces.length;t<r;t++)i=e.faces[t],a.push(i[0],i[1],i[2]);return n.setIndex(a),n.addAttribute("position",new M(o,3)),s.length>0&&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&&a<t.meshes.length;a++)s=t.meshes[a],l.add(new k(i[s],n[e.meshes[s].materialindex]));for(a=0;t.children&&a<t.children.length;a++)l.add(o(e,t.children[a],i,n));return l}var s=new Ue(this.manager);s.setPath(t).setCrossOrigin(this.crossOrigin);var l=i(e.meshes,n),u=i(e.materials,a);return o(e,e.rootnode,l,u)}},Object.assign(Ft.prototype,{calculateInverses:function(){var e=this;this.boneInverses=[];for(var t=0,i=this.bones.length;t<i;t++){var n=new r;e.bones[t]&&n.getInverse(e.bones[t].matrixWorld),e.boneInverses.push(n)}},pose:function(){var e,t,r,i=this;for(t=0,r=this.bones.length;t<r;t++)e=i.bones[t],e&&e.matrixWorld.getInverse(i.boneInverses[t]);for(t=0,r=this.bones.length;t<r;t++)e=i.bones[t],e&&(e.parent&&e.parent.isBone?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},update:function(){var e=new r,t=new r;return function(){for(var r=this.bones,i=this.boneInverses,n=this.boneMatrices,a=this.boneTexture,o=0,s=r.length;o<s;o++){var l=r[o]?r[o].matrixWorld:t;e.multiplyMatrices(l,i[o]),e.toArray(n,16*o)}void 0!==a&&(a.needsUpdate=!0)}}(),clone:function(){return new Ft(this.bones,this.boneInverses)},getBoneByName:function(e){for(var t=this,r=0,i=this.bones.length;r<i;r++){var n=t.bones[r];if(n.name===e)return n}}}),Rt.prototype=Object.assign(Object.create(k.prototype),{constructor:Rt,isSkinnedMesh:!0,initBones:function(){var e,t,r,i,n=this,a=[];if(this.geometry&&void 0!==this.geometry.bones){for(r=0,i=this.geometry.bones.length;r<i;r++)t=n.geometry.bones[r],e=new oe,a.push(e),e.name=t.name,e.position.fromArray(t.pos),e.quaternion.fromArray(t.rotq),void 0!==t.scl&&e.scale.fromArray(t.scl);for(r=0,i=this.geometry.bones.length;r<i;r++)t=n.geometry.bones[r],t.parent!==-1&&null!==t.parent&&void 0!==a[t.parent]?a[t.parent].add(a[r]):n.add(a[r])}return this.updateMatrixWorld(!0),a},bind:function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var e,t,r=this;if(this.geometry&&this.geometry.isGeometry)for(t=0;t<this.geometry.skinWeights.length;t++){var i=r.geometry.skinWeights[t];
|
|
e=1/i.manhattanLength(),e!==1/0?i.multiplyScalar(e):i.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){var n=new v,a=this.geometry.attributes.skinWeight;for(t=0;t<a.count;t++)n.x=a.getX(t),n.y=a.getY(t),n.z=a.getZ(t),n.w=a.getW(t),e=1/n.manhattanLength(),e!==1/0?n.multiplyScalar(e):n.set(1,0,0,0),a.setXYZW(t,n.x,n.y,n.z,n.w)}},updateMatrixWorld:function(e){k.prototype.updateMatrixWorld.call(this,e),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Hp=function(e){this.manager=void 0!==e?e:Du};Hp.prototype={constructor:Hp,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=Ru.extractUrlBase(e),o=new we(this.manager);o.setResponseType("arraybuffer"),o.load(e,function(e){t(n.parse(e,a))},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){function a(e){return Be<<e}function o(e){return ze<<e}function s(e){for(var t in e.mMeshes){var r=e.mMeshes[t];for(var i in r.mBones){var n=e.findNode(r.mBones[i].mName);n&&(n.isBone=!0)}}}function l(e,t){var r=new oe;r.matrix.copy(e.matrix),r.matrixWorld.copy(e.matrixWorld),r.position.copy(e.position),r.quaternion.copy(e.quaternion),r.scale.copy(e.scale),t.nodeCount++,r.name="bone_"+e.name+t.nodeCount.toString(),t.nodeToBoneMap[e.name]||(t.nodeToBoneMap[e.name]=[]),t.nodeToBoneMap[e.name].push(r);for(var i in e.children){var n=l(e.children[i],t);n&&r.add(n)}return r}function h(e,t){for(var r=[],i=0;i<e.length;i++)r.push({i:e[i],w:t[i]});for(r.sort(function(e,t){return t.w-e.w});r.length<4;)r.push({i:0,w:0});r.length>4&&(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;u<this.mBones.length;u++){var h=d(c,i.mBones[u].mName);if(h){var p=h;n.push(p),a.push(i.mBones[u].mOffsetMatrix.toTHREE())}else{var o=e.findNode(i.mBones[u].mName);if(!o)return;var s=o.toTHREE(e),c=(s.parent,l(s,e));i.threeNode.add(c);var h=d(c,i.mBones[u].mName),p=h;n.push(p),a.push(i.mBones[u].mOffsetMatrix.toTHREE())}}var f=new Ft(n,a);this.threeNode.bind(f,new r),this.threeNode.material.skinning=!0}},this.toTHREE=function(e){var t=this;if(this.threeNode)return this.threeNode;var r,i=new P;if(r=e.mMaterials[this.mMaterialIndex]?e.mMaterials[this.mMaterialIndex].toTHREE(e):new Me,i.setIndex(new g(new Uint32Array(this.mIndexArray),1)),i.addAttribute("position",new g(this.mVertexBuffer,3)),this.mNormalBuffer&&this.mNormalBuffer.length>0&&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;o<this.mBones.length;o++)for(var s=0;s<this.mBones[o].mWeights.length;s++){var l=t.mBones[o].mWeights[s];l&&(n[l.mVertexId]||(n[l.mVertexId]=[]),a[l.mVertexId]||(a[l.mVertexId]=[]),n[l.mVertexId].push(l.mWeight),a[l.mVertexId].push(parseInt(o)))}for(var o in a)h(a[o],n[o]);for(var c=[],u=[],o=0;o<n.length;o++)for(var s=0;s<4;s++)n[o]&&a[o]?(c.push(n[o][s]),u.push(a[o][s])):(c.push(0),u.push(0));i.addAttribute("skinWeight",new g(new Float32Array(c),Qe)),i.addAttribute("skinIndex",new g(new Float32Array(u),Qe))}var d;return 0==this.mBones.length&&(d=new k(i,r)),this.mBones.length>0&&(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;i<this.mChildren.length;i++)r.add(t.mChildren[i].toTHREE(e));for(var i=0;i<this.mMeshes.length;i++)r.add(e.mMeshes[t.mMeshes[i]].toTHREE(e));return this.threeNode=r,r.matrix.decompose(r.position,r.quaternion,r.scale),r}}function A(){this.mName="",this.mNumWeights=0,this.mOffsetMatrix=0}function M(){this.mKey="",this.mSemantic=0,this.mIndex=0,this.mData=[],this.mDataLength=0,this.mType=0,this.dataAsColor=function(){var e=new Uint8Array(this.mData).buffer,t=new DataView(e),r=t.getFloat32(0,!0),i=t.getFloat32(4,!0),n=t.getFloat32(8,!0);return new u(r,i,n)},this.dataAsFloat=function(){var e=new Uint8Array(this.mData).buffer,t=new DataView(e),r=t.getFloat32(0,!0);return r},this.dataAsBool=function(){var e=new Uint8Array(this.mData).buffer,t=new DataView(e),r=t.getFloat32(0,!0);return!!r},this.dataAsString=function(){var e=new b;return e.data=this.mData,e.toString()},this.dataAsMap=function(){var e=new b;e.data=this.mData;var t=e.toString();return t=t.replace(/\\/g,"/"),t.indexOf("/")!=-1&&(t=t.substr(t.lastIndexOf("/")+1)),ye.load(t)}}function T(){this.mNumAllocated=0,this.mNumProperties=0,this.mProperties=[],this.toTHREE=function(e){for(var t=this,r=(this.mProperties[0].dataAsString(),new Ee),i=0;i<this.mProperties.length;i++)if("float"==Ze[t.mProperties[i].mKey]&&(r[Je[t.mProperties[i].mKey]]=t.mProperties[i].dataAsFloat()),"color"==Ze[t.mProperties[i].mKey]&&(r[Je[t.mProperties[i].mKey]]=t.mProperties[i].dataAsColor()),"bool"==Ze[t.mProperties[i].mKey]&&(r[Je[t.mProperties[i].mKey]]=t.mProperties[i].dataAsBool()),"string"==Ze[t.mProperties[i].mKey]&&(r[Je[t.mProperties[i].mKey]]=t.mProperties[i].dataAsString()),"map"==Ze[t.mProperties[i].mKey]){var n=t.mProperties[i];n.mSemantic==Xe&&(r.map=t.mProperties[i].dataAsMap()),n.mSemantic==He&&(r.normalMap=t.mProperties[i].dataAsMap()),n.mSemantic==qe&&(r.lightMap=t.mProperties[i].dataAsMap()),n.mSemantic==Ye&&(r.alphaMap=t.mProperties[i].dataAsMap())}return r.ambient.r=.53,r.ambient.g=.53,r.ambient.b=.53,r.color.r=1,r.color.g=1,r.color.b=1,r}}function E(e,t,r){var n=new i,a=1-r;return n.x=e.x*r+t.x*a,n.y=e.y*r+t.y*a,n.z=e.z*r+t.z*a,n}function C(e,t,r){return e.clone().slerp(t,1-r)}function L(e,t,r,i){if(1==e.length)return e[0].mValue.toTHREE();for(var n=1/0,a=null,o=null,s=0;s<e.length;s++){var l=Math.abs(e[s].mTime-t);l<n&&e[s].mTime<=t&&(n=l,a=e[s],o=e[s+1])}if(a){if(o){var c=o.mTime-a.mTime,u=a.mTime-t,h=u/c;return i(a.mValue.toTHREE(),o.mValue.toTHREE(),h)}o=e[0].clone(),o.mTime+=r;var c=o.mTime-a.mTime,u=a.mTime-t,h=u/c;return i(a.mValue.toTHREE(),o.mValue.toTHREE(),h)}return null}function N(){this.mNodeName="",this.mNumPositionKeys=0,this.mNumRotationKeys=0,this.mNumScalingKeys=0,this.mPositionKeys=[],this.mRotationKeys=[],this.mScalingKeys=[],this.mPreState="",this.mPostState="",this.init=function(e){function t(t){t.mTime/=e}e||(e=1),this.mPositionKeys.forEach(t),this.mRotationKeys.forEach(t),this.mScalingKeys.forEach(t)},this.sortKeys=function(){function e(e,t){return e.mTime-t.mTime}this.mPositionKeys.sort(e),this.mRotationKeys.sort(e),this.mScalingKeys.sort(e)},this.getLength=function(){return Math.max(Math.max.apply(null,this.mPositionKeys.map(function(e){return e.mTime})),Math.max.apply(null,this.mRotationKeys.map(function(e){return e.mTime})),Math.max.apply(null,this.mScalingKeys.map(function(e){return e.mTime})))},this.toTHREE=function(e,t){var i=this;this.sortKeys();for(var n=this.getLength(),a=new xe.KeyFrameTrack,o=0;o<n;o+=.05){var s=new r,l=o,c=L(i.mPositionKeys,l,n,E),u=L(i.mScalingKeys,l,n,E),h=L(i.mRotationKeys,l,n,C);s.compose(c,h,u);var d=new xe.KeyFrame(l,s);a.addKey(d)}a.target=e.findNode(this.mNodeName).toTHREE();var p=[a];if(e.nodeToBoneMap[this.mNodeName])for(var o=0;o<e.nodeToBoneMap[this.mNodeName].length;o++){var f=a.clone();f.target=e.nodeToBoneMap[i.mNodeName][o],p.push(f)}return p}}function O(){this.mName="",this.mDuration=0,this.mTicksPerSecond=0,this.mNumChannels=0,this.mChannels=[],this.toTHREE=function(e){var t=this,r=new xe.Animation;for(var i in t.mChannels){t.mChannels[i].init(t.mTicksPerSecond);var n=t.mChannels[i].toTHREE(e);for(var a in n)n[a].init(),r.addTrack(n[a])}return r.length=Math.max.apply(null,r.tracks.map(function(e){return e.length})),r}}function D(){this.mWidth=0,this.mHeight=0,this.texAchFormatHint=[],this.pcData=[]}function F(){this.mName="",this.mType=0,this.mAttenuationConstant=0,this.mAttenuationLinear=0,this.mAttenuationQuadratic=0,this.mAngleInnerCone=0,this.mAngleOuterCone=0,this.mColorDiffuse=null,this.mColorSpecular=null,this.mColorAmbient=null}function R(){this.mName="",this.mPosition=null,this.mLookAt=null,this.mUp=null,this.mHorizontalFOV=0,this.mClipPlaneNear=0,this.mClipPlaneFar=0,this.mAspect=0}function I(){this.mFlags=0,this.mNumMeshes=0,this.mNumMaterials=0,this.mNumAnimations=0,this.mNumTextures=0,this.mNumLights=0,this.mNumCameras=0,this.mRootNode=null,this.mMeshes=[],this.mMaterials=[],this.mAnimations=[],this.mLights=[],this.mCameras=[],this.nodeToBoneMap={},this.findNode=function(e,t){var r=this;if(t||(t=this.mRootNode),t.mName==e)return t;for(var i=0;i<t.mChildren.length;i++){var n=r.findNode(e,t.mChildren[i]);if(n)return n}return null},this.toTHREE=function(){var e=this;this.nodeCount=0,s(this);var t=this.mRootNode.toTHREE(this);for(var r in e.mMeshes)e.mMeshes[r].hookupSkeletons(e,t);if(this.mAnimations.length>0)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;i<r;i++)t[i]=Q(e)}function ee(e,t,r){for(var i=0;i<r;i++)t[i]=Z(e)}function te(e,t,r){for(var i=0;i<r;i++)t[i]=K(e)}function re(e,t,r){return e.Seek(sizeof(t)*r,$e)}function ie(e){if(!e)throw"asset failed"}function ne(e,t,r){var i=W(e);ie(i==Oe),W(e);var n=new S;if(n.mParent=t,n.mDepth=r,n.mName=q(e),n.mTransformation=J(e),n.mNumChildren=G(e),n.mNumMeshes=G(e),n.mNumMeshes){n.mMeshes=[];for(var a=0;a<n.mNumMeshes;++a)n.mMeshes[a]=G(e)}if(n.mNumChildren){n.mChildren=[];for(var a=0;a<n.mNumChildren;++a){var o=ne(e,n,r++);n.mChildren[a]=o}}return n}function ae(e,t){var r=W(e);return ie(r==Pe),W(e),t.mName=q(e),t.mNumWeights=G(e),t.mOffsetMatrix=J(e),be?re(e,t.mWeights,t.mNumWeights):(t.mWeights=[],$(e,t.mWeights,t.mNumWeights)),t}function se(e,t){var r=W(e);ie(r==Te),W(e),t.mPrimitiveTypes=G(e),t.mNumVertices=G(e),t.mNumFaces=G(e),t.mNumBones=G(e),t.mMaterialIndex=G(e),t.mNumUVComponents=[];var i=G(e);i&Re&&(be?re(e,t.mVertices,t.mNumVertices):(t.mVertices=[],t.mVertexBuffer=e.subArray32(e.readOffset,e.readOffset+3*t.mNumVertices*4),e.Seek(3*t.mNumVertices*4,$e))),i&Ie&&(be?re(e,t.mNormals,t.mNumVertices):(t.mNormals=[],t.mNormalBuffer=e.subArray32(e.readOffset,e.readOffset+3*t.mNumVertices*4),e.Seek(3*t.mNumVertices*4,$e))),i&ke&&(be?(re(e,t.mTangents,t.mNumVertices),re(e,t.mBitangents,t.mNumVertices)):(t.mTangents=[],t.mTangentBuffer=e.subArray32(e.readOffset,e.readOffset+3*t.mNumVertices*4),e.Seek(3*t.mNumVertices*4,$e),t.mBitangents=[],t.mBitangentBuffer=e.subArray32(e.readOffset,e.readOffset+3*t.mNumVertices*4),e.Seek(3*t.mNumVertices*4,$e)));for(var n=0;n<je&&i&o(n);++n)be?re(e,t.mColors[n],t.mNumVertices):(t.mColors[n]=[],t.mColorBuffer=e.subArray32(e.readOffset,e.readOffset+4*t.mNumVertices*4),e.Seek(4*t.mNumVertices*4,$e));t.mTexCoordsBuffers=[];for(var n=0;n<Ve&&i&a(n);++n)if(t.mNumUVComponents[n]=G(e),be)re(e,t.mTextureCoords[n],t.mNumVertices);else{t.mTextureCoords[n]=[],t.mTexCoordsBuffers[n]=[];for(var s=0;s<t.mNumVertices;s++)t.mTexCoordsBuffers[n].push(B(e)),t.mTexCoordsBuffers[n].push(B(e)),B(e)}if(be)G(e);else{t.mFaces=[],t.mIndexArray=[];for(var l=0;l<t.mNumFaces;++l){var c=t.mFaces[l]=new f;c.mNumIndices=V(e),c.mIndices=[];for(var u=0;u<c.mNumIndices;++u)t.mNumVertices<65536?c.mIndices[u]=V(e):c.mIndices[u]=G(e);if(3===c.mNumIndices)t.mIndexArray.push(c.mIndices[0]),t.mIndexArray.push(c.mIndices[1]),t.mIndexArray.push(c.mIndices[2]);else{if(4!==c.mNumIndices)throw new Error("Sorry, can't currently triangulate polys. Use the triangulate preprocessor in Assimp.");t.mIndexArray.push(c.mIndices[0]),t.mIndexArray.push(c.mIndices[1]),t.mIndexArray.push(c.mIndices[2]),t.mIndexArray.push(c.mIndices[2]),t.mIndexArray.push(c.mIndices[3]),t.mIndexArray.push(c.mIndices[0])}}}if(t.mNumBones){t.mBones=[];for(var u=0;u<t.mNumBones;++u)t.mBones[u]=new A,ae(e,t.mBones[u])}}function le(e,t){var r=W(e);ie(r==Fe),W(e),t.mKey=q(e),t.mSemantic=G(e),t.mIndex=G(e),t.mDataLength=G(e),t.mType=G(e),t.mData=[],e.ReadBytes(t.mData,1,t.mDataLength)}function ce(e,t){var r=W(e);if(ie(r==De),W(e),t.mNumAllocated=t.mNumProperties=G(e),t.mNumProperties){t.mProperties&&delete t.mProperties,t.mProperties=[];for(var i=0;i<t.mNumProperties;++i)t.mProperties[i]=new M,le(e,t.mProperties[i])}}function ue(e,t){var r=W(e);ie(r==Ce),W(e),t.mNodeName=q(e),t.mNumPositionKeys=G(e),t.mNumRotationKeys=G(e),t.mNumScalingKeys=G(e),t.mPreState=G(e),t.mPostState=G(e),t.mNumPositionKeys&&(be?re(e,t.mPositionKeys,t.mNumPositionKeys):(t.mPositionKeys=[],ee(e,t.mPositionKeys,t.mNumPositionKeys))),t.mNumRotationKeys&&(be?re(e,t.mRotationKeys,t.mNumRotationKeys):(t.mRotationKeys=[],te(e,t.mRotationKeys,t.mNumRotationKeys))),t.mNumScalingKeys&&(be?re(e,t.mScalingKeys,t.mNumScalingKeys):(t.mScalingKeys=[],ee(e,t.mScalingKeys,t.mNumScalingKeys)))}function he(e,t){var r=W(e);if(ie(r==Ne),W(e),t.mName=q(e),t.mDuration=z(e),t.mTicksPerSecond=z(e),t.mNumChannels=G(e),t.mNumChannels){t.mChannels=[];for(var i=0;i<t.mNumChannels;++i)t.mChannels[i]=new N,ue(e,t.mChannels[i])}}function de(e,t){var r=W(e);ie(r==Ae),W(e),t.mWidth=G(e),t.mHeight=G(e),e.ReadBytes(t.achFormatHint,1,4),be||(t.mHeight?(t.pcData=[],e.ReadBytes(t.pcData,1,t.mWidth*t.mHeight*4)):(t.pcData=[],e.ReadBytes(t.pcData,1,t.mWidth)))}function pe(e,t){var r=W(e);ie(r==Se),W(e),t.mName=q(e),t.mType=G(e),t.mType!=Ge&&(t.mAttenuationConstant=B(e),t.mAttenuationLinear=B(e),t.mAttenuationQuadratic=B(e)),t.mColorDiffuse=H(e),t.mColorSpecular=H(e),t.mColorAmbient=H(e),t.mType==We&&(t.mAngleInnerCone=B(e),t.mAngleOuterCone=B(e))}function fe(e,t){var r=W(e);ie(r==_e),W(e),t.mName=q(e),t.mPosition=X(e),t.mLookAt=X(e),t.mUp=X(e),t.mHorizontalFOV=B(e),t.mClipPlaneNear=B(e),t.mClipPlaneFar=B(e),t.mAspect=B(e)}function me(e,t){var r=W(e);if(ie(r==Le),W(e),t.mFlags=G(e),t.mNumMeshes=G(e),t.mNumMaterials=G(e),t.mNumAnimations=G(e),t.mNumTextures=G(e),t.mNumLights=G(e),t.mNumCameras=G(e),t.mRootNode=new S,t.mRootNode=ne(e,null,0),t.mNumMeshes){t.mMeshes=[];for(var i=0;i<t.mNumMeshes;++i)t.mMeshes[i]=new p,se(e,t.mMeshes[i])}if(t.mNumMaterials){t.mMaterials=[];for(var i=0;i<t.mNumMaterials;++i)t.mMaterials[i]=new T,ce(e,t.mMaterials[i])}if(t.mNumAnimations){t.mAnimations=[];for(var i=0;i<t.mNumAnimations;++i)t.mAnimations[i]=new O,he(e,t.mAnimations[i])}if(t.mNumTextures){t.mTextures=[];for(var i=0;i<t.mNumTextures;++i)t.mTextures[i]=new D,de(e,t.mTextures[i])}if(t.mNumLights){t.mLights=[];for(var i=0;i<t.mNumLights;++i)t.mLights[i]=new F,pe(e,t.mLights[i])}if(t.mNumCameras){t.mCameras=[];for(var i=0;i<t.mNumCameras;++i)t.mCameras[i]=new R,fe(e,t.mCameras[i])}}function ve(e){e.readOffset=0,e.Seek=function(t,r){r==$e&&(e.readOffset+=t),r==et&&(e.readOffset=t)},e.ReadBytes=function(e,t,r){for(var i=this,n=t*r,a=0;a<n;a++)e[a]=j(i)},e.subArray32=function(e,t){var r=this.buffer,i=r.slice(e,t);return new Float32Array(i)},e.subArrayUint16=function(e,t){var r=this.buffer,i=r.slice(e,t);return new Uint16Array(i)},e.subArrayUint8=function(e,t){var r=this.buffer,i=r.slice(e,t);return new Uint8Array(i)},e.subArrayUint32=function(e,t){var r=this.buffer,i=r.slice(e,t);return new Uint32Array(i)}}function ge(e){var t=new I,r=new DataView(e);ve(r),r.Seek(44,$e);G(r),G(r),G(r),G(r);if(be=V(r)>0,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<this.length*this.fps;t++)for(var r=0;r<this.keys.length;r++){if(e.keys[r].time==t){e._accelTable[t]=r;break}if(e.keys[r].time<t/e.fps&&e.keys[r+1]&&e.keys[r+1].time>=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;n<i.length;n++)t.addKey(new xe.KeyFrame(n/r||i[n].time,i[n].targets[0].data));this.init()},this.parseFromCollada=function(e){for(var t=this,r=e.keys,i=this.fps,n=0;n<r.length;n++)t.addKey(new xe.KeyFrame(n/i||r[n].time,r[n].matrix));this.init()},this.sortKeys=function(){this.keys.sort(this.keySortFunc)},this.keySortFunc=function(e,t){return e.time-t.time},this.clone=function(){var e=this,t=new xe.KeyFrameTrack;t.target=this.target,t.time=this.time,t.length=this.length;for(var r=0;r<this.keys.length;r++)t.addKey(e.keys[r].clone());return t.init(),t},this.reTarget=function(e,t){t||(t=xe.TrackTargetNodeNameCompare),this.target=t(e,this.target)},this.keySearchAccel=function(e){return e*=this.fps,e=Math.floor(e),this._accelTable[e]||0},this.setTime=function(e){var t=this;e=Math.abs(e),this.length&&(e=e%this.length+.05);for(var r=null,i=null,n=this.keySearchAccel(e);n<this.keys.length;n++){if(t.keys[n].time==e){r=t.keys[n],i=t.keys[n];break}if(t.keys[n].time<e&&t.keys[n+1]&&t.keys[n+1].time>e){r=t.keys[n],i=t.keys[n+1];break}if(t.keys[n].time<e&&n==t.keys.length-1){r=t.keys[n],i=t.keys[0].clone(),i.time+=t.length+.05;break}}return r&&i&&r!==i?(this.target.matrixAutoUpdate=!1,this.target.matrix.copy(r.lerp(i,e)),void(this.target.matrixWorldNeedsUpdate=!0)):r&&i&&r==i?(this.target.matrixAutoUpdate=!1,this.target.matrix.copy(r.matrix),void(this.target.matrixWorldNeedsUpdate=!0)):void 0}},xe.TrackTargetNodeNameCompare=function(e,t){function r(e,t){if(e.name==t)return e;for(var i=0;i<e.children.length;i++){var n=r(e.children[i],t);if(n)return n}return null}return r(e,t.name)},xe.Animation=function(){this.tracks=[],this.length=0,this.addTrack=function(e){this.tracks.push(e),this.length=Math.max(e.length,this.length)},this.setTime=function(e){var t=this;this.time=e;for(var r=0;r<this.tracks.length;r++)t.tracks[r].setTime(e)},this.clone=function(e,t){var r=this;t||(t=xe.TrackTargetNodeNameCompare);var i=new xe.Animation;i.target=e;for(var n=0;n<this.tracks.length;n++){var a=r.tracks[n].clone();a.reTarget(e,t),i.addTrack(a)}return i}};var be,we,_e=4660,Se=4661,Ae=4662,Te=4663,Ce=4664,Le=4665,Pe=4666,Ne=4667,Oe=4668,De=4669,Fe=4670,Re=1,Ie=2,ke=4,Be=256,ze=65536,je=1,Ve=4,Ge=1,We=3,Xe=1,He=6,Ye=8,qe=10,Qe=4,Je={"?mat.name":"name","$mat.shadingm":"shading","$mat.twosided":"twoSided","$mat.wireframe":"wireframe","$clr.ambient":"ambient","$clr.diffuse":"color","$clr.specular":"specular","$clr.emissive":"emissive","$clr.transparent":"transparent","$clr.reflective":"reflect","$mat.shininess":"shininess","$mat.reflectivity":"reflectivity","$mat.refracti":"refraction","$tex.file":"map"},Ze={"?mat.name":"string","$mat.shadingm":"bool","$mat.twosided":"bool","$mat.wireframe":"bool","$clr.ambient":"color","$clr.diffuse":"color","$clr.specular":"color","$clr.emissive":"color","$clr.transparent":"color","$clr.reflective":"color","$mat.shininess":"float","$mat.reflectivity":"float","$mat.refracti":"float","$tex.file":"map"},Ke=!0,$e=0,et=1;return ge(e)}};var Yp=1,qp=2,Qp=3,Jp=4,Zp=5,Kp=6,$p=7,ef=8,tf=21,rf=23,nf=41,af=42,of=43,sf=44,lf=45,cf=46,uf=47,hf=21,df=23,pf=4,ff=5,mf=7,vf=8,gf=!0;Ut.prototype={set:function(e,t){this[e]=t},get:function(e,t){return this.hasOwnProperty(e)?this[e]:t}};var yf=function(e){this.manager=void 0!==e?e:Du,this.trunk=new c,this.materialFactory=void 0,this._url="",this._baseDir="",this._data=void 0,this._ptr=0,this._version=[],this._streaming=!1,this._optimized_for_accuracy=!1,this._compression=0,this._bodylen=4294967295,this._blocks=[new It],this._accuracyMatrix=!1,this._accuracyGeo=!1,this._accuracyProps=!1};yf.prototype={constructor:yf,load:function(e,t,r,i){var n=this;this._url=e,this._baseDir=e.substr(0,e.lastIndexOf("/")+1);var a=new we(this.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){t(n.parse(e))},r,i)},parse:function(e){var t=this,r=e.byteLength;for(this._ptr=0,this._data=new DataView(e),this._parseHeader(),0!=this._compression&&console.error("compressed AWD not supported"),this._streaming||this._bodylen==e.byteLength-this._ptr||console.error("AWDLoader: body len does not match file length",this._bodylen,r-this._ptr);this._ptr<r;)t.parseNextBlock();return this.trunk},parseNextBlock:function(){var e,t,r,i,n=this.readU32(),t=(this.readU8(),this.readU8()),r=(this.readU8(),this.readU32());switch(t){case 1:e=this.parseMeshData(r);break;case 22:e=this.parseContainer(r);break;case 23:e=this.parseMeshInstance(r);break;case 81:e=this.parseMaterial(r);break;case 82:e=this.parseTexture(r);break;case 101:e=this.parseSkeleton(r);break;case 112:e=this.parseMeshPoseAnimation(r,!1);break;case 113:e=this.parseVertexAnimationSet(r);break;case 102:e=this.parseSkeletonPose(r);break;case 103:e=this.parseSkeletonAnimation(r);break;case 122:e=this.parseAnimatorSet(r);break;default:this._ptr+=r}this._blocks[n]=i=new It,i.data=e,i.id=n},_parseHeader:function(){var e=this._version,t=this.readU8()<<16|this.readU8()<<8|this.readU8();if(4282180!=t)throw new Error("AWDLoader - bad magic");e[0]=this.readU8(),e[1]=this.readU8();var r=this.readU16();this._streaming=1==(1&r),2===e[0]&&1===e[1]&&(this._accuracyMatrix=2===(2&r),this._accuracyGeo=4===(4&r),this._accuracyProps=8===(8&r)),this._geoNrType=this._accuracyGeo?vf:mf,this._matrixNrType=this._accuracyMatrix?vf:mf,this._propsNrType=this._accuracyProps?vf:mf,this._optimized_for_accuracy=2===(2&r),this._compression=this.readU8(),this._bodylen=this.readU32()},parseContainer:function(e){var t,r=new c,i=this.readU32(),n=this.parseMatrix4();return r.name=this.readUTF(),r.applyMatrix(n),t=this._blocks[i].data||this.trunk,t.add(r),this.parseProperties({1:this._matrixNrType,2:this._matrixNrType,3:this._matrixNrType,4:pf}),r.extra=this.parseUserAttributes(),r},parseMeshInstance:function(e){var t,r,i,n,a,o,s,l,u,h,d,p,f,m,v=this;for(o=this.readU32(),l=this.parseMatrix4(),t=this.readUTF(),s=this.readU32(),p=this.readU16(),i=this.getBlock(s),u=[],m=0;m<p;m++)d=v.readU32(),h=v.getBlock(d),u.push(h);if(n=i.length,a=[],n>1)for(r=new c,m=0;m<n;m++){var g=new k(i[m]);a.push(g),r.add(g)}else r=new k(i[0]),a.push(r);r.applyMatrix(l),r.name=t,f=this.getBlock(o)||this.trunk,f.add(r);var y=u.length,x=Math.max(n,y);for(m=0;m<x;m++)a[m%n].material=u[m%y];return this.parseProperties(null),r.extra=this.parseUserAttributes(),r},parseMaterial:function(e){var t,r,i,n,a,o,s,l=this;for(t=this.readUTF(),r=this.readU8(),o=this.readU8(),i=this.parseProperties({1:Qp,2:rf,11:tf,12:$p,13:tf}),s=0;s<o;){l.readU16();l.parseProperties(null),l.parseUserAttributes()}if(a=this.parseUserAttributes(),void 0!==this.materialFactory&&(n=this.materialFactory(t)))return n;if(n=new Ee,1===r)n.color.setHex(i.get(1,13421772));else if(2===r){var c=i.get(2,0);n.map=this.getBlock(c)}return n.extra=a,n.alphaThreshold=i.get(12,0),n.repeat=i.get(13,!1),n},parseTexture:function(e){var t,r,i=(this.readUTF(),this.readU8());if(0===i){r=this.readU32();var n=this.readUTFBytes(r);console.log(n),t=this.loadTexture(n)}return this.parseProperties(null),this.parseUserAttributes(),t},loadTexture:function(e){var t=new ve,r=new Ie(this.manager);return r.load(this._baseDir+e,function(e){t.image=e,t.needsUpdate=!0}),t},parseSkeleton:function(e){var t=this,r=(this.readUTF(),this.readU16()),i=[],n=0;for(this.parseProperties(null);n<r;){var a,o;t.readU16(),a=new oe,a.parent=t.readU16()-1,a.name=t.readUTF(),o=t.parseMatrix4(),a.skinMatrix=o,t.parseProperties(null),t.parseUserAttributes(),i.push(a),n++}return this.parseUserAttributes(),i},parseSkeletonPose:function(e){var t=this,i=(this.readUTF(),this.readU16());this.parseProperties(null);for(var n=[],a=0;a<i;){var o,s;o=t.readU8(),s=1===o?t.parseMatrix4():new r,n[a]=s,a++}return this.parseUserAttributes(),n},parseSkeletonAnimation:function(e){var t,r,i,n=this,a=(this.readUTF(),[]),o=this.readU16();this.parseProperties(null);for(var s=0;s<o;)r=n.readU32(),t=n.readU16(),i=n._blocks[r].data,a.push({pose:i,duration:t}),s++;if(0!==a.length)return this.parseUserAttributes(),a},parseVertexAnimationSet:function(e){for(var t,r=this,i=(this.readUTF(),this.readU16()),n=(this.parseProperties({1:ff}),0),a=[];n<i;)t=r.readU32(),a.push(r._blocks[t].data),n++;return this.parseUserAttributes(),a},parseAnimatorSet:function(e){var t,r,i=this,n=(this.readUTF(),this.readU16()),a=this.parseProperties({1:df});t=this.readU32();for(var o=this.readU16(),s=[],l=0;l<o;l++)s.push(i.readU32());this.readU16(),Boolean(this.readU8());this.parseUserAttributes(),this.parseUserAttributes();var c=[];for(l=0;l<s.length;l++)c.push(i._blocks[s[l]].data);r=this._blocks[t].data;var u;for(1==n&&(u={animationSet:r,skeleton:this._blocks[a.get(1,0)].data}),l=0;l<c.length;l++)c[l].animator=u;return u},parseMeshData:function(e){var t,r,i=this,n=this.readUTF(),a=this.readU16(),o=0,s=[];for(this.parseProperties({1:this._geoNrType,2:this._geoNrType});o<a;){var l,c,u;for(t=new P,t.name=n,s.push(t),l=i.readU32(),c=i._ptr+l,i.parseProperties({1:i._geoNrType,2:i._geoNrType});this._ptr<c;){var h=0,d=i.readU8(),p=(i.readU8(),i.readU32()),f=p+i._ptr;if(1===d)for(r=new Float32Array(p/12*3),u=new g(r,3),t.addAttribute("position",u),h=0;this._ptr<f;)r[h]=-i.readF32(),r[h+1]=i.readF32(),r[h+2]=i.readF32(),h+=3;else if(2===d)for(r=new Uint16Array(p/2),u=new g(r,1),t.setIndex(u),h=0;this._ptr<f;)r[h+1]=i.readU16(),r[h]=i.readU16(),r[h+2]=i.readU16(),h+=3;else if(3===d)for(r=new Float32Array(p/8*2),u=new g(r,2),t.addAttribute("uv",u),h=0;this._ptr<f;)r[h]=i.readF32(),r[h+1]=1-i.readF32(),h+=2;else if(4===d)for(r=new Float32Array(p/12*3),u=new g(r,3),t.addAttribute("normal",u),h=0;this._ptr<f;)r[h]=-i.readF32(),r[h+1]=i.readF32(),r[h+2]=i.readF32(),h+=3;else i._ptr=f}i.parseUserAttributes(),t.computeBoundingSphere(),o++}return this.parseUserAttributes(),s},parseMeshPoseAnimation:function(e,t){var r,i,n,a,o,s,l,c,u,h,d=this,p=1,f=0,m={},v=[],g=(this.readUTF(),this.readU32()),y=this.getBlock(g);if(null===y)return void console.log("parseMeshPoseAnimation target mesh not found at:",g);for(l=y.geometry,l.morphTargets=[],t||(p=this.readU16()),r=this.readU16(),c=this.readU16(),u=0;u<c;)v.push(d.readU16()),u++;for(h=this.parseProperties({1:hf,2:hf}),m.looping=h.get(1,!0),m.stitchFinalFrame=h.get(2,!1),i=0;i<p;){for(a=d.readU16(),n=0;n<r;)for(u=0,o=d.readU32(),s=d._ptr+o;u<c;){if(1===v[u]){var x=new Float32Array(o/4);for(l.morphTargets.push({array:x}),f=0;this._ptr<s;)x[f]=d.readF32(),x[f+1]=d.readF32(),x[f+2]=d.readF32(),f+=3;n++}else d._ptr=s;u++}i++}return this.parseUserAttributes(),null},getBlock:function(e){return this._blocks[e].data},parseMatrix4:function(){var e=new r,t=e.elements;return t[0]=this.readF32(),t[1]=this.readF32(),t[2]=this.readF32(),t[3]=0,t[4]=this.readF32(),t[5]=this.readF32(),t[6]=this.readF32(),t[7]=0,t[8]=this.readF32(),t[9]=this.readF32(),t[10]=this.readF32(),t[11]=0,t[12]=-this.readF32(),t[13]=this.readF32(),t[14]=this.readF32(),t[15]=1,e},parseProperties:function(e){var t=this,r=this.readU32(),i=this._ptr+r,n=new Ut;if(e)for(;this._ptr<i;){var a,o=t.readU16(),s=t.readU32();e.hasOwnProperty(o)?(a=e[o],n.set(o,t.parseAttrValue(a,s))):t._ptr+=s}return n},parseUserAttributes:function(){return this._ptr=this.readU32()+this._ptr,null},parseAttrValue:function(e,t){var r,i,n=this;switch(e){case Yp:r=1,i=this.readI8;break;case qp:r=2,i=this.readI16;break;case Qp:r=4,i=this.readI32;break;case tf:case Jp:r=1,i=this.readU8;break;case Zp:r=2,i=this.readU16;break;case Kp:case rf:r=4,i=this.readU32;break;case $p:r=4,i=this.readF32;break;case ef:r=8,i=this.readF64;break;case nf:case af:case of:case sf:case lf:case cf:case uf:r=8,i=this.readF64}if(r<t){var a,o,s;for(a=[],o=0,s=t/r;o<s;)a.push(i.call(n)),o++;return a}return i.call(this)},readU8:function(){return this._data.getUint8(this._ptr++)},readI8:function(){return this._data.getInt8(this._ptr++)},readU16:function(){var e=this._data.getUint16(this._ptr,gf);return this._ptr+=2,e},readI16:function(){var e=this._data.getInt16(this._ptr,gf);
|
|
return this._ptr+=2,e},readU32:function(){var e=this._data.getUint32(this._ptr,gf);return this._ptr+=4,e},readI32:function(){var e=this._data.getInt32(this._ptr,gf);return this._ptr+=4,e},readF32:function(){var e=this._data.getFloat32(this._ptr,gf);return this._ptr+=4,e},readF64:function(){var e=this._data.getFloat64(this._ptr,gf);return this._ptr+=8,e},readUTF:function(){var e=this.readU16();return this.readUTFBytes(e)},readUTFBytes:function(e){for(var t=this,r=[],i=0;r.length<e;){var n=t._data.getUint8(t._ptr++,gf);if(n<128)r[i++]=String.fromCharCode(n);else if(n>191&&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;r<i;r++){var n=e.materials[r],a=new Ee;a.name=n.name,a.color.fromArray(n.diffuse),a.emissive.fromArray(n.emissive),a.specular.fromArray(n.specular),a.shininess=n.specularPower,a.opacity=n.alpha,t[n.id]=a}if(e.multiMaterials)for(var r=0,i=e.multiMaterials.length;r<i;r++){var n=e.multiMaterials[r];console.warn("BabylonLoader: Multi materials not yet supported."),t[n.id]=new Ee}return t}function r(e){var t=new P,r=e.indices,i=e.positions,n=e.normals,a=e.uvs;t.setIndex(r);for(var o=2,s=i.length;o<s;o+=3)i[o]=-i[o];if(t.addAttribute("position",new M(i,3)),n){for(var o=2,s=n.length;o<s;o+=3)n[o]=-n[o];t.addAttribute("normal",new M(n,3))}a&&t.addAttribute("uv",new M(a,2));var l=e.subMeshes;if(l)for(var o=0,s=l.length;o<s;o++){var c=l[o];t.addGroup(c.indexStart,c.indexCount)}return t}function i(e,t){for(var i={},n=new fe,a=e.cameras,o=0,s=a.length;o<s;o++){var l=a[o],c=new de(l.fov/Math.PI*180,1.33,l.minZ,l.maxZ);c.name=l.name,c.position.fromArray(l.position),l.rotation&&c.rotation.fromArray(l.rotation),i[l.id]=c}for(var u=e.lights,o=0,s=u.length;o<s;o++){var h,l=u[o];switch(l.type){case 0:h=new zt;break;case 1:h=new Vt;break;case 2:h=new Wt;break;case 3:h=new Xt}h.name=l.name,l.position&&h.position.set(l.position[0],l.position[1],-l.position[2]),h.color.fromArray(l.diffuse),l.groundColor&&h.groundColor.fromArray(l.groundColor),l.intensity&&(h.intensity=l.intensity),i[l.id]=h,n.add(h)}for(var d=e.meshes,o=0,s=d.length;o<s;o++){var p,l=d[o];if(l.indices){var f=r(l);p=new k(f,t[l.materialId])}else p=new Dt;p.name=l.name,p.position.set(l.position[0],l.position[1],-l.position[2]),p.rotation.fromArray(l.rotation),l.rotationQuaternion&&p.quaternion.fromArray(l.rotationQuaternion),p.scale.fromArray(l.scaling),l.parentId?i[l.parentId].add(p):n.add(p),i[l.id]=p}return n}var n=t(e),a=i(e,n);return a}};var bf=function(e){this.manager=void 0!==e?e:Du,this.animateBonePositions=!0,this.animateBoneRotations=!0};bf.prototype={constructor:bf,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){"HIERARCHY"!==l(e)&&console.error("BVHLoader: HIERARCHY expected.");var t=[],i=a(e,l(e),t);"MOTION"!==l(e)&&console.error("BVHLoader: MOTION expected.");var n=l(e).split(/[\s]+/),o=parseInt(n[1]);isNaN(o)&&console.error("BVHLoader: Failed to read number of frames."),n=l(e).split(/[\s]+/);var s=parseFloat(n[2]);isNaN(s)&&console.error("BVHLoader: Failed to read frame time.");for(var c=0;c<o;c++)n=l(e).split(/[\s]+/),r(n,c*s,i);return t}function r(e,t,a){if("ENDSITE"!==a.type){var o={time:t,position:new i,rotation:new n};a.frames.push(o);for(var s=new n,l=new i(1,0,0),c=new i(0,1,0),u=new i(0,0,1),h=0;h<a.channels.length;h++)switch(a.channels[h]){case"Xposition":o.position.x=parseFloat(e.shift().trim());break;case"Yposition":o.position.y=parseFloat(e.shift().trim());break;case"Zposition":o.position.z=parseFloat(e.shift().trim());break;case"Xrotation":s.setFromAxisAngle(l,parseFloat(e.shift().trim())*Math.PI/180),o.rotation.multiply(s);break;case"Yrotation":s.setFromAxisAngle(c,parseFloat(e.shift().trim())*Math.PI/180),o.rotation.multiply(s);break;case"Zrotation":s.setFromAxisAngle(u,parseFloat(e.shift().trim())*Math.PI/180),o.rotation.multiply(s);break;default:console.warn("BVHLoader: Invalid channel type.")}for(var h=0;h<a.children.length;h++)r(e,t,a.children[h])}}function a(e,t,r){var n={name:"",type:"",frames:[]};r.push(n);var o=t.split(/[\s]+/);"END"===o[0].toUpperCase()&&"SITE"===o[1].toUpperCase()?(n.type="ENDSITE",n.name="ENDSITE"):(n.name=o[1],n.type=o[0].toUpperCase()),"{"!==l(e)&&console.error("BVHLoader: Expected opening { after type & name"),o=l(e).split(/[\s]+/),"OFFSET"!==o[0]&&console.error("BVHLoader: Expected OFFSET but got: "+o[0]),4!==o.length&&console.error("BVHLoader: Invalid number of values for OFFSET.");var s=new i(parseFloat(o[1]),parseFloat(o[2]),parseFloat(o[3]));if((isNaN(s.x)||isNaN(s.y)||isNaN(s.z))&&console.error("BVHLoader: Invalid values of OFFSET."),n.offset=s,"ENDSITE"!==n.type){o=l(e).split(/[\s]+/),"CHANNELS"!==o[0]&&console.error("BVHLoader: Expected CHANNELS definition.");var c=parseInt(o[1]);n.channels=o.splice(2,c),n.children=[]}for(;;){var u=l(e);if("}"===u)return n;n.children.push(a(e,u,r))}}function o(e,t){var r=new oe;if(t.push(r),r.position.add(e.offset),r.name=e.name,"ENDSITE"!==e.type)for(var i=0;i<e.children.length;i++)r.add(o(e.children[i],t));return r}function s(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];if("ENDSITE"!==i.type){for(var n=[],a=[],o=[],s=0;s<i.frames.length;s++){var l=i.frames[s];n.push(l.time),a.push(l.position.x+i.offset.x),a.push(l.position.y+i.offset.y),a.push(l.position.z+i.offset.z),o.push(l.rotation.x),o.push(l.rotation.y),o.push(l.rotation.z),o.push(l.rotation.w)}c.animateBonePositions&&t.push(new te(".bones["+i.name+"].position",n,a)),c.animateBoneRotations&&t.push(new $(".bones["+i.name+"].quaternion",n,o))}}return new re("animation",(-1),t)}function l(e){for(var t;0===(t=e.shift().trim()).length;);return t}var c=this,u=e.split(/[\r\n]+/g),h=t(u),d=[];o(h[0],d);var p=s(h);return{skeleton:new Ft(d),clip:p}}},Ht.prototype=Object.assign(Object.create(kt.prototype),{constructor:Ht,isAmbientLight:!0}),Yt.prototype=Object.assign(Object.create(B.prototype),{constructor:Yt,isLineSegments:!0,computeLineDistances:function(){var e=new i,t=new i;return function(){var r=this.geometry;if(r.isBufferGeometry)if(null===r.index){for(var i=r.attributes.position,n=[],a=0,o=i.count;a<o;a+=2)e.fromBufferAttribute(i,a),t.fromBufferAttribute(i,a+1),n[a]=0===a?0:n[a-1],n[a+1]=n[a]+e.distanceTo(t);r.addAttribute("lineDistance",new M(n,1))}else console.warn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(r.isGeometry)for(var s=r.vertices,n=r.lineDistances,a=0,o=s.length;a<o;a+=2)e.copy(s[a]),t.copy(s[a+1]),n[a]=0===a?0:n[a-1],n[a+1]=n[a]+e.distanceTo(t);return this}}()});var wf=function(e){this.manager=void 0!==e?e:Du};wf.prototype={constructor:wf,load:function(e,t,r,i){var n=this,a=new ve,o=new we(this.manager);return o.setResponseType("arraybuffer"),o.setPath(this.path),o.load(e,function(e){a.image=n.parse(e),a.needsUpdate=!0,void 0!==t&&t(a)},r,i),a},parse:function(e){function t(e){switch(e.image_type){case h:case f:(e.colormap_length>256||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<s;)if(c=n[i++],u=(127&c)+1,128&c){for(h=0;h<o;++h)p[h]=n[i++];for(h=0;h<u;++h)a.set(p,d+h*o);d+=o*u}else{for(u*=o,h=0;h<u;++h)a[d+h]=n[i++];d+=u}}else a=n.subarray(i,i+=t?r.width*r.height:s);return{pixel_data:a,palettes:l}}function i(e,t,r,i,n,a,o,s,l){var c,u,h,d=l,p=0,f=M.width;for(h=t;h!==i;h+=r)for(u=n;u!==o;u+=a,p++)c=s[p],e[4*(u+f*h)+3]=255,e[4*(u+f*h)+2]=d[3*c+0],e[4*(u+f*h)+1]=d[3*c+1],e[4*(u+f*h)+0]=d[3*c+2];return e}function n(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+=2)l=s[h+0]+(s[h+1]<<8),e[4*(c+d*u)+0]=(31744&l)>>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;n<a;n++){var o=i[n];o.nodeName===t&&r.push(o)}return r}function s(e){if(0===e.length)return[];for(var t=e.trim().split(/\s+/),r=new Array(t.length),i=0,n=t.length;i<n;i++)r[i]=t[i];return r}function l(e){if(0===e.length)return[];for(var t=e.trim().split(/\s+/),r=new Array(t.length),i=0,n=t.length;i<n;i++)r[i]=parseFloat(t[i]);return r}function c(e){if(0===e.length)return[];for(var t=e.trim().split(/\s+/),r=new Array(t.length),i=0,n=t.length;i<n;i++)r[i]=parseInt(t[i]);return r}function h(e){return e.substring(1)}function d(){return"three_default_"+Jt++}function p(e){return 0===Object.keys(e).length}function f(e){return{unit:m(a(e,"unit")[0]),upAxis:v(a(e,"up_axis")[0])}}function m(e){return void 0!==e&&e.hasAttribute("meter")===!0?parseFloat(e.getAttribute("meter")):1}function v(e){return void 0!==e?e.textContent:"Y_UP"}function g(e,t,r,i){var n=a(e,t)[0];if(void 0!==n)for(var o=a(n,r),s=0;s<o.length;s++)i(o[s])}function y(e,t){for(var r in e){var i=e[r];i.build=t(e[r])}}function x(e,t){return void 0!==e.build?e.build:(e.build=t(e),e.build)}function b(e){for(var t={sources:{},samplers:{},channels:{}},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType){var a;switch(n.nodeName){case"source":a=n.getAttribute("id"),t.sources[a]=Be(n);break;case"sampler":a=n.getAttribute("id"),t.samplers[a]=w(n);break;case"channel":a=n.getAttribute("target"),t.channels[a]=_(n);break;default:console.log(n)}}}Zt.animations[e.getAttribute("id")]=t}function w(e){for(var t={inputs:{}},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"input":var a=h(n.getAttribute("source")),o=n.getAttribute("semantic");t.inputs[o]=a}}return t}function _(e){var t={},r=e.getAttribute("target"),i=r.split("/"),n=i.shift(),a=i.shift(),o=a.indexOf("(")!==-1,s=a.indexOf(".")!==-1;if(s)i=a.split("."),a=i.shift(),t.member=i.shift();else if(o){var l=a.split("(");a=l.shift();for(var c=0;c<l.length;c++)l[c]=parseInt(l[c].replace(/\)/,""));t.indices=l}return t.id=n,t.sid=a,t.arraySyntax=o,t.memberSyntax=s,t.sampler=h(e.getAttribute("source")),t}function S(e){var t=[],r=e.channels,i=e.samplers,n=e.sources;for(var a in r)if(r.hasOwnProperty(a)){var o=r[a],s=i[o.sampler],l=s.inputs.INPUT,c=s.inputs.OUTPUT,u=n[l],h=n[c],d=T(o,u,h);C(d,t)}return t}function A(e){return x(Zt.animations[e],S)}function T(e,t,r){var i,n,a,o,s,l,c=Zt.nodes[e.id],u=wt(c.id),h=c.transforms[e.sid],d=c.matrix.clone().transpose(),p={};switch(h){case"matrix":for(a=0,o=t.array.length;a<o;a++)if(i=t.array[a],n=a*r.stride,void 0===p[i]&&(p[i]={}),e.arraySyntax===!0){var f=r.array[n],m=e.indices[0]+4*e.indices[1];p[i][m]=f}else for(s=0,l=r.stride;s<l;s++)p[i][s]=r.array[n+s];break;case"translate":console.warn('ColladaLoader: Animation transform type "%s" not yet implemented.',h);break;case"rotate":console.warn('ColladaLoader: Animation transform type "%s" not yet implemented.',h);break;case"scale":console.warn('ColladaLoader: Animation transform type "%s" not yet implemented.',h)}var v=E(p,d),g={name:u.uuid,keyframes:v};return g}function E(e,t){function r(e,t){return e.time-t.time}var i=[];for(var n in e)i.push({time:parseFloat(n),value:e[n]});i.sort(r);for(var a=0;a<16;a++)L(i,a,t.elements[a]);return i}function C(e,t){for(var r=e.keyframes,i=e.name,n=[],a=[],o=[],s=[],l=0,c=r.length;l<c;l++){var u=r[l],h=u.time,d=u.value;Nt.fromArray(d).transpose(),Nt.decompose(Ct,Pt,Lt),n.push(h),a.push(Ct.x,Ct.y,Ct.z),o.push(Pt.x,Pt.y,Pt.z,Pt.w),s.push(Lt.x,Lt.y,Lt.z)}return a.length>0&&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<a;n++)i=e[n],void 0===i.value[t]?i.value[t]=null:o=!1;if(o===!0)for(n=0,a=e.length;n<a;n++)i=e[n],i.value[t]=r;else N(e,t)}function N(e,t){for(var r,i,n=0,a=e.length;n<a;n++){var o=e[n];if(null===o.value[t]){if(r=O(e,n,t),i=D(e,n,t),null===r){o.value[t]=i.value[t];continue}if(null===i){o.value[t]=r.value[t];continue}I(o,r,i,t)}}}function O(e,t,r){for(;t>=0;){var i=e[t];if(null!==i.value[r])return i;t--}return null}function D(e,t,r){for(;t<e.length;){var i=e[t];if(null!==i.value[r])return i;t++}return null}function I(e,t,r,i){return r.time-t.time===0?void(e.value[i]=t.value[i]):void(e.value[i]=(e.time-t.time)*(r.value[i]-t.value[i])/(r.time-t.time)+t.value[i])}function U(e){for(var t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"instance_animation":t.animations.push(h(n.getAttribute("url")))}}Zt.clips[e.getAttribute("id")]=t}function z(e){for(var t=[],r=e.name,i=e.end-e.start||-1,n=e.animations,a=0,o=n.length;a<o;a++)for(var s=A(n[a]),l=0,c=s.length;l<c;l++)t.push(s[l]);return new re(r,i,t)}function j(e){return x(Zt.clips[e],z)}function V(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"skin":t.id=h(n.getAttribute("source")),t.skin=G(n);break;case"morph":t.id=h(n.getAttribute("source")),console.warn("ColladaLoader: Morph target animation not supported yet.")}}Zt.controllers[e.getAttribute("id")]=t}function G(e){for(var t={sources:{}},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=l(n.textContent);break;case"source":var a=n.getAttribute("id");t.sources[a]=Be(n);break;case"joints":t.joints=W(n);break;case"vertex_weights":t.vertexWeights=X(n)}}return t}function W(e){for(var t={inputs:{}},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"input":var a=n.getAttribute("semantic"),o=h(n.getAttribute("source"));t.inputs[a]=o}}return t}function X(e){for(var t={inputs:{}},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"input":var a=n.getAttribute("semantic"),o=h(n.getAttribute("source")),s=parseInt(n.getAttribute("offset"));t.inputs[a]={id:o,offset:s};break;case"vcount":t.vcount=c(n.textContent);break;case"v":t.v=c(n.textContent)}}return t}function H(e){var t={id:e.id},r=Zt.geometries[t.id];return void 0!==e.skin&&(t.skin=Y(e.skin),r.sources.skinIndices=t.skin.indices,r.sources.skinWeights=t.skin.weights),t}function Y(e){function t(e,t){return t.weight-e.weight}var i,n,a,o=4,s={joints:[],indices:{array:[],stride:o},weights:{array:[],stride:o}},l=e.sources,c=e.vertexWeights,u=c.vcount,h=c.v,d=c.inputs.JOINT.offset,p=c.inputs.WEIGHT.offset,f=e.sources[e.joints.inputs.JOINT],m=e.sources[e.joints.inputs.INV_BIND_MATRIX],v=l[c.inputs.WEIGHT.id].array,g=0;for(i=0,a=u.length;i<a;i++){var y=u[i],x=[];for(n=0;n<y;n++){var b=h[g+d],w=h[g+p],_=v[w];x.push({index:b,weight:_}),g+=2}for(x.sort(t),n=0;n<o;n++){var S=x[n];void 0!==S?(s.indices.array.push(S.index),s.weights.array.push(S.weight)):(s.indices.array.push(0),s.weights.array.push(0))}}for(e.bindShapeMatrix?s.bindMatrix=(new r).fromArray(e.bindShapeMatrix).transpose():s.bindMatrix=(new r).identity(),i=0,a=f.array.length;i<a;i++){var A=f.array[i],M=(new r).fromArray(m.array,i*m.stride).transpose();s.joints.push({name:A,boneInverse:M})}return s}function q(e){return x(Zt.controllers[e],H)}function Q(e){var t={init_from:a(e,"init_from")[0].textContent};Zt.images[e.getAttribute("id")]=t}function J(e){return void 0!==e.build?e.build:e.init_from}function Z(e){var t=Zt.images[e];return void 0!==t?x(t,J):(console.warn("ColladaLoader: Couldn't find image with ID:",e),null)}function K(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"profile_COMMON":t.profile=ee(n)}}Zt.effects[e.getAttribute("id")]=t}function ee(e){for(var t={surfaces:{},samplers:{}},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"newparam":ie(n,t);break;case"technique":t.technique=se(n);break;case"extra":t.extra=ve(n)}}return t}function ie(e,t){for(var r=e.getAttribute("sid"),i=0,n=e.childNodes.length;i<n;i++){var a=e.childNodes[i];if(1===a.nodeType)switch(a.nodeName){case"surface":t.surfaces[r]=ne(a);break;case"sampler2D":t.samplers[r]=ae(a)}}}function ne(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"init_from":t.init_from=n.textContent}}return t}function ae(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"source":t.source=n.textContent}}return t}function se(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=n.nodeName,t.parameters=le(n)}}return t}function le(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"emission":case"diffuse":case"specular":case"shininess":case"transparency":t[n.nodeName]=ce(n);break;case"transparent":t[n.nodeName]={opaque:n.getAttribute("opaque"),data:ce(n)}}}return t}function ce(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"color":t[n.nodeName]=l(n.textContent);break;case"float":t[n.nodeName]=parseFloat(n.textContent);break;case"texture":t[n.nodeName]={id:n.getAttribute("texture"),extra:ue(n)}}}return t}function ue(e){for(var t={technique:{}},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"extra":he(n,t)}}return t}function he(e,t){for(var r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"technique":pe(n,t)}}}function pe(e,t){for(var r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[n.nodeName]=parseFloat(n.textContent);break;case"wrapU":case"wrapV":"TRUE"===n.textContent.toUpperCase()?t.technique[n.nodeName]=1:"FALSE"===n.textContent.toUpperCase()?t.technique[n.nodeName]=0:t.technique[n.nodeName]=parseInt(n.textContent)}}}function ve(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"technique":t.technique=ge(n)}}return t}function ge(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"double_sided":t[n.nodeName]=parseInt(n.textContent)}}return t}function ye(e){return e}function xe(e){return x(Zt.effects[e],ye)}function be(e){for(var t={name:e.getAttribute("name")},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"instance_effect":t.url=h(n.getAttribute("url"))}}Zt.materials[e.getAttribute("id")]=t}function we(e){var t,r=e.slice((e.lastIndexOf(".")-1>>>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;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"optics":t.optics=Te(n)}}Zt.cameras[e.getAttribute("id")]=t}function Te(e){for(var t=0;t<e.childNodes.length;t++){var r=e.childNodes[t];switch(r.nodeName){case"technique_common":return Ce(r)}}return{}}function Ce(e){for(var t={},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];switch(i.nodeName){case"perspective":case"orthographic":t.technique=i.nodeName,t.parameters=Le(i)}}return t}function Le(e){for(var t={},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];switch(i.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[i.nodeName]=parseFloat(i.textContent)}}return t}function Pe(e){var t;switch(e.optics.technique){case"perspective":t=new de(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":var r=e.optics.parameters.ymag,i=e.optics.parameters.xmag,n=e.optics.parameters.aspect_ratio;i=void 0===i?r*n:i,r=void 0===r?i/n:r,i*=.5,r*=.5,t=new me((-i),i,r,(-r),e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new de}return t.name=e.name,t}function Ne(e){var t=Zt.cameras[e];return void 0!==t?x(t,Pe):(console.warn("ColladaLoader: Couldn't find camera with ID:",e),null)}function Oe(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"technique_common":t=De(n)}}Zt.lights[e.getAttribute("id")]=t}function De(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=n.nodeName,t.parameters=Fe(n)}}return t}function Fe(e){for(var t={},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"color":var a=l(n.textContent);t.color=(new u).fromArray(a);break;case"falloff_angle":t.falloffAngle=parseFloat(n.textContent);break;case"quadratic_attenuation":var o=parseFloat(n.textContent);t.distance=o?Math.sqrt(1/o):0}}return t}function Re(e){var t;switch(e.technique){case"directional":t=new Vt;break;case"point":t=new zt;break;case"spot":t=new Wt;break;case"ambient":t=new Ht}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function Ie(e){var t=Zt.lights[e];return void 0!==t?x(t,Re):(console.warn("ColladaLoader: Couldn't find light with ID:",e),null)}function ke(e){var t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},r=a(e,"mesh")[0];if(void 0!==r){for(var i=0;i<r.childNodes.length;i++){var n=r.childNodes[i];if(1===n.nodeType){var o=n.getAttribute("id");switch(n.nodeName){case"source":t.sources[o]=Be(n);break;case"vertices":t.vertices=ze(n);break;case"polygons":console.warn("ColladaLoader: Unsupported primitive type: ",n.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(je(n));break;default:console.log(n)}}}Zt.geometries[e.getAttribute("id")]=t}}function Be(e){for(var t={array:[],stride:3},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"float_array":t.array=l(i.textContent);break;case"Name_array":t.array=s(i.textContent);break;case"technique_common":var n=a(i,"accessor")[0];void 0!==n&&(t.stride=parseInt(n.getAttribute("stride")))}}return t}function ze(e){for(var t={},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];1===i.nodeType&&(t[i.getAttribute("semantic")]=h(i.getAttribute("source")))}return t}function je(e){for(var t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1},r=0,i=e.childNodes.length;r<i;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"input":var a=h(n.getAttribute("source")),o=n.getAttribute("semantic"),s=parseInt(n.getAttribute("offset"));t.inputs[o]={id:a,offset:s},t.stride=Math.max(t.stride,s+1),"TEXCOORD"===o&&(t.hasUV=!0);break;case"vcount":t.vcount=c(n.textContent);break;case"p":t.p=c(n.textContent)}}return t}function Ve(e){for(var t={},r=0;r<e.length;r++){var i=e[r];void 0===t[i.type]&&(t[i.type]=[]),t[i.type].push(i)}return t}function Ge(e){for(var t=0,r=0,i=e.length;r<i;r++){var n=e[r];n.hasUV===!0&&t++}t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function We(e){var t={},r=e.sources,i=e.vertices,n=e.primitives;if(0===n.length)return{};var a=Ve(n);for(var o in a){var s=a[o];Ge(s),t[o]=Xe(s,r,i)}return t}function Xe(e,t,r){for(var i={},n={array:[],stride:0},a={array:[],stride:0},o={array:[],stride:0},s={array:[],stride:0},l={array:[],stride:4},c={array:[],stride:4},u=new P,h=[],d=0,p=0;p<e.length;p++){var f=e[p],m=f.inputs,v=0;switch(f.type){case"lines":case"linestrips":v=2*f.count;break;case"triangles":v=3*f.count;break;case"polylist":for(var g=0;g<f.count;g++){var y=f.vcount[g];
|
|
switch(y){case 3:v+=3;break;case 4:v+=6;break;default:v+=3*(y-2)}}break;default:console.warn("ColladaLoader: Unknow primitive type:",f.type)}u.addGroup(d,v,p),d+=v,f.material&&h.push(f.material);for(var x in m){var b=m[x];switch(x){case"VERTEX":for(var w in r){var _=r[w];switch(w){case"POSITION":var S=n.array.length;if(He(f,t[_],b.offset,n.array),n.stride=t[_].stride,t.skinWeights&&t.skinIndices&&(He(f,t.skinIndices,b.offset,l.array),He(f,t.skinWeights,b.offset,c.array)),f.hasUV===!1&&e.uvsNeedsFix===!0)for(var v=(n.array.length-S)/n.stride,A=0;A<v;A++)o.array.push(0,0);break;case"NORMAL":He(f,t[_],b.offset,a.array),a.stride=t[_].stride;break;case"COLOR":He(f,t[_],b.offset,s.array),s.stride=t[_].stride;break;case"TEXCOORD":He(f,t[_],b.offset,o.array),o.stride=t[_].stride;break;default:console.warn('ColladaLoader: Semantic "%s" not handled in geometry build process.',w)}}break;case"NORMAL":He(f,t[b.id],b.offset,a.array),a.stride=t[b.id].stride;break;case"COLOR":He(f,t[b.id],b.offset,s.array),s.stride=t[b.id].stride;break;case"TEXCOORD":He(f,t[b.id],b.offset,o.array),o.stride=t[b.id].stride}}}return n.array.length>0&&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;t<n;t++)i.push(l[t])}var a=e.p,o=e.stride,s=e.vcount,l=t.array,c=t.stride;if(void 0!==e.vcount)for(var u=0,h=0,d=s.length;h<d;h++){var p=s[h];if(4===p){var f=u+0*o,m=u+1*o,v=u+2*o,g=u+3*o;n(f),n(m),n(g),n(m),n(v),n(g)}else if(3===p){var f=u+0*o,m=u+1*o,v=u+2*o;n(f),n(m),n(v)}else if(p>4)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<d;h+=o)n(h)}function Ye(e){return x(Zt.geometries[e],We)}function qe(e){for(var t={name:e.getAttribute("name")||"",joints:{},links:[]},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"technique_common":Ze(i,t)}}Zt.kinematicsModels[e.getAttribute("id")]=t}function Qe(e){return void 0!==e.build?e.build:e}function Je(e){return x(Zt.kinematicsModels[e],Qe)}function Ze(e,t){for(var r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"joint":t.joints[i.getAttribute("sid")]=Ke(i);break;case"link":t.links.push(et(i))}}}function Ke(e){for(var t,r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"prismatic":case"revolute":t=$e(i)}}return t}function $e(e,t){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new i,limits:{min:0,max:0},type:e.nodeName,"static":!1,zeroPosition:0,middlePosition:0},r=0;r<e.childNodes.length;r++){var n=e.childNodes[r];if(1===n.nodeType)switch(n.nodeName){case"axis":var a=l(n.textContent);t.axis.fromArray(a);break;case"limits":var o=n.getElementsByTagName("max")[0],s=n.getElementsByTagName("min")[0];t.limits.max=parseFloat(o.textContent),t.limits.min=parseFloat(s.textContent)}}return t.limits.min>=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;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"attachment_full":t.attachments.push(tt(i));break;case"matrix":case"translate":case"rotate":t.transforms.push(rt(i))}}return t}function tt(e){for(var t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"link":t.links.push(et(i));break;case"matrix":case"translate":case"rotate":t.transforms.push(rt(i))}}return t}function rt(e){var t={type:e.nodeName},n=l(e.textContent);switch(t.type){case"matrix":t.obj=new r,t.obj.fromArray(n).transpose();break;case"translate":t.obj=new i,t.obj.fromArray(n);break;case"rotate":t.obj=new i,t.obj.fromArray(n),t.angle=Fs.degToRad(n[3])}return t}function it(e){for(var t={name:e.getAttribute("name")||"",rigidBodies:{}},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"rigid_body":t.rigidBodies[i.getAttribute("name")]={},nt(i,t.rigidBodies[i.getAttribute("name")])}}Zt.physicsModels[e.getAttribute("id")]=t}function nt(e,t){for(var r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"technique_common":at(i,t)}}}function at(e,t){for(var r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"inertia":t.inertia=l(i.textContent);break;case"mass":t.mass=l(i.textContent)[0]}}}function ot(e){for(var t={bindJointAxis:[]},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"bind_joint_axis":t.bindJointAxis.push(st(i))}}Zt.kinematicsScenes[h(e.getAttribute("url"))]=t}function st(e){for(var t={target:e.getAttribute("target").split("/").pop()},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];if(1===i.nodeType)switch(i.nodeName){case"axis":var n=i.getElementsByTagName("param")[0];t.axis=n.textContent;var a=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=a.substr(0,a.length-1)}}return t}function lt(e){return void 0!==e.build?e.build:e}function ct(e){return x(Zt.kinematicsScenes[e],lt)}function ut(){function e(e,t){var r=t.getAttribute("name"),i=a.joints[e];s.traverse(function(n){n.name===r&&(c[e]={object:n,transforms:ht(t),joint:i,position:i.zeroPosition})})}var t=Object.keys(Zt.kinematicsModels)[0],i=Object.keys(Zt.kinematicsScenes)[0],n=Object.keys(Zt.visualScenes)[0];if(void 0!==t&&void 0!==i){for(var a=Je(t),o=ct(i),s=Mt(n),l=o.bindJointAxis,c={},u=0,h=l.length;u<h;u++){var d=l[u],p=kt.querySelector('[sid="'+d.target+'"]');if(p){var f=p.parentElement;e(d.jointIndex,f)}}var m=new r;Qt={joints:a&&a.joints,getJointValue:function(e){var t=c[e];return t?t.position:void console.warn("ColladaLoader: Joint "+e+" doesn't exist.")},setJointValue:function(e,t){var r=c[e];if(r){var i=r.joint;if(t>i.limits.max||t<i.limits.min)console.warn("ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+i.limits.min+", max: "+i.limits.max+").");else if(i["static"])console.warn("ColladaLoader: Joint "+e+" is static.");else{var n=r.object,a=i.axis,o=r.transforms;Nt.identity();for(var s=0;s<o.length;s++){var l=o[s];if(l.sid&&l.sid.indexOf(e)!==-1)switch(i.type){case"revolute":Nt.multiply(m.makeRotationAxis(a,Fs.degToRad(t)));break;case"prismatic":Nt.multiply(m.makeTranslation(a.x*t,a.y*t,a.z*t));break;default:console.warn("ColladaLoader: Unknown joint type: "+i.type)}else switch(l.type){case"matrix":Nt.multiply(l.obj);break;case"translate":Nt.multiply(m.makeTranslation(l.obj.x,l.obj.y,l.obj.z));break;case"scale":Nt.scale(l.obj);break;case"rotate":Nt.multiply(m.makeRotationAxis(l.obj,l.angle))}}n.matrix.copy(Nt),n.matrix.decompose(n.position,n.quaternion,n.scale),c[e].position=t}}else console.log("ColladaLoader: "+e+" does not exist.")}}}}function ht(e){for(var t=[],n=kt.querySelector('[id="'+e.id+'"]'),a=0;a<n.childNodes.length;a++){var o=n.childNodes[a];if(1===o.nodeType)switch(o.nodeName){case"matrix":var s=l(o.textContent),c=(new r).fromArray(s).transpose();t.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:c});break;case"translate":case"scale":var s=l(o.textContent),u=(new i).fromArray(s);t.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:u});break;case"rotate":var s=l(o.textContent),u=(new i).fromArray(s),h=Fs.degToRad(s[3]);t.push({sid:o.getAttribute("sid"),type:o.nodeName,obj:u,angle:h})}}return t}function dt(e){for(var t=e.getElementsByTagName("node"),r=0;r<t.length;r++){var i=t[r];i.hasAttribute("id")===!1&&i.setAttribute("id",d())}}function pt(e){for(var t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new r,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}},i=0;i<e.childNodes.length;i++){var n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"node":t.nodes.push(n.getAttribute("id")),pt(n);break;case"instance_camera":t.instanceCameras.push(h(n.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(ft(n));break;case"instance_light":t.instanceLights.push(h(n.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(ft(n));break;case"instance_node":t.instanceNodes.push(h(n.getAttribute("url")));break;case"matrix":var a=l(n.textContent);t.matrix.multiply(Nt.fromArray(a).transpose()),t.transforms[n.getAttribute("sid")]=n.nodeName;break;case"translate":var a=l(n.textContent);Ot.fromArray(a),t.matrix.multiply(Nt.makeTranslation(Ot.x,Ot.y,Ot.z)),t.transforms[n.getAttribute("sid")]=n.nodeName;break;case"rotate":var a=l(n.textContent),o=Fs.degToRad(a[3]);t.matrix.multiply(Nt.makeRotationAxis(Ot.fromArray(a),o)),t.transforms[n.getAttribute("sid")]=n.nodeName;break;case"scale":var a=l(n.textContent);t.matrix.scale(Ot.fromArray(a)),t.transforms[n.getAttribute("sid")]=n.nodeName;break;case"extra":break;default:console.log(n)}}return bt(t.id)?console.warn("ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",t.id):Zt.nodes[t.id]=t,t}function ft(e){for(var t={id:h(e.getAttribute("url")),materials:{},skeletons:[]},r=0;r<e.childNodes.length;r++){var i=e.childNodes[r];switch(i.nodeName){case"bind_material":for(var n=i.getElementsByTagName("instance_material"),a=0;a<n.length;a++){var o=n[a],s=o.getAttribute("symbol"),l=o.getAttribute("target");t.materials[s]=h(l)}break;case"skeleton":t.skeletons.push(h(i.textContent))}}return t}function mt(e,t){var r,i,n,a=[],o=[];for(r=0;r<e.length;r++){var s,l=e[r];if(bt(l))s=wt(l),vt(s,t,a);else if(At(l))for(var c=Zt.visualScenes[l],u=c.children,i=0;i<u.length;i++){var h=u[i];if("JOINT"===h.type){var s=wt(h.id);vt(s,t,a)}}else console.error("ColladaLoader: Unable to find root bone of skeleton with ID:",l)}for(r=0;r<t.length;r++)for(i=0;i<a.length;i++)if(n=a[i],n.bone.name===t[r].name){o[r]=n,n.processed=!0;break}for(r=0;r<a.length;r++)n=a[r],n.processed===!1&&(o.push(n),n.processed=!0);var d=[],p=[];for(r=0;r<o.length;r++)n=o[r],d.push(n.bone),p.push(n.boneInverse);return new Ft(d,p)}function vt(e,t,i){e.traverse(function(e){if(e.isBone===!0){for(var n,a=0;a<t.length;a++){var o=t[a];if(o.name===e.name){n=o.boneInverse;break}}void 0===n&&(n=new r),i.push({bone:e,boneInverse:n,processed:!1})}})}function gt(e){for(var t=[],r=e.matrix,i=e.nodes,n=e.type,a=e.instanceCameras,o=e.instanceControllers,s=e.instanceLights,l=e.instanceGeometries,c=e.instanceNodes,u=0,h=i.length;u<h;u++)t.push(wt(i[u]));for(var u=0,h=a.length;u<h;u++){var d=Ne(a[u]);null!==d&&t.push(d.clone())}for(var u=0,h=o.length;u<h;u++)for(var p=o[u],f=q(p.id),m=Ye(f.id),v=xt(m,p.materials),g=p.skeletons,y=f.skin.joints,x=mt(g,y),b=0,w=v.length;b<w;b++){var _=v[b];_.isSkinnedMesh&&(_.bind(x,f.skin.bindMatrix),_.normalizeSkinWeights()),t.push(_)}for(var u=0,h=s.length;u<h;u++){var S=Ie(s[u]);null!==S&&t.push(S.clone())}for(var u=0,h=l.length;u<h;u++)for(var p=l[u],m=Ye(p.id),v=xt(m,p.materials),b=0,w=v.length;b<w;b++)t.push(v[b]);for(var u=0,h=c.length;u<h;u++)t.push(wt(c[u]).clone());var _;if(0===i.length&&1===t.length)_=t[0];else{_="JOINT"===n?new oe:new Dt;for(var u=0;u<t.length;u++)_.add(t[u])}return""===_.name&&(_.name="JOINT"===n?e.sid:e.name),_.matrix.copy(r),_.matrix.decompose(_.position,_.quaternion,_.scale),_}function yt(e,t){for(var r=[],i=0,n=e.length;i<n;i++){var a=t[e[i]];void 0===a?(console.warn("ColladaLoader: Material with key %s not found. Apply fallback material.",e[i]),r.push(It)):r.push(Se(a))}return r}function xt(e,t){var r=[];for(var i in e){var n=e[i],a=yt(n.materialKeys,t);0===a.length&&("lines"===i||"linestrips"===i?a.push(new R):a.push(new Ee));var o=void 0!==n.data.attributes.skinIndex;if(o)for(var s=0,l=a.length;s<l;s++)a[s].skinning=!0;var c,u=1===a.length?a[0]:a;switch(i){case"lines":c=new Yt(n.data,u);break;case"linestrips":c=new B(n.data,u);break;case"triangles":case"polylist":c=o?new Rt(n.data,u):new k(n.data,u)}r.push(c)}return r}function bt(e){return void 0!==Zt.nodes[e]}function wt(e){return x(Zt.nodes[e],gt)}function _t(e){var t={name:e.getAttribute("name"),children:[]};dt(e);for(var r=a(e,"node"),i=0;i<r.length;i++)t.children.push(pt(r[i]));Zt.visualScenes[e.getAttribute("id")]=t}function St(e){var t=new Dt;t.name=e.name;for(var r=e.children,i=0;i<r.length;i++){var n=r[i];t.add(wt(n.id))}return t}function At(e){return void 0!==Zt.visualScenes[e]}function Mt(e){return x(Zt.visualScenes[e],St)}function Tt(e){var t=a(e,"instance_visual_scene")[0];return Mt(h(t.getAttribute("url")))}function Et(){var e=Zt.clips;if(p(e)===!0){if(p(Zt.animations)===!1){var t=[];for(var r in Zt.animations)for(var i=A(r),n=0,a=i.length;n<a;n++)t.push(i[n]);qt.push(new re("default",(-1),t))}}else for(var r in e)qt.push(j(r))}var Ct=new i,Lt=new i,Pt=new n,Nt=new r,Ot=new i,It=new F({color:16711935});if(0===e.length)return{scene:new fe};var Ut=(new DOMParser).parseFromString(e,"application/xml"),kt=a(Ut,"COLLADA")[0],Bt=kt.getAttribute("version");console.log("ColladaLoader: File version",Bt);var jt=f(a(kt,"asset")[0]),Gt=new Ue(this.manager);Gt.setPath(t).setCrossOrigin(this.crossOrigin);var Xt;wf&&(Xt=new wf(this.manager),Xt.setPath(t));var qt=[],Qt={},Jt=0,Zt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};g(kt,"library_animations","animation",b),g(kt,"library_animation_clips","animation_clip",U),g(kt,"library_controllers","controller",V),g(kt,"library_images","image",Q),g(kt,"library_effects","effect",K),g(kt,"library_materials","material",be),g(kt,"library_cameras","camera",Ae),g(kt,"library_lights","light",Oe),g(kt,"library_geometries","geometry",ke),g(kt,"library_nodes","node",pt),g(kt,"library_visual_scenes","visual_scene",_t),g(kt,"library_kinematics_models","kinematics_model",qe),g(kt,"library_physics_models","physics_model",it),g(kt,"scene","instance_kinematics_scene",ot),y(Zt.animations,S),y(Zt.clips,z),y(Zt.controllers,H),y(Zt.images,J),y(Zt.effects,ye),y(Zt.materials,_e),y(Zt.cameras,Pe),y(Zt.lights,Re),y(Zt.geometries,We),y(Zt.visualScenes,St),Et(),ut();var Kt=Tt(a(kt,"scene")[0]);return"Z_UP"===jt.upAxis&&Kt.quaternion.setFromEuler(new o(-Math.PI/2,0,0)),Kt.scale.multiplyScalar(jt.unit),{animations:qt,kinematics:Qt,library:Zt,scene:Kt}}},qt.prototype=Object.create(ve.prototype),qt.prototype.constructor=qt,qt.prototype.isCompressedTexture=!0,Object.assign(Qt.prototype,{load:function(e,t,r,i){function n(n){l.load(e[n],function(e){var r=a._parser(e,!0);o[n]={width:r.width,height:r.height,format:r.format,mipmaps:r.mipmaps},c+=1,6===c&&(1===r.mipmapCount&&(s.minFilter=rc),s.format=r.format,s.needsUpdate=!0,t&&t(s))},r,i)}var a=this,o=[],s=new qt;s.image=o;var l=new we(this.manager);if(l.setPath(this.path),l.setResponseType("arraybuffer"),Array.isArray(e))for(var c=0,u=0,h=e.length;u<h;++u)n(u);else l.load(e,function(e){var r=a._parser(e,!0);if(r.isCubemap)for(var i=r.mipmaps.length/r.mipmapCount,n=0;n<i;n++){o[n]={mipmaps:[]};for(var l=0;l<r.mipmapCount;l++)o[n].mipmaps.push(r.mipmaps[n*r.mipmapCount+l]),o[n].format=r.format,o[n].width=r.width,o[n].height=r.height}else s.image.width=r.width,s.image.height=r.height,s.mipmaps=r.mipmaps;1===r.mipmapCount&&(s.minFilter=rc),s.format=r.format,s.needsUpdate=!0,t&&t(s)},r,i);return s},setPath:function(e){return this.path=e,this}});var Sf=function(e){Qt.call(this,e),this._parser=Sf.parse};Sf.prototype=Object.create(Qt.prototype),Sf.prototype.constructor=Sf,Sf.parse=function(e,t){function r(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function i(e){return String.fromCharCode(255&e,e>>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<i;c++)for(var u=0;u<r;u++){var h=a[l];l++;var d=a[l];l++;var p=a[l];l++;var f=a[l];l++,o[s]=p,s++,o[s]=d,s++,o[s]=h,s++,o[s]=f,s++}return o}var a={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},o=542327876,s=131072,l=512,c=1024,u=2048,h=4096,d=8192,p=16384,f=32768,m=4,v=r("DXT1"),g=r("DXT3"),y=r("DXT5"),x=r("ETC1"),b=31,w=0,_=1,S=2,A=3,M=4,T=7,E=20,C=21,L=22,P=23,N=24,O=25,D=26,F=28,R=new Int32Array(e,0,b);if(R[w]!==o)return console.error("DDSLoader.parse: Invalid magic number in DDS header."),a;if(!R[E]&m)return console.error("DDSLoader.parse: Unsupported format, must contain a FourCC code."),a;var I,U=R[C],k=!1;switch(U){case v:I=8,a.format=Mc;break;case g:I=16,a.format=Ec;break;case y:I=16,a.format=Cc;break;case x:I=8,a.format=Dc;break;default:if(!(32===R[L]&&16711680&R[P]&&65280&R[N]&&255&R[O]&&4278190080&R[D]))return console.error("DDSLoader.parse: Unsupported FourCC code ",i(U)),a;k=!0,I=64,a.format=xc}a.mipmapCount=1,R[S]&s&&t!==!1&&(a.mipmapCount=Math.max(1,R[T]));var B=R[F];if(a.isCubemap=!!(B&l),a.isCubemap&&(!(B&c)||!(B&u)||!(B&h)||!(B&d)||!(B&p)||!(B&f)))return console.error("DDSLoader.parse: Incomplete cubemap faces"),a;a.width=R[M],a.height=R[A];for(var z=R[_]+4,j=a.isCubemap?6:1,V=0;V<j;V++)for(var G=a.width,W=a.height,X=0;X<a.mipmapCount;X++){if(k)var H=n(e,z,G,W),Y=H.length;else var Y=Math.max(4,G)/4*Math.max(4,W)/4*I,H=new Uint8Array(e,z,Y);var q={data:H,width:G,height:W};a.mipmaps.push(q),z+=Y,G=Math.max(G>>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<o;s++){var l=t.call(r||i,e[s],s);l&&(a.push(l),l instanceof Promise?l.then(function(e,t){n[e]=t}.bind(i,s)):n[s]=l)}}else{n={};for(var c in e)if(e.hasOwnProperty(c)){var l=t.call(r||i,e[c],c);l&&(a.push(l),l instanceof Promise?l.then(function(e,t){n[e]=t}.bind(i,c)):n[c]=l)}}return Promise.all(a).then(function(){return n})}function h(e,t){return"string"!=typeof e||""===e?"":/^(https?:)?\/\//i.test(e)?e:/^data:.*,.*$/i.test(e)?e:/^blob:.*$/i.test(e)?e:(t||"")+e}function d(e,t){var r={};for(var i in t.attributes){var n=t.attributes[i],a=t.parameters[n],o=a.type,s=a.semantic;r[i]={type:o,semantic:s}}var l=t.parameters,c=t.attributes,u={};for(var i in r){var n=c[i],h=l[n],s=h.semantic;s&&(u[i]=h)}for(var n in u){var a=u[n],s=a.semantic,d=new RegExp("\\b"+n+"\\b","g");switch(s){case"POSITION":e=e.replace(d,"position");break;case"NORMAL":e=e.replace(d,"normal");break;case"TEXCOORD_0":case"TEXCOORD0":case"TEXCOORD":e=e.replace(d,"uv");break;case"TEXCOORD_1":e=e.replace(d,"uv2");break;case"COLOR_0":case"COLOR0":case"COLOR":e=e.replace(d,"color");break;case"WEIGHT":e=e.replace(d,"skinWeight");break;case"JOINT":e=e.replace(d,"skinIndex")}}return e}function p(){return new Ee({color:0,emissive:8947848,specular:0,shininess:0,transparent:!1,depthTest:!0,side:Js})}function m(e){this.isDeferredShaderMaterial=!0,this.params=e}function y(e,r,i){this.json=e||{},this.extensions=r||{},this.options=i||{},this.cache=new t}e.prototype={constructor:e,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=this.path&&"string"==typeof this.path?this.path:Ru.extractUrlBase(e),o=new we(n.manager);o.setResponseType("arraybuffer"),o.load(e,function(e){n.parse(e,a,t)},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){this.path=e},parse:function(e,t,r){var i,n={},s=Ru.decodeText(new Uint8Array(e,0,4));s===w.magic?(n[x.KHR_BINARY_GLTF]=new o(e),i=n[x.KHR_BINARY_GLTF].content):i=Ru.decodeText(new Uint8Array(e));var l=JSON.parse(i);l.extensionsUsed&&l.extensionsUsed.indexOf(x.KHR_MATERIALS_COMMON)>=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;c<l.length;c++)l[c].getInverse(a.sourceNode.matrixWorld).multiply(a.targetNode.skeleton.bones[c].matrixWorld).multiply(a.targetNode.skeleton.boneInverses[c]).multiply(a.targetNode.bindMatrix);break;default:console.warn("Unhandled shader semantic: "+a.semantic)}}},e.Animations={update:function(){console.warn("LegacyGLTFLoader.Animation has been deprecated. Use AnimationMixer instead.")}};var x={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_MATERIALS_COMMON:"KHR_materials_common"},b="binary_glTF",w={magic:"glTF",version:1,contentFormat:0},_=20;o.prototype.loadShader=function(e,t){var r=t[e.extensions[x.KHR_BINARY_GLTF].bufferView],i=new Uint8Array(r);return Ru.decodeText(i)};var S={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,TRIANGLES:4,LINES:1,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,VERTEX_SHADER:35633,FRAGMENT_SHADER:35632},A={5126:Number,35675:l,35676:r,35664:f,35665:i,35666:v,35678:ve},M={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},T={9728:$l,9729:rc,9984:ec,9985:ic,9986:tc,9987:nc},E={33071:Zl,33648:Kl,10497:Jl},C={6406:gc,6407:yc,6408:xc,6409:bc,6410:wc},L={5121:ac,32819:pc,32820:fc,33635:mc},N={1028:Zs,1029:Js},O={512:Tl,513:Cl,514:Pl,515:Ll,516:Nl,517:Dl,518:Nl,519:El},D={32774:ul,32778:hl,32779:dl},R={0:ml,1:vl,768:gl,769:yl,770:xl,771:bl,772:wl,773:_l,774:Sl,775:Al,776:Ml},I={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},U={scale:"scale",translation:"position",rotation:"quaternion"},z={LINEAR:Kc,STEP:Zc},j={2884:"CULL_FACE",2929:"DEPTH_TEST",3042:"BLEND",3089:"SCISSOR_TEST",32823:"POLYGON_OFFSET_FILL",32926:"SAMPLE_ALPHA_TO_COVERAGE"};return m.prototype.create=function(){var e=this,t=Mu.clone(this.params.uniforms);for(var r in e.params.uniforms){var i=e.params.uniforms[r];i.value instanceof ve&&(t[r].value=i.value,t[r].value.needsUpdate=!0),t[r].semantic=i.semantic,t[r].node=i.node}return this.params.uniforms=t,new Oe(this.params)},y.prototype._withDependencies=function(e){for(var t=this,r={},i=0;i<e.length;i++){var n=e[i],a="load"+n.charAt(0).toUpperCase()+n.slice(1),o=t.cache.get(n);if(void 0!==o)r[n]=o;else if(t[a]){var l=t[a]();t.cache.add(n,l),r[n]=l}}return s(r,function(e){return e})},y.prototype.parse=function(e){var t=this.json;this.cache.removeAll(),this._withDependencies(["scenes","cameras","animations"]).then(function(r){var i=[];for(var n in r.scenes)i.push(r.scenes[n]);var a=void 0!==t.scene?r.scenes[t.scene]:i[0],o=[];for(var n in r.cameras){var s=r.cameras[n];o.push(s)}var l=[];for(var n in r.animations)l.push(r.animations[n]);e(a,i,o,l)})},y.prototype.loadShaders=function(){var e=this.json,t=this.extensions,r=this.options;return this._withDependencies(["bufferViews"]).then(function(i){return s(e.shaders,function(e){return e.extensions&&e.extensions[x.KHR_BINARY_GLTF]?t[x.KHR_BINARY_GLTF].loadShader(e,i.bufferViews):new Promise(function(t){var i=new we(r.manager);i.setResponseType("text"),i.load(h(e.uri,r.path),function(e){t(e)})})})})},y.prototype.loadBuffers=function(){var e=this.json,t=this.extensions,r=this.options;return s(e.buffers,function(e,i){return i===b?t[x.KHR_BINARY_GLTF].body:"arraybuffer"===e.type||void 0===e.type?new Promise(function(t){var i=new we(r.manager);i.setResponseType("arraybuffer"),i.load(h(e.uri,r.path),function(e){t(e)})}):void console.warn("LegacyGLTFLoader: "+e.type+" buffer type is not supported")})},y.prototype.loadBufferViews=function(){var e=this.json;return this._withDependencies(["buffers"]).then(function(t){return s(e.bufferViews,function(e){var r=t.buffers[e.buffer],i=void 0!==e.byteLength?e.byteLength:0;return r.slice(e.byteOffset,e.byteOffset+i)})})},y.prototype.loadAccessors=function(){var e=this.json;return this._withDependencies(["bufferViews"]).then(function(t){return s(e.accessors,function(e){var r=t.bufferViews[e.bufferView],i=I[e.type],n=M[e.componentType],a=n.BYTES_PER_ELEMENT,o=a*i;if(e.byteStride&&e.byteStride!==o){var s=new n(r),l=new Lt(s,e.byteStride/a);return new Nt(l,i,e.byteOffset/a)}return s=new n(r,e.byteOffset,e.count*i),new g(s,i)})})},y.prototype.loadTextures=function(){var e=this.json,t=(this.extensions,this.options);return this._withDependencies(["bufferViews"]).then(function(r){return s(e.textures,function(i){if(i.source)return new Promise(function(n){var a=e.images[i.source],o=a.uri,s=!1;if(a.extensions&&a.extensions[x.KHR_BINARY_GLTF]){var l=a.extensions[x.KHR_BINARY_GLTF],c=r.bufferViews[l.bufferView],u=new Blob([c],{type:l.mimeType});o=URL.createObjectURL(u),s=!0}var d=ke.Handlers.get(o);null===d&&(d=new Ue(t.manager)),d.setCrossOrigin(t.crossOrigin),d.load(h(o,t.path),function(t){if(s&&URL.revokeObjectURL(o),t.flipY=!1,void 0!==i.name&&(t.name=i.name),t.format=void 0!==i.format?C[i.format]:xc,void 0!==i.internalFormat&&t.format!==C[i.internalFormat]&&console.warn("LegacyGLTFLoader: Three.js doesn't support texture internalFormat which is different from texture format. internalFormat will be forced to be the same value as format."),t.type=void 0!==i.type?L[i.type]:ac,i.sampler){var r=e.samplers[i.sampler];t.magFilter=T[r.magFilter]||rc,t.minFilter=T[r.minFilter]||tc,t.wrapS=E[r.wrapS]||Jl,t.wrapT=E[r.wrapT]||Jl}n(t)},void 0,function(){s&&URL.revokeObjectURL(o),n()})})})})},y.prototype.loadMaterials=function(){var e=this.json;return this._withDependencies(["shaders","textures"]).then(function(t){return s(e.materials,function(r){var i,n,a={},o={};if(r.extensions&&r.extensions[x.KHR_MATERIALS_COMMON]&&(n=r.extensions[x.KHR_MATERIALS_COMMON]),n){var s=["ambient","emission","transparent","transparency","doubleSided"];switch(n.technique){case"BLINN":case"PHONG":i=Ee,s.push("diffuse","specular","shininess");break;case"LAMBERT":i=Me,s.push("diffuse");break;case"CONSTANT":default:i=F}s.forEach(function(e){void 0!==n.values[e]&&(a[e]=n.values[e])}),(n.doubleSided||a.doubleSided)&&(o.side=Ks),(n.transparent||a.transparent)&&(o.transparent=!0,o.opacity=void 0!==a.transparency?a.transparency:1)}else if(void 0===r.technique)i=Ee,Object.assign(a,r.values);else{i=m;var l=e.techniques[r.technique];o.uniforms={};var c=e.programs[l.program];if(c){o.fragmentShader=t.shaders[c.fragmentShader],o.fragmentShader||(console.warn("ERROR: Missing fragment shader definition:",c.fragmentShader),i=Ee);var h=t.shaders[c.vertexShader];h||(console.warn("ERROR: Missing vertex shader definition:",c.vertexShader),i=Ee),o.vertexShader=d(h,l);var p=l.uniforms;for(var f in p){var v=p[f],g=l.parameters[v],y=g.type;if(!A[y])throw new Error("Unknown shader uniform param type: "+y);var b,w=g.count;void 0!==r.values&&(b=r.values[v]);var _=new A[y],M=g.semantic,T=g.node;switch(y){case S.FLOAT:_=g.value,"transparency"==v&&(o.transparent=!0),void 0!==b&&(_=b);break;case S.FLOAT_VEC2:case S.FLOAT_VEC3:case S.FLOAT_VEC4:case S.FLOAT_MAT3:g&&g.value&&_.fromArray(g.value),b&&_.fromArray(b);break;case S.FLOAT_MAT2:console.warn("FLOAT_MAT2 is not a supported uniform type");break;case S.FLOAT_MAT4:if(w){_=new Array(w);for(var E=0;E<w;E++)_[E]=new A[y];if(g&&g.value){var C=g.value;_.fromArray(C)}b&&_.fromArray(b)}else{if(g&&g.value){var L=g.value;_.fromArray(L)}b&&_.fromArray(b)}break;case S.SAMPLER_2D:_=void 0!==b?t.textures[b]:void 0!==g.value?t.textures[g.value]:null}o.uniforms[f]={value:_,semantic:M,node:T}}for(var P=l.states||{},I=P.enable||[],U=P.functions||{},k=!1,B=!1,z=!1,V=0,G=I.length;V<G;V++){var W=I[V];switch(j[W]){case"CULL_FACE":k=!0;break;case"DEPTH_TEST":B=!0;break;case"BLEND":z=!0;break;case"SCISSOR_TEST":case"POLYGON_OFFSET_FILL":case"SAMPLE_ALPHA_TO_COVERAGE":break;default:throw new Error("Unknown technique.states.enable: "+W)}}k?o.side=void 0!==U.cullFace?N[U.cullFace]:Js:o.side=Ks,o.depthTest=B,o.depthFunc=void 0!==U.depthFunc?O[U.depthFunc]:Cl,o.depthWrite=void 0===U.depthMask||U.depthMask[0],o.blending=z?cl:nl,o.transparent=z;var X=U.blendEquationSeparate;void 0!==X?(o.blendEquation=D[X[0]],o.blendEquationAlpha=D[X[1]]):(o.blendEquation=ul,o.blendEquationAlpha=ul);var H=U.blendFuncSeparate;void 0!==H?(o.blendSrc=R[H[0]],o.blendDst=R[H[1]],o.blendSrcAlpha=R[H[2]],o.blendDstAlpha=R[H[3]]):(o.blendSrc=vl,o.blendDst=ml,o.blendSrcAlpha=vl,o.blendDstAlpha=ml)}}Array.isArray(a.diffuse)?o.color=(new u).fromArray(a.diffuse):"string"==typeof a.diffuse&&(o.map=t.textures[a.diffuse]),delete o.diffuse,"string"==typeof a.reflective&&(o.envMap=t.textures[a.reflective]),"string"==typeof a.bump&&(o.bumpMap=t.textures[a.bump]),Array.isArray(a.emission)?i===F?o.color=(new u).fromArray(a.emission):o.emissive=(new u).fromArray(a.emission):"string"==typeof a.emission&&(i===F?o.map=t.textures[a.emission]:o.emissiveMap=t.textures[a.emission]),Array.isArray(a.specular)?o.specular=(new u).fromArray(a.specular):"string"==typeof a.specular&&(o.specularMap=t.textures[a.specular]),void 0!==a.shininess&&(o.shininess=a.shininess);var Y=new i(o);return void 0!==r.name&&(Y.name=r.name),Y})})},y.prototype.loadMeshes=function(){var e=this.json;return this._withDependencies(["accessors","materials"]).then(function(t){return s(e.meshes,function(r){var i=new Dt;void 0!==r.name&&(i.name=r.name),r.extras&&(i.userData=r.extras);var n=r.primitives||[];for(var a in n){var o=n[a];if(o.mode===S.TRIANGLES||void 0===o.mode){var s=new P,l=o.attributes;for(var c in l){var u=l[c];if(!u)return;var h=t.accessors[u];switch(c){case"POSITION":s.addAttribute("position",h);break;case"NORMAL":s.addAttribute("normal",h);break;case"TEXCOORD_0":case"TEXCOORD0":case"TEXCOORD":s.addAttribute("uv",h);break;case"TEXCOORD_1":s.addAttribute("uv2",h);break;case"COLOR_0":case"COLOR0":case"COLOR":s.addAttribute("color",h);break;case"WEIGHT":s.addAttribute("skinWeight",h);
|
|
break;case"JOINT":s.addAttribute("skinIndex",h);break;default:if(!o.material)break;var d=e.materials[o.material];if(!d.technique)break;var f=e.techniques[d.technique].parameters||{};for(var m in f)f[m].semantic===c&&s.addAttribute(m,h)}}o.indices&&s.setIndex(t.accessors[o.indices]);var d=void 0!==t.materials?t.materials[o.material]:p(),v=new k(s,d);v.castShadow=!0,v.name="0"===a?i.name:i.name+a,o.extras&&(v.userData=o.extras),i.add(v)}else if(o.mode===S.LINES){var s=new P,l=o.attributes;for(var c in l){var u=l[c];if(!u)return;var h=t.accessors[u];switch(c){case"POSITION":s.addAttribute("position",h);break;case"COLOR_0":case"COLOR0":case"COLOR":s.addAttribute("color",h)}}var v,d=t.materials[o.material];o.indices?(s.setIndex(t.accessors[o.indices]),v=new Yt(s,d)):v=new B(s,d),v.name="0"===a?i.name:i.name+a,o.extras&&(v.userData=o.extras),i.add(v)}else console.warn("Only triangular and line primitives are supported")}return i})})},y.prototype.loadCameras=function(){var e=this.json;return s(e.cameras,function(e){if("perspective"==e.type&&e.perspective){var t=e.perspective.yfov,r=void 0!==e.perspective.aspectRatio?e.perspective.aspectRatio:1,i=t*r,n=new de(Fs.radToDeg(i),r,e.perspective.znear||1,e.perspective.zfar||2e6);return void 0!==e.name&&(n.name=e.name),e.extras&&(n.userData=e.extras),n}if("orthographic"==e.type&&e.orthographic){var n=new me(Ds.innerWidth/-2,Ds.innerWidth/2,Ds.innerHeight/2,Ds.innerHeight/-2,e.orthographic.znear,e.orthographic.zfar);return void 0!==e.name&&(n.name=e.name),e.extras&&(n.userData=e.extras),n}})},y.prototype.loadSkins=function(){var e=this.json;return this._withDependencies(["accessors"]).then(function(t){return s(e.skins,function(e){var i=new r;void 0!==e.bindShapeMatrix&&i.fromArray(e.bindShapeMatrix);var n={bindShapeMatrix:i,jointNames:e.jointNames,inverseBindMatrices:t.accessors[e.inverseBindMatrices]};return n})})},y.prototype.loadAnimations=function(){var e=this.json;return this._withDependencies(["accessors","nodes"]).then(function(t){return s(e.animations,function(e,r){var i=[];for(var n in e.channels){var a=e.channels[n],o=e.samplers[a.sampler];if(o){var s=a.target,l=s.id,c=void 0!==e.parameters?e.parameters[o.input]:o.input,u=void 0!==e.parameters?e.parameters[o.output]:o.output,h=t.accessors[c],d=t.accessors[u],p=t.nodes[l];if(p){p.updateMatrix(),p.matrixAutoUpdate=!0;var f=U[s.path]===U.rotation?$:te,m=p.name?p.name:p.uuid,v=void 0!==o.interpolation?z[o.interpolation]:Kc;i.push(new f(m+"."+U[s.path],wu.arraySlice(h.array,0),wu.arraySlice(d.array,0),v))}}}var l=void 0!==e.name?e.name:"animation_"+r;return new re(l,(void 0),i)})})},y.prototype.loadNodes=function(){var e=this.json,t=this.extensions,i=this;return s(e.nodes,function(e){var t,i=new r;return e.jointName?(t=new oe,t.name=void 0!==e.name?e.name:e.jointName,t.jointName=e.jointName):(t=new c,void 0!==e.name&&(t.name=e.name)),e.extras&&(t.userData=e.extras),void 0!==e.matrix?(i.fromArray(e.matrix),t.applyMatrix(i)):(void 0!==e.translation&&t.position.fromArray(e.translation),void 0!==e.rotation&&t.quaternion.fromArray(e.rotation),void 0!==e.scale&&t.scale.fromArray(e.scale)),t}).then(function(n){return i._withDependencies(["meshes","skins","cameras"]).then(function(i){return s(n,function(a,o){var s=e.nodes[o];if(void 0!==s.meshes)for(var l in s.meshes){var c=s.meshes[l],u=i.meshes[c];if(void 0!==u)for(var h in u.children){var d,p=u.children[h],f=p.material,m=p.geometry,v=p.userData,g=p.name;switch(f.isDeferredShaderMaterial?f=d=f.create():d=f,p.type){case"LineSegments":p=new Yt(m,d);break;case"LineLoop":p=new Jt(m,d);break;case"Line":p=new B(m,d);break;default:p=new k(m,d)}p.castShadow=!0,p.userData=v,p.name=g;var y;if(s.skin&&(y=i.skins[s.skin]),y){var b=function(e){for(var t=Object.keys(n),r=0,i=t.length;r<i;r++){var a=n[t[r]];if(a.jointName===e)return a}return null},w=m,d=f;d.skinning=!0,p=new Rt(w,d),p.castShadow=!0,p.userData=v,p.name=g;for(var _=[],S=[],A=0,M=y.jointNames.length;A<M;A++){var T=y.jointNames[A],E=b(T);if(E){_.push(E);var C=y.inverseBindMatrices.array,L=(new r).fromArray(C,16*A);S.push(L)}else console.warn("WARNING: joint: '"+T+"' could not be found")}p.bind(new Ft(_,S),y.bindShapeMatrix);var P=function(t,r,i){var a=t[i];if(void 0!==a)for(var o=0,s=a.length;o<s;o++){var l=a[o],c=n[l],u=e.nodes[l];void 0!==c&&c.isBone===!0&&void 0!==u&&(r.add(c),P(u,c,"children"))}};P(s,p,"skeletons")}a.add(p)}else console.warn("LegacyGLTFLoader: Couldn't find node \""+c+'".')}if(void 0!==s.camera){var N=i.cameras[s.camera];a.add(N)}if(s.extensions&&s.extensions[x.KHR_MATERIALS_COMMON]&&s.extensions[x.KHR_MATERIALS_COMMON].light){var O=t[x.KHR_MATERIALS_COMMON].lights,D=O[s.extensions[x.KHR_MATERIALS_COMMON].light];a.add(D)}return a})})})},y.prototype.loadScenes=function(){function e(r,i,n){var a=n[r];i.add(a);var o=t.nodes[r];if(o.children)for(var s=o.children,l=0,c=s.length;l<c;l++){var u=s[l];e(u,a,n)}}var t=this.json;return this._withDependencies(["nodes"]).then(function(r){return s(t.scenes,function(t){var i=new fe;void 0!==t.name&&(i.name=t.name),t.extras&&(i.userData=t.extras);for(var a=t.nodes||[],o=0,s=a.length;o<s;o++){var l=a[o];e(l,i,r.nodes)}return i.traverse(function(e){e.material&&e.material.isRawShaderMaterial&&(e.gltfShader=new n(e,r.nodes),e.onBeforeRender=function(e,t,r){this.gltfShader.update(t,r)})}),i})})},e}(),Mf=function(e){this.timeLoaded=0,this.manager=e||Du,this.materials=null,this.verbosity=0,this.attributeOptions={},this.drawMode=iu,this.nativeAttributeMap={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"}};Mf.prototype={constructor:Mf,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.load(e,function(e){n.decodeDracoFile(e,t)},r,i)},setPath:function(e){return this.path=e,this},setVerbosity:function(e){return this.verbosity=e,this},setDrawMode:function(e){return this.drawMode=e,this},setSkipDequantization:function(e,t){var r=!0;return"undefined"!=typeof t&&(r=t),this.getAttributeOptions(e).skipDequantization=r,this},decodeDracoFile:function(e,t,r,i){var n=this;Mf.getDecoderModule().then(function(a){n.decodeDracoFileInternal(e,a.decoder,t,r||{},i||{})})},decodeDracoFileInternal:function(e,t,r,i,n){var a=new t.DecoderBuffer;a.Init(new Int8Array(e),e.byteLength);var o=new t.Decoder,s=o.GetEncodedGeometryType(a);if(s==t.TRIANGULAR_MESH)this.verbosity>0&&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;f<p;f++)s[i][f]=c.GetValue(f);o.addAttribute(i,new u(s[i],h)),e.destroy(c)},convertDracoGeometryTo3JS:function(e,t,r,i,n,a){var o=this;this.getAttributeOptions("position").skipDequantization===!0&&t.SkipAttributeTransform(e.POSITION);var s,l,c=performance.now();if(r===e.TRIANGULAR_MESH?(s=new e.Mesh,l=t.DecodeBufferToMesh(i,s)):(s=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,s)),!l.ok()||0==s.ptr){var u="DRACOLoader: Decoding failed: ";throw u+=l.error_msg(),console.error(u),e.destroy(t),e.destroy(s),new Error(u)}var h=performance.now();e.destroy(i);var d;r==e.TRIANGULAR_MESH?(d=s.num_faces(),this.verbosity>0&&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;E<T.size();++E)g.indices[E]=T.GetValue(E);e.destroy(T)}else{var C=3*d;g.indices=new Uint32Array(C);for(var L=new e.DracoInt32Array,E=0;E<d;++E){t.GetFaceFromMesh(s,E,L);var N=3*E;g.indices[N]=L.GetValue(0),g.indices[N+1]=L.GetValue(1),g.indices[N+2]=L.GetValue(2)}e.destroy(L)}y.drawMode=this.drawMode,r==e.TRIANGULAR_MESH&&y.setIndex(new(g.indices.length>65535?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 <common>\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<I;++i)(0==i||e[i>>3]&1<<(7&i))&&(t[r++]=i);for(var n=r-1;r<I;)t[r++]=0;return n}function r(e){for(var t=0;t<j;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}function i(e,t,r,i,n){for(;r<e;)t=t<<8|S(i,n),r+=8;r-=e,K.l=t>>r&(1<<e)-1,K.c=t,K.lc=r}function n(e){for(var t=0;t<=58;++t)$[t]=0;for(var t=0;t<z;++t)$[e[t]]+=1;for(var r=0,t=58;t>0;--t){var i=r+$[t]>>1;$[t]=r,r=i}for(var t=0;t<z;++t){var n=e[t];n>0&&(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;u<l.lit-1;++u)l.p[u]=c[u]}else l.p=new Array(1);l.p[l.lit-1]=t}else if(a)for(var h=0,u=1<<B-a;u>0;u--){var l=i[(n<<B-a)+h];if(l.len||l.p)throw"Invalid table entry";l.len=a,l.lit=t,h++}}return!0}function c(e,t,r,i){e=e<<8|S(r,i),t+=8,ee.c=e,ee.lc=t}function u(e,t,r,i,n,a,o,s,l,u){if(e==t){i<8&&(c(r,i,n,o),r=ee.c,i=ee.lc),i-=8;var h=r>>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.value<u))return!1;s[l.value++]=e}te.c=r,te.lc=i}function h(e){return 65535&e}function d(e){var t=h(e);return t>32767?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<g;)for(c(f,m,r,n),f=ee.c,m=ee.lc;m>=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<x.lit;b++){for(var w=o(e[x.p[b]]);m<w&&n.value<g;)c(f,m,r,n),f=ee.c,m=ee.lc;if(m>=w&&s(e[x.p[b]])==(f>>m-w&(1<<w)-1)){m-=w,u(x.p[b],l,f,m,r,i,n,d,p,v),f=te.c,m=te.lc;break}}if(b==x.lit)throw"hufDecode issues"}}var _=8-a&7;for(f>>=_,m-=_;m>0;){var x=t[f<<B-m&V];if(!x.len)throw"hufDecode issues";m-=x.len,u(x.lit,l,f,m,r,i,n,d,p,v),f=te.c,m=te.lc}return!0}function v(e,t,i,n,o,s,c){var u=i.value,h=_(t,i),d=_(t,i);i.value+=4;var p=_(t,i);if(i.value+=4,h<0||h>=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<r;++i)t[i]=e[t[i]]}function y(e,r,i,n,a,o,s,l,c,u){var h=new Uint8Array(U),d=E(n,a),p=E(n,a);if(p>=U)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(d<=p)for(var m=0;m<p-d+1;m++)h[m+d]=A(n,a);var y=new Uint16Array(I),x=t(h,y),b=_(n,a);v(i,n,a,b,e,r,o);for(var w=new Array(s),S=0,m=0;m<s;m++){l[m];w[m]={},w[m].start=S,w[m].end=w[m].start,w[m].nx=c,w[m].ny=u,w[m].size=1,S+=w[m].nx*w[m].ny*w[m].size}for(var M=0,m=0;m<s;m++)for(var T=0;T<w[m].size;++T)M+=f(T+M,e,w[m].nx,w[m].size,w[m].ny,w[m].nx*w[m].size,x);return g(y,e,S),!0}function x(e,t){for(var r=new Uint8Array(e),i=0;0!=r[t.value+i];)i+=1;var n=(new TextDecoder).decode(r.slice(t.value,t.value+i));return t.value=t.value+i+1,n}function b(e,t,r){var i=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+r));return t.value=t.value+r,i}function w(e,t){var r=e.getUint32(0,!0);return t.value=t.value+Y,r}function _(e,t){var r=e.getUint32(t.value,!0);return t.value=t.value+Q,r}function S(e,t){var r=e[t.value];return t.value=t.value+Z,r}function A(e,t){var r=e.getUint8(t.value);return t.value=t.value+Z,r}function M(e,t){var r=e.getFloat32(t.value,!0);return t.value+=q,r}function T(e){var t=(31744&e)>>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<n+i-1;){var o=x(t,r),s=_(e,r),l=A(e,r);r.value+=3;var c=_(e,r),u=_(e,r);a.push({name:o,pixelType:s,pLinear:l,xSampling:c,ySampling:u})}return r.value+=1,a}function P(e,t){var r=M(e,t),i=M(e,t),n=M(e,t),a=M(e,t),o=M(e,t),s=M(e,t),l=M(e,t),c=M(e,t);return{redX:r,redY:i,greenX:n,greenY:a,blueX:o,blueY:s,whiteX:l,whiteY:c}}function N(e,t){var r=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION"],i=A(e,t);return r[i]}function O(e,t){var r=_(e,t),i=_(e,t),n=_(e,t),a=_(e,t);return{xMin:r,yMin:i,xMax:n,yMax:a}}function D(e,t){var r=["INCREASING_Y"],i=A(e,t);return r[i]}function F(e,t){var r=M(e,t),i=M(e,t);return[r,i]}function R(e,t,r,i,n){if("string"===i||"iccProfile"===i)return b(t,r,n);if("chlist"===i)return L(e,t,r,n);if("chromaticities"===i)return P(e,r);if("compression"===i)return N(e,r);if("box2i"===i)return O(e,r);if("lineOrder"===i)return D(e,r);if("float"===i)return M(e,r);if("v2f"===i)return F(e,r);if("int"===i)return _(e,r);throw"Cannot parse value for unsupported type: "+i}for(var I=65536,U=I>>3,k=16,B=14,z=(1<<k)+1,j=1<<B,V=j-1,G=59,W=63,X=2+W-G,H=2,Y=8,q=4,Q=4,J=2,Z=1,K={l:0,c:0,lc:0},$=new Array(59),ee={c:0,lc:0},te={c:0,lc:0},re={a:0,b:0},ie=new DataView(e),ne=new Uint8Array(e),ae={},oe=(ie.getUint32(0,!0),ie.getUint8(4,!0),ie.getUint8(5,!0),{value:8}),se=!0;se;){var le=x(e,oe);if(0==le)se=!1;else{var ce=x(e,oe),ue=_(ie,oe),he=R(ie,e,oe,ce,ue);ae[le]=he}}var de=ae.dataWindow.yMax+1,pe=1;"PIZ_COMPRESSION"===ae.compression&&(pe=32);for(var fe=de/pe,me=0;me<fe;me++){w(ie,oe)}var ve=ae.dataWindow.xMax-ae.dataWindow.xMin+1,ge=ae.dataWindow.yMax-ae.dataWindow.yMin+1,ye=ae.channels.length,xe=new Float32Array(ve*ge*ye),be={R:0,G:1,B:2,A:3};if("NO_COMPRESSION"===ae.compression)for(var we=0;we<ge;we++)for(var _e=_(ie,oe),Se=(_(ie,oe),0);Se<ae.channels.length;Se++){var Ae=be[ae.channels[Se].name];if(1!==ae.channels[Se].pixelType)throw"Only supported pixel format is HALF";for(var Me=0;Me<ve;Me++){var Te=C(ie,oe);xe[(ge-_e)*(ve*ye)+Me*ye+Ae]=Te}}else{if("PIZ_COMPRESSION"!==ae.compression)throw"Cannot decompress unsupported compression";for(var Ee=0;Ee<ge/pe;Ee++){var Ce=(_(ie,oe),_(ie,oe),ve*pe*(ae.channels.length*H)),Le=new Uint16Array(Ce),Pe={value:0};y(Le,Pe,ne,ie,oe,Ce,ye,ae.channels,ve,pe);for(var Ne=0;Ne<pe;Ne++)for(var Se=0;Se<ae.channels.length;Se++){var Ae=be[ae.channels[Se].name];if(1!==ae.channels[Se].pixelType)throw"Only supported pixel format is HALF";for(var Me=0;Me<ve;Me++){var Te=T(Le[Se*(pe*ve)+Ne*ve+Me]),Oe=Ne+Ee*pe;xe[(ge-Oe)*(ve*ye)+Me*ye+Ae]=Te}}}}return{header:ae,width:ve,height:ge,data:xe,format:4==ae.channels.length?xc:yc,type:hc}};var Cf=function(){function e(e){this.manager=void 0!==e?e:Du}function t(e){this.textureLoader=e}function a(){}function s(){}function h(){}function d(){}function p(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}function f(){}function m(e){var t="Kaydara FBX Binary \0";return e.byteLength>=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;n<r.length;++n){var a=t(1);if(a===r[n])return!1}return!0}function x(e){var t=/FBXVersion: (\d+)/,r=e.match(t);if(r){var i=parseInt(r[1]);return i}throw new Error("FBXLoader: Cannot find the version number for the file given.")}function b(e){return e/46186158e3}function w(e,t,r,i){var n;switch(i.mappingType){case"ByPolygonVertex":n=e;break;case"ByPolygon":n=t;break;case"ByVertice":n=r;break;case"AllSame":n=i.indices[0];break;default:console.warn("FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(n=i.indices[n]);var a=n*i.dataSize,o=a+i.dataSize;return L(I,i.buffer,a,o)}function S(e){var t=new r;V.set(0,0,0),G.identity();var i=A(e.eulerOrder?e.eulerOrder:0);if(e.translation&&V.fromArray(e.translation),e.rotationOffset&&V.add(j.fromArray(e.rotationOffset)),e.rotation){var n=e.rotation.map(Fs.degToRad);n.push(i),G.makeRotationFromEuler(z.fromArray(n))}if(e.preRotation){var n=e.preRotation.map(Fs.degToRad);n.push(i),U.makeRotationFromEuler(z.fromArray(n)),G.premultiply(U)}if(e.postRotation){var n=e.postRotation.map(Fs.degToRad);n.push(i),U.makeRotationFromEuler(z.fromArray(n)),U.getInverse(U),G.multiply(U)}return e.scale&&t.scale(j.fromArray(e.scale)),t.setPosition(V),t.multiply(G),t}function A(e){var t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===e?(console.warn("FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function T(e){var t=e.split(",").map(function(e){return parseFloat(e)});return t}function E(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),Ru.decodeText(new Uint8Array(e,t,r))}function C(e,t){for(var r=0,i=e.length,n=t.length;r<n;r++,i++)e[i]=t[r]}function L(e,t,r,i){for(var n=r,a=0;n<i;n++,a++)e[a]=t[n];return e}function N(e,t,r){return e.slice(0,t).concat(r).concat(e.slice(t))}var O,D,F;e.prototype={constructor:e,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=Ru.extractUrlBase(e),o=new we(this.manager);o.setResponseType("arraybuffer"),o.load(e,function(r){try{var o=n.parse(r,a);t(o)}catch(s){setTimeout(function(){i&&i(s),n.manager.itemError(e)},0)}},r,i)},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,r){if(m(e))O=(new d).parse(e);else{var i=E(e);if(!y(i))throw new Error("FBXLoader: Unknown format.");if(x(i)<7e3)throw new Error("FBXLoader: FBX version not supported, FileVersion: "+x(i));O=(new h).parse(i)}var n=new Ue(this.manager).setPath(r).setCrossOrigin(this.crossOrigin);return new t(n).parse(O)}},t.prototype={constructor:t,parse:function(){D=this.parseConnections();var e=this.parseImages(),t=this.parseTextures(e),r=this.parseMaterials(t),i=this.parseDeformers(),n=(new a).parse(i);return this.parseScene(i,n,r),F},parseConnections:function(){var e=new Map;if("Connections"in O){var t=O.Connections.connections;t.forEach(function(t){var r=t[0],i=t[1],n=t[2];e.has(r)||e.set(r,{parents:[],children:[]});var a={ID:i,relationship:n};e.get(r).parents.push(a),e.has(i)||e.set(i,{parents:[],children:[]});var o={ID:r,relationship:n};e.get(i).children.push(o)})}return e},parseImages:function(){var e=this,t={},r={};if("Video"in O.Objects){var i=O.Objects.Video;for(var n in i){var a=i[n],o=parseInt(n);if(t[o]=a.RelativeFilename||a.Filename,"Content"in a){var s=a.Content instanceof ArrayBuffer&&a.Content.byteLength>0,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;i<e.children.length;i++){if(8===i){console.warn("FBXLoader: maximum of 8 morph targets supported. Ignoring additional targets.");break}var n=e.children[i],a=t[n.ID],o={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if("BlendShapeChannel"!==a.attrType)return;var s=D.get(parseInt(n.ID));s.children.forEach(function(e){
|
|
void 0===e.relationship&&(o.geoID=e.ID)}),r.push(o)}return r},parseScene:function(e,t,r){F=new Dt;var i=this.parseModels(e.skeletons,t,r),n=O.Objects.Model,a=this;i.forEach(function(e){var t=n[e.ID];a.setLookAtProperties(e,t);var r=D.get(e.ID).parents;r.forEach(function(t){var r=i.get(t.ID);void 0!==r&&r.add(e)}),null===e.parent&&F.add(e)}),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),this.setupMorphMaterials();var o=(new s).parse();1===F.children.length&&F.children[0].isGroup&&(F.children[0].animations=o,F=F.children[0]),F.animations=o},parseModels:function(e,t,r){var i=this,n=new Map,a=O.Objects.Model;for(var o in a){var s=parseInt(o),l=a[o],c=D.get(s),u=i.buildSkeleton(c,e,s,l.attrName);if(!u){switch(l.attrType){case"Camera":u=i.createCamera(c);break;case"Light":u=i.createLight(c);break;case"Mesh":u=i.createMesh(c,t,r);break;case"NurbsCurve":u=i.createCurve(c,t);break;case"LimbNode":case"Null":default:u=new Dt}u.name=W.sanitizeNodeName(l.attrName),u.ID=s}i.setModelTransforms(u,l),n.set(s,u)}return n},buildSkeleton:function(e,t,r,i){var n=null;return e.parents.forEach(function(e){for(var a in t){var o=t[a];o.rawBones.forEach(function(t,a){if(t.ID===e.ID){var s=n;n=new oe,n.matrixWorld.copy(t.transformLink),n.name=W.sanitizeNodeName(i),n.ID=r,o.bones[a]=n,null!==s&&n.add(s)}})}}),n},createCamera:function(e){var t,r;if(e.children.forEach(function(e){var t=O.Objects.NodeAttribute[e.ID];void 0!==t&&(r=t)}),void 0===r)t=new c;else{var i=0;void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(i=1);var n=1;void 0!==r.NearPlane&&(n=r.NearPlane.value/1e3);var a=1e3;void 0!==r.FarPlane&&(a=r.FarPlane.value/1e3);var o=Ds.innerWidth,s=Ds.innerHeight;void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(o=r.AspectWidth.value,s=r.AspectHeight.value);var l=o/s,u=45;void 0!==r.FieldOfView&&(u=r.FieldOfView.value);var h=r.FocalLength?r.FocalLength.value:null;switch(i){case 0:t=new de(u,l,n,a),null!==h&&t.setFocalLength(h);break;case 1:t=new me(-o/2,o/2,s/2,-s/2,n,a);break;default:console.warn("FBXLoader: Unknown camera type "+i+"."),t=new c}}return t},createLight:function(e){var t,r;if(e.children.forEach(function(e){var t=O.Objects.NodeAttribute[e.ID];void 0!==t&&(r=t)}),void 0===r)t=new c;else{var i;i=void 0===r.LightType?0:r.LightType.value;var n=16777215;void 0!==r.Color&&(n=(new u).fromArray(r.Color.value));var a=void 0===r.Intensity?1:r.Intensity.value/100;void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(a=0);var o=0;void 0!==r.FarAttenuationEnd&&(o=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value);var s=1;switch(i){case 0:t=new zt(n,a,o,s);break;case 1:t=new Vt(n,a);break;case 2:var l=Math.PI/3;void 0!==r.InnerAngle&&(l=Fs.degToRad(r.InnerAngle.value));var h=0;void 0!==r.OuterAngle&&(h=Fs.degToRad(r.OuterAngle.value),h=Math.max(h,1)),t=new Wt(n,a,o,l,h,s);break;default:console.warn("FBXLoader: Unknown light type "+r.LightType.value+", defaulting to a PointLight."),t=new zt(n,a)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(t.castShadow=!0)}return t},createMesh:function(e,t,r){var i,n=null,a=null,o=[];return e.children.forEach(function(e){t.has(e.ID)&&(n=t.get(e.ID)),r.has(e.ID)&&o.push(r.get(e.ID))}),o.length>1?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;u<c;u++)e.vertex.push(t.vertexPositions[r[0]]),e.vertex.push(t.vertexPositions[r[1]]),e.vertex.push(t.vertexPositions[r[2]]),e.vertex.push(t.vertexPositions[r[3*(u-1)]]),e.vertex.push(t.vertexPositions[r[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[r[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[r[3*u]]),e.vertex.push(t.vertexPositions[r[3*u+1]]),e.vertex.push(t.vertexPositions[r[3*u+2]]),t.skeleton&&(e.vertexWeights.push(s[0]),e.vertexWeights.push(s[1]),e.vertexWeights.push(s[2]),e.vertexWeights.push(s[3]),e.vertexWeights.push(s[4*(u-1)]),e.vertexWeights.push(s[4*(u-1)+1]),e.vertexWeights.push(s[4*(u-1)+2]),e.vertexWeights.push(s[4*(u-1)+3]),e.vertexWeights.push(s[4*u]),e.vertexWeights.push(s[4*u+1]),e.vertexWeights.push(s[4*u+2]),e.vertexWeights.push(s[4*u+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(a[0]),e.colors.push(a[1]),e.colors.push(a[2]),e.colors.push(a[3*(u-1)]),e.colors.push(a[3*(u-1)+1]),e.colors.push(a[3*(u-1)+2]),e.colors.push(a[3*u]),e.colors.push(a[3*u+1]),e.colors.push(a[3*u+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(i),e.materialIndex.push(i),e.materialIndex.push(i)),t.normal&&(e.normal.push(n[0]),e.normal.push(n[1]),e.normal.push(n[2]),e.normal.push(n[3*(u-1)]),e.normal.push(n[3*(u-1)+1]),e.normal.push(n[3*(u-1)+2]),e.normal.push(n[3*u]),e.normal.push(n[3*u+1]),e.normal.push(n[3*u+2])),t.uv&&t.uv.forEach(function(t,r){void 0===e.uvs[r]&&(e.uvs[r]=[]),e.uvs[r].push(o[r][0]),e.uvs[r].push(o[r][1]),e.uvs[r].push(o[r][2*(u-1)]),e.uvs[r].push(o[r][2*(u-1)+1]),e.uvs[r].push(o[r][2*u]),e.uvs[r].push(o[r][2*u+1])})},addMorphTargets:function(e,t,r,i){if(null!==r){e.morphAttributes.position=[],e.morphAttributes.normal=[];var n=this;r.rawTargets.forEach(function(r){var a=O.Objects.Geometry[r.geoID];void 0!==a&&n.genMorphGeometry(e,t,a,i)})}},genMorphGeometry:function(e,t,r,i){var n=new P;r.attrName&&(n.name=r.attrName);for(var a=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],o=void 0!==t.Vertices?t.Vertices.a.slice():[],s=void 0!==r.Vertices?r.Vertices.a:[],l=void 0!==r.Indexes?r.Indexes.a:[],c=0;c<l.length;c++){var u=3*l[c];o[u]+=s[3*c],o[u+1]+=s[3*c+1],o[u+2]+=s[3*c+2]}var h={vertexIndices:a,vertexPositions:o},d=this.genBuffers(h),p=new M(d.vertex,3);p.name=r.attrName,i.applyToBufferAttribute(p),e.morphAttributes.position.push(p)},parseNormals:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,i=e.Normals.a,n=[];return"IndexToDirect"===r&&("NormalIndex"in e?n=e.NormalIndex.a:"NormalsIndex"in e&&(n=e.NormalsIndex.a)),{dataSize:3,buffer:i,indices:n,mappingType:t,referenceType:r}},parseUVs:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,i=e.UV.a,n=[];return"IndexToDirect"===r&&(n=e.UVIndex.a),{dataSize:2,buffer:i,indices:n,mappingType:t,referenceType:r}},parseVertexColors:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType,i=e.Colors.a,n=[];return"IndexToDirect"===r&&(n=e.ColorIndex.a),{dataSize:4,buffer:i,indices:n,mappingType:t,referenceType:r}},parseMaterialIndices:function(e){var t=e.MappingInformationType,r=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:r};for(var i=e.Materials.a,n=[],a=0;a<i.length;++a)n.push(a);return{dataSize:1,buffer:i,indices:n,mappingType:t,referenceType:r}},parseNurbsGeometry:function(e){if(void 0===rh)return console.error("FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new P;var t=parseInt(e.Order);if(isNaN(t))return console.error("FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new P;for(var r=t-1,i=e.KnotVector.a,n=[],a=e.Points.a,o=0,s=a.length;o<s;o+=4)n.push((new v).fromArray(a,o));var l,c;if("Closed"===e.Form)n.push(n[0]);else if("Periodic"===e.Form){l=r,c=i.length-1-l;for(var o=0;o<r;++o)n.push(n[o])}var u=new rh(r,i,n,l,c),h=u.getPoints(7*n.length),d=new Float32Array(3*h.length);h.forEach(function(e,t){e.toArray(d,3*t)});var p=new P;return p.addAttribute("position",new g(d,3)),p}},s.prototype={constructor:s,parse:function(){var e=this,t=[],r=this.parseClips();if(void 0!==r){for(var i in r){var n=r[i],a=e.addClip(n);t.push(a)}return t}},parseClips:function(){if(void 0!==O.Objects.AnimationCurve){var e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);var t=this.parseAnimationLayers(e),r=this.parseAnimStacks(t);return r}},parseAnimationCurveNodes:function(){var e=O.Objects.AnimationCurveNode,t=new Map;for(var r in e){var i=e[r];if(null!==i.attrName.match(/S|R|T|DeformPercent/)){var n={id:i.id,attr:i.attrName,curves:{}};t.set(n.id,n)}}return t},parseAnimationCurves:function(e){var t=O.Objects.AnimationCurve;for(var r in t){var i={id:t[r].id,times:t[r].KeyTime.a.map(b),values:t[r].KeyValueFloat.a},n=D.get(i.id);if(void 0!==n){var a=n.parents[0].ID,o=n.parents[0].relationship;o.match(/X/)?e.get(a).curves.x=i:o.match(/Y/)?e.get(a).curves.y=i:o.match(/Z/)?e.get(a).curves.z=i:o.match(/d|DeformPercent/)&&e.has(a)&&(e.get(a).curves.morph=i)}}},parseAnimationLayers:function(e){var t=this,r=O.Objects.AnimationLayer,i=new Map;for(var n in r){var a=[],o=D.get(parseInt(n));if(void 0!==o){var s=o.children,l=t;s.forEach(function(t,r){if(e.has(t.ID)){var i=e.get(t.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===a[r]){var n;D.get(t.ID).parents.forEach(function(e){void 0!==e.relationship&&(n=e.ID)});var o=O.Objects.Model[n.toString()],s={modelName:W.sanitizeNodeName(o.attrName),initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1],transform:l.getModelAnimTransform(o)};"PreRotation"in o&&(s.preRotations=o.PreRotation.value),"PostRotation"in o&&(s.postRotations=o.PostRotation.value),a[r]=s}a[r][i.attr]=i}else if(void 0!==i.curves.morph){if(void 0===a[r]){var c;D.get(t.ID).parents.forEach(function(e){void 0!==e.relationship&&(c=e.ID)});var u=D.get(c).parents[0].ID,h=D.get(u).parents[0].ID,n=D.get(h).parents[0].ID,o=O.Objects.Model[n],s={modelName:W.sanitizeNodeName(o.attrName),morphName:O.Objects.Deformer[c].attrName};a[r]=s}a[r][i.attr]=i}}}),i.set(parseInt(n),a)}}return i},getModelAnimTransform:function(e){var t={};return"RotationOrder"in e&&(t.eulerOrder=parseInt(e.RotationOrder.value)),"Lcl_Translation"in e&&(t.translation=e.Lcl_Translation.value),"RotationOffset"in e&&(t.rotationOffset=e.RotationOffset.value),"Lcl_Rotation"in e&&(t.rotation=e.Lcl_Rotation.value),"PreRotation"in e&&(t.preRotation=e.PreRotation.value),"PostRotation"in e&&(t.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(t.scale=e.Lcl_Scaling.value),S(t)},parseAnimStacks:function(e){var t=O.Objects.AnimationStack,r={};for(var i in t){var n=D.get(parseInt(i)).children;n.length>1&&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<l.length;d+=3)u.set(l[d],l[d+1],l[d+2],"ZYX"),c.setFromEuler(u),void 0!==i&&c.premultiply(i),void 0!==a&&c.multiply(a),c.toArray(h,d/3*4);return new $(e+".quaternion",s,h)},generateMorphTrack:function(e){var t=e.DeformPercent.curves.morph,r=t.values.map(function(e){return e/100}),i=F.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Z(e.modelName+".morphTargetInfluences["+i+"]",t.times,r)},getTimesForAllAxes:function(e){var t=[];return void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}).filter(function(e,t,r){return r.indexOf(e)==t})},getKeyframeTrackValues:function(e,t,r){var i=r,n=[],a=-1,o=-1,s=-1;return e.forEach(function(e){if(t.x&&(a=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(s=t.z.times.indexOf(e)),a!==-1){var r=t.x.values[a];n.push(r),i[0]=r}else n.push(i[0]);if(o!==-1){var l=t.y.values[o];n.push(l),i[1]=l}else n.push(i[1]);if(s!==-1){var c=t.z.values[s];n.push(c),i[2]=c}else n.push(i[2])}),n},interpolateRotations:function(e){for(var t=1;t<e.values.length;t++){var r=e.values[t-1],i=e.values[t]-r,n=Math.abs(i);if(n>=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=[];h<e.times[t];)d.push(h),h+=u,p.push(s),s+=o;e.times=N(e.times,t,d),e.values=N(e.values,t,p)}}}},h.prototype={constructor:h,getPrevNode:function(){return this.nodeStack[this.currentIndent-2]},getCurrentNode:function(){return this.nodeStack[this.currentIndent-1]},getCurrentProp:function(){return this.currentProp},pushStack:function(e){this.nodeStack.push(e),this.currentIndent+=1},popStack:function(){this.nodeStack.pop(),this.currentIndent-=1},setCurrentProp:function(e,t){this.currentProp=e,this.currentPropName=t},parse:function(e){this.currentIndent=0,console.log("FBXTree: ",f),this.allNodes=new f,this.nodeStack=[],this.currentProp=[],this.currentPropName="";var t=this,r=e.split(/[\r\n]+/);return r.forEach(function(e,i){var n=e.match(/^[\s\t]*;/),a=e.match(/^[\s\t]*$/);if(!n&&!a){var o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),s=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):s?t.parseNodeProperty(e,s,r[++i]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}}),this.allNodes},parseNodeBegin:function(e,t){var r=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),n={name:r},a=this.parseNodeAttr(i),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(r,n):r in o?("PoseNode"===r?o.PoseNode.push(n):void 0!==o[r].id&&(o[r]={},o[r][o[r].id]=o[r]),""!==a.id&&(o[r][a.id]=n)):"number"==typeof a.id?(o[r]={},o[r][a.id]=n):"Properties70"!==r&&("PoseNode"===r?o[r]=[n]:o[r]=n),"number"==typeof a.id&&(n.id=a.id),""!==a.name&&(n.attrName=a.name),""!==a.type&&(n.attrType=a.type),this.pushStack(n)},parseNodeAttr:function(e){var t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));var r="",i="";return e.length>1&&(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;c<a;c++)l.push(r.parseProperty(e));var u=l.length>0?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<e;i++)r.push(t.getBoolean());return r},getUint8:function(){var e=this.dv.getUint8(this.offset);return this.offset+=1,e},getInt16:function(){var e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e},getInt32:function(){var e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e},getInt32Array:function(e){for(var t=this,r=[],i=0;i<e;i++)r.push(t.getInt32());return r},getUint32:function(){var e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e},getInt64:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e},getInt64Array:function(e){for(var t=this,r=[],i=0;i<e;i++)r.push(t.getInt64());return r},getUint64:function(){var e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e},getFloat32:function(){var e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e},getFloat32Array:function(e){for(var t=this,r=[],i=0;i<e;i++)r.push(t.getFloat32());return r},getFloat64:function(){var e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e},getFloat64Array:function(e){for(var t=this,r=[],i=0;i<e;i++)r.push(t.getFloat64());return r},getArrayBuffer:function(e){var t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t},getString:function(e){for(var t=this,r=[],i=0;i<e;i++)r[i]=t.getUint8();var n=r.indexOf(0);return n>=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;p<d.length;p++){var f=d[p].split(" "),m=f[0].toUpperCase(),v={};if(f.splice(1).forEach(function(e){if(void 0!==e[0]){var t=e[0].toLowerCase(),r=parseFloat(e.substring(1));v[t]=r}}),"G0"===m||"G1"===m){var g={x:void 0!==v.x?n(s.x,v.x):s.x,y:void 0!==v.y?n(s.y,v.y):s.y,z:void 0!==v.z?n(s.z,v.z):s.z,e:void 0!==v.e?n(s.e,v.e):s.e,f:void 0!==v.f?n(s.f,v.f):s.f};i(s.e,g.e)>0&&(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<l.length;p++){var x=l[p];a(x.vertex,!0),a(x.pathVertex,!1)}else{for(var b=[],w=[],p=0;p<l.length;p++){var x=l[p];b=b.concat(x.vertex),w=w.concat(x.pathVertex)}a(b,!0),a(w,!1)}return y.quaternion.setFromEuler(new o(-Math.PI/2,0,0)),y};var Pf={computeTangents:function(e){function t(e,t,r){v.fromArray(s,3*e),y.fromArray(s,3*t),x.fromArray(s,3*r),b.fromArray(c,2*e),w.fromArray(c,2*t),_.fromArray(c,2*r);var i=y.x-v.x,n=x.x-v.x,a=y.y-v.y,o=x.y-v.y,l=y.z-v.z,u=x.z-v.z,h=w.x-b.x,f=_.x-b.x,m=w.y-b.y,g=_.y-b.y,M=1/(h*g-f*m);S.set((g*i-m*n)*M,(g*a-m*o)*M,(g*l-m*u)*M),A.set((h*n-f*i)*M,(h*o-f*a)*M,(h*u-f*l)*M),d[e].add(S),d[t].add(S),d[r].add(S),p[e].add(A),p[t].add(A),p[r].add(A)}function r(e){U.fromArray(l,3*e),k.copy(U),D=d[e],R.copy(D),R.sub(U.multiplyScalar(U.dot(D))).normalize(),I.crossVectors(k,D),F=I.dot(p[e]),O=F<0?-1:1,h[4*e]=R.x,h[4*e+1]=R.y,h[4*e+2]=R.z,h[4*e+3]=O}var n=e.index,a=e.attributes;if(null===n||void 0===a.position||void 0===a.normal||void 0===a.uv)return void console.warn("BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");var o=n.array,s=a.position.array,l=a.normal.array,c=a.uv.array,u=s.length/3;void 0===a.tangent&&e.addAttribute("tangent",new g(new Float32Array(4*u),4));for(var h=a.tangent.array,d=[],p=[],m=0;m<u;m++)d[m]=new i,p[m]=new i;var v=new i,y=new i,x=new i,b=new f,w=new f,_=new f,S=new i,A=new i,M=e.groups;0===M.length&&(M=[{start:0,count:o.length}]);for(var m=0,T=M.length;m<T;++m)for(var E=M[m],C=E.start,L=E.count,P=C,N=C+L;P<N;P+=3)t(o[P+0],o[P+1],o[P+2]);for(var O,D,F,R=new i,I=new i,U=new i,k=new i,m=0,T=M.length;m<T;++m)for(var E=M[m],C=E.start,L=E.count,P=C,N=C+L;P<N;P+=3)r(o[P+0]),r(o[P+1]),r(o[P+2])},mergeBufferGeometries:function(e,t){for(var r=this,i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),a=new Set(Object.keys(e[0].morphAttributes)),o={},s={},l=new P,c=0,u=0;u<e.length;++u){var h=e[u];if(i!==(null!==h.index))return null;for(var d in h.attributes){if(!n.has(d))return null;void 0===o[d]&&(o[d]=[]),o[d].push(h.attributes[d])}for(var d in h.morphAttributes){if(!a.has(d))return null;void 0===s[d]&&(s[d]=[]),s[d].push(h.morphAttributes[d])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(h.userData),t){var p;if(i)p=h.index.count;else{if(void 0===h.attributes.position)return null;
|
|
p=h.attributes.position.count}l.addGroup(c,p,u),c+=p}}if(i){for(var f=0,m=[],u=0;u<e.length;++u){for(var v=e[u].index,g=0;g<v.count;++g)m.push(v.getX(g)+f);f+=e[u].attributes.position.count}l.setIndex(m)}for(var d in o){var y=r.mergeBufferAttributes(o[d]);if(!y)return null;l.addAttribute(d,y)}for(var d in s){var x=s[d][0].length;if(0===x)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(var u=0;u<x;++u){for(var b=[],g=0;g<s[d].length;++g)b.push(s[d][g][u]);var w=r.mergeBufferAttributes(b);if(!w)return null;l.morphAttributes[d].push(w)}}return l},mergeBufferAttributes:function(e){for(var t,r,i,n=0,a=0;a<e.length;++a){var o=e[a];if(o.isInterleavedBufferAttribute)return null;if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return null;if(void 0===r&&(r=o.itemSize),r!==o.itemSize)return null;if(void 0===i&&(i=o.normalized),i!==o.normalized)return null;n+=o.array.length}for(var s=new t(n),l=0,a=0;a<e.length;++a)s.set(e[a].array,l),l+=e[a].array.length;return new g(s,r,i)}},Nf=function(){function e(e){this.manager=void 0!==e?e:Du,this.dracoLoader=null}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={}}}}function i(){if(!Sf)throw new Error("GLTFLoader: Attempting to load .dds texture without importing DDSLoader");this.name=N.MSFT_TEXTURE_DDS,this.ddsLoader=new Sf}function n(e){var t=this;this.name=N.KHR_LIGHTS_PUNCTUAL,this.lights=[];for(var r=e.extensions&&e.extensions[N.KHR_LIGHTS_PUNCTUAL]||{},i=r.lights||[],n=0;n<i.length;n++){var a,o=i[n],s=new u(16777215);void 0!==o.color&&s.fromArray(o.color);var l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new Vt(s),a.target.position.set(0,0,1),a.add(a.target);break;case"point":a=new zt(s),a.distance=l;break;case"spot":a=new Wt(s),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,1),a.add(a.target);break;default:throw new Error('GLTFLoader: Unexpected light type, "'+o.type+'".')}a.decay=2,void 0!==o.intensity&&(a.intensity=o.intensity),a.name=o.name||"light_"+n,t.lights.push(a)}}function a(e){this.name=N.KHR_MATERIALS_UNLIT}function o(e){var t=this;this.name=N.KHR_BINARY_GLTF,this.content=null,this.body=null;var r=new DataView(e,0,I);if(this.header={magic:Ru.decodeText(new Uint8Array(e.slice(0,4))),version:r.getUint32(4,!0),length:r.getUint32(8,!0)},this.header.magic!==O)throw new Error("GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.");for(var i=new DataView(e,I),n=0;n<i.byteLength;){var a=i.getUint32(n,!0);n+=4;var o=i.getUint32(n,!0);if(n+=4,o===U.JSON){var s=new Uint8Array(e,I+n,a);t.content=Ru.decodeText(s)}else if(o===U.BIN){var l=I+n;t.body=e.slice(l,l+a)}n+=a}if(null===this.content)throw new Error("GLTFLoader: JSON content not found.")}function s(e,t){if(!t)throw new Error("GLTFLoader: No DRACOLoader instance provided.");this.name=N.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t}function l(){return{name:N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return pe},extendParams:function(e,t,r){var i=t.extensions[this.name],n=vp.standard,a=Mu.clone(n.uniforms),o=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),s=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),l=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),c=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),h=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb;","material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );","material.specularColor = specularFactor.rgb;"].join("\n"),d=n.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",o).replace("#include <metalnessmap_pars_fragment>",s).replace("#include <roughnessmap_fragment>",l).replace("#include <metalnessmap_fragment>",c).replace("#include <lights_physical_fragment>",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<n;i++)t[r[i]]=e[r[i]];return t},refreshUniforms:function(e,t,r,i,n,a){if(n.isGLTFSpecularGlossinessMaterial===!0){var o=n.uniforms,s=n.defines;o.opacity.value=n.opacity,o.diffuse.value.copy(n.color),o.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),o.map.value=n.map,o.specularMap.value=n.specularMap,o.alphaMap.value=n.alphaMap,o.lightMap.value=n.lightMap,o.lightMapIntensity.value=n.lightMapIntensity,o.aoMap.value=n.aoMap,o.aoMapIntensity.value=n.aoMapIntensity;var l;n.map?l=n.map:n.specularMap?l=n.specularMap:n.displacementMap?l=n.displacementMap:n.normalMap?l=n.normalMap:n.bumpMap?l=n.bumpMap:n.glossinessMap?l=n.glossinessMap:n.alphaMap?l=n.alphaMap:n.emissiveMap&&(l=n.emissiveMap),void 0!==l&&(l.isWebGLRenderTarget&&(l=l.texture),l.matrixAutoUpdate===!0&&l.updateMatrix(),o.uvTransform.value.copy(l.matrix)),o.envMap.value=n.envMap,o.envMapIntensity.value=n.envMapIntensity,o.flipEnvMap.value=n.envMap&&n.envMap.isCubeTexture?-1:1,o.refractionRatio.value=n.refractionRatio,o.specular.value.copy(n.specular),o.glossiness.value=n.glossiness,o.glossinessMap.value=n.glossinessMap,o.emissiveMap.value=n.emissiveMap,o.bumpMap.value=n.bumpMap,o.normalMap.value=n.normalMap,o.displacementMap.value=n.displacementMap,o.displacementScale.value=n.displacementScale,o.displacementBias.value=n.displacementBias,null!==o.glossinessMap.value&&void 0===s.USE_GLOSSINESSMAP&&(s.USE_GLOSSINESSMAP="",s.USE_ROUGHNESSMAP=""),null===o.glossinessMap.value&&void 0!==s.USE_GLOSSINESSMAP&&(delete s.USE_GLOSSINESSMAP,delete s.USE_ROUGHNESSMAP)}}}}function h(e,t,r,i){j.call(this,e,t,r,i)}function d(e,t){return"string"!=typeof e||""===e?"":/^(https?:)?\/\//i.test(e)?e:/^data:.*,.*$/i.test(e)?e:/^blob:.*$/i.test(e)?e:t+e}function p(){return new Ce({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Js})}function m(e,t,r){for(var i in r.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=r.extensions[i])}function v(e,t){void 0!==t.extras&&("object"==typeof t.extras?e.userData=t.extras:console.warn("GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function y(e,t,r){for(var i=!1,n=!1,a=0,o=t.length;a<o;a++){var s=t[a];if(void 0!==s.POSITION&&(i=!0),void 0!==s.NORMAL&&(n=!0),i&&n)break}if(i||n){for(var l=[],c=[],a=0,o=t.length;a<o;a++){var s=t[a],u="morphTarget"+a;if(i){if(void 0!==s.POSITION){var h=T(r[s.POSITION]);h.name=u;for(var d=e.attributes.position,p=0,f=h.count;p<f;p++)h.setXYZ(p,h.getX(p)+d.getX(p),h.getY(p)+d.getY(p),h.getZ(p)+d.getZ(p))}else h=e.attributes.position;l.push(h)}if(n){var m;if(void 0!==s.NORMAL){var m=T(r[s.NORMAL]);m.name=u;for(var v=e.attributes.normal,p=0,f=m.count;p<f;p++)m.setXYZ(p,m.getX(p)+v.getX(p),m.getY(p)+v.getY(p),m.getZ(p)+v.getZ(p))}else m=e.attributes.normal;c.push(m)}}i&&(e.morphAttributes.position=l),n&&(e.morphAttributes.normal=c)}}function x(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(var r=0,i=t.weights.length;r<i;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){var n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(var r=0,i=n.length;r<i;r++)e.morphTargetDictionary[n[r]]=r}else console.warn("GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function b(e,t){return e.indices===t.indices&&w(e.attributes,t.attributes)}function w(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var r in e)if(e[r]!==t[r])return!1;return!0}function _(e,t){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r<i;r++)if(e[r]!==t[r])return!1;return!0}function S(e,t){for(var r=0,i=e.length;r<i;r++){var n=e[r];if(b(n.primitive,t))return n.promise}return null}function A(e,t){for(var r=0,i=e.length;r<i;r++){var n=e[r];if(_(t,n.baseGeometries))return n.geometry}return null}function M(e,t,r){for(var i=0,n=e.length;i<n;i++){var a=e[i];if(t===a.baseGeometry&&_(r,a.primitives))return a.geometry}return null}function T(e){if(e.isInterleavedBufferAttribute){for(var t=e.count,r=e.itemSize,i=e.array.slice(0,t*r),n=0;n<t;++n)i[n]=e.getX(n),r>=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<n;i++){var a=e[i];if(t.mode!==a.mode)return!1;if(void 0===a.indices)return!1;if(!w(t.attributes,a.attributes))return!1;var o=a.targets||[];if(r.length!==o.length)return!1;for(var s=0,l=r.length;s<l;s++)if(!w(r[s],o[s]))return!1}return!0}function C(e,r,i){this.json=e||{},this.extensions=r||{},this.options=i||{},this.cache=new t,this.primitiveCache=[],this.multiplePrimitivesCache=[],this.multiPassGeometryCache=[],this.textureLoader=new Ue(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new we(this.options.manager),this.fileLoader.setResponseType("arraybuffer")}function L(e,t,r){var i=t.attributes;for(var n in i){var a=Y[n],o=r[i[n]];a&&(a in e.attributes||e.addAttribute(a,o))}void 0===t.indices||e.index||e.setIndex(r[t.indices]),void 0!==t.targets&&y(e,t.targets,r),v(e,t)}e.prototype={constructor:e,crossOrigin:"anonymous",load:function(e,t,r,i){var n=this,a=void 0!==this.path?this.path:Ru.extractUrlBase(e);n.manager.itemStart(e);var o=function(t){i?i(t):console.error(t),n.manager.itemEnd(e),n.manager.itemError(e)},s=new we(n.manager);s.setResponseType("arraybuffer"),s.load(e,function(r){try{n.parse(r,a,function(r){t(r),n.manager.itemEnd(e)},o)}catch(i){o(i)}},r,o)},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},setDRACOLoader:function(e){return this.dracoLoader=e,this},parse:function(e,t,r,c){var u,h=this,d={};if("string"==typeof e)u=e;else{var p=Ru.decodeText(new Uint8Array(e,0,4));if(p===O){try{d[N.KHR_BINARY_GLTF]=new o(e)}catch(f){return void(c&&c(f))}u=d[N.KHR_BINARY_GLTF].content}else u=Ru.decodeText(new Uint8Array(e))}var v=JSON.parse(u);if(void 0===v.asset||v.asset.version[0]<2)return void(c&&c(new Error("GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.")));if(v.extensionsUsed)for(var g=0;g<v.extensionsUsed.length;++g){var y=v.extensionsUsed[g],x=v.extensionsRequired||[];switch(y){case N.KHR_LIGHTS_PUNCTUAL:d[y]=new n(v);break;case N.KHR_MATERIALS_UNLIT:d[y]=new a(v);break;case N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:d[y]=new l;break;case N.KHR_DRACO_MESH_COMPRESSION:d[y]=new s(v,h.dracoLoader);break;case N.MSFT_TEXTURE_DDS:d[N.MSFT_TEXTURE_DDS]=new i;break;default:x.indexOf(y)>=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<o;a++)for(var s=t[a].joints,l=0,c=s.length;l<c;l++)e[s[l]].isBone=!0;for(var u=0,h=e.length;u<h;u++){var d=e[u];void 0!==d.mesh&&(void 0===i[d.mesh]&&(i[d.mesh]=n[d.mesh]=0),i[d.mesh]++,void 0!==d.skin&&(r[d.mesh].isSkinnedMesh=!0))}this.json.meshReferences=i,this.json.meshUses=n},C.prototype.getDependency=function(e,t){var r=e+":"+t,i=this.cache.get(r);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this.loadMesh(t);break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this.loadBufferView(t);break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this.loadMaterial(t);break;case"texture":i=this.loadTexture(t);break;case"skin":i=this.loadSkin(t);break;case"animation":i=this.loadAnimation(t);break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,i)}return i},C.prototype.getDependencies=function(e){var t=this.cache.get(e);if(!t){var r=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map(function(t,i){return r.getDependency(e,i)})),this.cache.add(e,t)}return t},C.prototype.getMultiDependencies=function(e){for(var t=this,r={},i=[],n=0,a=e.length;n<a;n++){var o=e[n],s=t.getDependencies(o);s=s.then(function(e,t){r[e]=t}.bind(t,o+("mesh"===o?"es":"s"))),i.push(s)}return Promise.all(i).then(function(){return r})},C.prototype.loadBuffer=function(e){var t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[N.KHR_BINARY_GLTF].body);var i=this.options;return new Promise(function(e,n){r.load(d(t.uri,i.path),e,void 0,function(){n(new Error('GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})},C.prototype.loadBufferView=function(e){var t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){var r=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+r)})},C.prototype.loadAccessor=function(e){var t=this,r=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse)return null;var n=[];return void 0!==i.bufferView?n.push(this.getDependency("bufferView",i.bufferView)):n.push(null),void 0!==i.sparse&&(n.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(n).then(function(e){var n,a,o=e[0],s=H[i.type],l=V[i.componentType],c=l.BYTES_PER_ELEMENT,u=c*s,h=i.byteOffset||0,d=void 0!==i.bufferView?r.bufferViews[i.bufferView].byteStride:void 0,p=i.normalized===!0;if(d&&d!==u){var f="InterleavedBuffer:"+i.bufferView+":"+i.componentType,m=t.cache.get(f);m||(n=new l(o),m=new Lt(n,d/c),t.cache.add(f,m)),a=new Nt(m,s,h/c,p)}else n=null===o?new l(i.count*s):new l(o,h,i.count*s),a=new g(n,s,p);if(void 0!==i.sparse){var v=H.SCALAR,y=V[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,b=i.sparse.values.byteOffset||0,w=new y(e[1],x,i.sparse.count*v),_=new l(e[2],b,i.sparse.count*s);null!==o&&a.setArray(a.array.slice());for(var S=0,A=w.length;S<A;S++){var M=w[S];if(a.setX(M,_[S*s]),s>=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;l<c;l++){var u=e[l],h=S(n,u);if(h)s.push(h);else if(u.extensions&&u.extensions[N.KHR_DRACO_MESH_COMPRESSION]){var d=i[N.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,r).then(function(e){return L(e,u,o),e});n.push({primitive:u,promise:d}),s.push(d)}else{var p=new P;L(p,u,o);var d=Promise.resolve(p);n.push({primitive:u,promise:d}),s.push(d)}}return Promise.all(s).then(function(i){if(a){var n=i[0],s=r.multiPassGeometryCache,l=M(s,n,t);if(null!==l)return[l.geometry];var c=new P;c.name=n.name,c.userData=n.userData;for(var u in n.attributes)c.addAttribute(u,n.attributes[u]);for(var u in n.morphAttributes)c.morphAttributes[u]=n.morphAttributes[u];for(var h=[],d=0,p=0,f=t.length;p<f;p++){for(var m=o[t[p].indices],v=0,g=m.count;v<g;v++)h.push(m.array[v]);c.addGroup(d,m.count,p),d+=m.count}return c.setIndex(h),s.push({geometry:c,baseGeometry:n,primitives:t}),[c]}if(i.length>1&&void 0!==Pf){for(var p=1,f=e.length;p<f;p++)if(e[0].mode!==e[p].mode)return i;var s=r.multiplePrimitivesCache,l=A(s,i);if(l){if(null!==l.geometry)return[l.geometry]}else{var c=Pf.mergeBufferGeometries(i,!0);if(s.push({geometry:c,baseGeometries:i}),null!==c)return[c]}}return i})})},C.prototype.loadMesh=function(e){var t=this,r=this.json,i=this.extensions,n=r.meshes[e];return this.getMultiDependencies(["accessor","material"]).then(function(r){for(var a=n.primitives,o=[],s=0,l=a.length;s<l;s++)o[s]=void 0===a[s].material?p():r.materials[a[s].material];return t.loadGeometries(a).then(function(r){for(var s=1===r.length&&r[0].groups.length>0,l=[],c=0,u=r.length;c<u;c++){var h,d=r[c],p=a[c],f=s?o:o[c];if(p.mode===z.TRIANGLES||p.mode===z.TRIANGLE_STRIP||p.mode===z.TRIANGLE_FAN||void 0===p.mode)h=n.isSkinnedMesh===!0?new Rt(d,f):new k(d,f),p.mode===z.TRIANGLE_STRIP?h.drawMode=nu:p.mode===z.TRIANGLE_FAN&&(h.drawMode=au);else if(p.mode===z.LINES)h=new Yt(d,f);else if(p.mode===z.LINE_STRIP)h=new B(d,f);else if(p.mode===z.LINE_LOOP)h=new Jt(d,f);else{if(p.mode!==z.POINTS)throw new Error("GLTFLoader: Primitive mode unsupported: "+p.mode);h=new Et(d,f)}Object.keys(h.geometry.morphAttributes).length>0&&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;A<M;A++){var f=m[A];if(h.isPoints){var T="PointsMaterial:"+f.uuid,E=t.cache.get(T);E||(E=new Ne,D.prototype.copy.call(E,f),E.color.copy(f.color),E.map=f.map,E.lights=!1,t.cache.add(T,E)),f=E}else if(h.isLine){var T="LineBasicMaterial:"+f.uuid,C=t.cache.get(T);C||(C=new R,D.prototype.copy.call(C,f),C.color.copy(f.color),C.lights=!1,t.cache.add(T,C)),f=C}if(y||b||w||_){var T="ClonedMaterial:"+f.uuid+":";f.isGLTFSpecularGlossinessMaterial&&(T+="specular-glossiness:"),w&&(T+="skinning:"),y&&(T+="vertex-colors:"),b&&(T+="flat-shading:"),_&&(T+="morph-targets:"),S&&(T+="morph-normals:");var L=t.cache.get(T);L||(L=f.isGLTFSpecularGlossinessMaterial?i[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].cloneMaterial(f):f.clone(),w&&(L.skinning=!0),y&&(L.vertexColors=il),b&&(L.flatShading=!0),_&&(L.morphTargets=!0),S&&(L.morphNormals=!0),t.cache.add(T,L)),f=L}m[A]=f,f.aoMap&&void 0===d.attributes.uv2&&void 0!==d.attributes.uv&&(console.log("GLTFLoader: Duplicating UVs to support aoMap."),d.addAttribute("uv2",new g(d.attributes.uv.array,2))),f.isGLTFSpecularGlossinessMaterial&&(h.onBeforeRender=i[N.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].refreshUniforms)}h.material=s?m:m[0]}if(1===l.length)return l[0];for(var P=new Dt,c=0,u=l.length;c<u;c++)P.add(l[c]);return P})})},C.prototype.loadCamera=function(e){var t,r=this.json.cameras[e],i=r[r.type];return i?("perspective"===r.type?t=new de(Fs.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===r.type&&(t=new me(i.xmag/-2,i.xmag/2,i.ymag/2,i.ymag/-2,i.znear,i.zfar)),void 0!==r.name&&(t.name=r.name),v(t,r),Promise.resolve(t)):void console.warn("GLTFLoader: Missing camera parameters.")},C.prototype.loadSkin=function(e){var t=this.json.skins[e],r={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(r):this.getDependency("accessor",t.inverseBindMatrices).then(function(e){return r.inverseBindMatrices=e,r})},C.prototype.loadAnimation=function(e){var t=this.json,r=t.animations[e];return this.getMultiDependencies(["accessor","node"]).then(function(t){for(var i=[],n=0,a=r.channels.length;n<a;n++){var o=r.channels[n],s=r.samplers[o.sampler];if(s){var l=o.target,c=void 0!==l.node?l.node:l.id,u=void 0!==r.parameters?r.parameters[s.input]:s.input,d=void 0!==r.parameters?r.parameters[s.output]:s.output,p=t.accessors[u],f=t.accessors[d],m=t.nodes[c];if(m){m.updateMatrix(),m.matrixAutoUpdate=!0;var v;switch(q[l.path]){case q.weights:v=Z;break;case q.rotation:v=$;break;case q.position:case q.scale:default:v=te}var g=m.name?m.name:m.uuid,y=void 0!==s.interpolation?Q[s.interpolation]:Kc,x=[];q[l.path]===q.weights?m.traverse(function(e){e.isMesh===!0&&e.morphTargetInfluences&&x.push(e.name?e.name:e.uuid)}):x.push(g);for(var b=0,w=x.length;b<w;b++){var _=new v(x[b]+"."+q[l.path],wu.arraySlice(p.array,0),wu.arraySlice(f.array,0),y);"CUBICSPLINE"===s.interpolation&&(_.createInterpolant=function(e){return new h(this.times,this.values,this.getValueSize()/3,e)},_.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),i.push(_)}}}}var c=void 0!==r.name?r.name:"animation_"+e;return new re(c,(void 0),i)})},C.prototype.loadNode=function(e){var t=this.json,i=this.extensions,n=t.meshReferences,a=t.meshUses,o=t.nodes[e];return this.getMultiDependencies(["mesh","skin","camera","light"]).then(function(e){var t;if(o.isBone===!0)t=new oe;else if(void 0!==o.mesh){var s=e.meshes[o.mesh];if(n[o.mesh]>1){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<h;u++)t.children[u].name+="_instance_"+l,t.children[u].onBeforeRender=s.children[u].onBeforeRender}else t=s}else if(void 0!==o.camera)t=e.cameras[o.camera];else if(o.extensions&&o.extensions[N.KHR_LIGHTS_PUNCTUAL]&&void 0!==o.extensions[N.KHR_LIGHTS_PUNCTUAL].light){var d=i[N.KHR_LIGHTS_PUNCTUAL].lights;t=d[o.extensions[N.KHR_LIGHTS_PUNCTUAL].light]}else t=new c;if(void 0!==o.name&&(t.name=W.sanitizeNodeName(o.name)),v(t,o),o.extensions&&m(i,t,o),void 0!==o.matrix){var p=new r;p.fromArray(o.matrix),t.applyMatrix(p)}else void 0!==o.translation&&t.position.fromArray(o.translation),void 0!==o.rotation&&t.quaternion.fromArray(o.rotation),void 0!==o.scale&&t.scale.fromArray(o.scale);return t})},C.prototype.loadScene=function(){function e(t,i,n,a,o){var s=a[t],l=n.nodes[t];if(void 0!==l.skin)for(var c=s.isGroup===!0?s.children:[s],u=0,h=c.length;u<h;u++){for(var d=c[u],p=o[l.skin],f=[],m=[],v=0,g=p.joints.length;v<g;v++){var y=p.joints[v],x=a[y];if(x){f.push(x);var b=new r;void 0!==p.inverseBindMatrices&&b.fromArray(p.inverseBindMatrices.array,16*v),m.push(b)}else console.warn('GLTFLoader: Joint "%s" could not be found.',y)}d.bind(new Ft(f,m),d.matrixWorld)}if(i.add(s),l.children)for(var w=l.children,u=0,h=w.length;u<h;u++){var _=w[u];e(_,s,n,a,o)}}return function(t){var r=this.json,i=this.extensions,n=this.json.scenes[t];return this.getMultiDependencies(["node","skin"]).then(function(t){var a=new fe;void 0!==n.name&&(a.name=n.name),v(a,n),n.extensions&&m(i,a,n);for(var o=n.nodes||[],s=0,l=o.length;s<l;s++)e(o[s],a,r,t.nodes,t.skins);return a})}}(),e}(),Of=function(e){this.manager=void 0!==e?e:Du};Of.prototype=Object.create(Kt.prototype),Of.prototype._parser=function(e){var t=-1,r=1,i=2,n=3,a=4,o=function(e,o){switch(e){case r:console.error("RGBELoader Read Error: "+(o||""));break;case i:console.error("RGBELoader Write Error: "+(o||""));break;case n:console.error("RGBELoader Bad File Format: "+(o||""));break;default:case a:console.error("RGBELoader: Error: "+(o||""))}return t},s=1,l=2,c=4,u="\n",h=function(e,t,r){t=t?t:1024;for(var i=e.pos,n=-1,a=0,o="",s=128,l=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+s)));0>(n=l.indexOf(u))&&a<t&&i<e.byteLength;)o+=l,
|
|
a+=l.length,i+=s,l+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+s)));return-1<n&&(!1!==r&&(e.pos+=a+n+1),o+l.slice(0,n))},d=function(e){var t,i,a=/^#\?(\S+)$/,u=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,d=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,p=/^\s*FORMAT=(\S+)\s*$/,f=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,m={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(e.pos>=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&&c<e.byteLength;){if(c+4>e.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;p<f&&c<e.byteLength;){if(u=e[c++],y=u>128,y&&(u-=128),0===u||p+u>f)return o(n,"bad scanline data");if(y)for(h=e[c++],m=0;m<u;m++)d[p++]=h;else d.set(e.subarray(c,c+u),p),p+=u,c+=u}for(v=b,m=0;m<v;m++)g=0,s[l]=d[m+g],g+=b,s[l+1]=d[m+g],g+=b,s[l+2]=d[m+g],g+=b,s[l+3]=d[m+g],l+=4;w--}return s},f=new Uint8Array(e);f.pos=0;var m=d(f);if(t!==m){var v=m.width,g=m.height,y=p(f.subarray(f.pos),v,g);if(t!==y)return{width:v,height:g,data:y,header:m.string,gamma:m.gamma,exposure:m.exposure,format:_c,type:ac}}return null};var Df=Of;$t.prototype=Object.create(ve.prototype),$t.prototype.constructor=$t,$t.prototype.isCubeTexture=!0,Object.defineProperty($t.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});var Ff=function(e){this.manager=void 0!==e?e:Du,this.hdrLoader=new Of};Ff.prototype.load=function(e,t,r,i,n){function a(r,i,n,a){var h=new we(c.manager);h.setResponseType("arraybuffer"),h.load(t[r],function(t){u++;var n=c._parser(t);if(n){if(e===hc){for(var a=n.data.length/4*3,h=new Float32Array(a),d=0;d<a;d++)o(n.data,4*d,h,3*d);n.data=h}else if(e===dc){for(var a=n.data.length/4*3,p=new Uint16Array(a),d=0;d<a;d++)s(n.data,4*d,p,3*d);n.data=p}if(void 0!==n.image)l[r].images=n.image;else if(void 0!==n.data){var f=new Mt(n.data,n.width,n.height);f.format=l.format,f.type=l.type,f.encoding=l.encoding,f.minFilter=l.minFilter,f.magFilter=l.magFilter,f.generateMipmaps=l.generateMipmaps,l.images[r]=f}6===u&&(l.needsUpdate=!0,i&&i(l))}},n,a)}var o=function(e,t,r,i){var n=e[t+3],a=Math.pow(2,n-128)/255;r[i+0]=e[t+0]*a,r[i+1]=e[t+1]*a,r[i+2]=e[t+2]*a},s=function(){function e(e){t[0]=e;var i=r[0],n=i>>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<t.length;h++)a(h,r,i,n);return l};var Rf=function(e){this.manager=void 0!==e?e:Du};Rf.prototype={constructor:Rf,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){for(var t in i.files)if(t.substr(-e.length)===e)return i.files[t]}var r=new be;r.setURLModifier(function(e){var r=t(e);if(r){console.log("Loading",e);var i=new Blob([r.asArrayBuffer()],{type:"application/octet-stream"});return URL.createObjectURL(i)}return e});var i=new JSZip(e);if(i.files["doc.kml"]){var n=(new DOMParser).parseFromString(i.files["doc.kml"].asText(),"application/xml"),a=n.querySelector("Placemark Model Link href");if(a){var o=new _f(r);return o.parse(i.files[a.textContent].asText())}}else{console.warn("KMZLoader: Missing doc.kml file.");for(var s in i.files){var l=s.split(".").pop().toLowerCase();if("dae"===l){var o=new _f(r);return o.parse(i.files[s].asText())}}}return console.error("KMZLoader: Couldn't find .dae file."),{scene:new Dt}}};var If=function(e){Qt.call(this,e),this._parser=If.parse};If.prototype=Object.create(Qt.prototype),If.prototype.constructor=If,If.parse=function(e,t){var r=new Uf(e,1);return{mipmaps:r.mipmaps(t),width:r.pixelWidth,height:r.pixelHeight,format:r.glInternalFormat,isCubemap:6===r.numberOfFaces,mipmapCount:r.numberOfMipmapLevels}};var Uf=function(){function e(t,r,i,n){this.arrayBuffer=t;var a=new Uint8Array(this.arrayBuffer,0,12);if(171!==a[0]||75!==a[1]||84!==a[2]||88!==a[3]||32!==a[4]||49!==a[5]||49!==a[6]||187!==a[7]||13!==a[8]||10!==a[9]||26!==a[10]||10!==a[11])return void console.error("texture missing KTX identifier");var o=new Int32Array(this.arrayBuffer,12,13),s=16909060===o[0];return this.glType=s?this.switchEndainness(o[1]):o[1],this.glTypeSize=s?this.switchEndainness(o[2]):o[2],this.glFormat=s?this.switchEndainness(o[3]):o[3],this.glInternalFormat=s?this.switchEndainness(o[4]):o[4],this.glBaseInternalFormat=s?this.switchEndainness(o[5]):o[5],this.pixelWidth=s?this.switchEndainness(o[6]):o[6],this.pixelHeight=s?this.switchEndainness(o[7]):o[7],this.pixelDepth=s?this.switchEndainness(o[8]):o[8],this.numberOfArrayElements=s?this.switchEndainness(o[9]):o[9],this.numberOfFaces=s?this.switchEndainness(o[10]):o[10],this.numberOfMipmapLevels=s?this.switchEndainness(o[11]):o[11],this.bytesOfKeyValueData=s?this.switchEndainness(o[12]):o[12],0!==this.glType?void console.warn("only compressed formats currently supported"):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?void console.warn("only 2D textures currently supported"):0!==this.numberOfArrayElements?void console.warn("texture arrays not currently supported"):this.numberOfFaces!==r?void console.warn("number of faces expected"+r+", but found "+this.numberOfFaces):void(this.loadType=e.COMPRESSED_2D))}return e.prototype.switchEndainness=function(e){return(255&e)<<24|(65280&e)<<8|e>>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;l<s;l++){for(var c=new Int32Array(r.arrayBuffer,n,1)[0],u=0;u<this.numberOfFaces;u++){var h=new Uint8Array(r.arrayBuffer,n+4,c);i.push({data:h,width:a,height:o}),n+=c+4,n+=3-(c+3)%4}a=Math.max(1,.5*a),o=Math.max(1,.5*o)}return i},e.HEADER_LEN=64,e.COMPRESSED_2D=0,e.COMPRESSED_3D=1,e.TEX_2D=2,e.TEX_3D=3,e}(),kf={};kf.Validator={isValid:function(e){return null!==e&&void 0!==e},verifyInput:function(e,t){return null===e||void 0===e?t:e}},kf.Callbacks=function(){function e(){this.onProgress=null,this.onReportError=null,this.onMeshAlter=null,this.onLoad=null,this.onLoadMaterials=null}var t=kf.Validator;return e.prototype.setCallbackOnProgress=function(e){this.onProgress=t.verifyInput(e,this.onProgress)},e.prototype.setCallbackOnReportError=function(e){this.onReportError=t.verifyInput(e,this.onReportError)},e.prototype.setCallbackOnMeshAlter=function(e){this.onMeshAlter=t.verifyInput(e,this.onMeshAlter)},e.prototype.setCallbackOnLoad=function(e){this.onLoad=t.verifyInput(e,this.onLoad)},e.prototype.setCallbackOnLoadMaterials=function(e){this.onLoadMaterials=t.verifyInput(e,this.onLoadMaterials)},e}(),kf.LoadedMeshUserOverride=function(){function e(e,t){this.disregardMesh=e===!0,this.alteredMesh=t===!0,this.meshes=[]}return e.prototype.addMesh=function(e){this.meshes.push(e),this.alteredMesh=!0},e.prototype.isDisregardMesh=function(){return this.disregardMesh},e.prototype.providesAlteredMeshes=function(){return this.alteredMesh},e}(),kf.ResourceDescriptor=function(){function e(e,r){var i=e.split("/");i.length<2?(this.path=null,this.name=e,this.url=e):(this.path=t.verifyInput(i.slice(0,i.length-1).join("/")+"/",null),this.name=i[i.length-1],this.url=e),this.name=t.verifyInput(this.name,"Unnamed_Resource"),this.extension=t.verifyInput(r,"default"),this.extension=this.extension.trim(),this.content=null}var t=kf.Validator;return e.prototype.setContent=function(e){this.content=t.verifyInput(e,null)},e}(),kf.PrepData=function(){function e(e){this.logging={enabled:!0,debug:!1},this.modelName=t.verifyInput(e,""),this.resources=[],this.callbacks=new kf.Callbacks}var t=kf.Validator;return e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.getCallbacks=function(){return this.callbacks},e.prototype.addResource=function(e){this.resources.push(e)},e.prototype.clone=function(){var e=this,t=new kf.PrepData(this.modelName);t.logging.enabled=this.logging.enabled,t.logging.debug=this.logging.debug,t.resources=this.resources,t.callbacks=this.callbacks;var r,i;for(r in e)i=e[r],t.hasOwnProperty(r)||"function"==typeof e[r]||(t[r]=i);return t},e.prototype.checkResourceDescriptorFiles=function(e,r){var i,n,a,o,s={};for(var l in e)if(i=e[l],o=!1,t.isValid(i.name))if(t.isValid(i.content)){for(a=0;a<r.length&&!o;a++)if(n=r[a],i.extension.toLowerCase()===n.ext.toLowerCase())if(n.ignore)o=!0;else if("ArrayBuffer"===n.type){if(!(i.content instanceof ArrayBuffer||i.content instanceof Uint8Array))throw"Provided content is not of type ArrayBuffer! Aborting...";s[n.ext]=i,o=!0}else if("String"===n.type){if(!("string"==typeof i.content||i.content instanceof String))throw"Provided content is not of type String! Aborting...";s[n.ext]=i,o=!0}if(!o)throw'Unidentified resource "'+i.name+'": '+i.url}else{if(!("string"==typeof i.name||i.name instanceof String))throw"Provided file is not properly defined! Aborting...";for(a=0;a<r.length&&!o;a++)n=r[a],i.extension.toLowerCase()===n.ext.toLowerCase()&&(n.ignore||(s[n.ext]=i),o=!0);if(!o)throw'Unidentified resource "'+i.name+'": '+i.url}return s},e}(),kf.MeshBuilder=function(){function e(){console.info("Using LoaderSupport.MeshBuilder version: "+t),this.logging={enabled:!0,debug:!1},this.callbacks=new kf.Callbacks,this.materials=[]}var t="1.2.2",r=kf.Validator;return e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0},e.prototype.init=function(){var e=new Ce({color:14479871});e.name="defaultMaterial";var t=new Ce({color:14479871});t.name="defaultVertexColorMaterial",t.vertexColors=il;var r=new R;r.name="defaultLineMaterial";var i=new Ne({size:1});i.name="defaultPointMaterial";var n={};n[e.name]=e,n[t.name]=t,n[r.name]=r,n[i.name]=i,this.updateMaterials({cmd:"materialData",materials:{materialCloneInstructions:null,serializedMaterials:null,runtimeMaterials:n}})},e.prototype.setMaterials=function(e){var t={cmd:"materialData",materials:{materialCloneInstructions:null,serializedMaterials:null,runtimeMaterials:r.isValid(this.callbacks.onLoadMaterials)?this.callbacks.onLoadMaterials(e):e}};this.updateMaterials(t)},e.prototype._setCallbacks=function(e){r.isValid(e.onProgress)&&this.callbacks.setCallbackOnProgress(e.onProgress),r.isValid(e.onReportError)&&this.callbacks.setCallbackOnReportError(e.onReportError),r.isValid(e.onMeshAlter)&&this.callbacks.setCallbackOnMeshAlter(e.onMeshAlter),r.isValid(e.onLoad)&&this.callbacks.setCallbackOnLoad(e.onLoad),r.isValid(e.onLoadMaterials)&&this.callbacks.setCallbackOnLoadMaterials(e.onLoadMaterials)},e.prototype.processPayload=function(e){return"meshData"===e.cmd?this.buildMeshes(e):"materialData"===e.cmd?(this.updateMaterials(e),null):void 0},e.prototype.buildMeshes=function(e){var t=this,i=e.params.meshName,n=new P;n.addAttribute("position",new g(new Float32Array(e.buffers.vertices),3)),r.isValid(e.buffers.indices)&&n.setIndex(new g(new Uint32Array(e.buffers.indices),1));var a=r.isValid(e.buffers.colors);a&&n.addAttribute("color",new g(new Float32Array(e.buffers.colors),3)),r.isValid(e.buffers.normals)?n.addAttribute("normal",new g(new Float32Array(e.buffers.normals),3)):n.computeVertexNormals(),r.isValid(e.buffers.uvs)&&n.addAttribute("uv",new g(new Float32Array(e.buffers.uvs),2));var o,s,l,c=e.materials.materialNames,u=e.materials.multiMaterial,h=[];for(l in c)s=c[l],o=t.materials[s],u&&h.push(o);if(u){o=h;var d,p=e.materials.materialGroups;for(l in p)d=p[l],n.addGroup(d.start,d.count,d.index)}var f,m,v=[],y=this.callbacks.onMeshAlter,x=!0,b=r.verifyInput(e.geometryType,0);if(r.isValid(y)&&(m=y({detail:{meshName:i,bufferGeometry:n,material:o,geometryType:b}}),r.isValid(m)))if(m.isDisregardMesh())x=!1;else if(m.providesAlteredMeshes()){for(var w in m.meshes)v.push(m.meshes[w]);x=!1}x&&(e.computeBoundingSphere&&n.computeBoundingSphere(),f=0===b?new k(n,o):1===b?new Yt(n,o):new Et(n,o),f.name=i,v.push(f));var _;if(r.isValid(v)&&v.length>0){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;s<this.maxWebWorkers;s++){var l=new kf.WorkerSupport;l.setLogging(o.logging.enabled,o.logging.debug),l.setForceWorkerDataCopy(o.workerDescription.forceWorkerDataCopy),o.workerDescription.workerSupports[s]={instanceNo:s,inUse:!1,terminateRequested:!1,workerSupport:l,loader:null}}},e.prototype.enqueueForRun=function(e){this.instructionQueue.length<this.maxQueueSize&&this.instructionQueue.push(e)},e.prototype.isRunning=function(){var e=Object.keys(this.workerDescription.workerSupports);return this.instructionQueue.length>0&&this.instructionQueuePointer<this.instructionQueue.length||e.length>0},e.prototype.processQueue=function(){var e,t,r=this;for(var i in r.workerDescription.workerSupports)t=r.workerDescription.workerSupports[i],t.inUse||(r.instructionQueuePointer<r.instructionQueue.length?(e=r.instructionQueue[r.instructionQueuePointer],r._kickWorkerRun(e,t),r.instructionQueuePointer++):r._deregister(t));this.isRunning()||null===this.callbackOnFinishedProcessing||(this.callbackOnFinishedProcessing(),this.callbackOnFinishedProcessing=null)},e.prototype._kickWorkerRun=function(e,t){t.inUse=!0,t.workerSupport.setTerminateRequested(t.terminateRequested),this.logging.enabled&&console.info("\nAssigning next item from queue to worker (queue length: "+this.instructionQueue.length+")\n\n");var i=this,n=e.getCallbacks(),a=this.workerDescription.globalCallbacks,o=function(e){r.isValid(a.onLoad)&&a.onLoad(e),r.isValid(n.onLoad)&&n.onLoad(e),i.objectsCompleted++,t.inUse=!1,i.processQueue()},s=function(e){r.isValid(a.onProgress)&&a.onProgress(e),r.isValid(n.onProgress)&&n.onProgress(e)},l=function(e,t){return r.isValid(a.onMeshAlter)&&(t=a.onMeshAlter(e,t)),r.isValid(n.onMeshAlter)&&(t=a.onMeshAlter(e,t)),t},c=function(e){return r.isValid(a.onLoadMaterials)&&(e=a.onLoadMaterials(e)),r.isValid(n.onLoadMaterials)&&(e=n.onLoadMaterials(e)),e},u=function(e){var o=!0;r.isValid(a.onReportError)&&(o=a.onReportError(t,e)),r.isValid(n.onReportError)&&(o=n.onReportError(t,e)),r.isValid(a.onReportError)||r.isValid(n.onReportError)||(console.error("Loader reported an error: "),console.error(e)),o&&(t.inUse=!1,i.processQueue())};t.loader=this._buildLoader(t.instanceNo);var h=new kf.Callbacks;h.setCallbackOnLoad(o),h.setCallbackOnProgress(s),h.setCallbackOnReportError(u),h.setCallbackOnMeshAlter(l),h.setCallbackOnLoadMaterials(c),e.callbacks=h,t.loader.run(e,t.workerSupport)},e.prototype._buildLoader=function(e){var t=this.workerDescription.classDef,i=Object.create(t.prototype);if(t.call(i,Du),!i.hasOwnProperty("instanceNo"))throw t.name+' has no property "instanceNo".';if(i.instanceNo=e,!i.hasOwnProperty("workerSupport"))throw t.name+' has no property "workerSupport".';if("function"!=typeof i.run)throw t.name+' has no function "run".';return i.hasOwnProperty("callbacks")&&r.isValid(i.callbacks)||(console.warn(t.name+' has an invalid property "callbacks". Will change to "LoaderSupport.Callbacks"'),i.callbacks=new kf.Callbacks),i},e.prototype._deregister=function(e){if(r.isValid(e)){e.workerSupport.setTerminateRequested(!0),this.logging.enabled&&console.info("Requested termination of worker #"+e.instanceNo+".");var t=e.loader.callbacks;r.isValid(t.onProgress)&&t.onProgress({detail:{text:""}}),delete this.workerDescription.workerSupports[e.instanceNo]}},e.prototype.tearDown=function(e){var t=this;this.logging.enabled&&console.info("WorkerDirector received the deregister call. Terminating all workers!"),this.instructionQueuePointer=this.instructionQueue.length,this.callbackOnFinishedProcessing=r.verifyInput(e,null);for(var i in t.workerDescription.workerSupports)t.workerDescription.workerSupports[i].terminateRequested=!0},e}();var Bf=function(e){this.manager=void 0!==e?e:Du};Bf.prototype={constructor:Bf,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(){var e=[[-.525731,0,.850651],[-.442863,.238856,.864188],[-.295242,0,.955423],[-.309017,.5,.809017],[-.16246,.262866,.951056],[0,0,1],[0,.850651,.525731],[-.147621,.716567,.681718],[.147621,.716567,.681718],[0,.525731,.850651],[.309017,.5,.809017],[.525731,0,.850651],[.295242,0,.955423],[.442863,.238856,.864188],[.16246,.262866,.951056],[-.681718,.147621,.716567],[-.809017,.309017,.5],[-.587785,.425325,.688191],[-.850651,.525731,0],[-.864188,.442863,.238856],[-.716567,.681718,.147621],[-.688191,.587785,.425325],[-.5,.809017,.309017],[-.238856,.864188,.442863],[-.425325,.688191,.587785],[-.716567,.681718,-.147621],[-.5,.809017,-.309017],[-.525731,.850651,0],[0,.850651,-.525731],[-.238856,.864188,-.442863],[0,.955423,-.295242],[-.262866,.951056,-.16246],[0,1,0],[0,.955423,.295242],[-.262866,.951056,.16246],[.238856,.864188,.442863],[.262866,.951056,.16246],[.5,.809017,.309017],[.238856,.864188,-.442863],[.262866,.951056,-.16246],[.5,.809017,-.309017],[.850651,.525731,0],[.716567,.681718,.147621],[.716567,.681718,-.147621],[.525731,.850651,0],[.425325,.688191,.587785],[.864188,.442863,.238856],[.688191,.587785,.425325],[.809017,.309017,.5],[.681718,.147621,.716567],[.587785,.425325,.688191],[.955423,.295242,0],[1,0,0],[.951056,.16246,.262866],[.850651,-.525731,0],[.955423,-.295242,0],[.864188,-.442863,.238856],[.951056,-.16246,.262866],[.809017,-.309017,.5],[.681718,-.147621,.716567],[.850651,0,.525731],[.864188,.442863,-.238856],[.809017,.309017,-.5],[.951056,.16246,-.262866],[.525731,0,-.850651],[.681718,.147621,-.716567],[.681718,-.147621,-.716567],[.850651,0,-.525731],[.809017,-.309017,-.5],[.864188,-.442863,-.238856],[.951056,-.16246,-.262866],[.147621,.716567,-.681718],[.309017,.5,-.809017],[.425325,.688191,-.587785],[.442863,.238856,-.864188],[.587785,.425325,-.688191],[.688191,.587785,-.425325],[-.147621,.716567,-.681718],[-.309017,.5,-.809017],[0,.525731,-.850651],[-.525731,0,-.850651],[-.442863,.238856,-.864188],[-.295242,0,-.955423],[-.16246,.262866,-.951056],[0,0,-1],[.295242,0,-.955423],[.16246,.262866,-.951056],[-.442863,-.238856,-.864188],[-.309017,-.5,-.809017],[-.16246,-.262866,-.951056],[0,-.850651,-.525731],[-.147621,-.716567,-.681718],[.147621,-.716567,-.681718],[0,-.525731,-.850651],[.309017,-.5,-.809017],[.442863,-.238856,-.864188],[.16246,-.262866,-.951056],[.238856,-.864188,-.442863],[.5,-.809017,-.309017],[.425325,-.688191,-.587785],[.716567,-.681718,-.147621],[.688191,-.587785,-.425325],[.587785,-.425325,-.688191],[0,-.955423,-.295242],[0,-1,0],[.262866,-.951056,-.16246],[0,-.850651,.525731],[0,-.955423,.295242],[.238856,-.864188,.442863],[.262866,-.951056,.16246],[.5,-.809017,.309017],[.716567,-.681718,.147621],[.525731,-.850651,0],[-.238856,-.864188,-.442863],[-.5,-.809017,-.309017],[-.262866,-.951056,-.16246],[-.850651,-.525731,0],[-.716567,-.681718,-.147621],[-.716567,-.681718,.147621],[-.525731,-.850651,0],[-.5,-.809017,.309017],[-.238856,-.864188,.442863],[-.262866,-.951056,.16246],[-.864188,-.442863,.238856],[-.809017,-.309017,.5],[-.688191,-.587785,.425325],[-.681718,-.147621,.716567],[-.442863,-.238856,.864188],[-.587785,-.425325,.688191],[-.309017,-.5,.809017],[-.147621,-.716567,.681718],[-.425325,-.688191,.587785],[-.16246,-.262866,.951056],[.442863,-.238856,.864188],[.16246,-.262866,.951056],[.309017,-.5,.809017],[.147621,-.716567,.681718],[0,-.525731,.850651],[.425325,-.688191,.587785],[.587785,-.425325,.688191],[.688191,-.587785,.425325],[-.955423,.295242,0],[-.951056,.16246,.262866],[-1,0,0],[-.850651,0,.525731],[-.955423,-.295242,0],[-.951056,-.16246,.262866],[-.864188,.442863,-.238856],[-.951056,.16246,-.262866],[-.809017,.309017,-.5],[-.864188,-.442863,-.238856],[-.951056,-.16246,-.262866],[-.809017,-.309017,-.5],[-.681718,.147621,-.716567],[-.681718,-.147621,-.716567],[-.850651,0,-.525731],[-.688191,.587785,-.425325],[-.587785,.425325,-.688191],[-.425325,.688191,-.587785],[-.425325,-.688191,-.587785],[-.587785,-.425325,-.688191],[-.688191,-.587785,-.425325]];return function(t){console.time("MD2Loader");for(var r=new DataView(t),n={},a=["ident","version","skinwidth","skinheight","framesize","num_skins","num_vertices","num_st","num_tris","num_glcmds","num_frames","offset_skins","offset_st","offset_tris","offset_frames","offset_glcmds","offset_end"],o=0;o<a.length;o++)n[a[o]]=r.getInt32(4*o,!0);if(844121161!==n.ident||8!==n.version)return void console.error("Not a valid MD2 file");if(n.offset_end!==r.byteLength)return void console.error("Corrupted MD2 file");for(var s=new P,l=[],c=n.offset_st,o=0,u=n.num_st;o<u;o++){var h=r.getInt16(c+0,!0),d=r.getInt16(c+2,!0);l.push(h/n.skinwidth,1-d/n.skinheight),c+=4}c=n.offset_tris;for(var p=[],f=[],o=0,u=n.num_tris;o<u;o++)p.push(r.getUint16(c+0,!0),r.getUint16(c+2,!0),r.getUint16(c+4,!0)),f.push(r.getUint16(c+6,!0),r.getUint16(c+8,!0),r.getUint16(c+10,!0)),c+=12;var m=new i,v=new i,g=[],y=[];c=n.offset_frames;for(var o=0,u=n.num_frames;o<u;o++){v.set(r.getFloat32(c+0,!0),r.getFloat32(c+4,!0),r.getFloat32(c+8,!0)),m.set(r.getFloat32(c+12,!0),r.getFloat32(c+16,!0),r.getFloat32(c+20,!0)),c+=24;for(var x=0;x<16;x++){var b=r.getUint8(c+x,!0);if(0===b)break;g[x]=b}var w={name:String.fromCharCode.apply(null,g),
|
|
vertices:[],normals:[]};c+=16;for(var x=0;x<n.num_vertices;x++){var _=r.getUint8(c++,!0),S=r.getUint8(c++,!0),A=r.getUint8(c++,!0),T=e[r.getUint8(c++,!0)];_=_*v.x+m.x,S=S*v.y+m.y,A=A*v.z+m.z,w.vertices.push(_,A,S),w.normals.push(T[0],T[2],T[1])}y.push(w)}for(var E=[],C=[],L=[],N=y[0].vertices,O=y[0].normals,o=0,u=p.length;o<u;o++){var D=p[o],F=3*D,_=N[F],S=N[F+1],A=N[F+2];E.push(_,S,A);var R=O[F],I=O[F+1],U=O[F+2];C.push(R,I,U);var k=f[o];F=2*k;var h=l[F],d=l[F+1];L.push(h,d)}s.addAttribute("position",new M(E,3)),s.addAttribute("normal",new M(C,3)),s.addAttribute("uv",new M(L,2));for(var B=[],z=[],o=0,u=y.length;o<u;o++){var w=y[o],j=w.name;if(w.vertices.length>0){for(var E=[],x=0,V=p.length;x<V;x++){var D=p[x],F=3*D,_=w.vertices[F],S=w.vertices[F+1],A=w.vertices[F+2];E.push(_,S,A)}var G=new M(E,3);G.name=j,B.push(G)}if(w.normals.length>0){for(var C=[],x=0,V=p.length;x<V;x++){var D=p[x],F=3*D,R=w.normals[F],I=w.normals[F+1],U=w.normals[F+2];C.push(R,I,U)}var W=new M(C,3);W.name=j,z.push(W)}}return s.morphAttributes.position=B,s.morphAttributes.normal=z,s.animations=re.CreateClipsFromMorphTargetSequences(y,10),console.timeEnd("MD2Loader"),s}}()};var zf=function(){function e(e){this.manager=void 0!==e?e:Du,this.loader=new we(this.manager),this.parser=null,this.meshBuilder=new t(this.manager),this.animationBuilder=new s}function t(e){this.geometryBuilder=new r,this.materialBuilder=new a(e)}function r(){}function a(e){this.manager=e,this.textureLoader=new Ue(this.manager),this.tgaLoader=null}function s(){}function l(e,t,r,i,n){j.call(this,e,t,r,i),this.interpolationParams=n}e.prototype={constructor:e,crossOrigin:"anonymous",setCrossOrigin:function(e){return this.crossOrigin=e,this},load:function(e,t,r,i){var n=this.meshBuilder.setCrossOrigin(this.crossOrigin),a=Ru.extractUrlBase(e),o=this._extractExtension(e).toLowerCase();return"pmd"!==o&&"pmx"!==o?void(i&&i(new Error("MMDLoader: Unknown model file extension ."+o+"."))):void this["pmd"===o?"loadPMD":"loadPMX"](e,function(e){t(n.build(e,a,r,i))},r,i)},loadAnimation:function(e,t,r,i,n){var a=this.animationBuilder;this.loadVMD(e,function(e){r(t.isCamera?a.buildCameraAnimation(e):a.build(e,t))},i,n)},loadWithAnimation:function(e,t,r,i,n){var a=this;this.load(e,function(e){a.loadAnimation(t,e,function(t){r({mesh:e,animation:t})},i,n)},i,n)},loadPMD:function(e,t,r,i){var n=this._getParser();this.loader.setMimeType(void 0).setResponseType("arraybuffer").load(e,function(e){t(n.parsePmd(e,!0))},r,i)},loadPMX:function(e,t,r,i){var n=this._getParser();this.loader.setMimeType(void 0).setResponseType("arraybuffer").load(e,function(e){t(n.parsePmx(e,!0))},r,i)},loadVMD:function(e,t,r,i){var n=this,a=Array.isArray(e)?e:[e],o=[],s=a.length,l=this._getParser();this.loader.setMimeType(void 0).setResponseType("arraybuffer");for(var c=0,u=a.length;c<u;c++)n.loader.load(a[c],function(e){o.push(l.parseVmd(e,!0)),o.length===s&&t(l.mergeVmds(o))},r,i)},loadVPD:function(e,t,r,i,n){var a=this._getParser();this.loader.setMimeType(t?void 0:"text/plain; charset=shift_jis").setResponseType("text").load(e,function(e){r(a.parseVpd(e,!0))},i,n)},_extractExtension:function(e){var t=e.lastIndexOf(".");return t<0?"":e.slice(t+1)},_getParser:function(){if(null===this.parser){if("undefined"==typeof MMDParser)throw new Error("MMDLoader: Import MMDParser https://github.com/takahirox/mmd-parser");this.parser=new MMDParser.Parser}return this.parser}};var c=["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/bWiiMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh8aBHZBl14e8wAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOUlEQVRYR+3WMREAMAwDsYY/yoDI7MLwIiP40+RJklfcCCBAgAABAgTqArfb/QMCCBAgQIAAgbbAB3z/e0F3js2cAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/B5ilMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh81dWyx0gFwKAAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOklEQVRYR+3WoREAMAwDsWb/UQtCy9wxTOQJ/oQ8SXKKGwEECBAgQIBAXeDt7f4BAQQIECBAgEBb4AOz8Hzx7WLY4wAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABPUlEQVRYR+1XwW7CMAy1+f9fZOMysSEOEweEOPRNdm3HbdOyIhAcklPrOs/PLy9RygBALxzcCDQFmgJNgaZAU6Ap0BR4PwX8gsRMVLssMRH5HcpzJEaWL7EVg9F1IHRlyqQohgVr4FGUlUcMJSjcUlDw0zvjeun70cLWmneoyf7NgBTQSniBTQQSuJAZsOnnaczjIMb5hCiuHKxokCrJfVnrctyZL0PkJAJe1HMil4nxeyi3Ypfn1kX51jpPvo/JeCNC4PhVdHdJw2XjBR8brF8PEIhNVn12AgP7uHsTBguBn53MUZCqv7Lp07Pn5k1Ro+uWmUNn7D+M57rtk7aG0Vo73xyF/fbFf0bPJjDXngnGocDTdFhygZjwUQrMNrDcmZlQT50VJ/g/UwNyHpu778+yW+/ksOz/BFo54P4AsUXMfRq7XWsAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACMElEQVRYR+2Xv4pTQRTGf2dubhLdICiii2KnYKHVolhauKWPoGAnNr6BD6CvIVaihYuI2i1ia0BY0MZGRHQXjZj/mSPnnskfNWiWZUlzJ5k7M2cm833nO5Mziej2DWWJRUoCpQKlAntSQCqgw39/iUWAGmh37jrRnVsKlgpiqmkoGVABA7E57fvY+pJDdgKqF6HzFCSADkDq+F6AHABtQ+UMVE5D7zXod7fFNhTEckTbj5XQgHzNN+5tQvc5NG7C6BNkp6D3EmpXHDR+dQAjFLchW3VS9rlw3JBh+B7ys5Cf9z0GW1C/7P32AyBAOAz1q4jGliIH3YPuBnSfQX4OGreTIgEYQb/pBDtPnEQ4CivXYPAWBk13oHrB54yA9QuSn2H4AcKRpEILDt0BUzj+RLR1V5EqjD66NPRBVpLcQwjHoHYJOhsQv6U4mnzmrIXJCFr4LDwm/xBUoboG9XX4cc9VKdYoSA2yk5NQLJaKDUjTBoveG3Z2TElTxwjNK4M3LEZgUdDdruvcXzKBpStgp2NPiWi3ks9ZXxIoFVi+AvHLdc9TqtjL3/aYjpPlrzOcEnK62Szhimdd7xX232zFDTgtxezOu3WNMRLjiKgjtOhHVMd1loynVHvOgjuIIJMaELEqhJAV/RCSLbWTcfPFakFgFlALTRRvx+ok6Hlp/Q+v3fmx90bMyUzaEAhmM3KvHlXTL5DxnbGf/1M8RNNACLL5MNtPxP/mypJAqcDSFfgFhpYqWUzhTEAAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII="];return t.prototype={constructor:t,crossOrigin:"anonymous",setCrossOrigin:function(e){return this.crossOrigin=e,this},build:function(e,t,r,i){var n=this.geometryBuilder.build(e),a=this.materialBuilder.setCrossOrigin(this.crossOrigin).setTexturePath(t).build(e,n,r,i),o=new Rt(n,a);return o}},r.prototype={constructor:r,build:function(e){function t(t,r,i){for(var n=0;n<r.elementCount;n++){var a,o=r.elements[n];a="pmd"===e.metadata.format?e.morphs[0].elements[o.index].index:o.index,t.array[3*a+0]+=o.position[0]*i,t.array[3*a+1]+=o.position[1]*i,t.array[3*a+2]+=o.position[2]*i}}for(var r=[],n=[],a=[],o=[],s=[],l=[],c=[],u=[],h=[],d=[],p=[],f=[],m=[],v=[],g=0,y={},x=0;x<e.metadata.vertexCount;x++){for(var b=e.vertices[x],w=0,S=b.position.length;w<S;w++)r.push(b.position[w]);for(var w=0,S=b.normal.length;w<S;w++)a.push(b.normal[w]);for(var w=0,S=b.uv.length;w<S;w++)n.push(b.uv[w]);for(var w=0;w<4;w++)c.push(b.skinIndices.length-1>=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<e.metadata.faceCount;x++)for(var A=e.faces[x],w=0,S=A.indices.length;w<S;w++)o.push(A.indices[w]);for(var x=0;x<e.metadata.materialCount;x++){var T=e.materials[x];s.push({offset:3*g,count:3*T.faceCount}),g+=T.faceCount}for(var x=0;x<e.metadata.rigidBodyCount;x++){var E=e.rigidBodies[x],C=y[E.boneIndex];C=void 0===C?E.type:Math.max(E.type,C),y[E.boneIndex]=C}for(var x=0;x<e.metadata.boneCount;x++){var L=e.bones[x],N={parent:L.parentIndex,name:L.name,pos:L.position.slice(0,3),rotq:[0,0,0,1],scl:[1,1,1],rigidBodyType:void 0!==y[x]?y[x]:-1};N.parent!==-1&&(N.pos[0]-=e.bones[N.parent].position[0],N.pos[1]-=e.bones[N.parent].position[1],N.pos[2]-=e.bones[N.parent].position[2]),l.push(N)}if("pmd"===e.metadata.format)for(var x=0;x<e.metadata.ikCount;x++){for(var O=e.iks[x],D={target:O.target,effector:O.effector,iteration:O.iteration,maxAngle:4*O.maxAngle,links:[]},w=0,S=O.links.length;w<S;w++){var F={};F.index=O.links[w].index,F.enabled=!0,e.bones[F.index].name.indexOf("ひざ")>=0&&(F.limitation=new i(1,0,0)),D.links.push(F)}p.push(D)}else for(var x=0;x<e.metadata.boneCount;x++){var O=e.bones[x].ik;if(void 0!==O){for(var D={target:x,effector:O.effector,iteration:O.iteration,maxAngle:O.maxAngle,links:[]},w=0,S=O.links.length;w<S;w++){var F={};if(F.index=O.links[w].index,F.enabled=!0,1===O.links[w].angleLimitation){var R=O.links[w].lowerLimitationAngle,I=O.links[w].upperLimitationAngle,U=-I[0],k=-I[1];I[0]=-R[0],I[1]=-R[1],R[0]=U,R[1]=k,F.rotationMin=(new i).fromArray(R),F.rotationMax=(new i).fromArray(I)}D.links.push(F)}p.push(D)}}if("pmx"===e.metadata.format){for(var x=0;x<e.metadata.boneCount;x++){var L=e.bones[x],B=L.grant;if(void 0!==B){var D={index:x,parentIndex:B.parentIndex,ratio:B.ratio,isLocal:B.isLocal,affectRotation:B.affectRotation,affectPosition:B.affectPosition,transformationClass:L.transformationClass};f.push(D)}}f.sort(function(e,t){return e.transformationClass-t.transformationClass})}for(var x=0;x<e.metadata.morphCount;x++){var z=e.morphs[x],j={name:z.name},V=new M(3*e.metadata.vertexCount,3);V.name=z.name;for(var w=0;w<3*e.metadata.vertexCount;w++)V.array[w]=r[w];if("pmd"===e.metadata.format)0!==x&&t(V,z,1);else if(0===z.type)for(var w=0;w<z.elementCount;w++){var G=e.morphs[z.elements[w].index],W=z.elements[w].ratio;1===G.type&&t(V,G,W)}else 1===z.type?t(V,z,1):2===z.type||3===z.type||4===z.type||5===z.type||6===z.type||7===z.type||8===z.type;h.push(j),d.push(V)}for(var x=0;x<e.metadata.rigidBodyCount;x++){var X=e.rigidBodies[x],j={};for(var H in X)j[H]=X[H];if("pmx"===e.metadata.format&&j.boneIndex!==-1){var N=e.bones[j.boneIndex];j.position[0]-=N.position[0],j.position[1]-=N.position[1],j.position[2]-=N.position[2]}m.push(j)}for(var x=0;x<e.metadata.constraintCount;x++){var Y=e.constraints[x],j={};for(var H in Y)j[H]=Y[H];var q=m[j.rigidBodyIndex1],Q=m[j.rigidBodyIndex2];0!==q.type&&2===Q.type&&q.boneIndex!==-1&&Q.boneIndex!==-1&&e.bones[Q.boneIndex].parentIndex===q.boneIndex&&(Q.type=1),v.push(j)}var J=new P;J.addAttribute("position",new M(r,3)),J.addAttribute("normal",new M(a,3)),J.addAttribute("uv",new M(n,2)),J.addAttribute("skinIndex",new _(c,4)),J.addAttribute("skinWeight",new M(u,4)),J.setIndex(o);for(var x=0,Z=s.length;x<Z;x++)J.addGroup(s[x].offset,s[x].count,x);return J.bones=l,J.morphTargets=h,J.morphAttributes.position=d,J.userData.MMD={bones:l,iks:p,grants:f,rigidBodies:m,constraints:v,format:e.metadata.format},J.computeBoundingSphere(),J}},a.prototype={constructor:a,crossOrigin:"anonymous",texturePath:void 0,setCrossOrigin:function(e){return this.crossOrigin=e,this},setTexturePath:function(e){return this.texturePath=e,this},build:function(e,t,r,i){function n(e,t){for(var r=0,i=e.length;r<i;r++){var n=e[r];if(n.index!==-1){var a=t[n.index];a.opacity!==n.diffuse[3]&&(a.transparent=!0)}}}var a=this,o=[],s={};this.textureLoader.setCrossOrigin(this.crossOrigin);for(var l=0;l<e.metadata.materialCount;l++){var c=e.materials[l],h={userData:{}};if(void 0!==c.name&&(h.name=c.name),h.color=(new u).fromArray(c.diffuse),h.opacity=c.diffuse[3],h.specular=(new u).fromArray(c.specular),h.emissive=(new u).fromArray(c.ambient),h.shininess=Math.max(c.shininess,1e-4),h.transparent=1!==h.opacity,h.skinning=t.bones.length>0,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;l<g;l++){var y=e.morphs[l],x=y.elements;if(0===y.type)for(var b=0,w=x.length;b<w;b++){var _=e.morphs[x[b].index];8===_.type&&n(_.elements,o)}else 8===y.type&&n(x,o)}return o},_getTGALoader:function(){if(null===this.tgaLoader){if(void 0===wf)throw new Error("MMDLoader: Import TGALoader");this.tgaLoader=new wf(this.manager)}return this.tgaLoader},_isDefaultToonTexture:function(e){return 10===e.length&&/toon(10|0[0-9])\.bmp/.test(e)},_loadTexture:function(e,t,r,i,n){r=r||{};var a,o=this;if(r.isDefaultToonTexture===!0){var s;try{s=parseInt(e.match("toon([0-9]{2}).bmp$")[1])}catch(l){console.warn("MMDLoader: "+e+" seems like a not right default texture path. Using toon00.bmp instead."),s=0}a=c[s]}else a=this.texturePath+e;if(void 0!==t[a])return t[a];var u=Loader.Handlers.get(a);null===u&&(u=".tga"===e.slice(-4).toLowerCase()?this._getTGALoader():this.textureLoader);var h=u.load(a,function(e){r.isToonTexture===!0&&(e.image=o._getRotatedImage(e.image)),e.flipY=!1,e.wrapS=Jl,e.wrapT=Jl;for(var t=0;t<h.readyCallbacks.length;t++)h.readyCallbacks[t](h);delete h.readyCallbacks},i,n);return r.sphericalReflectionMapping===!0&&(h.mapping=Yl),h.readyCallbacks=[],t[a]=h,h},_getRotatedImage:function(e){var t=document.createElement("canvas"),r=t.getContext("2d"),i=e.width,n=e.height;return t.width=i,t.height=n,r.clearRect(0,0,i,n),r.translate(i/2,n/2),r.rotate(.5*Math.PI),r.translate(-i/2,-n/2),r.drawImage(e,0,0),r.getImageData(0,0,i,n)},_checkImageTransparency:function(e,t,r){e.readyCallbacks.push(function(i){function n(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,t.width,t.height)}function a(e,t,r){var i=e.width,n=e.height,a=e.data,s=253;if(a.length/(i*n)!==4)return!1;for(var l=0;l<r.length;l+=3){for(var c={x:0,y:0},u=0;u<3;u++){var h=r[3*l+u],d={x:t[2*h+0],y:t[2*h+1]};if(o(e,d)<s)return!0;c.x+=d.x,c.y+=d.y}if(c.x/=3,c.y/=3,o(e,c)<s)return!0}return!1}function o(e,t){var r=e.width,i=e.height,n=Math.round(t.x*r)%r,a=Math.round(t.y*i)%i;n<0&&(n+=r),a<0&&(a+=i);var o=a*r+n;return e.data[4*o+3]}var s=void 0!==i.image.data?i.image:n(i.image),l=t.groups[r];a(s,t.attributes.uv.array,t.index.array.slice(l.start,l.start+l.count))&&(e.transparent=!0)})}},s.prototype={constructor:s,build:function(e,t){for(var r=this.buildSkeletalAnimation(e,t).tracks,i=this.buildMorphAnimation(e,t).tracks,n=0,a=i.length;n<a;n++)r.push(i[n]);return new re("",(-1),r)},buildSkeletalAnimation:function(e,t){function r(e,t,r){e.push(t[r+0]/127),e.push(t[r+8]/127),e.push(t[r+4]/127),e.push(t[r+12]/127)}for(var i=this,n=[],a={},o=t.skeleton.bones,s={},l=0,c=o.length;l<c;l++)s[o[l].name]=!0;for(var l=0;l<e.metadata.motionCount;l++){var u=e.motions[l],h=u.boneName;void 0!==s[h]&&(a[h]=a[h]||[],a[h].push(u))}for(var d in a){var p=a[d];p.sort(function(e,t){return e.frameNum-t.frameNum});for(var f=[],m=[],v=[],g=[],y=[],x=t.skeleton.getBoneByName(d).position.toArray(),l=0,c=p.length;l<c;l++){var b=p[l].frameNum/30,w=p[l].position,_=p[l].rotation,S=p[l].interpolation;f.push(b);for(var A=0;A<3;A++)m.push(x[A]+w[A]);for(var A=0;A<4;A++)v.push(_[A]);for(var A=0;A<3;A++)r(g,S,A);r(y,S,3)}var M=".bones["+d+"]";n.push(i._createTrack(M+".position",VectorKeyframeTrack,f,m,g)),n.push(i._createTrack(M+".quaternion",QuaternionKeyframeTrack,f,v,y))}return new re("",(-1),n)},buildMorphAnimation:function(e,t){for(var r=[],i={},n=t.morphTargetDictionary,a=0;a<e.metadata.morphCount;a++){var o=e.morphs[a],s=o.morphName;void 0!==n[s]&&(i[s]=i[s]||[],i[s].push(o))}for(var l in i){var c=i[l];c.sort(function(e,t){return e.frameNum-t.frameNum});for(var u=[],h=[],a=0,d=c.length;a<d;a++)u.push(c[a].frameNum/30),h.push(c[a].weight);r.push(new Z(".morphTargetInfluences["+n[l]+"]",u,h))}return new re("",(-1),r)},buildCameraAnimation:function(e){function t(e,t){e.push(t.x),e.push(t.y),e.push(t.z)}function r(e,t){e.push(t.x),e.push(t.y),e.push(t.z),e.push(t.w)}function a(e,t,r){e.push(t[4*r+0]/127),e.push(t[4*r+1]/127),e.push(t[4*r+2]/127),e.push(t[4*r+3]/127)}var s=[],l=void 0===e.cameras?[]:e.cameras.slice();l.sort(function(e,t){return e.frameNum-t.frameNum});for(var c=[],u=[],h=[],d=[],p=[],f=[],m=[],v=[],g=[],y=new n,x=new o,b=new i,w=new i,_=0,S=l.length;_<S;_++){var A=l[_],M=A.frameNum/30,T=A.position,E=A.rotation,C=A.distance,L=A.fov,P=A.interpolation;c.push(M),b.set(0,0,-C),w.set(T[0],T[1],T[2]),x.set(-E[0],-E[1],-E[2]),y.setFromEuler(x),b.add(w),b.applyQuaternion(y),t(u,w),r(h,y),t(d,b),p.push(L);for(var N=0;N<3;N++)a(f,P,N);a(m,P,3);for(var N=0;N<3;N++)a(v,P,4);a(g,P,5)}var s=[];return s.push(this._createTrack("target.position",VectorKeyframeTrack,c,u,f)),s.push(this._createTrack(".quaternion",QuaternionKeyframeTrack,c,h,m)),s.push(this._createTrack(".position",VectorKeyframeTrack,c,d,v)),s.push(this._createTrack(".fov",Z,c,p,g)),new re("",(-1),s)},_createTrack:function(e,t,r,i,n){if(r.length>2){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;c<u;c++){for(var h=0;h<a;h++)if(i[s*a+h]!==i[(s-1)*a+h]||i[s*a+h]!==i[c*a+h]){s++;break}if(c>s){r[s]=r[c];for(var h=0;h<a;h++)i[s*a+h]=i[c*a+h];for(var h=0;h<o;h++)n[s*o+h]=n[c*o+h]}}r.length=s+1,i.length=(s+1)*a,n.length=(s+1)*o}var d=new t(e,r,i);return d.createInterpolant=function(e){return new l(this.times,this.values,this.getValueSize(),e,new Float32Array(n))},d}},l.prototype=Object.assign(Object.create(j.prototype),{constructor:l,interpolate_:function(e,t,r,i){var a=this,o=this.resultBuffer,s=this.sampleValues,l=this.valueSize,c=this.interpolationParams,u=e*l,h=u-l,d=i-t<.05?0:(r-t)/(i-t);if(4===l){var p=c[4*e+0],f=c[4*e+1],m=c[4*e+2],v=c[4*e+3],g=this._calculate(p,f,m,v,d);n.slerpFlat(o,0,s,h,s,u,g)}else if(3===l)for(var y=0;y!==l;++y){var p=c[12*e+4*y+0],f=c[12*e+4*y+1],m=c[12*e+4*y+2],v=c[12*e+4*y+3],g=a._calculate(p,f,m,v,d);o[y]=s[h+y]*(1-g)+s[u+y]*g}else{var p=c[4*e+0],f=c[4*e+1],m=c[4*e+2],v=c[4*e+3],g=this._calculate(p,f,m,v,d);o[0]=s[h]*(1-g)+s[u]*g}return o},_calculate:function(e,t,r,i,n){for(var a,o,s,l=.5,c=l,u=1-c,h=15,d=1e-5,p=Math,f=0;f<h;f++){a=3*u*u*c,o=3*u*c*c,s=c*c*c;var m=a*e+o*t+s-n;if(p.abs(m)<d)break;l/=2,c+=m<0?l:-l,u=1-c}return a*r+o*i+s}}),e}(),jf=function(e){this.manager=void 0!==e?e:Du};jf.prototype={constructor:jf,load:function(e,t,r,i){var n=this,a=new we(this.manager);a.setPath(this.path),a.load(e,function(e){t(n.parse(e))},r,i)},setPath:function(e){return this.path=e,this},setTexturePath:function(e){return this.texturePath=e,this},setBaseUrl:function(e){return console.warn("MTLLoader: .setBaseUrl() is deprecated. Use .setTexturePath( path ) for texture path or .setPath( path ) for general base path instead."),this.setTexturePath(e)},setCrossOrigin:function(e){return this.crossOrigin=e,this},setMaterialOptions:function(e){return this.materialOptions=e,this},parse:function(e){for(var t=e.split("\n"),r={},i=/\s+/,n={},a=0;a<t.length;a++){var o=t[a];if(o=o.trim(),0!==o.length&&"#"!==o.charAt(0)){var s=o.indexOf(" "),l=s>=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;s<o.length;){var l,c,u=o[s++];"in"==u||"out"==u||"inout"==u?l=o[s++]:(l=u,u=""),c=o[s++],n.inputs.push({name:c,type:l,qualifier:u})}}else this.type="",this.name=""}this.value=e};var Gf={nodes:{},keywords:{},add:function(e){this.nodes[e.name]=e},addKeyword:function(e,t,r){r=void 0===r||r,this.keywords[e]={callback:t,cache:r}},remove:function(e){delete this.nodes[e.name]},removeKeyword:function(e){delete this.keywords[e]},get:function(e){return this.nodes[e]},getKeyword:function(e,t){return this.keywords[e].callback.call(this,t)},getKeywordData:function(e){return this.keywords[e]},contains:function(e){return void 0!=this.nodes[e]},containsKeyword:function(e){return void 0!=this.keywords[e]}},Wf=["uv","uv2"],Xf=["vUv","vUv2"];rr.prototype=Object.create(tr.prototype),rr.prototype.constructor=rr,rr.prototype.nodeType="UV",rr.prototype.generate=function(e,t){e.requires.uv[this.index]=!0;var r=e.isShader("vertex")?Wf[this.index]:Xf[this.index];return e.format(r,this.getType(e),t)},rr.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.index=e.index},rr.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t},Gf.addKeyword("uv",function(){return new rr}),Gf.addKeyword("uv2",function(){return new rr(1)}),ir.LOCAL="local",ir.WORLD="world",ir.VIEW="view",ir.PROJECTION="projection",ir.prototype=Object.create(tr.prototype),ir.prototype.constructor=ir,ir.prototype.nodeType="Position",ir.prototype.getType=function(){switch(this.scope){case ir.PROJECTION:return"v4"}return this.type},ir.prototype.isShared=function(e){switch(this.scope){case ir.LOCAL:case ir.WORLD:return!1}return!0},ir.prototype.generate=function(e,t){var r;switch(this.scope){case ir.LOCAL:e.requires.position=!0,r=e.isShader("vertex")?"transformed":"vPosition";break;case ir.WORLD:e.requires.worldPosition=!0,r="vWPosition";break;case ir.VIEW:r=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case ir.PROJECTION:r=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )"}return e.format(r,this.getType(e),t)},ir.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.scope=e.scope},ir.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t},Gf.addKeyword("position",function(){return new ir}),Gf.addKeyword("worldPosition",function(){return new ir(ir.WORLD)}),Gf.addKeyword("viewPosition",function(){return new ir(NormalNode.VIEW)}),nr.LOCAL="local",nr.WORLD="world",nr.VIEW="view",nr.prototype=Object.create(tr.prototype),nr.prototype.constructor=nr,nr.prototype.nodeType="Normal",nr.prototype.isShared=function(e){switch(this.scope){case nr.WORLD:return!0}return!1},nr.prototype.generate=function(e,t){var r;switch(this.scope){case nr.LOCAL:e.requires.normal=!0,r="normal";break;case nr.WORLD:e.requires.worldNormal=!0,r=e.isShader("vertex")?"( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz":"vWNormal";break;case nr.VIEW:r="vNormal"}return e.format(r,this.getType(e),t)},nr.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.scope=e.scope},nr.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t},Gf.addKeyword("normal",function(){return new nr}),Gf.addKeyword("worldNormal",function(){return new nr(nr.WORLD)}),Gf.addKeyword("viewNormal",function(){return new nr(nr.VIEW)}),ar.prototype=Object.create(tr.prototype),ar.prototype.constructor=ar,ar.prototype.isReadonly=function(e){return this.readonly},ar.prototype.copy=function(e){tr.prototype.copy.call(this,e),void 0!==e.readonly&&(this.readonly=e.readonly)},ar.prototype.createJSONNode=function(e){var t=tr.prototype.createJSONNode.call(this,e);return this.readonly===!0&&(t.readonly=this.readonly),t},ar.prototype.generate=function(e,t,r,i,n,a){r=e.getUuid(r||this.getUuid()),i=i||this.getType(e);var o=e.getNodeData(r),s=this.isReadonly(e)&&void 0!==this.generateReadonly;return s?this.generateReadonly(e,t,r,i,n,a):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(i,this,n,a)),e.format(o.vertex.name,i,t)):(o.fragment||(o.fragment=e.createFragmentUniform(i,this,n,a)),e.format(o.fragment.name,i,t))},or.prototype=Object.create(ar.prototype),or.prototype.constructor=or,or.prototype.nodeType="Float",or.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format(this.value+(this.value%1?"":".0"),i,t)},or.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value=e.value},or.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,this.readonly===!0&&(t.readonly=!0)),t},sr.GLOBAL="global",sr.LOCAL="local",sr.DELTA="delta",sr.prototype=Object.create(or.prototype),sr.prototype.constructor=sr,sr.prototype.nodeType="Timer",sr.prototype.isReadonly=function(){return!1},sr.prototype.isUnique=function(){
|
|
return this.timeScale&&(this.scope===sr.GLOBAL||this.scope===sr.DELTA)},sr.prototype.updateFrame=function(e){var t=this.timeScale?this.scale:1;switch(this.scope){case sr.LOCAL:this.value+=e.delta*t;break;case sr.DELTA:this.value=e.delta*t;break;default:this.value=e.time*t}},sr.prototype.copy=function(e){or.prototype.copy.call(this,e),this.scope=e.scope,this.scale=e.scale,this.timeScale=e.timeScale},sr.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope,t.scale=this.scale,t.timeScale=this.timeScale),t},Gf.addKeyword("time",function(){return new sr});var Hf=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i;lr.PI="PI",lr.PI2="PI2",lr.RECIPROCAL_PI="RECIPROCAL_PI",lr.RECIPROCAL_PI2="RECIPROCAL_PI2",lr.LOG2="LOG2",lr.EPSILON="EPSILON",lr.prototype=Object.create(tr.prototype),lr.prototype.constructor=lr,lr.prototype.nodeType="Const",lr.prototype.getType=function(e){return e.getTypeByFormat(this.type)},lr.prototype.eval=function(e,t){this.src=e||"";var r,i,n="",a=this.src.match(Hf);this.useDefine=t||"#"===this.src.charAt(0),a&&a.length>1?(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;o<this.includes.length;o++)e.include(i.includes[o],i);for(var s in i.extensions)e.material.extensions[s]=!0;for(;r=Vf.rProperties.exec(this.value);){var l=r[0],c=!i.isMethod||!i.getInputByName(l),u=l;if(i.keywords[l]||i.useKeywords&&c&&Gf.containsKeyword(l)){var h=i.keywords[l];if(!h){var d=Gf.getKeywordData(l);d.cache&&(h=e.keywords[l]),h=h||Gf.getKeyword(l,e),d.cache&&(e.keywords[l]=h)}u=h.build(e)}l!=u&&(a=a.substring(0,r.index+n)+u+a.substring(r.index+l.length+n),n+=u.length-l.length),void 0===i.getIncludeByName(u)&&Gf.contains(u)&&e.include(Gf.get(u))}return"source"===t?a:this.isMethod?(e.include(this,!1,a),this.name):e.format("("+a+")",this.getType(e),t)},cr.Nodes=function(){var e=new Vf(["float depthColor( float mNear, float mFar ) {","\t#ifdef USE_LOGDEPTHBUF_EXT","\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;","\t#else","\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;","\t#endif","\treturn 1.0 - smoothstep( mNear, mFar, depth );","}"].join("\n"));return{depthColor:e}}(),cr.POSITION="position",cr.DEPTH="depth",cr.TO_VERTEX="toVertex",cr.prototype=Object.create(tr.prototype),cr.prototype.constructor=cr,cr.prototype.nodeType="Camera",cr.prototype.setCamera=function(e){this.camera=e,this.updateFrame=void 0!==e?this.onUpdateFrame:void 0},cr.prototype.setScope=function(e){switch(this.scope){case cr.DEPTH:delete this.near,delete this.far}switch(this.scope=e,e){case cr.DEPTH:var t=this.camera;this.near=new or(t?t.near:1),this.far=new or(t?t.far:1200)}},cr.prototype.getType=function(e){switch(this.scope){case cr.DEPTH:return"f"}return this.type},cr.prototype.isUnique=function(e){switch(this.scope){case cr.DEPTH:case cr.TO_VERTEX:return!0}return!1},cr.prototype.isShared=function(e){switch(this.scope){case cr.POSITION:return!1}return!0},cr.prototype.generate=function(e,t){var r;switch(this.scope){case cr.POSITION:r="cameraPosition";break;case cr.DEPTH:var i=e.include(cr.Nodes.depthColor);r=i+"( "+this.near.build(e,"f")+", "+this.far.build(e,"f")+" )";break;case cr.TO_VERTEX:r="normalize( "+new ir(ir.WORLD).build(e,"v3")+" - cameraPosition )"}return e.format(r,this.getType(e),t)},cr.prototype.onUpdateFrame=function(e){switch(this.scope){case cr.DEPTH:var t=this.camera;this.near.value=t.near,this.far.value=t.far}},cr.prototype.copy=function(e){switch(tr.prototype.copy.call(this,e),this.setScope(e.scope),e.camera&&this.setCamera(e.camera),e.scope){case cr.DEPTH:this.near.number=e.near,this.far.number=e.far}},cr.prototype.toJSON=function(e){var t=this.getJSONNode(e);if(!t)switch(t=this.createJSONNode(e),t.scope=this.scope,this.camera&&(t.camera=this.camera.uuid),this.scope){case cr.DEPTH:t.near=this.near.value,t.far=this.far.value}return t};var Yf=function(e,t){this.manager=void 0!==e?e:Du,this.nodes={},this.materials={},this.passes={},this.names={},this.library=t||{}};Object.assign(Yf.prototype,{load:function(e,t,r,i){var n=this,a=new we(n.manager);return a.load(e,function(e){t(n.parse(JSON.parse(e)))},r,i),this},getObjectByName:function(e){return this.names[e]},getObjectById:function(e){return this.library[e]||this.nodes[e]||this.materials[e]||this.passes[e]||this.names[e]},getNode:function(e){var t=this.getObjectById(e);return t||console.warn('Node "'+e+'" not found.'),t},resolve:function(e){var t=this;switch(typeof e){case"boolean":case"number":return e;case"string":return/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/i.test(e)||this.library[e]?this.getNode(e):e;default:if(Array.isArray(e))for(var r=0;r<e.length;r++)e[r]=t.resolve(e[r]);else for(var i in e)"uuid"!==i&&(e[i]=t.resolve(e[i]))}return e},declare:function(e){var t,r,i,n=this;for(t in e.nodes)r=e.nodes[t],i=new THREE[r.nodeType+"Node"],r.name&&(i.name=r.name,n.names[i.name]=i),n.nodes[t]=i;for(t in e.materials)r=e.materials[t],i=new THREE[r.type],r.name&&(i.name=r.name,n.names[i.name]=i),n.materials[t]=i;for(t in e.passes)r=e.passes[t],i=new THREE[r.type],r.name&&(i.name=r.name,n.names[i.name]=i),n.passes[t]=i;return e.material&&(this.material=this.materials[e.material]),e.pass&&(this.pass=this.passes[e.pass]),e},parse:function(e){var t,r=this;e=this.resolve(this.declare(e));for(t in e.nodes)r.nodes[t].copy(e.nodes[t]);for(t in e.materials)r.materials[t].copy(e.materials[t]);for(t in e.passes)r.passes[t].copy(e.passes[t]);return this.material||this.pass||this}});var qf=function(){function e(){var e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1)return this.object.name=e,void(this.object.fromDeclaration=t!==!1);var r=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(e,t){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var i={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?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;i<n;i++)t.addVertexPoint(t.parseVertexIndex(e[i],r))},addLineGeometry:function(e,t){var r=this;this.object.geometry.type="Line";for(var i=this.vertices.length,n=this.uvs.length,a=0,o=e.length;a<o;a++)r.addVertexLine(r.parseVertexIndex(e[a],i));for(var s=0,o=t.length;s<o;s++)r.addUVLine(r.parseUVIndex(t[s],n))}};return e.startObject("",!1),e}function t(e){this.manager=void 0!==e?e:Du,this.materials=null}var r=/^[og]\s*(.+)?/,i=/^mtllib /,n=/^usemtl /;return t.prototype={constructor:t,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setPath(this.path),a.load(e,function(e){t(n.parse(e))},r,i)},setPath:function(e){return this.path=e,this},setMaterials:function(e){return this.materials=e,this},parse:function(t){var a=this;console.time("OBJLoader");var o=new e;t.indexOf("\r\n")!==-1&&(t=t.replace(/\r\n/g,"\n")),t.indexOf("\\\n")!==-1&&(t=t.replace(/\\\n/g,""));for(var s=t.split("\n"),l="",c="",u=0,h=[],d="function"==typeof"".trimLeft,p=0,f=s.length;p<f;p++)if(l=s[p],l=d?l.trimLeft():l.trim(),u=l.length,0!==u&&(c=l.charAt(0),"#"!==c))if("v"===c){var m=l.split(/\s+/);switch(m[0]){case"v":o.vertices.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])),8===m.length&&o.colors.push(parseFloat(m[4]),parseFloat(m[5]),parseFloat(m[6]));break;case"vn":o.normals.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3]));break;case"vt":o.uvs.push(parseFloat(m[1]),parseFloat(m[2]))}}else if("f"===c){for(var v=l.substr(1).trim(),g=v.split(/\s+/),y=[],x=0,b=g.length;x<b;x++){var w=g[x];if(w.length>0){var _=w.split("/");y.push(_)}}for(var S=y[0],x=1,b=y.length-1;x<b;x++){var A=y[x],T=y[x+1];o.addFace(S[0],A[0],T[0],S[1],A[1],T[1],S[2],A[2],T[2])}}else if("l"===c){var E=l.substring(1).trim().split(" "),C=[],L=[];if(l.indexOf("/")===-1)C=E;else for(var N=0,O=E.length;N<O;N++){var D=E[N].split("/");""!==D[0]&&C.push(D[0]),""!==D[1]&&L.push(D[1])}o.addLineGeometry(C,L)}else if("p"===c){var v=l.substr(1).trim(),F=v.split(" ");o.addPointGeometry(F)}else if(null!==(h=r.exec(l))){var I=(" "+h[0].substr(1).trim()).substr(1);o.startObject(I)}else if(n.test(l))o.object.startMaterial(l.substring(7).trim(),o.materialLibraries);else if(i.test(l))o.materialLibraries.push(l.substring(7).trim());else{if("s"!==c){if("\0"===l)continue;throw new Error('OBJLoader: Unexpected line: "'+l+'"')}if(h=l.split(" "),h.length>1){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;p<f;p++){var j=o.objects[p],V=j.geometry,G=j.materials,W="Line"===V.type,X="Points"===V.type,H=!1;if(0!==V.vertices.length){var Y=new P;Y.addAttribute("position",new M(V.vertices,3)),V.normals.length>0?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;Q<J;Q++){var Z=G[Q],B=void 0;if(null!==a.materials)if(B=a.materials.create(Z.name),!W||!B||B instanceof R){if(X&&B&&!(B instanceof Ne)){var K=new Ne({size:10,sizeAttenuation:!1});$.copy(B),B=K}}else{var $=new R;$.copy(B),$.lights=!1,B=$}B||(B=W?new R:X?new Ne({size:1,sizeAttenuation:!1}):new Ee,B.name=Z.name),B.flatShading=!Z.smooth,B.vertexColors=H?il:tl,q.push(B)}var ee;if(q.length>1){for(var Q=0,J=G.length;Q<J;Q++){var Z=G[Q];Y.addGroup(Z.groupStart,Z.groupCount,Q)}ee=W?new Yt(Y,q):X?new Et(Y,q):new k(Y,q)}else ee=W?new Yt(Y,q[0]):X?new Et(Y,q[0]):new k(Y,q[0]);ee.name=j.name,z.add(ee)}}return console.timeEnd("OBJLoader"),z}},t}();void 0===kf&&console.error('"LoaderSupport" is not available. "OBJLoader2" requires it. Please include "LoaderSupport.js" in your HTML.');var Qf=function(){function e(e){console.info("Using OBJLoader2 version: "+t),this.manager=r.verifyInput(e,Du),this.logging={enabled:!0,debug:!1},this.modelName="",this.instanceNo=0,this.path="",this.useIndices=!1,this.disregardNormals=!1,this.materialPerSmoothingGroup=!1,this.useOAsMesh=!1,this.loaderRootNode=new Dt,this.meshBuilder=new kf.MeshBuilder,this.callbacks=new kf.Callbacks,this.workerSupport=new kf.WorkerSupport,this.terminateWorkerOnLoad=!0}var t="2.4.2",r=kf.Validator;e.prototype.setLogging=function(e,t){this.logging.enabled=e===!0,this.logging.debug=t===!0,this.meshBuilder.setLogging(this.logging.enabled,this.logging.debug)},e.prototype.setModelName=function(e){this.modelName=r.verifyInput(e,this.modelName)},e.prototype.setPath=function(e){this.path=r.verifyInput(e,this.path)},e.prototype.setStreamMeshesTo=function(e){this.loaderRootNode=r.verifyInput(e,this.loaderRootNode)},e.prototype.setMaterials=function(e){this.meshBuilder.setMaterials(e)},e.prototype.setUseIndices=function(e){this.useIndices=e===!0},e.prototype.setDisregardNormals=function(e){this.disregardNormals=e===!0},e.prototype.setMaterialPerSmoothingGroup=function(e){this.materialPerSmoothingGroup=e===!0},e.prototype.setUseOAsMesh=function(e){this.useOAsMesh=e===!0},e.prototype._setCallbacks=function(e){r.isValid(e.onProgress)&&this.callbacks.setCallbackOnProgress(e.onProgress),r.isValid(e.onReportError)&&this.callbacks.setCallbackOnReportError(e.onReportError),r.isValid(e.onMeshAlter)&&this.callbacks.setCallbackOnMeshAlter(e.onMeshAlter),r.isValid(e.onLoad)&&this.callbacks.setCallbackOnLoad(e.onLoad),r.isValid(e.onLoadMaterials)&&this.callbacks.setCallbackOnLoadMaterials(e.onLoadMaterials),this.meshBuilder._setCallbacks(this.callbacks)},e.prototype.onProgress=function(e,t,i){var n=r.isValid(t)?t:"",a={detail:{type:e,modelName:this.modelName,instanceNo:this.instanceNo,text:n,numericalValue:i}};r.isValid(this.callbacks.onProgress)&&this.callbacks.onProgress(a),this.logging.enabled&&this.logging.debug&&console.debug(n)},e.prototype._onError=function(e){var t="Error occurred while downloading!";e.currentTarget&&null!==e.currentTarget.statusText&&(t+="\nurl: "+e.currentTarget.responseURL+"\nstatus: "+e.currentTarget.statusText),this.onProgress("error",t,-1),this._throwError(t)},e.prototype._throwError=function(e){if(!r.isValid(this.callbacks.onReportError))throw e;this.callbacks.onReportError(e)},e.prototype.load=function(e,t,r,i,n,a){var o=new kf.ResourceDescriptor(e,"OBJ");this._loadObj(o,t,r,i,n,a)},e.prototype._loadObj=function(e,t,i,n,a,o){var s=this;r.isValid(n)||(n=function(e){s._onError(e)}),r.isValid(e)||n("An invalid ResourceDescriptor was provided. Unable to continue!");var l=function(r){if(e.content=r,o)s.parseAsync(r,t);else{var i=new kf.Callbacks;i.setCallbackOnMeshAlter(a),s._setCallbacks(i),t({detail:{loaderRootNode:s.parse(r),modelName:s.modelName,instanceNo:s.instanceNo}})}};if(!r.isValid(e.url)||r.isValid(e.content))l(r.isValid(e.content)?e.content:null);else{if(!r.isValid(i)){var c=0,u=0;i=function(t){if(t.lengthComputable&&(u=t.loaded/t.total,u>c)){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;c<i;c++)switch(n=r[c]){case 32:o.length>0&&(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;l<r;l++)switch(i=e[l]){case" ":a.length>0&&(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;a<i;a++)n+=e[a];else for(a=r;a<i;a++)n+=String.fromCharCode(e[a]);n=n.trim()}return n};switch(s=e[0]){case"v":this.vertices.push(parseFloat(e[1])),this.vertices.push(parseFloat(e[2])),this.vertices.push(parseFloat(e[3])),t>4&&(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;o<a;o++)i.buildFace(e[1]),i.buildFace(e[o]),i.buildFace(e[o+1]);else if(n===2*r)for(this.checkFaceType(1),o=3,a=n-2;o<a;o+=2)i.buildFace(e[1],e[2]),i.buildFace(e[o],e[o+1]),i.buildFace(e[o+2],e[o+3]);else if(2*n===3*r)for(this.checkFaceType(2),o=4,a=n-3;o<a;o+=3)i.buildFace(e[1],e[2],e[3]),i.buildFace(e[o],e[o+1],e[o+2]),i.buildFace(e[o+3],e[o+4],e[o+5]);else for(this.checkFaceType(3),o=3,a=n-2;o<a;o+=2)i.buildFace(e[1],void 0,e[2]),i.buildFace(e[o],void 0,e[o+1]),i.buildFace(e[o+2],void 0,e[o+3]);break;case"l":case"p":if(n=t-1,n===2*r)for(this.checkFaceType(4),o=1,a=n+1;o<a;o+=2)i.buildFace(e[o],e[o+1]);else for(this.checkFaceType("l"===s?5:6),o=1,a=n+1;o<a;o++)i.buildFace(e[o]);break;case"s":this.pushSmoothingGroup(e[1]);break;case"g":this.processCompletedMesh(),this.rawMesh.groupName=l(this.contentRef,this.legacyMode,this.globalCounts.lineByte+2,this.globalCounts.currentByte);break;case"o":this.useOAsMesh&&this.processCompletedMesh(),this.rawMesh.objectName=l(this.contentRef,this.legacyMode,this.globalCounts.lineByte+2,this.globalCounts.currentByte);break;case"mtllib":this.rawMesh.mtllibName=l(this.contentRef,this.legacyMode,this.globalCounts.lineByte+7,this.globalCounts.currentByte);break;case"usemtl":var c=l(this.contentRef,this.legacyMode,this.globalCounts.lineByte+7,this.globalCounts.currentByte);""!==c&&this.rawMesh.activeMtlName!==c&&(this.rawMesh.activeMtlName=c,this.rawMesh.counts.mtlCount++,this.checkSubGroup())}}},e.prototype.pushSmoothingGroup=function(e){var t=parseInt(e);isNaN(t)&&(t="off"===e?0:1);var r=this.rawMesh.smoothingGroup.normalized;this.rawMesh.smoothingGroup.normalized=this.rawMesh.smoothingGroup.splitMaterials?t:0===t?0:1,this.rawMesh.smoothingGroup.real=t,r!==t&&(this.rawMesh.counts.smoothingGroupCount++,this.checkSubGroup())},e.prototype.checkFaceType=function(e){this.rawMesh.faceType!==e&&(this.processCompletedMesh(),this.rawMesh.faceType=e,this.checkSubGroup())},e.prototype.checkSubGroup=function(){var e=this.rawMesh.activeMtlName+"|"+this.rawMesh.smoothingGroup.normalized;this.rawMesh.subGroupInUse=this.rawMesh.subGroups[e],kf.Validator.isValid(this.rawMesh.subGroupInUse)||(this.rawMesh.subGroupInUse={index:e,objectName:this.rawMesh.objectName,groupName:this.rawMesh.groupName,materialName:this.rawMesh.activeMtlName,smoothingGroup:this.rawMesh.smoothingGroup.normalized,vertices:[],indexMappingsCount:0,indexMappings:[],indices:[],colors:[],uvs:[],normals:[]},this.rawMesh.subGroups[e]=this.rawMesh.subGroupInUse)},e.prototype.buildFace=function(e,t,r){this.disregardNormals&&(r=void 0);var i=this,n=function(){var n=parseInt(e),a=3*(n>0?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;n<a;n++)t.count.push(1)}t.offset={};for(var o=0,n=0,a=t.fields.length;n<a;n++)"ascii"===t.data?t.offset[t.fields[n]]=n:(t.offset[t.fields[n]]=o,o+=t.size[n]);return t.rowSize=o,t}var i=this,n=Ru.decodeText(e),a=r(n),o=[],s=[],l=[];if("ascii"===a.data)for(var c=a.offset,u=n.substr(a.headerLen),h=u.split("\n"),d=0,p=h.length;d<p;d++)if(""!==h[d]){var f=h[d].split(" ");if(void 0!==c.x&&(o.push(parseFloat(f[c.x])),o.push(parseFloat(f[c.y])),o.push(parseFloat(f[c.z]))),void 0!==c.rgb){var m=new Float32Array([parseFloat(f[c.rgb])]),v=new DataView(m.buffer,0);l.push(v.getUint8(0)/255),l.push(v.getUint8(1)/255),l.push(v.getUint8(2)/255)}void 0!==c.normal_x&&(s.push(parseFloat(f[c.normal_x])),s.push(parseFloat(f[c.normal_y])),s.push(parseFloat(f[c.normal_z])))}if("binary_compressed"===a.data)return void console.error("PCDLoader: binary_compressed files are not supported");if("binary"===a.data)for(var v=new DataView(e,a.headerLen),c=a.offset,d=0,g=0;d<a.points;d++,g+=a.rowSize)void 0!==c.x&&(o.push(v.getFloat32(g+c.x,i.littleEndian)),o.push(v.getFloat32(g+c.y,i.littleEndian)),o.push(v.getFloat32(g+c.z,i.littleEndian))),void 0!==c.rgb&&(l.push(v.getUint8(g+c.rgb+0)/255),l.push(v.getUint8(g+c.rgb+1)/255),l.push(v.getUint8(g+c.rgb+2)/255)),void 0!==c.normal_x&&(s.push(v.getFloat32(g+c.normal_x,i.littleEndian)),s.push(v.getFloat32(g+c.normal_y,i.littleEndian)),s.push(v.getFloat32(g+c.normal_z,i.littleEndian)));var y=new P;o.length>0&&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;e++){var l=d[e],c=l[0],u=l[1],h=l[2];a.push(c,u,h);var f=l[3][0]/255,m=l[3][1]/255,v=l[3][2]/255;o.push(f,m,v)}for(e=0,t=p.length;e<t;e++){var g=p[e],y=g[0],x=g[1];s.push(a[3*y+0]),s.push(a[3*y+1]),s.push(a[3*y+2]),s.push(a[3*x+0]),s.push(a[3*x+1]),s.push(a[3*x+2])}return i.addAttribute("position",new M(a,3)),i.addAttribute("color",new M(o,3)),n.addAttribute("position",new M(s,3)),r}for(var o,s,l,c,u,h={h:[255,255,255],he:[217,255,255],li:[204,128,255],be:[194,255,0],b:[255,181,181],c:[144,144,144],n:[48,80,248],o:[255,13,13],f:[144,224,80],ne:[179,227,245],na:[171,92,242],mg:[138,255,0],al:[191,166,166],si:[240,200,160],p:[255,128,0],s:[255,255,48],cl:[31,240,31],ar:[128,209,227],k:[143,64,212],ca:[61,255,0],sc:[230,230,230],ti:[191,194,199],v:[166,166,171],cr:[138,153,199],mn:[156,122,199],fe:[224,102,51],co:[240,144,160],ni:[80,208,80],cu:[200,128,51],zn:[125,128,176],ga:[194,143,143],ge:[102,143,143],as:[189,128,227],se:[255,161,0],br:[166,41,41],kr:[92,184,209],rb:[112,46,176],sr:[0,255,0],y:[148,255,255],zr:[148,224,224],nb:[115,194,201],mo:[84,181,181],tc:[59,158,158],ru:[36,143,143],rh:[10,125,140],pd:[0,105,133],ag:[192,192,192],cd:[255,217,143],"in":[166,117,115],sn:[102,128,128],sb:[158,99,181],te:[212,122,0],i:[148,0,148],xe:[66,158,176],cs:[87,23,143],ba:[0,201,0],la:[112,212,255],ce:[255,255,199],pr:[217,255,199],nd:[199,255,199],pm:[163,255,199],sm:[143,255,199],eu:[97,255,199],gd:[69,255,199],tb:[48,255,199],dy:[31,255,199],ho:[0,255,156],er:[0,230,117],tm:[0,212,82],yb:[0,191,56],lu:[0,171,36],hf:[77,194,255],ta:[77,166,255],w:[33,148,214],re:[38,125,171],os:[38,102,150],ir:[23,84,135],pt:[208,208,224],au:[255,209,35],hg:[184,184,208],tl:[166,84,77],pb:[87,89,97],bi:[158,79,181],po:[171,92,0],at:[117,79,69],rn:[66,130,150],fr:[66,0,102],ra:[0,125,0],ac:[112,171,250],th:[0,186,255],pa:[0,161,255],u:[0,143,255],np:[0,128,255],pu:[0,107,255],am:[84,92,242],cm:[120,92,227],bk:[138,79,227],cf:[161,54,212],es:[179,31,212],fm:[179,31,186],md:[179,13,166],no:[189,13,135],lr:[199,0,102],rf:[204,0,89],db:[209,0,79],sg:[217,0,69],bh:[224,0,56],hs:[230,0,46],mt:[235,0,38],ds:[235,0,38],rg:[235,0,38],cn:[235,0,38],uut:[235,0,38],uuq:[235,0,38],uup:[235,0,38],uuh:[235,0,38],uus:[235,0,38],uuo:[235,0,38]},d=[],p=[],f={},m=e.split("\n"),v=0,g=m.length;v<g;v++)if("ATOM"===m[v].substr(0,4)||"HETATM"===m[v].substr(0,6))o=parseFloat(m[v].substr(30,7)),s=parseFloat(m[v].substr(38,7)),l=parseFloat(m[v].substr(46,7)),c=parseInt(m[v].substr(6,5))-1,u=t(m[v].substr(76,2)).toLowerCase(),""===u&&(u=t(m[v].substr(12,2)).toLowerCase()),d[c]=[o,s,l,h[u],r(u)];else if("CONECT"===m[v].substr(0,6)){var y=parseInt(m[v].substr(6,5));n(11,5),n(16,5),n(21,5),n(26,5)}return a()}};var Kf=function(e){this.manager=void 0!==e?e:Du};Kf.prototype={constructor:Kf,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){var t={};for(var r in e){var i,n=e[r],a=n.type,o=n.components;switch(a){case"float32":i=new M(n.data,o);break;case"uint8":i=new x(n.data,o);break;case"uint16":i=new _(n.data,o);break;default:console.log('PlayCanvasLoader: Array type "%s" not yet supported.',a)}t[r]=i}e._attributes=t}function r(e){var t=new P;t.setIndex(e.indices);var r=a.vertices[e.vertices]._attributes;for(var i in r){var n=r[i];"texCoord0"===i&&(i="uv"),t.addAttribute(i,n)}e._geometry=t}function i(e){var t=a.nodes[e.node],r=a.meshes[e.mesh];void 0===t._geometries&&(t._geometries=[]),t._geometries.push(r._geometry)}function n(e){var t=new Dt,r=e._geometries;if(void 0!==r)for(var i=new Ee,n=0,a=r.length;n<a;n++){var s=r[n];t.add(new k(s,i))}for(var n=0,a=e.rotation.length;n<a;n++)e.rotation[n]*=Math.PI/180;t.name=e.name,t.position.fromArray(e.position),t.quaternion.setFromEuler((new o).fromArray(e.rotation)),t.scale.fromArray(e.scale),e._object=t}for(var a=e.model,s=0,l=a.vertices.length;s<l;s++)t(a.vertices[s]);for(var s=0,l=a.meshes.length;s<l;s++)r(a.meshes[s]);for(var s=0,l=a.meshInstances.length;s<l;s++)i(a.meshInstances[s]);for(var s=0,l=a.nodes.length;s<l;s++)n(a.nodes[s]);for(var s=0,l=a.parents.length;s<l;s++){var c=a.parents[s];c!==-1&&a.nodes[c]._object.add(a.nodes[s]._object)}return a.nodes[0]._object}};var $f=function(e){this.manager=void 0!==e?e:Du,this.propertyNameMapping={}};$f.prototype={constructor:$f,load:function(e,t,r,i){var n=this,a=new we(this.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){t(n.parse(e))},r,i)},setPropertyNameMapping:function(e){this.propertyNameMapping=e},parse:function(e){function t(e){function t(e,t){var r={type:e[0]};return"list"===r.type?(r.name=e[3],r.countType=e[1],r.itemType=e[2]):r.name=e[1],r.name in t&&(r.name=t[r.name]),r}var r=/ply([\s\S]*)end_header\s/,i="",n=0,a=r.exec(e);null!==a&&(i=a[1],n=a[0].length);for(var o,s,l,c={comments:[],elements:[],headerLength:n},u=i.split("\n"),d=0;d<u.length;d++){var p=u[d];if(p=p.trim(),""!==p)switch(l=p.split(/\s+/),s=l.shift(),p=l.join(" "),s){case"format":c.format=l[0],c.version=l[1];break;case"comment":c.comments.push(p);break;case"element":void 0!==o&&c.elements.push(o),o={},o.name=l[0],o.count=parseInt(l[1]),o.properties=[];break;case"property":o.properties.push(t(l,h.propertyNameMapping));break;default:console.log("unhandled",s,l)}}return void 0!==o&&c.elements.push(o),c}function r(e,t){switch(t){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(e);case"float":case"double":case"float32":case"float64":return parseFloat(e)}}function i(e,t){for(var i=t.split(/\s+/),n={},a=0;a<e.length;a++)if("list"===e[a].type){for(var o=[],s=r(i.shift(),e[a].countType),l=0;l<s;l++)o.push(r(i.shift(),e[a].itemType));n[e[a].name]=o}else n[e[a].name]=r(i.shift(),e[a].type);return n}function n(e,t){var r,n={indices:[],vertices:[],normals:[],uvs:[],colors:[]},s=/end_header\s([\s\S]*)$/,l="";null!==(r=s.exec(e))&&(l=r[1]);for(var c=l.split("\n"),u=0,h=0,d=0;d<c.length;d++){var p=c[d];if(p=p.trim(),""!==p){h>=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;l<r.length;l++)if("list"===r[l].type){var c=[];n=s(e,t+o,r[l].countType,i);var u=n[0];o+=n[1];for(var h=0;h<u;h++)n=s(e,t+o,r[l].itemType,i),c.push(n[0]),o+=n[1];a[r[l].name]=c}else n=s(e,t+o,r[l].type,i),a[r[l].name]=n[0],o+=n[1];return[a,o]}function c(e,t){for(var r,i={indices:[],vertices:[],normals:[],uvs:[],colors:[]},n="binary_little_endian"===t.format,s=new DataView(e,t.headerLength),c=0,u=0;u<t.elements.length;u++)for(var h=0;h<t.elements[u].count;h++){r=l(s,c,t.elements[u].properties,n),c+=r[1];var d=r[0];o(i,t.elements[u].name,d)}return a(i)}var u,h=this;if(e instanceof ArrayBuffer){var d=Ru.decodeText(new Uint8Array(e)),p=t(d);u="ascii"===p.format?n(d,p):c(e,p)}else u=n(e,t(e));return u}};var em=null,tm=[null,Float32Array,null,Int8Array,Int16Array,null,Int32Array,Uint8Array,Uint16Array,null,Uint32Array],rm={Uint16Array:"getUint16",Uint32Array:"getUint32",Int16Array:"getInt16",Int32Array:"getInt32",Float32Array:"getFloat32",Float64Array:"getFloat64"},im=function(e){this.manager=void 0!==e?e:Du};im.prototype={constructor:im,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setResponseType("arraybuffer"),e=e.replace(/\*/g,ur()?"be":"le"),a.load(e,function(e){t(n.parse(e))},r,i)},parse:function(e){console.time("PRWMLoader");var t,r,i=dr(e),n=Object.keys(i.attributes),a=new P;for(r=0;r<n.length;r++)t=i.attributes[n[r]],a.addAttribute(n[r],new g(t.values,t.cardinality,t.normalized));return null!==i.indices&&a.setIndex(new g(i.indices,1)),console.timeEnd("PRWMLoader"),a}},im.isBigEndianPlatform=function(){return ur()};var nm=function(e){Qt.call(this,e),this._parser=nm.parse};nm.prototype=Object.create(Qt.prototype),nm.prototype.constructor=nm,nm.parse=function(e,t){var r=13,i=new Uint32Array(e,0,r),n={buffer:e,header:i,loadMipmaps:t};return 55727696===i[0]?nm._parseV3(n):559044176===i[11]?nm._parseV2(n):void console.error("PVRLoader: Unknown PVR format.")},nm._parseV3=function(e){var t,r,i=e.header,n=i[12],a=i[2],o=i[6],s=i[7],l=i[10],c=i[11];switch(a){case 0:t=2,r=Pc;break;case 1:t=2,r=Oc;break;case 2:t=4,r=Lc;break;case 3:t=4,r=Nc;break;default:console.error("PVRLoader: Unsupported PVR format:",a)}return e.dataPtr=52+n,e.bpp=t,e.format=r,e.width=s,e.height=o,e.numSurfaces=l,e.numMipmaps=c,e.isCubemap=6===l,nm._extract(e)},nm._parseV2=function(e){var t,r,i=e.header,n=i[0],a=i[1],o=i[2],s=i[3],l=i[4],c=i[10],u=i[12],h=255,d=24,p=25,f=l&h,m=c>0;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<e.numMipmaps;){var p=e.width>>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<a;m++){var v=new Uint8Array(r,i,o),g={data:v,width:p,height:f};t.mipmaps[m*e.numMipmaps+d]=g,i+=o}d++}return t};var am=function(e){this.manager=void 0!==e?e:Du};am.prototype={constructor:am,load:function(e,t,r,i){var n=this,a=new we(n.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){try{t(n.parse(e))}catch(r){i&&i(r)}},r,i)},parse:function(e){function t(e){var t,i,n,a;if(a=new DataView(e),i=50,n=a.getUint32(80,!0),t=84+n*i,t===a.byteLength)return!0;for(var o=[115,111,108,105,100],s=0;s<5;s++)if(r(o,a,s))return!1;return!0}function r(e,t,r){for(var i=0,n=e.length;i<n;i++)if(e[i]!==t.getUint8(r+i,!1))return!1;return!0}function n(e){for(var t,r,i,n,a,o,s,l,c=new DataView(e),u=c.getUint32(80,!0),h=!1,d=0;d<70;d++)1129270351==c.getUint32(d,!1)&&82==c.getUint8(d+4)&&61==c.getUint8(d+5)&&(h=!0,n=[],a=c.getUint8(d+6)/255,o=c.getUint8(d+7)/255,s=c.getUint8(d+8)/255,l=c.getUint8(d+9)/255);for(var p=84,f=50,m=new P,v=[],y=[],x=0;x<u;x++){var b=p+x*f,w=c.getFloat32(b,!0),_=c.getFloat32(b+4,!0),S=c.getFloat32(b+8,!0);if(h){var A=c.getUint16(b+48,!0);0===(32768&A)?(t=(31&A)/31,r=(A>>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;r<e.length;r++)t[r]=255&e.charCodeAt(r);return t.buffer||t}return e}var l=s(e);return t(l)?n(l):a(o(e))}},pr.prototype=Object.create(at.prototype),pr.prototype.constructor=pr,pr.prototype.isEllipseCurve=!0,pr.prototype.getPoint=function(e,t){for(var r=t||new f,i=2*Math.PI,n=this.aEndAngle-this.aStartAngle,a=Math.abs(n)<Number.EPSILON;n<0;)n+=i;for(;n>i;)n-=i;n<Number.EPSILON&&(n=a?0:i),this.aClockwise!==!0||a||(n===i?n=-i:n-=i);var o=this.aStartAngle+e*n,s=this.aX+this.xRadius*Math.cos(o),l=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){var c=Math.cos(this.aRotation),u=Math.sin(this.aRotation),h=s-this.aX,d=l-this.aY;s=h*c-d*u+this.aX,l=h*u+d*c+this.aY}return r.set(s,l)},pr.prototype.copy=function(e){return at.prototype.copy.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},pr.prototype.toJSON=function(){var e=at.prototype.toJSON.call(this);return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e},pr.prototype.fromJSON=function(e){return at.prototype.fromJSON.call(this,e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this},fr.prototype=Object.create(pr.prototype),fr.prototype.constructor=fr,fr.prototype.isArcCurve=!0;var om=new i,sm=new mr,lm=new mr,cm=new mr;vr.prototype=Object.create(at.prototype),vr.prototype.constructor=vr,vr.prototype.isCatmullRomCurve3=!0,vr.prototype.getPoint=function(e,t){var r=t||new i,n=this.points,a=n.length,o=(a-(this.closed?0:1))*e,s=Math.floor(o),l=o-s;this.closed?s+=s>0?0:(Math.floor(Math.abs(s)/a)+1)*a:0===l&&s===a-1&&(s=a-2,l=1);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+2<a?d=n[(s+2)%a]:(om.subVectors(n[a-1],n[a-2]).add(n[a-1]),d=om),"centripetal"===this.curveType||"chordal"===this.curveType){var p="chordal"===this.curveType?.5:.25,f=Math.pow(c.distanceToSquared(u),p),m=Math.pow(u.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(d),p);m<1e-4&&(m=1),f<1e-4&&(f=m),v<1e-4&&(v=m),sm.initNonuniformCatmullRom(c.x,u.x,h.x,d.x,f,m,v),lm.initNonuniformCatmullRom(c.y,u.y,h.y,d.y,f,m,v),cm.initNonuniformCatmullRom(c.z,u.z,h.z,d.z,f,m,v)}else"catmullrom"===this.curveType&&(sm.initCatmullRom(c.x,u.x,h.x,d.x,this.tension),lm.initCatmullRom(c.y,u.y,h.y,d.y,this.tension),cm.initCatmullRom(c.z,u.z,h.z,d.z,this.tension));return r.set(sm.calc(l),lm.calc(l),cm.calc(l)),r},vr.prototype.copy=function(e){var t=this;at.prototype.copy.call(this,e),this.points=[];for(var r=0,i=e.points.length;r<i;r++){var n=e.points[r];t.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},vr.prototype.toJSON=function(){var e=this,t=at.prototype.toJSON.call(this);t.points=[];for(var r=0,i=this.points.length;r<i;r++){var n=e.points[r];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t},vr.prototype.fromJSON=function(e){var t=this;at.prototype.fromJSON.call(this,e),this.points=[];for(var r=0,n=e.points.length;r<n;r++){var a=e.points[r];t.points.push((new i).fromArray(a))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this},Er.prototype=Object.create(at.prototype),Er.prototype.constructor=Er,Er.prototype.isCubicBezierCurve=!0,Er.prototype.getPoint=function(e,t){var r=t||new f,i=this.v0,n=this.v1,a=this.v2,o=this.v3;return r.set(Tr(e,i.x,n.x,a.x,o.x),Tr(e,i.y,n.y,a.y,o.y)),r},Er.prototype.copy=function(e){return at.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Er.prototype.toJSON=function(){var e=at.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Er.prototype.fromJSON=function(e){return at.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},Cr.prototype=Object.create(at.prototype),Cr.prototype.constructor=Cr,Cr.prototype.isCubicBezierCurve3=!0,Cr.prototype.getPoint=function(e,t){var r=t||new i,n=this.v0,a=this.v1,o=this.v2,s=this.v3;return r.set(Tr(e,n.x,a.x,o.x,s.x),Tr(e,n.y,a.y,o.y,s.y),Tr(e,n.z,a.z,o.z,s.z)),r},Cr.prototype.copy=function(e){return at.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this},Cr.prototype.toJSON=function(){var e=at.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e},Cr.prototype.fromJSON=function(e){return at.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this},Lr.prototype=Object.create(at.prototype),Lr.prototype.constructor=Lr,Lr.prototype.isLineCurve=!0,Lr.prototype.getPoint=function(e,t){var r=t||new f;return 1===e?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r},Lr.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Lr.prototype.getTangent=function(){var e=this.v2.clone().sub(this.v1);return e.normalize()},Lr.prototype.copy=function(e){return at.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Lr.prototype.toJSON=function(){var e=at.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Lr.prototype.fromJSON=function(e){return at.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Pr.prototype=Object.create(at.prototype),Pr.prototype.constructor=Pr,Pr.prototype.isLineCurve3=!0,Pr.prototype.getPoint=function(e,t){var r=t||new i;return 1===e?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(e).add(this.v1)),r},Pr.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},Pr.prototype.copy=function(e){return at.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Pr.prototype.toJSON=function(){var e=at.prototype.toJSON.call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Pr.prototype.fromJSON=function(e){return at.prototype.fromJSON.call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Nr.prototype=Object.create(at.prototype),Nr.prototype.constructor=Nr,Nr.prototype.isQuadraticBezierCurve=!0,Nr.prototype.getPoint=function(e,t){var r=t||new f,i=this.v0,n=this.v1,a=this.v2;return r.set(wr(e,i.x,n.x,a.x),wr(e,i.y,n.y,a.y)),r},Nr.prototype.copy=function(e){return at.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Nr.prototype.toJSON=function(){var e=at.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Nr.prototype.fromJSON=function(e){return at.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Or.prototype=Object.create(at.prototype),Or.prototype.constructor=Or,Or.prototype.isQuadraticBezierCurve3=!0,Or.prototype.getPoint=function(e,t){var r=t||new i,n=this.v0,a=this.v1,o=this.v2;return r.set(wr(e,n.x,a.x,o.x),wr(e,n.y,a.y,o.y),wr(e,n.z,a.z,o.z)),r},Or.prototype.copy=function(e){return at.prototype.copy.call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Or.prototype.toJSON=function(){var e=at.prototype.toJSON.call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e},Or.prototype.fromJSON=function(e){return at.prototype.fromJSON.call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this},Dr.prototype=Object.create(at.prototype),Dr.prototype.constructor=Dr,Dr.prototype.isSplineCurve=!0,Dr.prototype.getPoint=function(e,t){var r=t||new f,i=this.points,n=(i.length-1)*e,a=Math.floor(n),o=n-a,s=i[0===a?a:a-1],l=i[a],c=i[a>i.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<i;r++){var n=e.points[r];t.points.push(n.clone())}return this},Dr.prototype.toJSON=function(){var e=this,t=at.prototype.toJSON.call(this);t.points=[];for(var r=0,i=this.points.length;r<i;r++){var n=e.points[r];t.points.push(n.toArray())}return t},Dr.prototype.fromJSON=function(e){var t=this;at.prototype.fromJSON.call(this,e),this.points=[];for(var r=0,i=e.points.length;r<i;r++){var n=e.points[r];t.points.push((new f).fromArray(n))}return this};var um={ArcCurve:fr,CatmullRomCurve3:vr,CubicBezierCurve:Er,CubicBezierCurve3:Cr,EllipseCurve:pr,LineCurve:Lr,LineCurve3:Pr,QuadraticBezierCurve:Nr,QuadraticBezierCurve3:Or,SplineCurve:Dr};Fr.prototype=Object.assign(Object.create(at.prototype),{constructor:Fr,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new um.LineCurve(t,e))},getPoint:function(e){for(var t=this,r=e*this.getLength(),i=this.getCurveLengths(),n=0;n<i.length;){if(i[n]>=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;i<n;i++)r+=e.curves[i].getLength(),
|
|
t.push(r);return this.cacheLengths=t,t},getSpacedPoints:function(e){var t=this;void 0===e&&(e=40);for(var r=[],i=0;i<=e;i++)r.push(t.getPoint(i/e));return this.autoClose&&r.push(r[0]),r},getPoints:function(e){e=e||12;for(var t,r=[],i=0,n=this.curves;i<n.length;i++)for(var a=n[i],o=a&&a.isEllipseCurve?2*e:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o),l=0;l<s.length;l++){var c=s[l];t&&t.equals(c)||(r.push(c),t=c)}return this.autoClose&&r.length>1&&!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;r<i;r++){var n=e.curves[r];t.curves.push(n.clone())}return this.autoClose=e.autoClose,this},toJSON:function(){var e=this,t=at.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(var r=0,i=this.curves.length;r<i;r++){var n=e.curves[r];t.curves.push(n.toJSON())}return t},fromJSON:function(e){var t=this;at.prototype.fromJSON.call(this,e),this.autoClose=e.autoClose,this.curves=[];for(var r=0,i=e.curves.length;r<i;r++){var n=e.curves[r];t.curves.push((new um[n.type]).fromJSON(n))}return this}}),Rr.prototype=Object.assign(Object.create(Fr.prototype),{constructor:Rr,setFromPoints:function(e){var t=this;this.moveTo(e[0].x,e[0].y);for(var r=1,i=e.length;r<i;r++)t.lineTo(e[r].x,e[r].y)},moveTo:function(e,t){this.currentPoint.set(e,t)},lineTo:function(e,t){var r=new Lr(this.currentPoint.clone(),new f(e,t));this.curves.push(r),this.currentPoint.set(e,t)},quadraticCurveTo:function(e,t,r,i){var n=new Nr(this.currentPoint.clone(),new f(e,t),new f(r,i));this.curves.push(n),this.currentPoint.set(r,i)},bezierCurveTo:function(e,t,r,i,n,a){var o=new Er(this.currentPoint.clone(),new f(e,t),new f(r,i),new f(n,a));this.curves.push(o),this.currentPoint.set(n,a)},splineThru:function(e){var t=[this.currentPoint.clone()].concat(e),r=new Dr(t);this.curves.push(r),this.currentPoint.copy(e[e.length-1])},arc:function(e,t,r,i,n,a){var o=this.currentPoint.x,s=this.currentPoint.y;this.absarc(e+o,t+s,r,i,n,a)},absarc:function(e,t,r,i,n,a){this.absellipse(e,t,r,r,i,n,a)},ellipse:function(e,t,r,i,n,a,o,s){var l=this.currentPoint.x,c=this.currentPoint.y;this.absellipse(e+l,t+c,r,i,n,a,o,s)},absellipse:function(e,t,r,i,n,a,o,s){var l=new pr(e,t,r,i,n,a,o,s);if(this.curves.length>0){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;i<n;i++)r[i]=t.holes[i].getPoints(e);return r},extractPoints:function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},copy:function(e){var t=this;Rr.prototype.copy.call(this,e),this.holes=[];for(var r=0,i=e.holes.length;r<i;r++){var n=e.holes[r];t.holes.push(n.clone())}return this},toJSON:function(){var e=this,t=Rr.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(var r=0,i=this.holes.length;r<i;r++){var n=e.holes[r];t.holes.push(n.toJSON())}return t},fromJSON:function(e){var t=this;Rr.prototype.fromJSON.call(this,e),this.uuid=e.uuid,this.holes=[];for(var r=0,i=e.holes.length;r<i;r++){var n=e.holes[r];t.holes.push((new Rr).fromJSON(n))}return this}});var hm={triangulate:function(e,t,r){r=r||2;var i=t&&t.length,n=i?t[0]*r:e.length,a=Ur(e,0,n,r,!0),o=[];if(!a)return o;var s,l,c,u,h,d,p;if(i&&(a=Wr(e,t,a,r)),e.length>80*r){s=c=e[0],l=u=e[1];for(var f=r;f<n;f+=r)h=e[f],d=e[f+1],h<s&&(s=h),d<l&&(l=d),h>c&&(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;n<t;i=n++)r+=e[i].x*e[n].y-e[n].x*e[i].y;return.5*r},isClockWise:function(e){return dm.area(e)<0},triangulateShape:function(e,t){var r=[],i=[],n=[];hi(e),di(r,e);var a=e.length;t.forEach(hi);for(var o=0;o<t.length;o++)i.push(a),a+=t[o].length,di(r,t[o]);for(var s=hm.triangulate(r,i),o=0;o<s.length;o+=3)n.push(s.slice(o,o+3));return n}};Object.assign(pi.prototype,{moveTo:function(e,t){this.currentPath=new Rr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t)},lineTo:function(e,t){this.currentPath.lineTo(e,t)},quadraticCurveTo:function(e,t,r,i){this.currentPath.quadraticCurveTo(e,t,r,i)},bezierCurveTo:function(e,t,r,i,n,a){this.currentPath.bezierCurveTo(e,t,r,i,n,a)},splineThru:function(e){this.currentPath.splineThru(e)},toShapes:function(e,t){function r(e){for(var t=[],r=0,i=e.length;r<i;r++){var n=e[r],a=new Ir;a.curves=n.curves,t.push(a)}return t}function i(e,t){for(var r=t.length,i=!1,n=r-1,a=0;a<r;n=a++){var o=t[n],s=t[a],l=s.x-o.x,c=s.y-o.y;if(Math.abs(c)>Number.EPSILON){if(c<0&&(o=t[a],l=-l,s=t[n],c=-c),e.y<o.y||e.y>s.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;v<g;v++)s=a[v],h=s.getPoints(),o=n(h),o=e?!o:o,o?(!u&&p[m]&&m++,p[m]={s:new Ir,p:h},p[m].s.curves=s.curves,u&&m++,f[m]=[]):f[m].push({h:s,p:h[0]});if(!p[0])return r(a);if(p.length>1){for(var y=!1,x=[],b=0,w=p.length;b<w;b++)d[b]=[];for(var b=0,w=p.length;b<w;b++)for(var _=f[b],S=0;S<_.length;S++){for(var A=_[S],M=!0,T=0;T<p.length;T++)i(A.p,p[T].p)&&(b!==T&&x.push({froms:b,tos:T,hole:S}),M?(M=!1,d[T].push(A)):y=!0);M&&d[b].push(A)}x.length>0&&(y||(f=d))}for(var E,v=0,C=p.length;v<C;v++){l=p[v].s,c.push(l),E=f[v];for(var L=0,P=E.length;L<P;L++)l.holes.push(E[L].h)}return c}});var pm=function(e){this.manager=void 0!==e?e:Du};pm.prototype={constructor:pm,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,i){if(1===e.nodeType){var n=y(e),a=null;switch(e.nodeName){case"svg":break;case"g":i=p(e,i);break;case"path":i=p(e,i),e.hasAttribute("d")&&m(i)&&(a=r(e,i));break;case"rect":i=p(e,i),m(i)&&(a=o(e,i));break;case"polygon":i=p(e,i),m(i)&&(a=s(e,i));break;case"polyline":i=p(e,i),m(i)&&(a=c(e,i));break;case"circle":i=p(e,i),m(i)&&(a=u(e,i));break;case"ellipse":i=p(e,i),m(i)&&(a=h(e,i));break;case"line":i=p(e,i),m(i)&&(a=d(e,i));break;default:console.log(e)}a&&(b(a,L),A.push(a));for(var l=e.childNodes,f=0;f<l.length;f++)t(l[f],i);n&&L.copy(M.pop())}}function r(e,t){var r=new pi;r.color.setStyle(t.fill);for(var i=new f,a=new f,o=new f,s=!0,l=!1,c=e.getAttribute("d"),u=c.match(/[a-df-z][^a-df-z]*/gi),h=0,d=u.length;h<d;h++){var p=u[h],m=p.charAt(0),y=p.substr(1).trim();switch(s&&(l=!0),s=!1,m){case"M":for(var x=g(y),b=0,w=x.length;b<w;b+=2)i.x=x[b+0],i.y=x[b+1],a.x=i.x,a.y=i.y,0===b?r.moveTo(i.x,i.y):r.lineTo(i.x,i.y);break;case"H":for(var x=g(y),b=0,w=x.length;b<w;b++)i.x=x[b],a.x=i.x,a.y=i.y,r.lineTo(i.x,i.y);break;case"V":for(var x=g(y),b=0,w=x.length;b<w;b++)i.y=x[b],a.x=i.x,a.y=i.y,r.lineTo(i.x,i.y);break;case"L":for(var x=g(y),b=0,w=x.length;b<w;b+=2)i.x=x[b+0],i.y=x[b+1],a.x=i.x,a.y=i.y,r.lineTo(i.x,i.y);break;case"C":for(var x=g(y),b=0,w=x.length;b<w;b+=6)r.bezierCurveTo(x[b+0],x[b+1],x[b+2],x[b+3],x[b+4],x[b+5]),a.x=x[b+2],a.y=x[b+3],i.x=x[b+4],i.y=x[b+5];break;case"S":for(var x=g(y),b=0,w=x.length;b<w;b+=4)r.bezierCurveTo(v(i.x,a.x),v(i.y,a.y),x[b+0],x[b+1],x[b+2],x[b+3]),a.x=x[b+0],a.y=x[b+1],i.x=x[b+2],i.y=x[b+3];break;case"Q":for(var x=g(y),b=0,w=x.length;b<w;b+=4)r.quadraticCurveTo(x[b+0],x[b+1],x[b+2],x[b+3]),a.x=x[b+0],a.y=x[b+1],i.x=x[b+2],i.y=x[b+3];break;case"T":for(var x=g(y),b=0,w=x.length;b<w;b+=2){var _=v(i.x,a.x),S=v(i.y,a.y);r.quadraticCurveTo(_,S,x[b+0],x[b+1]),a.x=_,a.y=S,i.x=x[b+0],i.y=x[b+1]}break;case"A":for(var x=g(y),b=0,w=x.length;b<w;b+=7){var A=i.clone();i.x=x[b+5],i.y=x[b+6],a.x=i.x,a.y=i.y,n(r,x[b],x[b+1],x[b+2],x[b+3],x[b+4],A,i)}break;case"m":for(var x=g(y),b=0,w=x.length;b<w;b+=2)i.x+=x[b+0],i.y+=x[b+1],a.x=i.x,a.y=i.y,0===b?r.moveTo(i.x,i.y):r.lineTo(i.x,i.y);break;case"h":for(var x=g(y),b=0,w=x.length;b<w;b++)i.x+=x[b],a.x=i.x,a.y=i.y,r.lineTo(i.x,i.y);break;case"v":for(var x=g(y),b=0,w=x.length;b<w;b++)i.y+=x[b],a.x=i.x,a.y=i.y,r.lineTo(i.x,i.y);break;case"l":for(var x=g(y),b=0,w=x.length;b<w;b+=2)i.x+=x[b+0],i.y+=x[b+1],a.x=i.x,a.y=i.y,r.lineTo(i.x,i.y);break;case"c":for(var x=g(y),b=0,w=x.length;b<w;b+=6)r.bezierCurveTo(i.x+x[b+0],i.y+x[b+1],i.x+x[b+2],i.y+x[b+3],i.x+x[b+4],i.y+x[b+5]),a.x=i.x+x[b+2],a.y=i.y+x[b+3],i.x+=x[b+4],i.y+=x[b+5];break;case"s":for(var x=g(y),b=0,w=x.length;b<w;b+=4)r.bezierCurveTo(v(i.x,a.x),v(i.y,a.y),i.x+x[b+0],i.y+x[b+1],i.x+x[b+2],i.y+x[b+3]),a.x=i.x+x[b+0],a.y=i.y+x[b+1],i.x+=x[b+2],i.y+=x[b+3];break;case"q":for(var x=g(y),b=0,w=x.length;b<w;b+=4)r.quadraticCurveTo(i.x+x[b+0],i.y+x[b+1],i.x+x[b+2],i.y+x[b+3]),a.x=i.x+x[b+0],a.y=i.y+x[b+1],i.x+=x[b+2],i.y+=x[b+3];break;case"t":for(var x=g(y),b=0,w=x.length;b<w;b+=2){var _=v(i.x,a.x),S=v(i.y,a.y);r.quadraticCurveTo(_,S,i.x+x[b+0],i.y+x[b+1]),a.x=_,a.y=S,i.x=i.x+x[b+0],i.y=i.y+x[b+1]}break;case"a":for(var x=g(y),b=0,w=x.length;b<w;b+=7){var A=i.clone();i.x+=x[b+5],i.y+=x[b+6],a.x=i.x,a.y=i.y,n(r,x[b],x[b+1],x[b+2],x[b+3],x[b+4],A,i)}break;case"Z":case"z":r.currentPath.autoClose=!0,r.currentPath.curves.length>0&&(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;r<t.length;r++){var i=t[r];if(i.indexOf(".")!==i.lastIndexOf("."))for(var n=i.split("."),a=2;a<n.length;a++)t.splice(r+a-1,0,"0."+n[a]);t[r]=parseFloat(i)}return t}function y(e){if(!e.hasAttribute("transform"))return null;var t=x(e);return t&&(M.length>0&&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<n){var a=t.substr(0,i),o=g(t.substr(i+1,n-i-1));switch(a){case"translate":if(o.length>=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<c;l++)for(var u=s[l],h=u.curves,d=0;d<h.length;d++){var p=h[d];p.isLineCurve?(r(p.v1),r(p.v2)):p.isCubicBezierCurve?(r(p.v0),r(p.v1),r(p.v2),r(p.v3)):p.isQuadraticBezierCurve?(r(p.v0),r(p.v1),r(p.v2)):p.isEllipseCurve&&(n&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),a.set(p.aX,p.aY),r(a),p.aX=a.x,p.aY=a.y,p.xRadius*=_(t),p.yRadius*=S(t))}}function w(e){return 0!==e.elements[1]||0!==e.elements[3]}function _(e){var t=e.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function S(e){var t=e.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}console.log("SVGLoader");var A=[],M=[],T=new l,E=new l,C=new l,L=new l;console.time("SVGLoader: DOMParser");var P=(new DOMParser).parseFromString(e,"image/svg+xml");return console.timeEnd("SVGLoader: DOMParser"),console.time("SVGLoader: Parse"),t(P.documentElement,{fill:"#000"}),console.timeEnd("SVGLoader: Parse"),A}};var fm=function(e){this.manager=void 0!==e?e:Du,this.debug=!1,this.group=null,this.position=0,this.materials=[],this.meshes=[]};fm.prototype={constructor:fm,load:function(e,t,r,i){var n=this,a=void 0!==this.path?this.path:Ru.extractUrlBase(e),o=new we(this.manager);o.setResponseType("arraybuffer"),o.load(e,function(e){t(n.parse(e,a))},r,i)},parse:function(e,t){var r=this;this.group=new Dt,this.position=0,this.materials=[],this.meshes=[],this.readFile(e,t);for(var i=0;i<this.meshes.length;i++)r.group.add(r.meshes[i]);return this.group},readFile:function(e,t){var r=this,i=new DataView(e),n=this.readChunk(i);if(n.id===vm||n.id===gm||n.id===mm)for(var a=this.nextChunk(i,n);0!==a;){if(a===ym){var o=r.readDWord(i);r.debugMessage("3DS file version: "+o)}else a===Sm?(r.resetPosition(i),r.readMeshData(i,t)):r.debugMessage("Unknown main chunk: "+a.toString(16));a=r.nextChunk(i,n)}this.debugMessage("Parsed "+this.meshes.length+" meshes")},readMeshData:function(e,t){for(var r=this,i=this.readChunk(e),n=this.nextChunk(e,i);0!==n;){if(n===Am){var a=+r.readDWord(e);r.debugMessage("Mesh Version: "+a)}else if(n===Mm){var o=r.readFloat(e);r.debugMessage("Master scale: "+o),r.group.scale.set(o,o,o)}else n===Xm?(r.debugMessage("Named Object"),r.resetPosition(e),r.readNamedObject(e)):n===Tm?(r.debugMessage("Material"),r.resetPosition(e),r.readMaterialEntry(e,t)):r.debugMessage("Unknown MDATA chunk: "+n.toString(16));n=r.nextChunk(e,i)}},readNamedObject:function(e){var t=this,r=this.readChunk(e),i=this.readString(e,64);r.cur=this.position;for(var n=this.nextChunk(e,r);0!==n;){if(n===Hm){t.resetPosition(e);var a=t.readMesh(e);a.name=i,t.meshes.push(a)}else t.debugMessage("Unknown named object chunk: "+n.toString(16));n=t.nextChunk(e,r)}this.endChunk(r)},readMaterialEntry:function(e,t){for(var r=this,i=this.readChunk(e),n=this.nextChunk(e,i),a=new Ee;0!==n;){if(n===Em)a.name=r.readString(e,64),r.debugMessage(" Name: "+a.name);else if(n===Fm)r.debugMessage(" Wireframe"),a.wireframe=!0;else if(n===Rm){var o=r.readByte(e);a.wireframeLinewidth=o,r.debugMessage(" Wireframe Thickness: "+o)}else if(n===Om)a.side=Ks,r.debugMessage(" DoubleSided");else if(n===Dm)r.debugMessage(" Additive Blending"),a.blending=ol;else if(n===Lm)r.debugMessage(" Diffuse Color"),a.color=r.readColor(e);else if(n===Pm)r.debugMessage(" Specular Color"),a.specular=r.readColor(e);else if(n===Cm)r.debugMessage(" Ambient color"),a.color=r.readColor(e);else if(n===Nm){var s=r.readWord(e);a.shininess=s,r.debugMessage(" Shininess : "+s)}else n===Im?(r.debugMessage(" ColorMap"),r.resetPosition(e),a.map=r.readMap(e,t)):n===km?(r.debugMessage(" BumpMap"),r.resetPosition(e),a.bumpMap=r.readMap(e,t)):n===Um?(r.debugMessage(" OpacityMap"),r.resetPosition(e),a.alphaMap=r.readMap(e,t)):n===Bm?(r.debugMessage(" SpecularMap"),r.resetPosition(e),a.specularMap=r.readMap(e,t)):r.debugMessage(" Unknown material chunk: "+n.toString(16));n=r.nextChunk(e,i)}this.endChunk(i),this.materials[a.name]=a},readMesh:function(e){var t=this,i=this.readChunk(e),n=this.nextChunk(e,i),a=new P,o=[],s=new Ee,l=new k(a,s);for(l.name="mesh";0!==n;){if(n===Ym){var c=t.readWord(e);t.debugMessage(" Vertex: "+c);for(var u=[],h=0;h<c;h++)u.push(t.readFloat(e)),u.push(t.readFloat(e)),u.push(t.readFloat(e));a.addAttribute("position",new M(u,3))}else if(n===qm)t.resetPosition(e),t.readFaceArray(e,l);else if(n===Jm){var d=t.readWord(e);t.debugMessage(" UV: "+d);for(var o=[],h=0;h<d;h++)o.push(t.readFloat(e)),o.push(t.readFloat(e));a.addAttribute("uv",new M(o,2))}else if(n===Zm){t.debugMessage(" Tranformation Matrix (TODO)");for(var p=[],h=0;h<12;h++)p[h]=t.readFloat(e);var f=new r;f.elements[0]=p[0],f.elements[1]=p[6],f.elements[2]=p[3],f.elements[3]=p[9],f.elements[4]=p[2],f.elements[5]=p[8],f.elements[6]=p[5],f.elements[7]=p[11],f.elements[8]=p[1],f.elements[9]=p[7],f.elements[10]=p[4],f.elements[11]=p[10],f.elements[12]=0,f.elements[13]=0,f.elements[14]=0,f.elements[15]=1,f.transpose();var m=new r;m.getInverse(f,!0),a.applyMatrix(m),f.decompose(l.position,l.quaternion,l.scale)}else t.debugMessage(" Unknown mesh chunk: "+n.toString(16));n=t.nextChunk(e,i)}return this.endChunk(i),a.computeVertexNormals(),l},readFaceArray:function(e,t){var r=this,i=this.readChunk(e),n=this.readWord(e);this.debugMessage(" Faces: "+n);for(var a=[],o=0;o<n;++o){a.push(r.readWord(e),r.readWord(e),r.readWord(e));r.readWord(e)}for(t.geometry.setIndex(a);this.position<i.end;){var i=r.readChunk(e);if(i.id===Qm){r.debugMessage(" Material Group"),r.resetPosition(e);var s=r.readMaterialGroup(e),l=r.materials[s.name];void 0!==l&&(t.material=l,""===l.name&&(l.name=t.name))}else r.debugMessage(" Unknown face array chunk: "+i.toString(16));r.endChunk(i)}this.endChunk(i)},readMap:function(e,t){var r=this,i=this.readChunk(e),n=this.nextChunk(e,i),a={},o=new Ue(this.manager);for(o.setPath(t);0!==n;){if(n===zm){var s=r.readString(e,128);a=o.load(s),r.debugMessage(" File: "+t+s)}else n===Gm?(a.offset.x=r.readFloat(e),r.debugMessage(" OffsetX: "+a.offset.x)):n===Wm?(a.offset.y=r.readFloat(e),r.debugMessage(" OffsetY: "+a.offset.y)):n===jm?(a.repeat.x=r.readFloat(e),r.debugMessage(" RepeatX: "+a.repeat.x)):n===Vm?(a.repeat.y=r.readFloat(e),r.debugMessage(" RepeatY: "+a.repeat.y)):r.debugMessage(" Unknown map chunk: "+n.toString(16));n=r.nextChunk(e,i)}return this.endChunk(i),a},readMaterialGroup:function(e){var t=this,r=(this.readChunk(e),this.readString(e,64)),i=this.readWord(e);this.debugMessage(" Name: "+r),this.debugMessage(" Faces: "+i);for(var n=[],a=0;a<i;++a)n.push(t.readWord(e));return{name:r,index:n}},readColor:function(e){var t=this.readChunk(e),r=new u;if(t.id===bm||t.id===wm){var i=this.readByte(e),n=this.readByte(e),a=this.readByte(e);r.setRGB(i/255,n/255,a/255),this.debugMessage(" Color: "+r.r+", "+r.g+", "+r.b)}else if(t.id===xm||t.id===_m){var i=this.readFloat(e),n=this.readFloat(e),a=this.readFloat(e);r.setRGB(i,n,a),this.debugMessage(" Color: "+r.r+", "+r.g+", "+r.b)}else this.debugMessage(" Unknown color chunk: "+t.toString(16));return this.endChunk(t),r},readChunk:function(e){var t={};return t.cur=this.position,t.id=this.readWord(e),t.size=this.readDWord(e),t.end=t.cur+t.size,t.cur+=6,t},endChunk:function(e){this.position=e.end},nextChunk:function(e,t){if(t.cur>=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;n<t;n++){var a=r.readByte(e);if(!a)break;i+=String.fromCharCode(a)}return i},setPath:function(e){return this.path=e,this},debugMessage:function(e){this.debug&&console.log(e)}};var mm=19789,vm=15786,gm=49725,ym=2,xm=16,bm=17,wm=18,_m=19,Sm=15677,Am=15678,Mm=256,Tm=45055,Em=40960,Cm=40976,Lm=40992,Pm=41008,Nm=41024,Om=41089,Dm=41091,Fm=41093,Rm=41095,Im=41472,Um=41488,km=41520,Bm=41476,zm=41728,jm=41812,Vm=41814,Gm=41816,Wm=41818,Xm=16384,Hm=16640,Ym=16656,qm=16672,Qm=16688,Jm=16704,Zm=16736,Km=function(e){this.manager=void 0!==e?e:Du,this.reversed=!1};Km.prototype={constructor:Km,load:function(e,t,r,i){var n=this,a=new we(this.manager);a.setResponseType("arraybuffer"),a.load(e,function(e){t(n.parse(e))},r,i)},parse:function(e){function t(e,t){for(var i=Math.round,n={},a=1e5/(72*(e.unitsPerEm||2048)),o=0;o<e.glyphs.length;o++){var s=e.glyphs.glyphs[o];if(void 0!==s.unicode){var l={ha:i(s.advanceWidth*a),x_min:i(s.xMin*a),x_max:i(s.xMax*a),o:""};t&&(s.path.commands=r(s.path.commands)),s.path.commands.forEach(function(e,t){"c"===e.type.toLowerCase()&&(e.type="b"),l.o+=e.type.toLowerCase()+" ",void 0!==e.x&&void 0!==e.y&&(l.o+=i(e.x*a)+" "+i(e.y*a)+" "),void 0!==e.x1&&void 0!==e.y1&&(l.o+=i(e.x1*a)+" "+i(e.y1*a)+" "),void 0!==e.x2&&void 0!==e.y2&&(l.o+=i(e.x2*a)+" "+i(e.y2*a)+" ")}),n[String.fromCharCode(s.unicode)]=l}}return{glyphs:n,familyName:e.familyName,ascender:i(e.ascender*a),descender:i(e.descender*a),underlinePosition:e.tables.post.underlinePosition,underlineThickness:e.tables.post.underlineThickness,boundingBox:{xMin:e.tables.head.xMin,xMax:e.tables.head.xMax,yMin:e.tables.head.yMin,yMax:e.tables.head.yMax},resolution:1e3,original_font_information:e.tables.name}}function r(e){var t,r=[];e.forEach(function(e){"m"===e.type.toLowerCase()?(t=[e],r.push(t)):"z"!==e.type.toLowerCase()&&t.push(e)});var i=[];return r.forEach(function(e){var t={type:"m",x:e[e.length-1].x,y:e[e.length-1].y};i.push(t);for(var r=e.length-1;r>0;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;d<r.length;d++){var p={x:o*(Math.cos(r[d])*t),y:o*(Math.sin(r[d])*t)};s.push(p)}for(var f=e.index,m=e.attributes.position,v=new g(new Float32Array(3*e.attributes.position.count),3),y=new i,x=new u,b=0;b<f.count;b++){var w=f.getX(b);y.fromBufferAttribute(m,w);for(var _=0;_<n.length;_++)if(0===_?(l.x=0,l.y=a===!0?t:-1*t):(l.x=s[_-1].x,l.y=s[_-1].y),c=s[_],void 0!==c)if(h=a===!0?y.y<=l.y&&y.y>c.y:y.y>=l.y&&y.y<c.y,h===!0){var S=n[_],A=n[_+1],M=Math.abs(y.y-l.y)/(l.y-c.y);x.copy(S).lerp(A,M),v.setXYZ(w,x.r,x.g,x.b)}else{var T=a===!0?n.length-1:0,E=n[T];v.setXYZ(w,E.r,E.g,E.b)}}e.addAttribute("color",v)}function s(e,t){for(var i,n,a,o=[],s={},l=/[^\s,\[\]]+/g;null!==(i=l.exec(t));)o.push(i[0]);switch(n=o[0]){case"skyAngle":case"groundAngle":r.recordingFieldname=n,r.isRecordingAngles=!0,r.angles=[];break;case"skyColor":case"groundColor":r.recordingFieldname=n,r.isRecordingColors=!0,r.colors=[];break;case"point":r.recordingFieldname=n,r.isRecordingPoints=!0,r.points=[];break;case"coordIndex":case"texCoordIndex":r.recordingFieldname=n,r.isRecordingFaces=!0,r.indexes=[]}if(r.isRecordingFaces){if(o.length>0)for(var c=0;c<o.length;c++)/(-?\d+)/.test(o[c])&&("-1"===o[c]?(y.length>0&&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<o.length;c++)p.test(o[c])&&r.angles.push(parseFloat(o[c]));/]/.exec(t)&&(r.isRecordingAngles=!1,e[r.recordingFieldname]=r.angles)}else if(r.isRecordingColors){for(;null!==(o=v.exec(t));){var u={r:parseFloat(o[1]),g:parseFloat(o[2]),b:parseFloat(o[3])};r.colors.push(u)}/]/.exec(t)&&(r.isRecordingColors=!1,e[r.recordingFieldname]=r.colors)}else if("NULL"!==o[o.length-1]&&"children"!==n){switch(n){case"diffuseColor":case"emissiveColor":case"specularColor":case"color":if(4!==o.length){console.warn("VRMLLoader: Invalid color format detected for %s.",n);break}s={r:parseFloat(o[1]),g:parseFloat(o[2]),b:parseFloat(o[3])};break;case"location":case"direction":case"translation":case"scale":case"size":if(4!==o.length){console.warn("VRMLLoader: Invalid vector format detected for %s.",n);break}s={x:parseFloat(o[1]),y:parseFloat(o[2]),z:parseFloat(o[3])};break;case"intensity":case"cutOffAngle":case"radius":case"topRadius":case"bottomRadius":case"height":case"transparency":case"shininess":case"ambientIntensity":if(2!==o.length){console.warn("VRMLLoader: Invalid single float value specification detected for %s.",n);break}s=parseFloat(o[1]);break;case"rotation":if(5!==o.length){console.warn("VRMLLoader: Invalid quaternion format detected for %s.",n);break}s={x:parseFloat(o[1]),y:parseFloat(o[2]),z:parseFloat(o[3]),w:parseFloat(o[4])};break;case"on":case"ccw":case"solid":case"colorPerVertex":case"convex":if(2!==o.length){console.warn("VRMLLoader: Invalid format detected for %s.",n);break}s="TRUE"===o[1]}e[n]=s}return s}function l(e){for(var t,r,i={string:"Scene",children:[]},n=i,a=0;a<e.length;a++){var o="",l=e[a];if(null===/^\s+?$/g.exec(l)&&(l=l.trim(),""!==l)){if(/#/.exec(l)){var c=l.split("#");l=c[0],o=c[1]}if(t=/([^\s]*){1}(?:\s+)?{/.exec(l)){var u={nodeType:t[1],string:l,parent:n,children:[],comment:o};n.children.push(u),n=u,/}/.exec(l)&&(r=/{(.*)}/.exec(l)[1],u.children.push(r),s(n,r),n=n.parent)}else/}/.exec(l)?n=n.parent:""!==l&&(s(n,l),n.children.push(l))}}return i}function h(e,r){var s;if("string"!=typeof e){s=r,e.string.indexOf("AmbientLight")>-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<I;R++){var G=e.children[R];if("TextureCoordinate"===G.nodeType&&G.points)for(U=0,B=G.points.length;U<B;U++)D=G.points[U],V.push(D.x,D.y);if("Coordinate"===G.nodeType){if(G.points)for(U=0,B=G.points.length;U<B;U++)N=G.points[U],j.push(N.x,N.y,N.z);if(G.string.indexOf("DEF")>-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<I;R++){var Q=e.coordIndex[R];for(H=0;Q.length>=3&&H<Q.length-2;){void 0===e.ccw&&(e.ccw=!0);var J=Q[0],Z=Q[H+(e.ccw?1:2)],K=Q[H+(e.ccw?2:1)];N.fromArray(j,3*J),D.fromArray(V,2*J),Y.push(N.x,N.y,N.z),q.push(D.x,D.y),N.fromArray(j,3*Z),D.fromArray(V,2*Z),Y.push(N.x,N.y,N.z),q.push(D.x,D.y),N.fromArray(j,3*K),D.fromArray(V,2*K),Y.push(N.x,N.y,N.z),q.push(D.x,D.y),H++}}j=Y,V=q}else r.parent.remove(r);!1===e.solid&&(r.material.side=Ks),z.solid=e.solid,z.addAttribute("position",new M(j,3)),V.length>0&&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<e.children.length;R++){var G=e.children[R];if("Material"===G.nodeType){var $=new Ee;if(void 0!==G.diffuseColor){var ee=G.diffuseColor;
|
|
$.color.setRGB(ee.r,ee.g,ee.b)}if(void 0!==G.emissiveColor){var te=G.emissiveColor;$.emissive.setRGB(te.r,te.g,te.b)}if(void 0!==G.specularColor){var w=G.specularColor;$.specular.setRGB(w.r,w.g,w.b)}if(void 0!==G.transparency){var x=G.transparency;$.opacity=Math.abs(1-x),$.transparent=!0}/DEF/.exec(e.string)&&($.name=/DEF ([^\s]+)/.exec(e.string)[1],d[$.name]=$),r.material=$}if("ImageTexture"===G.nodeType){var re=/"([^"]+)"/.exec(G.children[0]);re&&(r.material.name=re[1],r.material.map=a.load(n+re[1]))}}return}}for(var R=0,ie=e.children.length;R<ie;R++)h(e.children[R],s)}else if(/USE/.exec(e)){var X=/USE\s+?([^\s]+)/.exec(e)[1];void 0==d[X]?console.warn("VRMLLoader: %s is not defined.",X):/appearance/.exec(e)&&X?r.material=d[X].clone():/geometry/.exec(e)&&X?(r.geometry=d[X].clone(),void 0!==d[X].solid&&d[X].solid===!1&&(r.geometry.solid=!1,r.material.side=Ks)):X&&(s=d[X].clone(),r.add(s))}}var d={},p=/(\b|\-|\+)([\d\.e]+)/,m=/([\d\.\+\-e]+)\s+([\d\.\+\-e]+)/g,v=/([\d\.\+\-e]+)\s+([\d\.\+\-e]+)\s+([\d\.\+\-e]+)/g,y=[];h(l(e),t)}var r=this,n=this.texturePath||"",a=new Ue(this.manager);a.setCrossOrigin(this.crossOrigin);for(var o=new fe,s=e.split("\n"),l=s.length-1;l>-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<L-2;++I)O=parseInt(N[R]),D=parseInt(N[R+1]),r.push(F,O,D),R++}}else if(g){if(null!==(t=s.exec(A))){var L=parseInt(t[1]),N=t[2].split(/\s+/);if(L>=3)for(var F,O,D,I=0;I<L-2;I++)I%2===1?(F=parseInt(N[I]),O=parseInt(N[I+2]),D=parseInt(N[I+1]),r.push(F,O,D)):(F=parseInt(N[I]),O=parseInt(N[I+1]),D=parseInt(N[I+2]),r.push(F,O,D))}}else if(y||x)if(b)for(;null!==(t=o.exec(A));){var U=parseFloat(t[1]),k=parseFloat(t[2]),B=parseFloat(t[3]);n.push(U,k,B)}else if(w)for(;null!==(t=o.exec(A));){var z=parseFloat(t[1]),j=parseFloat(t[2]),V=parseFloat(t[3]);a.push(z,j,V)}null!==c.exec(A)?(v=!0,m=!1,g=!1):null!==l.exec(A)?(v=!1,m=!0,g=!1):null!==u.exec(A)?(v=!1,m=!1,g=!0):null!==h.exec(A)?(y=!0,m=!1,v=!1,g=!1):null!==d.exec(A)?(x=!0,m=!1,v=!1,g=!1):null!==p.exec(A)?(b=!0,w=!1,m=!1,v=!1,g=!1):null!==f.exec(A)&&(w=!0,b=!1,m=!1,v=!1,g=!1)}var G=new P;if(G.setIndex(r),G.addAttribute("position",new M(i,3)),a.length===i.length&&G.addAttribute("normal",new M(a,3)),n.length!==r.length)n.length===i.length&&G.addAttribute("color",new M(n,3));else{G=G.toNonIndexed();var W=G.attributes.position.count/3;if(n.length===3*W){for(var X=[],S=0;S<W;S++){var U=n[3*S+0],k=n[3*S+1],B=n[3*S+2];X.push(U,k,B),X.push(U,k,B),X.push(U,k,B)}G.addAttribute("color",new M(X,3))}}return G}function r(e){function t(e,t){for(var r=t,i=e[r],n=[];10!==i;)n.push(String.fromCharCode(i)),r++,i=e[r];return{start:t,end:r,next:r+1,parsedString:n.join("")}}for(var r,i,n,a,o,s,l,c=new Uint8Array(e),u=new DataView(e),h=[],d=[],p=[],f=0;;){if(s=t(c,f),l=s.parsedString,0===l.indexOf("POINTS")){for(a=parseInt(l.split(" ")[1],10),r=4*a*3,h=new Float32Array(3*a),i=s.next,n=0;n<a;n++)h[3*n]=u.getFloat32(i,!1),h[3*n+1]=u.getFloat32(i+4,!1),h[3*n+2]=u.getFloat32(i+8,!1),i+=12;s.next=s.next+r+1}else if(0===l.indexOf("TRIANGLE_STRIPS")){var m=parseInt(l.split(" ")[1],10),v=parseInt(l.split(" ")[2],10);r=4*v,p=new Uint32Array(3*v-9*m);var y=0;for(i=s.next,n=0;n<m;n++){var x=u.getInt32(i,!1),b=[];for(i+=4,o=0;o<x;o++)b.push(u.getInt32(i,!1)),i+=4;for(var w=0;w<x-2;w++)w%2?(p[y++]=b[w],p[y++]=b[w+2],p[y++]=b[w+1]):(p[y++]=b[w],p[y++]=b[w+1],p[y++]=b[w+2])}s.next=s.next+r+1}else if(0===l.indexOf("POLYGONS")){var m=parseInt(l.split(" ")[1],10),v=parseInt(l.split(" ")[2],10);r=4*v,p=new Uint32Array(3*v-9*m);var y=0;for(i=s.next,n=0;n<m;n++){var x=u.getInt32(i,!1),b=[];for(i+=4,o=0;o<x;o++)b.push(u.getInt32(i,!1)),i+=4;for(var w=1;w<x-1;w++)p[y++]=b[0],p[y++]=b[w],p[y++]=b[w+1]}s.next=s.next+r+1}else if(0===l.indexOf("POINT_DATA")){for(a=parseInt(l.split(" ")[1],10),s=t(c,s.next),r=4*a*3,d=new Float32Array(3*a),i=s.next,n=0;n<a;n++)d[3*n]=u.getFloat32(i,!1),d[3*n+1]=u.getFloat32(i+4,!1),d[3*n+2]=u.getFloat32(i+8,!1),i+=12;s.next=s.next+r}if(f=s.next,f>=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;i<e.attributes.length;i++){var n=e.attributes.item(i);r.attributes[n.nodeName]=n.nodeValue.trim()}}}else 3===e.nodeType&&(r=e.nodeValue.trim());if(e.hasChildNodes())for(var a=0;a<e.childNodes.length;a++){var o=e.childNodes.item(a),s=o.nodeName;if("undefined"==typeof r[s]){var l=t(o);""!==l&&(r[s]=l)}else{if("undefined"==typeof r[s].push){var c=r[s];r[s]=[c]}var l=t(o);""!==l&&r[s].push(l)}}return r}function r(e){var t,r="undefined"!=typeof Uint8Array?Uint8Array:Array,i=[],n=[],a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=a.length;for(t=0;t<o;t++)i[t]=a[t];for(t=0;t<o;++t)n[a.charCodeAt(t)]=t;n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63;var s,l,c,u,h,o=e.length;if(o%4>0)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<l;t+=4,s+=3)c=n[e.charCodeAt(t)]<<18|n[e.charCodeAt(t+1)]<<12|n[e.charCodeAt(t+2)]<<6|n[e.charCodeAt(t+3)],h[d++]=(16711680&c)>>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;g<a-1;g++)u|=l[g]<<g*a;d=(u+3)*a,p=d%3>0?3-d%3:0,d+=p,f=[],m=d,f.push(m),h=3*a;for(var g=0;g<u;g++){for(var y=l[g*a+h],x=1;x<a-1;x++)y|=l[g*a+h+x]<<8*x;m+=y,f.push(m)}for(var g=0;g<f.length-1;g++){var b=new Zlib.Inflate(l.slice(f[g],f[g+1]),{resize:!0,verify:!0});s=b.decompress(),s=s.buffer,"Float32"===e.attributes.type?(s=new Float32Array(s),v=i(v,s)):"Int64"===e.attributes.type&&(s=new Int32Array(s),v=n(v,s))}delete e["#text"],"Float32"===e.attributes.type?"binary"===e.attributes.format&&(t||(v=v.filter(function(e,t){if(0!==t)return!0}))):"Int64"===e.attributes.type&&"binary"===e.attributes.format&&(t||(v=v.filter(function(e,t){if(0!==t)return!0})),v=v.filter(function(e,t){if(t%2!==1)return!0}))}else{if("binary"!==e.attributes.format||t)if(e["#text"])var s=e["#text"].split(/\s+/).filter(function(e){if(""!==e)return e});else var s=new Int32Array(0).buffer;else{var s=r(e["#text"]);s=s.slice(a).buffer}if(delete e["#text"],"Float32"===e.attributes.type)var v=new Float32Array(s);else if("Int32"===e.attributes.type)var v=new Int32Array(s);else if("Int64"===e.attributes.type){var v=new Int32Array(s);"binary"===e.attributes.format&&(v=v.filter(function(e,t){if(t%2!==1)return!0}))}}return v}var o=null;if(Ds.DOMParser)try{o=(new DOMParser).parseFromString(e,"text/xml")}catch(s){o=null}else{if(!Ds.ActiveXObject)throw new Error("Cannot parse xml string!");try{if(o=new ActiveXObject("Microsoft.XMLDOM"),o.async=!1,!o.loadXML())throw new Error(o.parseError.reason+o.parseError.srcText)}catch(s){o=null}}var l=o.documentElement,c=t(l),u=[],h=[],d=[];if(c.PolyData){for(var p=c.PolyData.Piece,f=c.attributes.hasOwnProperty("compressor"),m=["PointData","Points","Strips","Polys"],v=0,y=m.length;v<y;){var x=p[m[v]];if(x&&x.DataArray){if("[object Array]"===Object.prototype.toString.call(x.DataArray))var b=x.DataArray;else var b=[x.DataArray];for(var w=0,_=b.length;w<_;)"#text"in b[w]&&b[w]["#text"].length>0&&(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;M<T;M++)if(A===b[M].attributes.Name){var E=b[M].attributes.NumberOfComponents;h=new Float32Array(S*E),h.set(b[M].text,0)}break;case"Points":var S=parseInt(p.attributes.NumberOfPoints);if(S>0){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;M<T;M++){for(var F=[],R=0,I=N[M],U=0;R<I-U;R++)F.push(L[R]),M>0&&(U=N[M-1]);for(var k=0,I=N[M],U=0;k<I-U-2;k++)k%2?(d[D++]=F[k],d[D++]=F[k+2],d[D++]=F[k+1]):(d[D++]=F[k],d[D++]=F[k+1],d[D++]=F[k+2]),M>0&&(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<T;){for(var j=[],R=0,I=N[M];R<I-U;)j.push(L[z++]),R++;for(var k=1;k<I-U-1;)d[D++]=j[0],d[D++]=j[k],d[D++]=j[k+1],k++;M++,U=N[M-1]}}}}v++}var V=new P;return V.setIndex(new g(d,1)),V.addAttribute("position",new g(u,3)),h.length===u.length&&V.addAttribute("normal",new g(h,3)),V}}function o(e){for(var t="",r=new Uint8Array(e),i=0,n=r.length;n--;)t+=String.fromCharCode(r[i++]);return t}var s=Ru.decodeText(new Uint8Array(e,0,250)).split("\n");return s[0].indexOf("xml")!==-1?a(o(e)):s[2].includes("ASCII")?t(o(e)):r(e)}}),fi.prototype=Object.create(c.prototype),fi.prototype.constructor=fi,fi.prototype.isImmediateRenderObject=!0;var rv=function(e,t,r,i){function n(e,t,r){return e+(t-e)*r}function a(e,t,r,i,a,o,s,l){var c=(r-s)/(l-s),u=d.normal_cache;p[t+0]=i+c*d.delta,p[t+1]=a,p[t+2]=o,f[t+0]=n(u[e+0],u[e+3],c),f[t+1]=n(u[e+1],u[e+4],c),f[t+2]=n(u[e+2],u[e+5],c)}function o(e,t,r,i,a,o,s,l){var c=(r-s)/(l-s),u=d.normal_cache;p[t+0]=i,p[t+1]=a+c*d.delta,p[t+2]=o;var h=e+3*d.yd;f[t+0]=n(u[e+0],u[h+0],c),f[t+1]=n(u[e+1],u[h+1],c),f[t+2]=n(u[e+2],u[h+2],c)}function s(e,t,r,i,a,o,s,l){var c=(r-s)/(l-s),u=d.normal_cache;p[t+0]=i,p[t+1]=a,p[t+2]=o+c*d.delta;var h=e+3*d.zd;f[t+0]=n(u[e+0],u[h+0],c),f[t+1]=n(u[e+1],u[h+1],c),f[t+2]=n(u[e+2],u[h+2],c)}function l(e){var t=3*e;0===d.normal_cache[t]&&(d.normal_cache[t+0]=d.field[e-1]-d.field[e+1],d.normal_cache[t+1]=d.field[e-d.yd]-d.field[e+d.yd],d.normal_cache[t+2]=d.field[e-d.zd]-d.field[e+d.zd])}function c(e,t,r,i,n,c){var h=i+1,m=i+d.yd,v=i+d.zd,g=h+d.yd,y=h+d.zd,x=i+d.yd+d.zd,b=h+d.yd+d.zd,w=0,_=d.field[i],S=d.field[h],A=d.field[m],M=d.field[g],T=d.field[v],E=d.field[y],C=d.field[x],L=d.field[b];_<n&&(w|=1),S<n&&(w|=2),A<n&&(w|=8),M<n&&(w|=4),T<n&&(w|=16),E<n&&(w|=32),C<n&&(w|=128),L<n&&(w|=64);var P=iv[w];if(0===P)return 0;var N=d.delta,O=e+N,D=t+N,F=r+N;1&P&&(l(i),l(h),a(3*i,0,n,e,t,r,_,S)),2&P&&(l(h),l(g),o(3*h,3,n,O,t,r,S,M)),4&P&&(l(m),l(g),a(3*m,6,n,e,D,r,A,M)),8&P&&(l(i),l(m),o(3*i,9,n,e,t,r,_,A)),16&P&&(l(v),l(y),a(3*v,12,n,e,t,F,T,E)),32&P&&(l(y),l(b),o(3*y,15,n,O,t,F,E,L)),64&P&&(l(x),l(b),a(3*x,18,n,e,D,F,C,L)),128&P&&(l(v),l(x),o(3*v,21,n,e,t,F,T,C)),256&P&&(l(i),l(v),s(3*i,24,n,e,t,r,_,T)),512&P&&(l(h),l(y),s(3*h,27,n,O,t,r,S,E)),1024&P&&(l(g),l(b),s(3*g,30,n,O,D,r,M,L)),2048&P&&(l(m),l(x),s(3*m,33,n,e,D,r,A,C)),w<<=4;for(var R,I,U,k=0,B=0;nv[w+B]!=-1;)R=w+B,I=R+1,U=R+2,u(p,f,3*nv[R],3*nv[I],3*nv[U],c),B+=3,k++;return k}function u(e,t,r,i,n,a){var o=3*d.count;if(d.positionArray[o+0]=e[r],d.positionArray[o+1]=e[r+1],d.positionArray[o+2]=e[r+2],d.positionArray[o+3]=e[i],d.positionArray[o+4]=e[i+1],d.positionArray[o+5]=e[i+2],d.positionArray[o+6]=e[n],d.positionArray[o+7]=e[n+1],d.positionArray[o+8]=e[n+2],d.material.flatShading===!0){var s=(t[r+0]+t[i+0]+t[n+0])/3,l=(t[r+1]+t[i+1]+t[n+1])/3,c=(t[r+2]+t[i+2]+t[n+2])/3;d.normalArray[o+0]=s,d.normalArray[o+1]=l,d.normalArray[o+2]=c,d.normalArray[o+3]=s,d.normalArray[o+4]=l,d.normalArray[o+5]=c,d.normalArray[o+6]=s,d.normalArray[o+7]=l,d.normalArray[o+8]=c}else d.normalArray[o+0]=t[r+0],d.normalArray[o+1]=t[r+1],d.normalArray[o+2]=t[r+2],d.normalArray[o+3]=t[i+0],d.normalArray[o+4]=t[i+1],d.normalArray[o+5]=t[i+2],d.normalArray[o+6]=t[n+0],d.normalArray[o+7]=t[n+1],d.normalArray[o+8]=t[n+2];if(d.enableUvs){var u=2*d.count;d.uvArray[u+0]=e[r+0],d.uvArray[u+1]=e[r+2],d.uvArray[u+2]=e[i+0],d.uvArray[u+3]=e[i+2],d.uvArray[u+4]=e[n+0],d.uvArray[u+5]=e[n+2]}d.enableColors&&(d.colorArray[o+0]=e[r+0],d.colorArray[o+1]=e[r+1],d.colorArray[o+2]=e[r+2],d.colorArray[o+3]=e[i+0],d.colorArray[o+4]=e[i+1],d.colorArray[o+5]=e[i+2],d.colorArray[o+6]=e[n+0],d.colorArray[o+7]=e[n+1],d.colorArray[o+8]=e[n+2]),d.count+=3,d.count>=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;r<this.positionArray.length;r++)t.positionArray[r]=0;this.hasPositions=!0,this.hasNormals=!0,this.enableUvs&&this.material.map&&(this.hasUvs=!0),this.enableColors&&this.material.vertexColors!==tl&&(this.hasColors=!0),e(this)}},this.addBall=function(e,t,r,i,n){var a=this,o=Math.sign(i);i=Math.abs(i);var s=this.size*Math.sqrt(i/n),l=r*this.size,c=t*this.size,u=e*this.size,h=Math.floor(l-s);h<1&&(h=1);var d=Math.floor(l+s);d>this.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;x<d;x++)for(w=a.size2*x,A=x/a.size-r,M=A*A,y=p;y<f;y++)for(b=w+a.size*y,S=y/a.size-t,T=S*S,g=m;g<v;g++)_=g/a.size-e,E=i/(1e-6+_*_+T+M)-n,E>0&&(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;r<p;r++)if(s=r/c,a=s*s,o=e/(1e-4+a)-t,o>0)for(i=0;i<c;i++)for(l=r+i*u,n=0;n<c;n++)d[h*n+l]+=o},this.addPlaneY=function(e,t){var r,i,n,a,o,s,l,c,u=this.size,h=this.yd,d=this.zd,p=this.field,f=u*Math.sqrt(e/t);for(f>u&&(f=u),i=0;i<f;i++)if(s=i/u,a=s*s,o=e/(1e-4+a)-t,o>0)for(l=i*h,r=0;r<u;r++)for(c=l+r,n=0;n<u;n++)p[d*n+c]+=o},this.addPlaneZ=function(e,t){var r,i,n,a,o,s,l,c,u=this.size,h=this.yd,d=this.zd,p=this.field,f=u*Math.sqrt(e/t);for(f>u&&(f=u),n=0;n<f;n++)if(s=n/u,a=s*s,o=e/(1e-4+a)-t,o>0)for(l=d*n,i=0;i<u;i++)for(c=l+i*h,r=0;r<u;r++)p[c+r]+=o},this.reset=function(){var e,t=this;for(e=0;e<this.size3;e++)t.normal_cache[3*e]=0,t.field[e]=0},this.render=function(e){var t=this;this.begin();for(var r=this.size-2,i=1;i<r;i++)for(var n=t.size2*i,a=(i-t.halfsize)/t.halfsize,o=1;o<r;o++)for(var s=n+t.size*o,l=(o-t.halfsize)/t.halfsize,u=1;u<r;u++){var h=(u-t.halfsize)/t.halfsize,d=s+u;c(h,l,a,d,t.isolation,e)}this.end(e)},this.generateGeometry=function(){return console.warn("MarchingCubes: generateGeometry() now returns BufferGeometry"),this.generateBufferGeometry()},this.generateBufferGeometry=function(){var e=new P,t=new Float32Array,r=new Float32Array,i=new Float32Array,n=new Float32Array,a=this,o=function(e){a.hasPositions&&(t=h(t,e.positionArray,3*e.count)),a.hasNormals&&(r=h(r,e.normalArray,3*e.count)),a.hasColors&&(i=h(i,e.colorArray,3*e.count)),a.hasUvs&&(n=h(n,e.uvArray,2*e.count)),e.count=0};return this.render(o),this.hasPositions&&e.addAttribute("position",new g(t,3)),this.hasNormals&&e.addAttribute("normal",new g(r,3)),this.hasColors&&e.addAttribute("color",new g(i,3)),this.hasUvs&&e.addAttribute("uv",new g(n,2)),e},this.init(e)};rv.prototype=Object.create(fi.prototype),rv.prototype.constructor=rv;var iv=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]),nv=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3,0,4,1,2,10,-1,-1,-1,-1,-1,-1,-1,9,2,10,9,0,2,8,4,7,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,7,2,7,3,7,9,4,-1,-1,-1,-1,8,4,7,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,4,7,11,2,4,2,0,4,-1,-1,-1,-1,-1,-1,-1,9,0,1,8,4,7,2,3,11,-1,-1,-1,-1,-1,-1,-1,4,7,11,9,4,11,9,11,2,9,2,1,-1,-1,-1,-1,3,10,1,3,11,10,7,8,4,-1,-1,-1,-1,-1,-1,-1,1,11,10,1,4,11,1,0,4,7,11,4,-1,-1,-1,-1,4,7,8,9,0,11,9,11,10,11,0,3,-1,-1,-1,-1,4,7,11,4,11,9,9,11,10,-1,-1,-1,-1,-1,-1,-1,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,5,4,1,5,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,5,4,8,3,5,3,1,5,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,10,4,9,5,-1,-1,-1,-1,-1,-1,-1,5,2,10,5,4,2,4,0,2,-1,-1,-1,-1,-1,-1,-1,2,10,5,3,2,5,3,5,4,3,4,8,-1,-1,-1,-1,9,5,4,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,0,8,11,4,9,5,-1,-1,-1,-1,-1,-1,-1,0,5,4,0,1,5,2,3,11,-1,-1,-1,-1,-1,-1,-1,2,1,5,2,5,8,2,8,11,4,8,5,-1,-1,-1,-1,10,3,11,10,1,3,9,5,4,-1,-1,-1,-1,-1,-1,-1,4,9,5,0,8,1,8,10,1,8,11,10,-1,-1,-1,-1,5,4,0,5,0,11,5,11,10,11,0,3,-1,-1,-1,-1,5,4,8,5,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,9,7,8,5,7,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,3,0,9,5,3,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,7,8,0,1,7,1,5,7,-1,-1,-1,-1,-1,-1,-1,1,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,7,8,9,5,7,10,1,2,-1,-1,-1,-1,-1,-1,-1,10,1,2,9,5,0,5,3,0,5,7,3,-1,-1,-1,-1,8,0,2,8,2,5,8,5,7,10,5,2,-1,-1,-1,-1,2,10,5,2,5,3,3,5,7,-1,-1,-1,-1,-1,-1,-1,7,9,5,7,8,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,9,5,7,9,7,2,9,2,0,2,7,11,-1,-1,-1,-1,2,3,11,0,1,8,1,7,8,1,5,7,-1,-1,-1,-1,11,2,1,11,1,7,7,1,5,-1,-1,-1,-1,-1,-1,-1,9,5,8,8,5,7,10,1,3,10,3,11,-1,-1,-1,-1,5,7,0,5,0,9,7,11,0,1,0,10,11,10,0,-1,11,10,0,11,0,3,10,5,0,8,0,7,5,7,0,-1,11,10,5,7,11,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,1,5,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,1,9,8,5,10,6,-1,-1,-1,-1,-1,-1,-1,1,6,5,2,6,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,6,5,1,2,6,3,0,8,-1,-1,-1,-1,-1,-1,-1,9,6,5,9,0,6,0,2,6,-1,-1,-1,-1,-1,-1,-1,5,9,8,5,8,2,5,2,6,3,2,8,-1,-1,-1,-1,2,3,11,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,0,8,11,2,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,0,1,9,2,3,11,5,10,6,-1,-1,-1,-1,-1,-1,-1,5,10,6,1,9,2,9,11,2,9,8,11,-1,-1,-1,-1,6,3,11,6,5,3,5,1,3,-1,-1,-1,-1,-1,-1,-1,0,8,11,0,11,5,0,5,1,5,11,6,-1,-1,-1,-1,3,11,6,0,3,6,0,6,5,0,5,9,-1,-1,-1,-1,6,5,9,6,9,11,11,9,8,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,4,7,3,6,5,10,-1,-1,-1,-1,-1,-1,-1,1,9,0,5,10,6,8,4,7,-1,-1,-1,-1,-1,-1,-1,10,6,5,1,9,7,1,7,3,7,9,4,-1,-1,-1,-1,6,1,2,6,5,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,1,2,5,5,2,6,3,0,4,3,4,7,-1,-1,-1,-1,8,4,7,9,0,5,0,6,5,0,2,6,-1,-1,-1,-1,7,3,9,7,9,4,3,2,9,5,9,6,2,6,9,-1,3,11,2,7,8,4,10,6,5,-1,-1,-1,-1,-1,-1,-1,5,10,6,4,7,2,4,2,0,2,7,11,-1,-1,-1,-1,0,1,9,4,7,8,2,3,11,5,10,6,-1,-1,-1,-1,9,2,1,9,11,2,9,4,11,7,11,4,5,10,6,-1,8,4,7,3,11,5,3,5,1,5,11,6,-1,-1,-1,-1,5,1,11,5,11,6,1,0,11,7,11,4,0,4,11,-1,0,5,9,0,6,5,0,3,6,11,6,3,8,4,7,-1,6,5,9,6,9,11,4,7,9,7,11,9,-1,-1,-1,-1,10,4,9,6,4,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,10,6,4,9,10,0,8,3,-1,-1,-1,-1,-1,-1,-1,10,0,1,10,6,0,6,4,0,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,6,8,6,4,6,1,10,-1,-1,-1,-1,1,4,9,1,2,4,2,6,4,-1,-1,-1,-1,-1,-1,-1,3,0,8,1,2,9,2,4,9,2,6,4,-1,-1,-1,-1,0,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,8,2,4,4,2,6,-1,-1,-1,-1,-1,-1,-1,10,4,9,10,6,4,11,2,3,-1,-1,-1,-1,-1,-1,-1,0,8,2,2,8,11,4,9,10,4,10,6,-1,-1,-1,-1,3,11,2,0,1,6,0,6,4,6,1,10,-1,-1,-1,-1,6,4,1,6,1,10,4,8,1,2,1,11,8,11,1,-1,9,6,4,9,3,6,9,1,3,11,6,3,-1,-1,-1,-1,8,11,1,8,1,0,11,6,1,9,1,4,6,4,1,-1,3,11,6,3,6,0,0,6,4,-1,-1,-1,-1,-1,-1,-1,6,4,8,11,6,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,10,6,7,8,10,8,9,10,-1,-1,-1,-1,-1,-1,-1,0,7,3,0,10,7,0,9,10,6,7,10,-1,-1,-1,-1,10,6,7,1,10,7,1,7,8,1,8,0,-1,-1,-1,-1,10,6,7,10,7,1,1,7,3,-1,-1,-1,-1,-1,-1,-1,1,2,6,1,6,8,1,8,9,8,6,7,-1,-1,-1,-1,2,6,9,2,9,1,6,7,9,0,9,3,7,3,9,-1,7,8,0,7,0,6,6,0,2,-1,-1,-1,-1,-1,-1,-1,7,3,2,6,7,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,11,10,6,8,10,8,9,8,6,7,-1,-1,-1,-1,2,0,7,2,7,11,0,9,7,6,7,10,9,10,7,-1,1,8,0,1,7,8,1,10,7,6,7,10,2,3,11,-1,11,2,1,11,1,7,10,6,1,6,7,1,-1,-1,-1,-1,8,9,6,8,6,7,9,1,6,11,6,3,1,3,6,-1,0,9,1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,7,0,6,3,11,0,11,6,0,-1,-1,-1,-1,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,8,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,11,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,1,9,8,3,1,11,7,6,-1,-1,-1,-1,-1,-1,-1,10,1,2,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,8,6,11,7,-1,-1,-1,-1,-1,-1,-1,2,9,0,2,10,9,6,11,7,-1,-1,-1,-1,-1,-1,-1,6,11,7,2,10,3,10,8,3,10,9,8,-1,-1,-1,-1,7,2,3,6,2,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,0,8,7,6,0,6,2,0,-1,-1,-1,-1,-1,-1,-1,2,7,6,2,3,7,0,1,9,-1,-1,-1,-1,-1,-1,-1,1,6,2,1,8,6,1,9,8,8,7,6,-1,-1,-1,-1,10,7,6,10,1,7,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,7,6,1,7,10,1,8,7,1,0,8,-1,-1,-1,-1,0,3,7,0,7,10,0,10,9,6,10,7,-1,-1,-1,-1,7,6,10,7,10,8,8,10,9,-1,-1,-1,-1,-1,-1,-1,6,8,4,11,8,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,6,11,3,0,6,0,4,6,-1,-1,-1,-1,-1,-1,-1,8,6,11,8,4,6,9,0,1,-1,-1,-1,-1,-1,-1,-1,9,4,6,9,6,3,9,3,1,11,3,6,-1,-1,-1,-1,6,8,4,6,11,8,2,10,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,3,0,11,0,6,11,0,4,6,-1,-1,-1,-1,4,11,8,4,6,11,0,2,9,2,10,9,-1,-1,-1,-1,10,9,3,10,3,2,9,4,3,11,3,6,4,6,3,-1,8,2,3,8,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,0,4,2,4,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,4,2,4,6,4,3,8,-1,-1,-1,-1,1,9,4,1,4,2,2,4,6,-1,-1,-1,-1,-1,-1,-1,8,1,3,8,6,1,8,4,6,6,10,1,-1,-1,-1,-1,10,1,0,10,0,6,6,0,4,-1,-1,-1,-1,-1,-1,-1,4,6,3,4,3,8,6,10,3,0,3,9,10,9,3,-1,10,9,4,6,10,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,5,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,5,11,7,6,-1,-1,-1,-1,-1,-1,-1,5,0,1,5,4,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,11,7,6,8,3,4,3,5,4,3,1,5,-1,-1,-1,-1,9,5,4,10,1,2,7,6,11,-1,-1,-1,-1,-1,-1,-1,6,11,7,1,2,10,0,8,3,4,9,5,-1,-1,-1,-1,7,6,11,5,4,10,4,2,10,4,0,2,-1,-1,-1,-1,3,4,8,3,5,4,3,2,5,10,5,2,11,7,6,-1,7,2,3,7,6,2,5,4,9,-1,-1,-1,-1,-1,-1,-1,9,5,4,0,8,6,0,6,2,6,8,7,-1,-1,-1,-1,3,6,2,3,7,6,1,5,0,5,4,0,-1,-1,-1,-1,6,2,8,6,8,7,2,1,8,4,8,5,1,5,8,-1,9,5,4,10,1,6,1,7,6,1,3,7,-1,-1,-1,-1,1,6,10,1,7,6,1,0,7,8,7,0,9,5,4,-1,4,0,10,4,10,5,0,3,10,6,10,7,3,7,10,-1,7,6,10,7,10,8,5,4,10,4,8,10,-1,-1,-1,-1,6,9,5,6,11,9,11,8,9,-1,-1,-1,-1,-1,-1,-1,3,6,11,0,6,3,0,5,6,0,9,5,-1,-1,-1,-1,0,11,8,0,5,11,0,1,5,5,6,11,-1,-1,-1,-1,6,11,3,6,3,5,5,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,9,5,11,9,11,8,11,5,6,-1,-1,-1,-1,0,11,3,0,6,11,0,9,6,5,6,9,1,2,10,-1,11,8,5,11,5,6,8,0,5,10,5,2,0,2,5,-1,6,11,3,6,3,5,2,10,3,10,5,3,-1,-1,-1,-1,5,8,9,5,2,8,5,6,2,3,8,2,-1,-1,-1,-1,9,5,6,9,6,0,0,6,2,-1,-1,-1,-1,-1,-1,-1,1,5,8,1,8,0,5,6,8,3,8,2,6,2,8,-1,1,5,6,2,1,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,6,1,6,10,3,8,6,5,6,9,8,9,6,-1,10,1,0,10,0,6,9,5,0,5,6,0,-1,-1,-1,-1,0,3,8,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,7,5,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,5,10,11,7,5,8,3,0,-1,-1,-1,-1,-1,-1,-1,5,11,7,5,10,11,1,9,0,-1,-1,-1,-1,-1,-1,-1,10,7,5,10,11,7,9,8,1,8,3,1,-1,-1,-1,-1,11,1,2,11,7,1,7,5,1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,7,1,7,5,7,2,11,-1,-1,-1,-1,9,7,5,9,2,7,9,0,2,2,11,7,-1,-1,-1,-1,7,5,2,7,2,11,5,9,2,3,2,8,9,8,2,-1,2,5,10,2,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,2,0,8,5,2,8,7,5,10,2,5,-1,-1,-1,-1,9,0,1,5,10,3,5,3,7,3,10,2,-1,-1,-1,-1,9,8,2,9,2,1,8,7,2,10,2,5,7,5,2,-1,1,3,5,3,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,0,7,1,1,7,5,-1,-1,-1,-1,-1,-1,-1,9,0,3,9,3,5,5,3,7,-1,-1,-1,-1,-1,-1,-1,9,8,7,5,9,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,8,4,5,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,5,0,4,5,11,0,5,10,11,11,3,0,-1,-1,-1,-1,0,1,9,8,4,10,8,10,11,10,4,5,-1,-1,-1,-1,10,11,4,10,4,5,11,3,4,9,4,1,3,1,4,-1,2,5,1,2,8,5,2,11,8,4,5,8,-1,-1,-1,-1,0,4,11,0,11,3,4,5,11,2,11,1,5,1,11,-1,0,2,5,0,5,9,2,11,5,4,5,8,11,8,5,-1,9,4,5,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,5,10,3,5,2,3,4,5,3,8,4,-1,-1,-1,-1,5,10,2,5,2,4,4,2,0,-1,-1,-1,-1,-1,-1,-1,3,10,2,3,5,10,3,8,5,4,5,8,0,1,9,-1,5,10,2,5,2,4,1,9,2,9,4,2,-1,-1,-1,-1,8,4,5,8,5,3,3,5,1,-1,-1,-1,-1,-1,-1,-1,0,4,5,1,0,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,4,5,8,5,3,9,0,5,0,3,5,-1,-1,-1,-1,9,4,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,11,7,4,9,11,9,10,11,-1,-1,-1,-1,-1,-1,-1,0,8,3,4,9,7,9,11,7,9,10,11,-1,-1,-1,-1,1,10,11,1,11,4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]),av={setHSV:function(e,t,r,i){return t=Fs.euclideanModulo(t,1),r=Fs.clamp(r,0,1),i=Fs.clamp(i,0,1),e.setHSL(t,r*i/((t=(2-r)*i)<1?t:2-t),.5*t)},getHSV:function(){var e={};return function(t,r){return void 0===r&&(console.warn("ColorConverter: .getHSV() target is now required"),r={h:0,s:0,l:0}),t.getHSL(e),e.s*=e.l<.5?e.l:1-e.l,r.h=e.h,r.s=2*e.s/(e.l+e.s),r.v=e.l+e.s,r}}(),setCMYK:function(e,t,r,i,n){var a=(1-t)*(1-n),o=(1-r)*(1-n),s=(1-i)*(1-n);return e.setRGB(a,o,s)},getCMYK:function(e,t){void 0===t&&(console.warn("ColorConverter: .getCMYK() target is now required"),t={c:0,m:0,y:0,k:0});var r=e.r,i=e.g,n=e.b,a=1-Math.max(r,i,n),o=(1-r-a)/(1-a),s=(1-i-a)/(1-a),l=(1-n-a)/(1-a);return t.c=o,t.m=s,t.y=l,t.k=a,t}};mi.prototype=Object.create(ve.prototype),mi.prototype.constructor=mi,mi.prototype.isCanvasTexture=!0;var ov;vi.prototype=Object.assign(Object.create(c.prototype),{constructor:vi,isSprite:!0,raycast:function(){function e(e,t,r,i,n,a){o.subVectors(e,r).addScalar(.5).multiply(i),void 0!==n?(s.x=a*o.x-n*o.y,s.y=n*o.x+a*o.y):s.copy(o),e.copy(t),e.x+=s.x,e.y+=s.y,e.applyMatrix4(l)}var t=new i,n=new i,a=new i,o=new f,s=new f,l=new r,c=new i,u=new i,h=new i,d=new f,p=new f,m=new f;return function(r,i){n.setFromMatrixScale(this.matrixWorld),l.getInverse(this.modelViewMatrix).premultiply(this.matrixWorld),a.setFromMatrixPosition(this.modelViewMatrix);var o,s,v=this.material.rotation;0!==v&&(s=Math.cos(v),o=Math.sin(v));var g=this.center;e(c.set(-.5,-.5,0),a,g,n,o,s),e(u.set(.5,-.5,0),a,g,n,o,s),e(h.set(.5,.5,0),a,g,n,o,s),d.set(0,0),p.set(1,0),m.set(1,1);var y=r.ray.intersectTriangle(c,u,h,!1,t);if(null!==y||(e(u.set(-.5,.5,0),a,g,n,o,s),p.set(0,1),y=r.ray.intersectTriangle(c,h,u,!1,t),null!==y)){var x=r.ray.origin.distanceTo(t);x<r.near||x>r.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<this.map.length-1;a++)if(n>=r.map[a][0]&&n<r.map[a+1][0]){var o=r.map[a][0],s=r.map[a+1][0],l=new u(16777215).setHex(r.map[a][1]),c=new u(16777215).setHex(r.map[a+1][1]),h=l.lerp(c,(n-o)/(s-o));r.lut.push(h)}return this.set(this)};sv.prototype={constructor:sv,lut:[],map:[],mapname:"rainbow",n:256,minV:0,maxV:1,legend:null,set:function(e){return e instanceof sv&&this.copy(e),this},setMin:function(e){return this.minV=e,this},setMax:function(e){return this.maxV=e,this},changeNumberOfColors:function(e){return this.n=e,new sv(this.mapname,this.n)},changeColorMap:function(e){return this.mapname=e,new sv(this.mapname,this.n)},copy:function(e){return this.lut=e.lut,this.mapname=e.mapname,this.map=e.map,this.n=e.n,this.minV=e.minV,this.maxV=e.maxV,this},getColor:function(e){e<=this.minV?e=this.minV:e>=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][0]&&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;y<this.legend.labels.ticks;y++){var x=(r.maxV-r.minV)/(r.legend.labels.ticks-1)*y+r.minV;x=t?t(x):"scientific"==r.legend.labels.notation?x.toExponential(r.legend.labels.decimal):x.toFixed(r.legend.labels.decimal);var b=document.createElement("canvas"),w=b.getContext("2d");w.font="Normal "+r.legend.labels.fontsize+"px "+r.legend.labels.fontface,w.fillStyle="rgba("+n.r+","+n.g+","+n.b+","+n.a+")",w.strokeStyle="rgba("+a.r+","+a.g+","+a.b+","+a.a+")",w.lineWidth=o,w.fillStyle="rgba( 0, 0, 0, 1.0 )",w.fillText(x.toString(),o,r.legend.labels.fontsize+o);var _=new mi(b);_.minFilter=rc;var S=new Fe({map:_}),A=new vi(S);if(A.scale.set(2,1,1),"vertical"==r.legend.layout){var M=m+(f-m)*((x-r.minV)/(r.maxV-r.minV));A.position.set(r.legend.position.x+2.7*r.legend.dimensions.width,M,r.legend.position.z)}if("horizontal"==r.legend.layout){var M=g+(v-g)*((x-r.minV)/(r.maxV-r.minV));if(r.legend.labels.ticks>5)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;a<t.length;a++)n[a]=i.load(e+t[a],r),n[a].mapping=Vl,n[a].name=t[a];return n}function t(e,t){var r=new Me({color:16755200,wireframe:!0,morphTargets:!0,morphNormals:!0}),i=new Me({color:16777215,wireframe:!1,map:t,morphTargets:!0,morphNormals:!0}),n=new k(e,i);return n.rotation.y=-Math.PI/2,n.castShadow=!0,n.receiveShadow=!0,n.materialTexture=i,n.materialWireframe=r,n}function r(){i.loadCounter-=1,0===i.loadCounter&&i.onLoadComplete()}var i=this;this.scale=1,this.animationFPS=6,this.root=new c,this.meshBody=null,this.meshWeapon=null,this.skinsBody=[],this.skinsWeapon=[],this.weapons=[],this.activeAnimation=null,this.mixer=null,this.onLoadComplete=function(){},this.loadCounter=0,this.loadParts=function(n){this.loadCounter=2*n.weapons.length+n.skins.length+1;for(var a=[],o=0;o<n.weapons.length;o++)a[o]=n.weapons[o][1];this.skinsBody=e(n.baseUrl+"skins/",n.skins),this.skinsWeapon=e(n.baseUrl+"skins/",a);var s=new Bf;s.load(n.baseUrl+n.body,function(e){e.computeBoundingBox(),i.root.position.y=-i.scale*e.boundingBox.min.y;var n=t(e,i.skinsBody[0]);n.scale.set(i.scale,i.scale,i.scale),i.root.add(n),i.meshBody=n,i.meshBody.clipOffset=0,i.activeAnimationClipName=n.geometry.animations[0].name,i.mixer=new ae(n),r()});for(var l=function(e,n){return function(a){var o=t(a,i.skinsWeapon[e]);o.scale.set(i.scale,i.scale,i.scale),o.visible=!1,o.name=n,i.root.add(o),i.weapons[e]=o,i.meshWeapon=o,r()}},o=0;o<n.weapons.length;o++)s.load(n.baseUrl+n.weapons[o][0],l(o,n.weapons[o][0]))},this.setPlaybackRate=function(e){0!==e?this.mixer.timeScale=1/e:this.mixer.timeScale=0},this.setWireframe=function(e){e?(this.meshBody&&(this.meshBody.material=this.meshBody.materialWireframe),this.meshWeapon&&(this.meshWeapon.material=this.meshWeapon.materialWireframe)):(this.meshBody&&(this.meshBody.material=this.meshBody.materialTexture),this.meshWeapon&&(this.meshWeapon.material=this.meshWeapon.materialTexture))},this.setSkin=function(e){this.meshBody&&this.meshBody.material.wireframe===!1&&(this.meshBody.material.map=this.skinsBody[e])},this.setWeapon=function(e){for(var t=this,r=0;r<this.weapons.length;r++)t.weapons[r].visible=!1;var n=this.weapons[e];n&&(n.visible=!0,this.meshWeapon=n,i.syncWeaponAnimation())},this.setAnimation=function(e){if(this.meshBody){this.meshBody.activeAction&&(this.meshBody.activeAction.stop(),this.meshBody.activeAction=null);var t=this.mixer.clipAction(e,this.meshBody);t&&(this.meshBody.activeAction=t.play())}i.activeClipName=e,i.syncWeaponAnimation()},this.syncWeaponAnimation=function(){var e=i.activeClipName;if(i.meshWeapon){this.meshWeapon.activeAction&&(this.meshWeapon.activeAction.stop(),this.meshWeapon.activeAction=null);var t=this.mixer.clipAction(e,this.meshWeapon);t&&(this.meshWeapon.activeAction=t.syncWith(this.meshBody.activeAction).play())}},this.update=function(e){this.mixer&&this.mixer.update(e)}},uv=function(e,t){k.call(this,e,t),this.animationsMap={},this.animationsList=[];var r=Object.keys(this.morphTargetDictionary).length,i="__default",n=0,a=r-1,o=r/1;this.createAnimation(i,n,a,o),this.setAnimationWeight(i,1)};uv.prototype=Object.assign(Object.create(k.prototype),{constructor:uv,createAnimation:function(e,t,r,i){var n={start:t,end:r,length:r-t+1,fps:i,duration:(r-t)/i,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[e]=n,this.animationsList.push(n)},autoCreateAnimations:function(e){var t,r=this,i=/([a-z]+)_?(\d+)/i,n={},a=0;for(var o in r.morphTargetDictionary){var s=o.match(i);if(s&&s.length>1){var l=s[1];n[l]||(n[l]={start:1/0,end:-(1/0)});var c=n[l];a<c.start&&(c.start=a),a>c.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;r<i;r++){var n=t.animationsList[r];if(n.active){var a=n.duration/n.length;n.time+=n.direction*e,n.mirroredLoop?(n.time>n.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;a<t.length;a++)n[a]=i.load(e+t[a],r),n[a].mapping=Vl,n[a].name=t[a];return n}function t(e,t){var r=new Me({color:16755200,wireframe:!0,morphTargets:!0,morphNormals:!0}),i=new Me({color:16777215,wireframe:!1,map:t,morphTargets:!0,morphNormals:!0}),a=new uv(e,i);return a.rotation.y=-Math.PI/2,a.materialTexture=i,a.materialWireframe=r,a.autoCreateAnimations(n.animationFPS),a}function r(){n.loadCounter-=1,0===n.loadCounter&&n.onLoadComplete()}function i(e){return 1===e?1:-Math.pow(2,-10*e)+1}var n=this;this.scale=1,this.animationFPS=6,this.transitionFrames=15,this.maxSpeed=275,this.maxReverseSpeed=-275,this.frontAcceleration=600,this.backAcceleration=600,this.frontDecceleration=600,this.angularSpeed=2.5,this.root=new c,this.meshBody=null,this.meshWeapon=null,this.controls=null,this.skinsBody=[],this.skinsWeapon=[],this.weapons=[],this.currentSkin=void 0,this.onLoadComplete=function(){},this.meshes=[],this.animations={},this.loadCounter=0,this.speed=0,this.bodyOrientation=0,this.walkSpeed=this.maxSpeed,this.crouchSpeed=.5*this.maxSpeed,this.activeAnimation=null,this.oldAnimation=null,this.enableShadows=function(e){for(var t=this,r=0;r<this.meshes.length;r++)t.meshes[r].castShadow=e,t.meshes[r].receiveShadow=e},this.setVisible=function(e){for(var t=this,r=0;r<this.meshes.length;r++)t.meshes[r].visible=e,t.meshes[r].visible=e},this.shareParts=function(e){var r=this;this.animations=e.animations,this.walkSpeed=e.walkSpeed,this.crouchSpeed=e.crouchSpeed,this.skinsBody=e.skinsBody,this.skinsWeapon=e.skinsWeapon;var i=t(e.meshBody.geometry,this.skinsBody[0]);i.scale.set(this.scale,this.scale,this.scale),this.root.position.y=e.root.position.y,this.root.add(i),this.meshBody=i,this.meshes.push(i);for(var n=0;n<e.weapons.length;n++){var a=t(e.weapons[n].geometry,r.skinsWeapon[n]);a.scale.set(r.scale,r.scale,r.scale),a.visible=!1,a.name=e.weapons[n].name,r.root.add(a),r.weapons[n]=a,r.meshWeapon=a,r.meshes.push(a)}},this.loadParts=function(i){this.animations=i.animations,this.walkSpeed=i.walkSpeed,this.crouchSpeed=i.crouchSpeed,this.loadCounter=2*i.weapons.length+i.skins.length+1;for(var a=[],o=0;o<i.weapons.length;o++)a[o]=i.weapons[o][1];this.skinsBody=e(i.baseUrl+"skins/",i.skins),this.skinsWeapon=e(i.baseUrl+"skins/",a);var s=new Bf;s.load(i.baseUrl+i.body,function(e){e.computeBoundingBox(),n.root.position.y=-n.scale*e.boundingBox.min.y;var i=t(e,n.skinsBody[0]);i.scale.set(n.scale,n.scale,n.scale),n.root.add(i),n.meshBody=i,n.meshes.push(i),r()});for(var l=function(e,i){return function(a){var o=t(a,n.skinsWeapon[e]);o.scale.set(n.scale,n.scale,n.scale),o.visible=!1,o.name=i,n.root.add(o),n.weapons[e]=o,n.meshWeapon=o,n.meshes.push(o),r()}},o=0;o<i.weapons.length;o++)s.load(i.baseUrl+i.weapons[o][0],l(o,i.weapons[o][0]))},this.setPlaybackRate=function(e){this.meshBody&&(this.meshBody.duration=this.meshBody.baseDuration/e),this.meshWeapon&&(this.meshWeapon.duration=this.meshWeapon.baseDuration/e)},this.setWireframe=function(e){e?(this.meshBody&&(this.meshBody.material=this.meshBody.materialWireframe),this.meshWeapon&&(this.meshWeapon.material=this.meshWeapon.materialWireframe)):(this.meshBody&&(this.meshBody.material=this.meshBody.materialTexture),this.meshWeapon&&(this.meshWeapon.material=this.meshWeapon.materialTexture))},this.setSkin=function(e){this.meshBody&&this.meshBody.material.wireframe===!1&&(this.meshBody.material.map=this.skinsBody[e],this.currentSkin=e)},this.setWeapon=function(e){for(var t=this,r=0;r<this.weapons.length;r++)t.weapons[r].visible=!1;var i=this.weapons[e];i&&(i.visible=!0,this.meshWeapon=i,this.activeAnimation&&(i.playAnimation(this.activeAnimation),this.meshWeapon.setAnimationTime(this.activeAnimation,this.meshBody.getAnimationTime(this.activeAnimation))))},this.setAnimation=function(e){e!==this.activeAnimation&&e&&(this.meshBody&&(this.meshBody.setAnimationWeight(e,0),this.meshBody.playAnimation(e),this.oldAnimation=this.activeAnimation,this.activeAnimation=e,this.blendCounter=this.transitionFrames),this.meshWeapon&&(this.meshWeapon.setAnimationWeight(e,0),this.meshWeapon.playAnimation(e)))},this.update=function(e){this.controls&&this.updateMovementModel(e),this.animations&&(this.updateBehaviors(e),this.updateAnimations(e))},this.updateAnimations=function(e){var t=1;this.blendCounter>0&&(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<i;r++){var n=t.length,a=e.faces[r],o=a.a,s=a.b,l=a.c,c=e.vertices[o],u=e.vertices[s],h=e.vertices[l];t.push(c.clone()),t.push(u.clone()),t.push(h.clone()),a.a=n,a.b=n+1,a.c=n+2}e.vertices=t};var pv=function(){};!function(){function e(e,t){e.indexOf(t)===-1&&e.push(t)}function t(e,t){var r=e.indexOf(t);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<l;r++)i=e.faces[r],i.hasVertex(t)&&s.push(i);for(r=0;r<l;r++){var c=1;i=e.faces[r];for(var u=0;u<s.length;u++){n=s[u];var h=i.normal.dot(n.normal);c=Math.min(c,(1.001-h)/2)}o=Math.max(o,c)}var d=0;s.length<2&&(o=1);var p=a*o+d;return p}function n(e){if(0===e.neighbors.length)return e.collapseNeighbor=null,void(e.collapseCost=-.01);e.collapseCost=1e5,e.collapseNeighbor=null;for(var t=0;t<e.neighbors.length;t++){var i=r(e,e.neighbors[t]);e.collapseNeighbor||(e.collapseNeighbor=e.neighbors[t],e.collapseCost=i,e.minCost=i,e.totalCost=0,e.costCount=0),e.costCount++,e.totalCost+=i,i<e.minCost&&(e.collapseNeighbor=e.neighbors[t],e.minCost=i)}e.collapseCost=e.totalCost/e.costCount}function a(e,r){for(console.assert(0===e.faces.length);e.neighbors.length;){var i=e.neighbors.pop();t(i.neighbors,e)}t(r,e)}function o(e,r){t(r,e),e.v1&&t(e.v1.faces,e),e.v2&&t(e.v2.faces,e),e.v3&&t(e.v3.faces,e);for(var i,n,a=[e.v1,e.v2,e.v3],o=0;o<3;o++)i=a[o],n=a[(o+1)%3],i&&n&&(i.removeIfNonNeighbor(n),n.removeIfNonNeighbor(i))}function s(e,t,r,i){if(!i)return void a(r,e);var s,l=[];for(s=0;s<r.neighbors.length;s++)l.push(r.neighbors[s]);for(s=r.faces.length-1;s>=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;s<l.length;s++)n(l[s])}function l(e){for(var t=e[0],r=0;r<e.length;r++)e[r].collapseCost<t.collapseCost&&(t=e[r]);return t}function c(e,t,r,n,a,o){this.a=n,this.b=a,this.c=o,this.v1=e,this.v2=t,this.v3=r,this.normal=new i,this.computeNormal(),e.faces.push(this),e.addUniqueNeighbor(t),e.addUniqueNeighbor(r),t.faces.push(this),t.addUniqueNeighbor(e),t.addUniqueNeighbor(r),r.faces.push(this),r.addUniqueNeighbor(e),r.addUniqueNeighbor(t)}function u(e,t){this.position=e,this.id=t,this.faces=[],this.neighbors=[],this.collapseCost=0,this.collapseNeighbor=null}var h=new i,d=new i;c.prototype.computeNormal=function(){var e=this.v1.position,t=this.v2.position,r=this.v3.position;h.subVectors(r,t),d.subVectors(e,t),h.cross(d).normalize(),this.normal.copy(h)},c.prototype.hasVertex=function(e){return e===this.v1||e===this.v2||e===this.v3},c.prototype.replaceVertex=function(e,r){e===this.v1?this.v1=r:e===this.v2?this.v2=r:e===this.v3&&(this.v3=r),t(e.faces,this),r.faces.push(this),e.removeIfNonNeighbor(this.v1),this.v1.removeIfNonNeighbor(e),e.removeIfNonNeighbor(this.v2),this.v2.removeIfNonNeighbor(e),e.removeIfNonNeighbor(this.v3),this.v3.removeIfNonNeighbor(e),this.v1.addUniqueNeighbor(this.v2),this.v1.addUniqueNeighbor(this.v3),this.v2.addUniqueNeighbor(this.v1),this.v2.addUniqueNeighbor(this.v3),this.v3.addUniqueNeighbor(this.v1),this.v3.addUniqueNeighbor(this.v2),this.computeNormal()},u.prototype.addUniqueNeighbor=function(t){e(this.neighbors,t)},u.prototype.removeIfNonNeighbor=function(e){var t=this.neighbors,r=this.faces,i=t.indexOf(e);if(i!==-1){for(var n=0;n<r.length;n++)if(r[n].hasVertex(e))return;t.splice(i,1)}},pv.prototype.modify=function(e,t){e.isBufferGeometry&&(e=(new m).fromBufferGeometry(e)),e.mergeVertices();var r,i,a=e.vertices,o=e.faces,h=[],d=[];for(r=0,i=a.length;r<i;r++){var p=new u(a[r],r);h.push(p)}for(r=0,i=o.length;r<i;r++){var f=o[r],v=f.a,g=f.b,y=f.c,x=new c(h[v],h[g],h[y],v,g,y);d.push(x)}for(r=0,i=h.length;r<i;r++)n(h[r]);for(var b,w=t;w--;){if(b=l(h),!b){console.log("SimplifyModifier: No next vertex");break}s(h,d,b,b.collapseNeighbor)}var _=new P,S=[],A=[];for(r=0;r<h.length;r++){var p=h[r].position;S.push(p.x,p.y,p.z)}for(r=0;r<d.length;r++){var f=d[r],v=h.indexOf(f.v1),g=h.indexOf(f.v2),y=h.indexOf(f.v3);A.push(v,g,y)}return _.addAttribute("position",new M(S,3)),_.setIndex(A),_}}();var fv=function(e){this.subdivisions=void 0===e?1:e};fv.prototype.modify=function(e){var t=this;e=e.isBufferGeometry?(new m).fromBufferGeometry(e):e.clone(),e.mergeVertices();for(var r=this.subdivisions;r-- >0;)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;a<o;a++)i[a]={edges:[]};for(a=0,o=r.length;a<o;a++)s=r[a],t(s.a,s.b,e,n,s,i),t(s.b,s.c,e,n,s,i),t(s.c,s.a,e,n,s,i)}function n(e,t,r,i,n){e.push(new h(t,r,i,(void 0),(void 0),n))}function a(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function o(e,t,r,i){e.push([t.clone(),r.clone(),i.clone()])}var s=["a","b","c"];fv.prototype.smooth=function(t){var l,c,u,h,d,p,m,v,g,y,x,b,b,w,_,S=new i,A=[];l=t.vertices,c=t.faces,u=t.faceVertexUvs[0];var M=void 0!==u&&u.length>0;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;g<O;g++){for(L=E.faces[g],y=0;y<3&&(T=l[L[s[y]]],T===E.a||T===E.b);y++);S.add(T)}S.multiplyScalar(N),C.add(S),E.newEdge=w.length,w.push(C)}var D,F,R,I,U,k,B;for(_=[],m=0,v=l.length;m<v;m++){for(k=l[m],U=x[m].edges,p=U.length,3==p?D=3/16:p>3&&(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;g<p;g++)I=U[g],T=I.a!==k?I.a:I.b,S.add(T);S.multiplyScalar(R),B.add(S),_.push(B)}h=_.concat(w);var z,j,V,G=_.length;d=[];var W,X,H,Y,q=new f,Q=new f,J=new f;for(m=0,v=c.length;m<v;m++)L=c[m],z=e(L.a,L.b,b).newEdge+G,j=e(L.b,L.c,b).newEdge+G,V=e(L.c,L.a,b).newEdge+G,n(d,z,j,V,L.materialIndex),n(d,L.a,z,V,L.materialIndex),n(d,L.b,j,z,L.materialIndex),n(d,L.c,V,j,L.materialIndex),M&&(W=u[m],X=W[0],H=W[1],Y=W[2],q.set(a(X.x,H.x),a(X.y,H.y)),Q.set(a(H.x,Y.x),a(H.y,Y.y)),J.set(a(X.x,Y.x),a(X.y,Y.y)),o(A,q,Q,J),o(A,X,q,J),o(A,H,Q,q),o(A,Y,J,Q));t.vertices=h,t.faces=d,M&&(t.faceVertexUvs[0]=A)}}();var mv=function(e){this.maxEdgeLength=e};mv.prototype.modify=function(e){for(var t,r=[],i=[],n=this.maxEdgeLength*this.maxEdgeLength,a=0,o=e.faceVertexUvs.length;a<o;a++)i[a]=[];for(var a=0,o=e.faces.length;a<o;a++){var s=e.faces[a];if(s instanceof h){var l=s.a,c=s.b,u=s.c,d=e.vertices[l],p=e.vertices[c],f=e.vertices[u],m=d.distanceToSquared(p),v=p.distanceToSquared(f),g=d.distanceToSquared(f);if(m>n||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<M;A++)if(e.faceVertexUvs[A].length){var T=e.faceVertexUvs[A][a],E=T[0],C=T[1],L=T[2];if(0===t){var P=E.clone();P.lerp(C,.5);var N=[E.clone(),P.clone(),L.clone()],O=[P.clone(),C.clone(),L.clone()]}else if(1===t){var P=C.clone();P.lerp(L,.5);var N=[E.clone(),C.clone(),P.clone()],O=[P.clone(),L.clone(),E.clone()]}else{var P=E.clone();P.lerp(L,.5);var N=[E.clone(),C.clone(),P.clone()],O=[P.clone(),C.clone(),L.clone()]}i[A].push(N,O)}}else{r.push(s);for(var A=0,M=e.faceVertexUvs.length;A<M;A++)i[A].push(e.faceVertexUvs[A][a])}}}e.faces=r,e.faceVertexUvs=i};var vv=function(e,t){k.call(this,e,t),this.type="MorphAnimMesh",this.mixer=new ae(this),this.activeAction=null};vv.prototype=Object.create(k.prototype),vv.prototype.constructor=vv,vv.prototype.setDirectionForward=function(){this.mixer.timeScale=1},vv.prototype.setDirectionBackward=function(){this.mixer.timeScale=-1},vv.prototype.playAnimation=function(e,t){this.activeAction&&(this.activeAction.stop(),this.activeAction=null);var r=re.findByName(this,e);if(!r)throw new Error("MorphAnimMesh: animations["+e+"] undefined in .playAnimation()");var i=this.mixer.clipAction(r);i.timeScale=r.tracks.length*t/r.duration,this.activeAction=i.play()},vv.prototype.updateAnimation=function(e){this.mixer.update(e)},vv.prototype.copy=function(e){return k.prototype.copy.call(this,e),this.mixer=new ae(this),this};var gv=["color","color2"],yv=["vColor","vColor2"];gi.prototype=Object.create(tr.prototype),gi.prototype.constructor=gi,gi.prototype.generate=function(e,t){e.requires.color[this.index]=!0;var r=e.isShader("vertex")?gv[this.index]:yv[this.index];return e.format(r,this.getType(e),t)},gi.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.index=e.index},gi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t},yi.TOTAL="total",yi.prototype=Object.create(tr.prototype),yi.prototype.constructor=yi,yi.prototype.nodeType="Light",yi.prototype.generate=function(e,t){return e.isCache("light")?e.format("reflectedLight.directDiffuse",this.type,t):(console.warn('LightNode is only compatible in "light" channel.'),e.format("vec3( 0.0 )",this.type,t))},yi.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.scope=e.scope},yi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t},xi.CUBE="cube",xi.SPHERE="sphere",xi.VECTOR="vector",xi.prototype=Object.create(tr.prototype),xi.prototype.constructor=xi,xi.prototype.nodeType="Reflect",xi.prototype.getType=function(e){switch(this.scope){case xi.SPHERE:return"v2"}return this.type},xi.prototype.generate=function(e,t){if(e.isShader("fragment")){var r;switch(this.scope){case xi.VECTOR:e.addNodeCode("vec3 reflectVec = inverseTransformDirection( reflect( -normalize( vViewPosition ), normal ), viewMatrix );"),r="reflectVec";break;case xi.CUBE:var i=new xi(xi.VECTOR).build(e,"v3");e.addNodeCode("vec3 reflectCubeVec = vec3( -1.0 * "+i+".x, "+i+".yz );"),r="reflectCubeVec";break;case xi.SPHERE:var i=new xi(xi.VECTOR).build(e,"v3");e.addNodeCode("vec2 reflectSphereVec = normalize( ( viewMatrix * vec4( "+i+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5;"),r="reflectSphereVec"}return e.format(r,this.getType(e),t)}return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)},xi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t};var xv={elements:["x","y","z","w"],addShortcuts:function(){function e(e,t,r){return r?{get:function(){return this[e][t][r]},set:function(i){this[e][t][r]=i}}:{get:function(){return this[e][t]},set:function(r){this[e][t]=r}}}return function(t,r,i){for(var n={},a=0;a<i.length;++a){
|
|
var o=i[a].split("."),s=o[0],l=o[1];n[s]=e(r,s,l)}Object.defineProperties(t,n)}}()};Object.defineProperties(bi.prototype,{value:{get:function(){return this.node.value},set:function(e){this.node.value=e}}});var bv=/^struct\s*([a-z_0-9]+)\s*{\s*((.|\n)*?)}/gim,wv=/\s*(\w*?)\s*(\w*?)(\=|\;)/gim;wi.prototype=Object.create(tr.prototype),wi.prototype.constructor=wi,wi.prototype.nodeType="Struct",wi.prototype.getType=function(e){return e.getTypeByFormat(this.name)},wi.prototype.getInputByName=function(e){for(var t=this,r=this.inputs.length;r--;)if(t.inputs[r].name===e)return t.inputs[r]},wi.prototype.generate=function(e,t){return"source"===t?this.src+";":e.format("( "+src+" )",this.getType(e),t)},wi.prototype.eval=function(e){var t=this;this.src=e||"",this.inputs=[];var r=bv.exec(this.src);if(r){for(var i,n=r[2];i=wv.exec(n);)t.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name},wi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src),t},_i.prototype=Object.create(ar.prototype),_i.prototype.constructor=_i,_i.prototype.nodeType="Vector3",xv.addShortcuts(_i.prototype,"value",["x","y","z"]),_i.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format("vec3( "+this.x+", "+this.y+", "+this.z+" )",i,t)},_i.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value.copy(e)},_i.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.x,t.y=this.y,t.z=this.z,this.readonly===!0&&(t.readonly=!0)),t},Si.prototype=Object.create(ar.prototype),Si.prototype.constructor=Si,Si.prototype.nodeType="Vector4",xv.addShortcuts(Si.prototype,"value",["x","y","z","w"]),Si.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format("vec4( "+this.x+", "+this.y+", "+this.z+", "+this.w+" )",i,t)},Si.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value.copy(e)},Si.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.x,t.y=this.y,t.z=this.z,t.w=this.w,this.readonly===!0&&(t.readonly=!0)),t},Ai.Nodes=function(){var e=new Vf(["vec4 LinearToLinear( in vec4 value ) {","\treturn value;","}"].join("\n")),t=new Vf(["vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {","\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );","}"].join("\n")),r=new Vf(["vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {","\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );","}"].join("\n")),i=new Vf(["vec4 sRGBToLinear( in vec4 value ) {","\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.w );","}"].join("\n")),n=new Vf(["vec4 LinearTosRGB( in vec4 value ) {","\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.w );","}"].join("\n")),a=new Vf(["vec4 RGBEToLinear( in vec4 value ) {","\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );","}"].join("\n")),o=new Vf(["vec4 LinearToRGBE( in vec4 value ) {","\tfloat maxComponent = max( max( value.r, value.g ), value.b );","\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );","\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );","}"].join("\n")),s=new Vf(["vec3 RGBMToLinear( in vec4 value, in float maxRange ) {","\treturn vec4( value.xyz * value.w * maxRange, 1.0 );","}"].join("\n")),l=new Vf(["vec3 LinearToRGBM( in vec4 value, in float maxRange ) {","\tfloat maxRGB = max( value.x, max( value.g, value.b ) );","\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );","\tM = ceil( M * 255.0 ) / 255.0;","\treturn vec4( value.rgb / ( M * maxRange ), M );","}"].join("\n")),c=new Vf(["vec3 RGBDToLinear( in vec4 value, in float maxRange ) {","\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );","}"].join("\n")),u=new Vf(["vec3 LinearToRGBD( in vec4 value, in float maxRange ) {","\tfloat maxRGB = max( value.x, max( value.g, value.b ) );","\tfloat D = max( maxRange / maxRGB, 1.0 );","\tD = min( floor( D ) / 255.0, 1.0 );","\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );","}"].join("\n")),h=new lr("const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );"),d=new Vf(["vec4 LinearToLogLuv( in vec4 value ) {","\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;","\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));","\tvec4 vResult;","\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;","\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;","\tvResult.w = fract(Le);","\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;","\treturn vResult;","}"].join("\n"),[h]),p=new lr("const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );"),f=new Vf(["vec4 LogLuvToLinear( in vec4 value ) {","\tfloat Le = value.z * 255.0 + value.w;","\tvec3 Xp_Y_XYZp;","\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);","\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;","\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;","\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;","\treturn vec4( max(vRGB, 0.0), 1.0 );","}"].join("\n"),[p]);return{LinearToLinear:e,GammaToLinear:t,LinearToGamma:r,sRGBToLinear:i,LinearTosRGB:n,RGBEToLinear:a,LinearToRGBE:o,RGBMToLinear:s,LinearToRGBM:l,RGBDToLinear:c,LinearToRGBD:u,cLogLuvM:h,LinearToLogLuv:d,cLogLuvInverseM:p,LogLuvToLinear:f}}(),Ai.LINEAR_TO_LINEAR="LinearToLinear",Ai.GAMMA_TO_LINEAR="GammaToLinear",Ai.LINEAR_TO_GAMMA="LinearToGamma",Ai.SRGB_TO_LINEAR="sRGBToLinear",Ai.LINEAR_TO_SRGB="LinearTosRGB",Ai.RGBE_TO_LINEAR="RGBEToLinear",Ai.LINEAR_TO_RGBE="LinearToRGBE",Ai.RGBM_TO_LINEAR="RGBMToLinear",Ai.LINEAR_TO_RGBM="LinearToRGBM",Ai.RGBD_TO_LINEAR="RGBDToLinear",Ai.LINEAR_TO_RGBD="LinearToRGBD",Ai.LINEAR_TO_LOG_LUV="LinearToLogLuv",Ai.LOG_LUV_TO_LINEAR="LogLuvToLinear",Ai.prototype=Object.create(tr.prototype),Ai.prototype.constructor=Ai,Ai.prototype.nodeType="ColorAdjustment",Ai.prototype.generate=function(e,t){var r=e.context.input||this.input.build(e,"v4"),i=void 0!==e.context.encoding?this.getEncodingMethod(e.context.encoding):[this.method],n=this.factor?this.factor.build(e,"f"):i[1],a=e.include(Ai.Nodes[i[0]]);return n?e.format(a+"( "+r+", "+n+" )",this.getType(e),t):e.format(a+"( "+r+" )",this.getType(e),t)},Ai.prototype.getDecodingMethod=function(e){var t=this.getEncodingComponents(e);return t[0]+="ToLinear",t},Ai.prototype.getEncodingMethod=function(e){var t=this.getEncodingComponents(e);return t[0]="LinearTo"+t[0],t},Ai.prototype.getEncodingComponents=function(e){switch(e){case ou:return["Linear"];case su:return["sRGB"];case cu:return["RGBE"];case hu:return["RGBM","7.0"];case du:return["RGBM","16.0"];case pu:return["RGBD","256.0"];case lu:return["Gamma","float( GAMMA_FACTOR )"]}},Ai.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.input=e.input,this.method=e.method},Ai.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.input=this.input.toJSON(e).uuid,t.method=this.method),t},Mi.prototype=Object.create(ar.prototype),Mi.prototype.constructor=Mi,Mi.prototype.nodeType="Texture",Mi.prototype.getTexture=function(e,t){return ar.prototype.generate.call(this,e,t,this.value.uuid,"t")},Mi.prototype.generate=function(e,t){if("sampler2D"===t)return this.getTexture(e,t);var r=this.getTexture(e,t),i=this.uv.build(e,this.project?"v4":"v2"),n=this.bias?this.bias.build(e,"f"):void 0;void 0==n&&e.context.bias&&(n=new e.context.bias(this).build(e,"f"));var a,o;return a=this.project?"texture2DProj":n?"tex2DBias":"tex2D",o=n?a+"( "+r+", "+i+", "+n+" )":a+"( "+r+", "+i+" )",e.addContext({input:o,encoding:e.getTextureEncodingFromMap(this.value),include:e.isShader("vertex")}),this.colorSpace=this.colorSpace||new Ai(this),o=this.colorSpace.build(e,this.type),e.removeContext(),e.format(o,this.type,t)},Mi.prototype.copy=function(e){ar.prototype.copy.call(this,e),e.value&&(this.value=e.value),this.uv=e.uv,e.bias&&(this.bias=e.bias),void 0!==e.project&&(this.project=e.project)},Mi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value.uuid),t.uv=this.uv.toJSON(e).uuid,t.project=this.project,this.bias&&(t.bias=this.bias.toJSON(e).uuid)),t},Ti.prototype=Object.create(ar.prototype),Ti.prototype.constructor=Ti,Ti.prototype.nodeType="CubeTexture",Ti.prototype.getTexture=function(e,t){return ar.prototype.generate.call(this,e,t,this.value.uuid,"tc")},Ti.prototype.generate=function(e,t){if("samplerCube"===t)return this.getTexture(e,t);var r=this.getTexture(e,t),i=this.uv.build(e,"v3"),n=this.bias?this.bias.build(e,"f"):void 0;void 0===n&&e.context.bias&&(n=new e.context.bias(this).build(e,"f"));var a;return a=n?"texCubeBias( "+r+", "+i+", "+n+" )":"texCube( "+r+", "+i+" )",e.addContext({input:a,encoding:e.getTextureEncodingFromMap(this.value),include:e.isShader("vertex")}),this.colorSpace=this.colorSpace||new Ai(this),a=this.colorSpace.build(e,this.type),e.removeContext(),e.format(a,this.type,t)},Ti.prototype.copy=function(e){ar.prototype.copy.call(this,e),e.value&&(this.value=e.value),this.uv=e.uv,e.bias&&(this.bias=e.bias)},Ti.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.uuid,t.uv=this.uv.toJSON(e).uuid,this.bias&&(t.bias=this.bias.toJSON(e).uuid)),t},Ei.prototype=Object.create(tr.prototype),Ei.prototype.constructor=Ei,Ei.prototype.nodeType="BlinnShininessExponent",Ei.prototype.generate=function(e,t){return e.isCache("clearCoat")?e.format("Material_ClearCoat_BlinnShininessExponent( material )",this.type,t):e.format("Material_BlinnShininessExponent( material )",this.type,t)},Ci.prototype=Object.create(tr.prototype),Ci.prototype.constructor=Ci,Ci.prototype.nodeType="BlinnExponentToRoughness",Ci.prototype.generate=function(e,t){return e.format("BlinnExponentToGGXRoughness( "+this.blinnExponent.build(e,"f")+" )",this.type,t)},Ci.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.blinnExponent=e.blinnExponent},Ci.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.blinnExponent=this.blinnExponent),t},Li.Nodes=function(){var e=new wi(["struct TextureCubeUVData {","\tvec2 uv_10;","\tvec2 uv_20;","\tfloat t;","}"].join("\n")),t=new Vf(["int getFaceFromDirection(vec3 direction) {","\tvec3 absDirection = abs(direction);","\tint face = -1;","\tif( absDirection.x > 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;n<a;++n){var o=e[n],s=o.type,l=o.name,c=r.getFormatByType(s);if(void 0===c)throw new Error("Node pars "+c+" not found.");i+=t+" "+c+" "+l+";\n"}return i},getVars:function(e){return this.inputs.vars[e||this.shader]},getNodeData:function(e){var t=e.isNode?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}},createUniform:function(e,t,r,i,n){var a=this.inputs.uniforms,o=a.list.length,s=new bi({type:t,name:i?i:"nVu"+o,node:r,needsUpdate:n});return a.list.push(s),a[e].push(s),a[e][s.name]=s,this.uniforms[s.name]=s,s},createVertexUniform:function(e,t,r,i){return this.createUniform("vertex",e,t,r,i)},createFragmentUniform:function(e,t,r,i){return this.createUniform("fragment",e,t,r,i)},include:function(e,t,r){var i,n=this;if(e="string"==typeof e?Gf.get(e):e,this.context.include===!1)return e.name;e instanceof Vf?i=this.includes.functions:e instanceof lr?i=this.includes.consts:e instanceof wi&&(i=this.includes.structs);var a=i[this.shader]=i[this.shader]||[];if(e){var o=a[e.name];if(o||(o=a[e.name]={node:e,deps:[]},a.push(o),o.src=e.build(this,"source")),e instanceof Vf&&t&&a[t.name]&&a[t.name].deps.indexOf(e)==-1&&(a[t.name].deps.push(e),e.includes&&e.includes.length)){var s=0;do n.include(e.includes[s++],t);while(s<e.includes.length)}return r&&(o.src=r),e.name}throw new Error("Include not found.")},colorToVectorProperties:function(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")},colorToVector:function(e){return e.replace(/c/g,"v3")},getIncludes:function(e,t){return this.includes[e][t||this.shader]},getIncludesCode:function(){function e(e,t){return e.deps.length-t.deps.length}return function(t,r){var i=this.getIncludes(t,r);if(!i)return"";for(var n="",i=i.sort(e),a=0;a<i.length;a++)i[a].src&&(n+=i[a].src+"\n");return n}}(),getConstructorFromLength:function(e){return Sv[e-1]},isTypeMatrix:function(e){return/^m/.test(e)},getTypeLength:function(e){return"f"===e?1:parseInt(this.colorToVector(e).substr(1))},getTypeFromLength:function(e){return 1===e?"f":"v"+e},findNode:function(){for(var e=arguments,t=0;t<arguments.length;t++){var r=e[t];if(void 0!==r&&r.isNode)return r}},resolve:function(){for(var e=arguments,t=0;t<arguments.length;t++){var r=e[t];if(void 0!==r){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case Gl:case Wl:return new Ti(r);case ql:case Ql:return new Pi(new Mi(r));default:return new Mi(r)}else{if(r.isVector2)return new Ri(r);if(r.isVector3)return new _i(r);if(r.isVector4)return new Si(r)}}}},format:function(e,t,r){var i=this.colorToVector(r+" <- "+t);switch(i){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":return"vec4( float( "+e+" ) )";case"i <- f":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )"}return e},getTypeByFormat:function(e){return Av[e]||e},getFormatByType:function(e){return Mv[e]||e},getUuid:function(e,t){return t=void 0===t||t,t&&this.cache&&(e=this.cache+"-"+e),e},getElementByIndex:function(e){return _v[e]},getIndexByElement:function(e){return _v.indexOf(e)},isShader:function(e){return this.shader===e},setShader:function(e){return this.shader=e,this},mergeDefines:function(e){var t=this;for(var r in e)t.defines[r]=e[r];return this.defines},mergeUniform:function(e){var t=this;for(var r in e)t.uniforms[r]=e[r];return this.uniforms},getTextureEncodingFromMap:function(e,t){t=void 0!==t?t:this.context.gamma&&!!this.renderer&&this.renderer.gammaInput;var r;return e?e.isTexture?r=e.encoding:e.isWebGLRenderTarget&&(console.warn("WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),r=e.texture.encoding):r=ou,r===ou&&t&&(r=lu),r}},Oi.prototype=Object.create(ar.prototype),Oi.prototype.constructor=Oi,Oi.prototype.nodeType="Color",xv.addShortcuts(Oi.prototype,"value",["r","g","b"]),Oi.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format("vec3( "+this.r+", "+this.g+", "+this.b+" )",i,t)},Oi.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value.copy(e)},Oi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.r=this.r,t.g=this.g,t.b=this.b,this.readonly===!0&&(t.readonly=!0)),t},Di.prototype=Object.create(er.prototype),Di.prototype.constructor=Di,Di.prototype.nodeType="Raw",Di.prototype.generate=function(e){var t=this.value.parseAndBuildCode(e,this.type),r=t.code+"\n";return r+=e.isShader("vertex")?"gl_Position = "+t.result+";":"gl_FragColor = "+t.result+";"},Di.prototype.copy=function(e){er.prototype.copy.call(this,e),this.value=e.value},Di.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid),t},Fi.prototype=Object.create(pe.prototype),Fi.prototype.constructor=Fi,Fi.prototype.type="NodeMaterial",Fi.prototype.isNodeMaterial=!0,Object.defineProperties(Fi.prototype,{properties:{get:function(){return this.fragment.properties}}}),Fi.prototype.updateFrame=function(e){for(var t=this,r=0;r<this.updaters.length;++r)e.updateNode(t.updaters[r])},Fi.prototype.onBeforeCompile=function(e,t){this.needsUpdate&&(this.build({renderer:t}),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader)},Fi.prototype.build=function(e){e=e||{};var t=e.builder||new Ni;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>al,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;s<n.inputs.length;s++){var l=n.inputs[s],c=r.inputs[s]||r.inputs[l.name];o.push(c.build(e,e.getTypeByFormat(l.type)))}return a+=o.join(", ")+" )",e.format(a,i,t)},Vi.prototype.copy=function(e){var t=this;tr.prototype.copy.call(this,e);for(var r in e.inputs)t.inputs[r]=e.inputs[r];this.value=e.value},Vi.prototype.toJSON=function(e){var t=this,r=this.getJSONNode(e);if(!r){var i=this.value;if(r=this.createJSONNode(e),r.value=this.value.toJSON(e).uuid,i.inputs.length){r.inputs={};for(var n=0;n<i.inputs.length;n++){var a=i.inputs[n],o=t.inputs[n]||t.inputs[a.name];r.inputs[a.name]=o.toJSON(e).uuid}}}return r},Gi.prototype={constructor:Gi,update:function(e){return++this.id,this.time+=e,this.delta=e,this},setRenderer:function(e){return this.renderer=e,this},setRenderTexture:function(e){return this.renderTexture=e,this},updateNode:function(e){return e.frameId===this.id?this:(e.updateFrame(this),e.frameId=this.id,this)}},Wi.prototype=Object.create(er.prototype),Wi.prototype.constructor=Wi,Wi.prototype.nodeType="Var",Wi.prototype.getType=function(e){return e.getTypeByFormat(this.type)},Wi.prototype.generate=function(e,t){var r=e.getVar(this.uuid,this.type);return this.value&&e.isShader("vertex")&&e.addNodeCode(r.name+" = "+this.value.build(e,this.getType(e))+";"),e.format(r.name,this.getType(e),t)},Wi.prototype.copy=function(e){er.prototype.copy.call(this,e),this.type=e.type,this.value=e.value},Wi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.type=this.type,this.value&&(t.value=this.value.toJSON(e).uuid)),t},Xi.Nodes=function(){var e=new Vf(["vec4 blurX( sampler2D texture, vec2 uv, float s ) {","\tvec4 sum = vec4( 0.0 );","\tsum += texture2D( texture, vec2( uv.x - 4.0 * s, uv.y ) ) * 0.051;","\tsum += texture2D( texture, vec2( uv.x - 3.0 * s, uv.y ) ) * 0.0918;","\tsum += texture2D( texture, vec2( uv.x - 2.0 * s, uv.y ) ) * 0.12245;","\tsum += texture2D( texture, vec2( uv.x - 1.0 * s, uv.y ) ) * 0.1531;","\tsum += texture2D( texture, vec2( uv.x, uv.y ) ) * 0.1633;","\tsum += texture2D( texture, vec2( uv.x + 1.0 * s, uv.y ) ) * 0.1531;","\tsum += texture2D( texture, vec2( uv.x + 2.0 * s, uv.y ) ) * 0.12245;","\tsum += texture2D( texture, vec2( uv.x + 3.0 * s, uv.y ) ) * 0.0918;","\tsum += texture2D( texture, vec2( uv.x + 4.0 * s, uv.y ) ) * 0.051;","\treturn sum * .667;","}"].join("\n")),t=new Vf(["vec4 blurY( sampler2D texture, vec2 uv, float s ) {","\tvec4 sum = vec4( 0.0 );","\tsum += texture2D( texture, vec2( uv.x, uv.y - 4.0 * s ) ) * 0.051;","\tsum += texture2D( texture, vec2( uv.x, uv.y - 3.0 * s ) ) * 0.0918;","\tsum += texture2D( texture, vec2( uv.x, uv.y - 2.0 * s ) ) * 0.12245;","\tsum += texture2D( texture, vec2( uv.x, uv.y - 1.0 * s ) ) * 0.1531;","\tsum += texture2D( texture, vec2( uv.x, uv.y ) ) * 0.1633;","\tsum += texture2D( texture, vec2( uv.x, uv.y + 1.0 * s ) ) * 0.1531;","\tsum += texture2D( texture, vec2( uv.x, uv.y + 2.0 * s ) ) * 0.12245;","\tsum += texture2D( texture, vec2( uv.x, uv.y + 3.0 * s ) ) * 0.0918;","\tsum += texture2D( texture, vec2( uv.x, uv.y + 4.0 * s ) ) * 0.051;","\treturn sum * .667;","}"].join("\n"));return{blurX:e,blurY:t}}(),Xi.prototype=Object.create(tr.prototype),Xi.prototype.constructor=Xi,Xi.prototype.nodeType="Blur",Xi.prototype.updateFrame=function(e){if(this.size)this.horizontal.value=this.radius.x/this.size.x,this.vertical.value=this.radius.y/this.size.y;else if(this.value.value&&this.value.value.image){var t=this.value.value.image;this.horizontal.value=this.radius.x/t.width,this.vertical.value=this.radius.y/t.height}},Xi.prototype.generate=function(e,t){if(e.isShader("fragment")){var r,i=[],n=e.include(Xi.Nodes.blurX),a=e.include(Xi.Nodes.blurY);return this.blurX&&i.push(n+"( "+this.value.build(e,"sampler2D")+", "+this.uv.build(e,"v2")+", "+this.horizontal.build(e,"f")+" )"),this.blurY&&i.push(a+"( "+this.value.build(e,"sampler2D")+", "+this.uv.build(e,"v2")+", "+this.vertical.build(e,"f")+" )"),r=2==i.length?"( "+i.join(" + ")+" / 2.0 )":i.length?"( "+i[0]+" )":"vec4( 0.0 )",e.format(r,this.getType(e),t)}return console.warn("BlurNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)},Xi.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.value=e.value,this.uv=e.uv,this.radius=e.radius,void 0!==e.size&&(this.size=new f(e.size.x,e.size.y)),this.blurX=e.blurX,this.blurY=e.blurY},Xi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,t.uv=this.uv.toJSON(e).uuid,t.radius=this.radius.toJSON(e).uuid,this.size&&(t.size={x:this.size.x,y:this.size.y}),t.blurX=this.blurX,t.blurY=this.blurY),t},Hi.Nodes=function(){var e=new lr("vec3 LUMA vec3( 0.2125, 0.7154, 0.0721 )"),t=new Vf(["float luminance( vec3 rgb ) {","\treturn dot( rgb, LUMA );","}"].join("\n"),[e]);return{LUMA:e,luminance:t}}(),Hi.prototype=Object.create(tr.prototype),Hi.prototype.constructor=Hi,Hi.prototype.nodeType="Luminance",Hi.prototype.generate=function(e,t){var r=e.include(Hi.Nodes.luminance);return e.format(r+"( "+this.rgb.build(e,"v3")+" )",this.getType(e),t)},Hi.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.rgb=e.rgb},Hi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.rgb=this.rgb.toJSON(e).uuid),t},Yi.Nodes=function(){var e=new Vf(["vec3 hue(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")),t=new Vf(["vec3 saturation(vec3 rgb, float adjustment) {","\tvec3 intensity = vec3( luminance( rgb ) );","\treturn mix( intensity, rgb, adjustment );","}"].join("\n"),[Hi.Nodes.luminance]),r=new Vf(["vec3 vibrance(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"));return{hue:e,saturation:t,vibrance:r}}(),Yi.SATURATION="saturation",Yi.HUE="hue",Yi.VIBRANCE="vibrance",Yi.BRIGHTNESS="brightness",Yi.CONTRAST="contrast",Yi.prototype=Object.create(tr.prototype),Yi.prototype.constructor=Yi,Yi.prototype.nodeType="ColorAdjustment",Yi.prototype.generate=function(e,t){var r=this.rgb.build(e,"v3"),i=this.adjustment.build(e,"f");switch(this.method){case Yi.BRIGHTNESS:return e.format("( "+r+" + "+i+" )",this.getType(e),t);case Yi.CONTRAST:return e.format("( "+r+" * "+i+" )",this.getType(e),t)}var n=e.include(Yi.Nodes[this.method]);return e.format(n+"( "+r+", "+i+" )",this.getType(e),t)},Yi.prototype.copy=function(e){tr.prototype.copy.call(this,e),this.rgb=e.rgb,this.adjustment=e.adjustment,this.method=e.method},Yi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.rgb=this.rgb.toJSON(e).uuid,t.adjustment=this.adjustment.toJSON(e).uuid,t.method=this.method),t},qi.prototype=Object.create(ar.prototype),qi.prototype.constructor=qi,qi.prototype.nodeType="Int",qi.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format(this.value,i,t)},qi.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value=e.value},qi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,this.readonly===!0&&(t.readonly=!0)),t},Qi.prototype=Object.create(ar.prototype),Qi.prototype.constructor=Qi,Qi.prototype.nodeType="Matrix3",Object.defineProperties(Qi.prototype,{elements:{set:function(e){this.value.elements=e},get:function(){return this.value.elements}}}),Qi.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format("mat3( "+this.value.elements.join(", ")+" )",i,t)},Qi.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.value.fromArray(e.elements)},Qi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t},Ji.prototype=Object.create(ar.prototype),Ji.prototype.constructor=Ji,Ji.prototype.nodeType="Matrix4",Object.defineProperties(Ji.prototype,{elements:{set:function(e){this.value.elements=e},get:function(){return this.value.elements}}}),Ji.prototype.generateReadonly=function(e,t,r,i,n,a){return e.format("mat4( "+this.value.elements.join(", ")+" )",i,t)},Ji.prototype.copy=function(e){ar.prototype.copy.call(this,e),this.scope.value.fromArray(e.elements)},Ji.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t},Zi.prototype=Object.create(ar.prototype),Zi.prototype.constructor=Zi,Zi.prototype.nodeType="Property",Object.defineProperties(Zi.prototype,{value:{get:function(){return this.object[this.property]},set:function(e){this.object[this.property]=e}}}),Zi.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,t.property=this.property),t},Ki.ADD="+",Ki.SUB="-",Ki.MUL="*",Ki.DIV="/",Ki.prototype=Object.create(tr.prototype),Ki.prototype.constructor=Ki,Ki.prototype.nodeType="Operator",Ki.prototype.getType=function(e){var t=this.a.getType(e),r=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(r)>e.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 <fog_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","#include <shadowmap_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));var i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","#include <defaultnormal_vertex>","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","#include <begin_vertex>"];r&&i.push(r.code,r.result?"transformed = "+r.result+";":""),i.push("#include <morphtarget_vertex>","#include <skinning_vertex>","#include <project_vertex>","#include <fog_vertex>","#include <logdepthbuf_vertex>","#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),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 <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>","#include <logdepthbuf_pars_fragment>","#include <logdepthbuf_vertex>"].join("\n"));var i=["#include <clipping_planes_fragment>","\t#include <normal_fragment_begin>","\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 <logdepthbuf_fragment>",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 <lights_fragment_begin>"),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 <lights_fragment_end>"),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 <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>","#include <premultiplied_alpha_fragment>","#include <dithering_fragment>"),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;a<l;a++)o=Math.max(o,e.getIndexByElement(s.charAt(a)));for(o>n&&(o=n),i+=".",a=0;a<l;a++){var c=(s.charAt(a),e.getIndexByElement(s.charAt(a)));c>o&&(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 <fog_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","#include <shadowmap_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));var i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","#include <defaultnormal_vertex>","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","#include <begin_vertex>"];r&&i.push(r.code,r.result?"transformed = "+r.result+";":""),i.push("\t#include <morphtarget_vertex>","\t#include <skinning_vertex>","\t#include <project_vertex>","\t#include <fog_vertex>","\t#include <logdepthbuf_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),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 <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <logdepthbuf_pars_fragment>"].join("\n"));var i=["#include <normal_fragment_begin>","\tBlinnPhongMaterial material;",n.code,"\tvec3 diffuseColor = "+n.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","#include <logdepthbuf_fragment>",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 <lights_fragment_begin>","#include <lights_fragment_end>"),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 <premultiplied_alpha_fragment>","#include <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>"),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 <fog_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n")),t=["#include <clipping_planes_fragment>","#include <begin_vertex>"],
|
|
r&&t.push(r.code,r.result?"transformed = "+r.result+";":""),t.push("#include <project_vertex>","#include <fog_vertex>","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 <logdepthbuf_vertex>","#include <clipping_planes_vertex>","#include <fog_vertex>")}else{e.addParsCode(["#include <fog_pars_fragment>","#include <logdepthbuf_pars_fragment>","#include <clipping_planes_pars_fragment>"].join("\n")),e.addCode(["#include <clipping_planes_fragment>","#include <logdepthbuf_fragment>"].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 <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>")}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;o<n;o++){var s=r[Cv[o]];a.push(s?s.build(e,"f"):"0.0")}var l=(n>1?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;n<i;n++){var a=t[Cv[n]];a&&(r.inputs[Cv[n]]=a.toJSON(e).uuid)}}return r},An.prototype=Object.create(ji.prototype),An.prototype.constructor=An,An.prototype.nodeType="UVTransform",An.prototype.generate=function(e,t){return this.keywords.uvNode=this.uv,this.keywords.uvTransform=this.position,ji.prototype.generate.call(this,e,t)},An.prototype.setUvTransform=function(e,t,r,i,n,a,o){a=void 0!==a?a:.5,o=void 0!==o?o:.5,this.position.value.setUvTransform(e,t,r,i,n,a,o)},An.prototype.copy=function(e){ji.prototype.copy.call(this,e),this.uv=e.uv,this.position=e.position},An.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.uv=this.uv.toJSON(e).uuid,t.position=this.position.toJSON(e).uuid),t},Mn.prototype=Object.create(_i.prototype),Mn.prototype.constructor=Mn,Mn.prototype.nodeType="Velocity",Mn.prototype.isReadonly=function(e){return!1},Mn.prototype.setParams=function(e){switch(this.params.type){case"elastic":delete this.moment,delete this.speed,delete this.springVelocity,delete this.lastVelocity}switch(this.params=e||{},this.params.type){case"elastic":this.moment=new i,this.speed=new i,this.springVelocity=new i,this.lastVelocity=new i}},Mn.prototype.setTarget=function(e){this.target&&(delete this.position,delete this.oldPosition),this.target=e,e&&(this.position=e.getWorldPosition(this.position||new i),this.oldPosition=this.position.clone())},Mn.prototype.updateFrameVelocity=function(e){this.target&&(this.position=this.target.getWorldPosition(this.position||new i),this.velocity.subVectors(this.position,this.oldPosition),this.oldPosition.copy(this.position))},Mn.prototype.updateFrame=function(e){switch(this.updateFrameVelocity(e),this.params.type){case"elastic":var t=e.delta*(this.params.fps||60),r=Math.pow(this.params.spring,t),i=Math.pow(this.params.damping,t);this.velocity.multiplyScalar(Math.exp(-this.params.damping*t)),this.velocity.add(this.springVelocity),this.velocity.add(this.speed.multiplyScalar(i).multiplyScalar(1-r)),this.speed.subVectors(this.velocity,this.lastVelocity),this.springVelocity.add(this.speed),this.springVelocity.multiplyScalar(r),this.moment.add(this.springVelocity),this.moment.multiplyScalar(i),this.lastVelocity.copy(this.velocity),this.value.copy(this.moment);break;default:this.value.copy(this.velocity)}},Mn.prototype.copy=function(e){_i.prototype.copy.call(this,e),e.target&&object.setTarget(e.target),object.setParams(e.params)},Mn.prototype.toJSON=function(e){var t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.target&&(t.target=this.target.uuid),t.params=JSON.parse(JSON.stringify(this.params))),t},Object.assign(Tn.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){var t=this;this.makeEmpty();for(var r=0,i=e.length;r<i;r++)t.expandByPoint(e[r]);return this},setFromCenterAndSize:function(){var e=new f;return function(t,r){var i=e.copy(r).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=+(1/0),this.max.x=this.max.y=-(1/0),this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(e){return void 0===e&&(console.warn("Box2: .getCenter() target is now required"),e=new f),this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(e){return void 0===e&&(console.warn("Box2: .getSize() target is now required"),e=new f),this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(e){return this.min.min(e),this.max.max(e),this},expandByVector:function(e){return this.min.sub(e),this.max.add(e),this},expandByScalar:function(e){return this.min.addScalar(-e),this.max.addScalar(e),this},containsPoint:function(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.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;A<M;A++){var T=l[A],w=h.uniforms;w.color.value.copy(T.color),w.map.value=T.texture,w.screenPosition.value.x=e.x+_*T.distance,w.screenPosition.value.y=e.y+S*T.distance;var b=T.size/y.w,f=y.w/y.z;w.scale.value.set(b*f,b),h.uniformsNeedUpdate=!0,i.renderBufferDirect(u,null,n,h,d,null)}}},this.dispose=function(){a.dispose(),o.dispose(),h.dispose(),t.dispose(),r.dispose();for(var e=0,i=l.length;e<i;e++)l[e].texture.dispose()}};Lv.prototype=Object.create(k.prototype),Lv.prototype.constructor=Lv,Lv.prototype.isLensflare=!0;var Pv=function(e,t,r,i){this.texture=e,this.size=t||1,this.distance=r||0,this.color=i||new u(16777215)};Pv.Shader={uniforms:{map:{value:null},occlusionMap:{value:null},color:{value:null},scale:{value:null},screenPosition:{value:null}},vertexShader:["precision highp float;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform sampler2D occlusionMap;","attribute vec3 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","\tvUV = uv;","\tvec2 pos = position.xy;","\tvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","\tvVisibility = visibility.r / 9.0;","\tvVisibility *= 1.0 - visibility.g / 9.0;","\tvVisibility *= visibility.b / 9.0;","\tgl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["precision highp float;","uniform sampler2D map;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","\tvec4 texture = texture2D( map, vUV );","\ttexture.a *= vVisibility;","\tgl_FragColor = texture;","\tgl_FragColor.rgb *= color;","}"].join("\n")},Lv.Geometry=function(){var e=new P,t=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),r=new Lt(t,5);return e.setIndex([0,1,2,0,2,3]),e.addAttribute("position",new Nt(r,3,0,(!1))),e.addAttribute("uv",new Nt(r,2,3,(!1))),e}();var Nv=function(e,t){k.call(this,e),this.type="Reflector";var n=this;t=t||{};var a=new u(void 0!==t.color?t.color:8355711),o=t.textureWidth||512,s=t.textureHeight||512,l=t.clipBias||0,c=t.shader||Nv.ReflectorShader,h=void 0!==t.recursion?t.recursion:0,d=new ze,p=new i,f=new i,m=new i,g=new r,y=new i(0,0,(-1)),x=new v,b=new v,w=new i,_=new i,S=new v,A=new r,M=new de,T={minFilter:rc,magFilter:rc,format:yc,stencilBuffer:!1},E=new ge(o,s,T);Fs.isPowerOfTwo(o)&&Fs.isPowerOfTwo(s)||(E.texture.generateMipmaps=!1);var C=new pe({uniforms:Mu.clone(c.uniforms),fragmentShader:c.fragmentShader,vertexShader:c.vertexShader});C.uniforms.tDiffuse.value=E.texture,C.uniforms.color.value=a,C.uniforms.textureMatrix.value=A,this.material=C,this.renderOrder=-(1/0),this.onBeforeRender=function(e,t,r){if("recursion"in r.userData){if(r.userData.recursion===h)return;r.userData.recursion++}if(f.setFromMatrixPosition(n.matrixWorld),m.setFromMatrixPosition(r.matrixWorld),g.extractRotation(n.matrixWorld),p.set(0,0,1),p.applyMatrix4(g),w.subVectors(f,m),!(w.dot(p)>0)){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 Rv=function(){var e=Rv.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)};Rv.prototype=Object.create(k.prototype),Rv.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 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 <fog_pars_vertex>","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 <fog_vertex>","}"].join("\n"),fragmentShader:["#include <common>","#include <fog_pars_fragment>","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 <tonemapping_fragment>","\t#include <encodings_fragment>","\t#include <fog_fragment>","}"].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;r<this.resolution;r++)for(var i=0;i<this.resolution;i++)t[r*e.resolution*4+4*i]=2*Math.random()*Math.PI,t[r*e.resolution*4+4*i+1]=0,t[r*e.resolution*4+4*i+2]=0,t[r*e.resolution*4+4*i+3]=0;this.pingPhaseTexture=new Mt(t,this.resolution,this.resolution,xc),this.pingPhaseTexture.wrapS=Zl,this.pingPhaseTexture.wrapT=Zl,this.pingPhaseTexture.type=hc,this.pingPhaseTexture.needsUpdate=!0},Uv.prototype.renderInitialSpectrum=function(){this.scene.overrideMaterial=this.materialInitialSpectrum,this.materialInitialSpectrum.uniforms.u_wind.value.set(this.windX,this.windY),this.materialInitialSpectrum.uniforms.u_size.value=this.size,this.renderer.render(this.scene,this.oceanCamera,this.initialSpectrumFramebuffer,!0)},Uv.prototype.renderWavePhase=function(){this.scene.overrideMaterial=this.materialPhase,this.screenQuad.material=this.materialPhase,this.initial?(this.materialPhase.uniforms.u_phases.value=this.pingPhaseTexture,this.initial=!1):this.materialPhase.uniforms.u_phases.value=this.pingPhase?this.pingPhaseFramebuffer.texture:this.pongPhaseFramebuffer.texture,this.materialPhase.uniforms.u_deltaTime.value=this.deltaTime,this.materialPhase.uniforms.u_size.value=this.size,this.renderer.render(this.scene,this.oceanCamera,this.pingPhase?this.pongPhaseFramebuffer:this.pingPhaseFramebuffer),this.pingPhase=!this.pingPhase},Uv.prototype.renderSpectrum=function(){this.scene.overrideMaterial=this.materialSpectrum,this.materialSpectrum.uniforms.u_initialSpectrum.value=this.initialSpectrumFramebuffer.texture,this.materialSpectrum.uniforms.u_phases.value=this.pingPhase?this.pingPhaseFramebuffer.texture:this.pongPhaseFramebuffer.texture,this.materialSpectrum.uniforms.u_choppiness.value=this.choppiness,this.materialSpectrum.uniforms.u_size.value=this.size,this.renderer.render(this.scene,this.oceanCamera,this.spectrumFramebuffer)},Uv.prototype.renderSpectrumFFT=function(){var e=this,t=Math.log(this.resolution)/Math.log(2);this.scene.overrideMaterial=this.materialOceanHorizontal;for(var r=0;r<t;r++)0===r?(e.materialOceanHorizontal.uniforms.u_input.value=e.spectrumFramebuffer.texture,e.materialOceanHorizontal.uniforms.u_subtransformSize.value=Math.pow(2,r%t+1),e.renderer.render(e.scene,e.oceanCamera,e.pingTransformFramebuffer)):r%2===1?(e.materialOceanHorizontal.uniforms.u_input.value=e.pingTransformFramebuffer.texture,e.materialOceanHorizontal.uniforms.u_subtransformSize.value=Math.pow(2,r%t+1),e.renderer.render(e.scene,e.oceanCamera,e.pongTransformFramebuffer)):(e.materialOceanHorizontal.uniforms.u_input.value=e.pongTransformFramebuffer.texture,e.materialOceanHorizontal.uniforms.u_subtransformSize.value=Math.pow(2,r%t+1),e.renderer.render(e.scene,e.oceanCamera,e.pingTransformFramebuffer));this.scene.overrideMaterial=this.materialOceanVertical;for(var r=t;r<2*t;r++)r===2*t-1?(e.materialOceanVertical.uniforms.u_input.value=t%2===0?e.pingTransformFramebuffer.texture:e.pongTransformFramebuffer.texture,e.materialOceanVertical.uniforms.u_subtransformSize.value=Math.pow(2,r%t+1),e.renderer.render(e.scene,e.oceanCamera,e.displacementMapFramebuffer)):r%2===1?(e.materialOceanVertical.uniforms.u_input.value=e.pingTransformFramebuffer.texture,e.materialOceanVertical.uniforms.u_subtransformSize.value=Math.pow(2,r%t+1),e.renderer.render(e.scene,e.oceanCamera,e.pongTransformFramebuffer)):(e.materialOceanVertical.uniforms.u_input.value=e.pongTransformFramebuffer.texture,e.materialOceanVertical.uniforms.u_subtransformSize.value=Math.pow(2,r%t+1),e.renderer.render(e.scene,e.oceanCamera,e.pingTransformFramebuffer))},Uv.prototype.renderNormalMap=function(){this.scene.overrideMaterial=this.materialNormal,this.changed&&(this.materialNormal.uniforms.u_size.value=this.size),this.materialNormal.uniforms.u_displacementMap.value=this.displacementMapFramebuffer.texture,this.renderer.render(this.scene,this.oceanCamera,this.normalMapFramebuffer,!0)},Ln.prototype=Object.create(Yt.prototype),Ln.prototype.constructor=Ln,Ln.prototype.update=function(){var e=new d;return function(t){if(void 0!==t&&console.warn("BoxHelper: .update() has no longer arguments."),void 0!==this.object&&e.setFromObject(this.object),!e.isEmpty()){var r=e.min,i=e.max,n=this.geometry.attributes.position,a=n.array;a[0]=i.x,a[1]=i.y,a[2]=i.z,a[3]=r.x,a[4]=i.y,a[5]=i.z,a[6]=r.x,a[7]=r.y,a[8]=i.z,a[9]=i.x,a[10]=r.y,a[11]=i.z,a[12]=i.x,a[13]=i.y,a[14]=r.z,a[15]=r.x,a[16]=i.y,a[17]=r.z,a[18]=r.x,a[19]=r.y,a[20]=r.z,a[21]=i.x,a[22]=r.y,a[23]=r.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}}}(),Ln.prototype.setFromObject=function(e){return this.object=e,this.update(),this};var kv=function(e){if(e=e||{},e.tree=this,this.nodeCount=0,this.INDEX_INSIDE_CROSS=-1,this.INDEX_OUTSIDE_OFFSET=2,this.INDEX_OUTSIDE_POS_X=Pn(e.INDEX_OUTSIDE_POS_X)?e.INDEX_OUTSIDE_POS_X:0,this.INDEX_OUTSIDE_NEG_X=Pn(e.INDEX_OUTSIDE_NEG_X)?e.INDEX_OUTSIDE_NEG_X:1,this.INDEX_OUTSIDE_POS_Y=Pn(e.INDEX_OUTSIDE_POS_Y)?e.INDEX_OUTSIDE_POS_Y:2,this.INDEX_OUTSIDE_NEG_Y=Pn(e.INDEX_OUTSIDE_NEG_Y)?e.INDEX_OUTSIDE_NEG_Y:3,this.INDEX_OUTSIDE_POS_Z=Pn(e.INDEX_OUTSIDE_POS_Z)?e.INDEX_OUTSIDE_POS_Z:4,this.INDEX_OUTSIDE_NEG_Z=Pn(e.INDEX_OUTSIDE_NEG_Z)?e.INDEX_OUTSIDE_NEG_Z:5,this.INDEX_OUTSIDE_MAP=[],this.INDEX_OUTSIDE_MAP[this.INDEX_OUTSIDE_POS_X]={index:this.INDEX_OUTSIDE_POS_X,count:0,x:1,y:0,z:0},this.INDEX_OUTSIDE_MAP[this.INDEX_OUTSIDE_NEG_X]={index:this.INDEX_OUTSIDE_NEG_X,count:0,x:-1,y:0,z:0},this.INDEX_OUTSIDE_MAP[this.INDEX_OUTSIDE_POS_Y]={index:this.INDEX_OUTSIDE_POS_Y,count:0,x:0,y:1,z:0},this.INDEX_OUTSIDE_MAP[this.INDEX_OUTSIDE_NEG_Y]={index:this.INDEX_OUTSIDE_NEG_Y,count:0,x:0,y:-1,z:0},this.INDEX_OUTSIDE_MAP[this.INDEX_OUTSIDE_POS_Z]={index:this.INDEX_OUTSIDE_POS_Z,count:0,x:0,y:0,z:1},this.INDEX_OUTSIDE_MAP[this.INDEX_OUTSIDE_NEG_Z]={index:this.INDEX_OUTSIDE_NEG_Z,count:0,x:0,y:0,z:-1},this.FLAG_POS_X=1<<this.INDEX_OUTSIDE_POS_X+1,this.FLAG_NEG_X=1<<this.INDEX_OUTSIDE_NEG_X+1,this.FLAG_POS_Y=1<<this.INDEX_OUTSIDE_POS_Y+1,this.FLAG_NEG_Y=1<<this.INDEX_OUTSIDE_NEG_Y+1,this.FLAG_POS_Z=1<<this.INDEX_OUTSIDE_POS_Z+1,this.FLAG_NEG_Z=1<<this.INDEX_OUTSIDE_NEG_Z+1,this.utilVec31Search=new i,this.utilVec32Search=new i,this.scene=e.scene,this.scene){var t=new Ln(new k(new le(1,1,1)),16711782);this.visualGeometry=t.geometry,this.visualMaterial=t.material}this.objects=[],this.objectsMap={},this.objectsData=[],this.objectsDeferred=[],this.depthMax=Pn(e.depthMax)?e.depthMax:1/0,this.objectsThreshold=Pn(e.objectsThreshold)?e.objectsThreshold:8,this.overlapPct=Pn(e.overlapPct)?e.overlapPct:.15,this.undeferred=e.undeferred||!1,this.root=e.root instanceof zv?e.root:new zv(e)};kv.prototype={update:function(){var e=this;if(this.objectsDeferred.length>0){for(var t=0,r=this.objectsDeferred.length;t<r;t++){var i=e.objectsDeferred[t];e.addDeferred(i.object,i.options)}this.objectsDeferred.length=0}},add:function(e,t){this.undeferred?(this.updateObject(e),this.addDeferred(e,t)):this.objectsDeferred.push({object:e,options:t})},addDeferred:function(e,t){var r,i,n,a,o,s,l,c=this;if(e instanceof Bv&&(e=e.object),e.uuid||(e.uuid=Fs.generateUUID()),!this.objectsMap[e.uuid])if(this.objects.push(e),this.objectsMap[e.uuid]=e,t&&(o=t.useFaces,l=t.useVertices),l===!0)for(n=e.geometry,s=n.vertices,r=0,i=s.length;r<i;r++)c.addObjectData(e,s[r]);else if(o===!0)for(n=e.geometry,a=n.faces,r=0,i=a.length;r<i;r++)c.addObjectData(e,a[r]);else this.addObjectData(e)},addObjectData:function(e,t){var r=new Bv(e,t);this.objectsData.push(r),this.root.addObject(r)},remove:function(e){var t,r,i,n,a=this,o=e;if(e instanceof Bv&&(e=e.object),this.objectsMap[e.uuid]){if(this.objectsMap[e.uuid]=void 0,i=Dn(this.objects,e),i!==-1)for(this.objects.splice(i,1),n=this.root.removeObject(o),t=0,r=n.length;t<r;t++)o=n[t],i=Dn(a.objectsData,o),i!==-1&&a.objectsData.splice(i,1)}else this.objectsDeferred.length>0&&(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;t<r;t++)n=i[t],a.add(n,{useFaces:n.faces,useVertices:n.vertices})},rebuild:function(){var e,t,r,i,n,a,o=this,s=[];for(e=0,t=this.objectsData.length;e<t;e++)i=o.objectsData[e],r=i.node,i.update(),r instanceof zv&&!i.positionLast.equals(i.position)&&(a=i.indexOctant,n=r.getOctantIndex(i),n!==a&&s.push(i));for(e=0,t=s.length;e<t;e++)i=s[e],i.node.removeObject(i),o.root.addObject(i)},updateObject:function(e){var t,r,i,n,a=[e];for(i=e.parent;i;)a.push(i),i=i.parent;for(t=0,r=a.length;t<r;t++)i=a[t],i.matrixWorldNeedsUpdate===!0&&(n=i);"undefined"!=typeof n&&n.updateMatrixWorld()},search:function(e,t,r,n){var a,o,s,l,c,u,h,d,p,f,m,v=this;for(l=[].concat(this.root.objects),t>0||(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<o;a++)s=v.root.nodesByIndex[v.root.nodesIndices[a]],l=s.search(e,t,l,n,m);if(r===!0)for(h=[],p=[],a=0,o=l.length;a<o;a++)c=l[a],u=c.object,f=Dn(p,u),f===-1?(d={object:u,faces:[],vertices:[]},h.push(d),p.push(u)):d=h[f],c.faces?d.faces.push(c.faces):c.vertices&&d.vertices.push(c.vertices);else h=l;return h},setRoot:function(e){e instanceof zv&&(this.root=e,this.root.updateProperties())},getDepthEnd:function(){return this.root.getDepthEnd()},getNodeCountEnd:function(){return this.root.getNodeCountEnd()},getObjectCountEnd:function(){return this.root.getObjectCountEnd()},toConsole:function(){this.root.toConsole()}};var Bv=function(e,t){this.object=e,t instanceof h?(this.faces=t,this.face3=!0,this.utilVec31FaceBounds=new i):t instanceof i&&(this.vertices=t),this.radius=0,this.position=new i,this.object instanceof c&&this.update(),this.positionLast=this.position.clone()};Bv.prototype={update:function(){this.face3?(this.radius=this.getFace3BoundingRadius(this.object,this.faces),this.position.copy(this.faces.centroid).applyMatrix4(this.object.matrixWorld)):this.vertices?(this.radius=this.object.material.size||1,this.position.copy(this.vertices).applyMatrix4(this.object.matrixWorld)):this.object.geometry?(null===this.object.geometry.boundingSphere&&this.object.geometry.computeBoundingSphere(),this.radius=this.object.geometry.boundingSphere.radius,this.position.copy(this.object.geometry.boundingSphere.center).applyMatrix4(this.object.matrixWorld)):(this.radius=this.object.boundRadius,this.position.setFromMatrixPosition(this.object.matrixWorld)),this.radius=this.radius*Math.max(this.object.scale.x,this.object.scale.y,this.object.scale.z)},getFace3BoundingRadius:function(e,t){void 0===t.centroid&&(t.centroid=new i);var r,n=e.geometry||e,a=n.vertices,o=t.centroid,s=a[t.a],l=a[t.b],c=a[t.c],u=this.utilVec31FaceBounds;return o.addVectors(s,l).add(c).divideScalar(3),r=Math.max(u.subVectors(o,s).length(),u.subVectors(o,l).length(),u.subVectors(o,c).length())}};var zv=function(e){this.utilVec31Branch=new i,this.utilVec31Expand=new i,this.utilVec31Ray=new i,e=e||{},e.tree instanceof kv?this.tree=e.tree:e.parent instanceof zv!=!0&&(e.root=this,this.tree=new kv(e)),
|
|
this.id=this.tree.nodeCount++,this.position=e.position instanceof i?e.position:new i,this.radius=e.radius>0?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<t;e++)r.nodesByIndex[r.nodesIndices[e]].updateProperties()},reset:function(e,t){var r,i,n,a=this.nodesIndices||[],o=this.nodesByIndex;for(this.objects=[],this.nodesIndices=[],this.nodesByIndex={},r=0,i=a.length;r<i;r++)n=o[a[r]],n.setParent(void 0),e===!0&&n.reset(e,t);t===!0&&this.visual&&this.visual.parent&&this.visual.parent.remove(this.visual)},addNode:function(e,t){e.indexOctant=t,Dn(this.nodesIndices,t)===-1&&this.nodesIndices.push(t),this.nodesByIndex[t]=e,e.parent!==this&&e.setParent(this)},removeNode:function(e){var t,r;t=Dn(this.nodesIndices,e),this.nodesIndices.splice(t,1),r=r||this.nodesByIndex[e],delete this.nodesByIndex[e],r.parent===this&&r.setParent(void 0)},addObject:function(e){var t,r,i;r=this.getOctantIndex(e),r>-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;t<r;t++)i=e[t],n.objects.push(i),i.node=n},removeObject:function(e){var t,r,i,n;if(n=this.removeObjectRecursive(e,{searchComplete:!1,nodesRemovedFrom:[],objectsDataRemoved:[]}),i=n.nodesRemovedFrom,i.length>0)for(t=0,r=i.length;t<r;t++)i[t].shrink();return n.objectsDataRemoved},removeObjectRecursive:function(e,t){var r,i,n,a,o,s=this,l=-1;if(e instanceof Bv)l=Dn(this.objects,e),l!==-1&&(this.objects.splice(l,1),e.node=void 0,t.objectsDataRemoved.push(e),t.searchComplete=o=!0);else for(r=this.objects.length-1;r>=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;r<i&&(a=s.nodesByIndex[s.nodesIndices[r]],t=a.removeObjectRecursive(e,t),t.searchComplete!==!0);r++);return t},checkGrow:function(){this.objects.length>this.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<i;r++)t=n.objects[r],e=n.getOctantIndex(t),e>-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<this.tree.depthMax){for(e=e||this.objects,t=t||[],s=[],r=0,i=e.length;r<i;r++)a=e[r],n=t[r],n>-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()<this.tree.depthMax){for(e=e||this.objects,t=t||[],o=[],s=[],r=0,n=D.length;r<n;r++)D[r].count=0;for(r=0,n=e.length;r<n;r++)a=e[r],l=t[r],l<-1?(c=-l-O.tree.INDEX_OUTSIDE_OFFSET,c&O.tree.FLAG_POS_X?D[O.tree.INDEX_OUTSIDE_POS_X].count++:c&O.tree.FLAG_NEG_X&&D[O.tree.INDEX_OUTSIDE_NEG_X].count++,c&O.tree.FLAG_POS_Y?D[O.tree.INDEX_OUTSIDE_POS_Y].count++:c&O.tree.FLAG_NEG_Y&&D[O.tree.INDEX_OUTSIDE_NEG_Y].count++,c&O.tree.FLAG_POS_Z?D[O.tree.INDEX_OUTSIDE_POS_Z].count++:c&O.tree.FLAG_NEG_Z&&D[O.tree.INDEX_OUTSIDE_NEG_Z].count++,s.push(a)):o.push(a);if(s.length>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;r<n;r++)O.tree.root.addObject(s[r]);e===this.objects&&(this.objects=o)}else o=e;return o},shrink:function(){this.checkMerge(),this.tree.root.checkContract()},checkMerge:function(){for(var e,t=this;t.parent instanceof zv&&t.getObjectCountEnd()<this.tree.objectsThreshold;)e=t,t=t.parent;t!==this&&t.merge(e)},merge:function(e){var t,r,i,n=this;for(e=On(e),t=0,r=e.length;t<r;t++)i=e[t],n.addObjectWithoutCheck(i.getObjectsEnd()),i.reset(!0,!0),n.removeNode(i.indexOctant,i);this.checkMerge()},checkContract:function(){var e,t,r,i,n,a,o,s=this;if(this.nodesIndices.length>0){for(a=0,o=this.objects.length,e=0,t=this.nodesIndices.length;e<t;e++)r=s.nodesByIndex[s.nodesIndices[e]],i=r.getObjectCountEnd(),o+=i,(n instanceof zv==!1||i>a)&&(n=r,a=i);o-=a,o<this.tree.objectsThreshold&&n instanceof zv&&this.contract(n)}},contract:function(e){var t,r,i,n=this;for(t=0,r=this.nodesIndices.length;t<r;t++)i=n.nodesByIndex[n.nodesIndices[t]],i!==e&&(e.addObjectWithoutCheck(i.getObjectsEnd()),i.reset(!0,!0));e.addObjectWithoutCheck(this.objects),this.reset(!1,!0),this.tree.setRoot(e),e.checkContract()},getOctantIndex:function(e){var t,r,i,n,a,o,s,l,c,u=this.position,h=this.radiusOverlap,d=this.overlap,p=0;if(e instanceof Bv?(r=e.radius,t=e.position,e.positionLast.copy(t)):e instanceof zv&&(t=e.position,r=0),i=t.x-u.x,n=t.y-u.y,a=t.z-u.z,o=Math.abs(i),s=Math.abs(n),l=Math.abs(a),c=Math.max(o,s,l),c+r>h)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))return e.indexOctant=this.tree.INDEX_INSIDE_CROSS,e.indexOctant;if(n-r>-d)p=2|p;else if(!(n+r<d))return e.indexOctant=this.tree.INDEX_INSIDE_CROSS,e.indexOctant;if(a-r>-d)p=4|p;else if(!(a+r<d))return e.indexOctant=this.tree.INDEX_INSIDE_CROSS,e.indexOctant;return e.indexOctant=p,e.indexOctant},getOctantIndexFromPosition:function(e,t,r){var i=0;return e>0&&(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;a<o;a++)s=c.nodesByIndex[c.nodesIndices[a]],r=s.search(e,t,r,i);return r},intersectSphere:function(e,t){var r=t*t,i=e.x,n=e.y,a=e.z;return i<this.left?r-=Math.pow(i-this.left,2):i>this.right&&(r-=Math.pow(i-this.right,2)),n<this.bottom?r-=Math.pow(n-this.bottom,2):n>this.top&&(r-=Math.pow(n-this.top,2)),a<this.back?r-=Math.pow(a-this.back,2):a>this.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;t<r;t++)i=n.nodesByIndex[n.nodesIndices[t]],e=i.getDepthEnd(e);else e=!e||this.depth>e?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<t;e++)i+=r.nodesByIndex[r.nodesIndices[e]].getNodeCountRecursive();return i},getObjectsEnd:function(e){var t,r,i,n=this;for(e=(e||[]).concat(this.objects),t=0,r=this.nodesIndices.length;t<r;t++)i=n.nodesByIndex[n.nodesIndices[t]],e=i.getObjectsEnd(e);return e},getObjectCountEnd:function(){var e,t,r=this,i=this.objects.length;for(e=0,t=this.nodesIndices.length;e<t;e++)i+=r.nodesByIndex[r.nodesIndices[e]].getObjectCountEnd();return i},getObjectCountStart:function(){for(var e=this.objects.length,t=this.parent;t instanceof zv;)e+=t.objects.length,t=t.parent;return e},toConsole:function(e){var t,r,i,n=this,a=" ";for(e="string"==typeof e?e:a,console.log(this.parent?e+" octree NODE > ":" 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;t<r;t++)i=n.nodesByIndex[n.nodesIndices[t]],i.toConsole(e+a)}},je.prototype.intersectOctreeObject=function(e,t){var r,i,n,a;return e.object instanceof c?(i=e,e=i.object,a=i.faces,n=e.geometry.faces,a.length>0&&(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;r<i;r++)a=a.concat(n.intersectOctreeObject(e[r],t));return a};var jv=function(e){var t=this;this.cubeLods=e;var r=4*e[0].width,i=e[0].texture,n={format:i.format,magFilter:i.magFilter,minFilter:i.minFilter,type:i.type,generateMipmaps:i.generateMipmaps,anisotropy:i.anisotropy,encoding:i.encoding===cu?du:i.encoding};n.encoding===du&&(n.magFilter=rc,n.minFilter=rc),this.CubeUVRenderTarget=new ge(r,r,n),this.CubeUVRenderTarget.texture.name="PMREMCubeUVPacker.cubeUv",this.CubeUVRenderTarget.texture.mapping=ql,this.camera=new me(.5*-r,.5*r,.5*-r,.5*r,0,1),this.scene=new fe,this.objects=[];var a=new xe(1,1),o=[];o.push(new f(0,0)),o.push(new f(1,0)),o.push(new f(2,0)),o.push(new f(0,1)),o.push(new f(1,1)),o.push(new f(2,1));var s=r;r=e[0].width;var l=0,c=4;this.numLods=Math.log(e[0].width)/Math.log(2)-2;for(var u=0;u<this.numLods;u++){var h=.5*(s-s/c);r>16&&(c*=2);for(var d=r>16?6:1,p=0,m=0,v=r,g=0;g<d;g++){for(var y=0;y<6;y++){var x=t.getShader();x.uniforms.envMap.value=t.cubeLods[u].texture,x.envMap=t.cubeLods[u].texture,x.uniforms.faceIndex.value=y,x.uniforms.mapSize.value=v;var b=new k(a,x);b.position.x=o[y].x*v-h+p,b.position.y=o[y].y*v-h+l+m,b.material.side=Zs,b.scale.setScalar(v),t.scene.add(b),t.objects.push(b)}m+=1.75*v,p+=1.25*v,v/=2}l+=2*r,r>16&&(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<r;t++)e.objects[t].material.dispose();this.objects[0].geometry.dispose()}};var Vv=function(e,t,r){var i=this;this.sourceTexture=e,this.resolution=void 0!==r?r:256,this.samplesPerLevel=void 0!==t?t:16;var n=e.encoding===ou||e.encoding===lu||e.encoding===su;this.sourceTexture.minFilter=n?rc:$l,this.sourceTexture.magFilter=n?rc:$l,this.sourceTexture.generateMipmaps=this.sourceTexture.generateMipmaps&&n,this.cubeLods=[];var a=this.resolution,o={format:this.sourceTexture.format,magFilter:this.sourceTexture.magFilter,minFilter:this.sourceTexture.minFilter,type:this.sourceTexture.type,generateMipmaps:this.sourceTexture.generateMipmaps,anisotropy:this.sourceTexture.anisotropy,encoding:this.sourceTexture.encoding};this.numLods=Math.log(a)/Math.log(2)-2;for(var s=0;s<this.numLods;s++){var l=new Zt(a,a,o);l.texture.name="PMREMGenerator.cube"+s,i.cubeLods.push(l),a=Math.max(16,a/2)}this.camera=new me((-1),1,1,(-1),0,1e3),this.shader=this.getShader(),this.shader.defines.SAMPLES_PER_LEVEL=this.samplesPerLevel,this.planeMesh=new k(new xe(2,2,0),this.shader),this.planeMesh.material.side=Ks,this.scene=new fe,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.shader.uniforms.envMap.value=this.sourceTexture,this.shader.envMap=this.sourceTexture};Vv.prototype={constructor:Vv,update:function(e){var t=this;this.shader.uniforms.envMap.value=this.sourceTexture,this.shader.envMap=this.sourceTexture;var r=e.gammaInput,i=e.gammaOutput,n=e.toneMapping,a=e.toneMappingExposure,o=e.getRenderTarget();e.toneMapping=kl,e.toneMappingExposure=1,e.gammaInput=!1,e.gammaOutput=!1;for(var s=0;s<this.numLods;s++){var l=s/(t.numLods-1);t.shader.uniforms.roughness.value=.9*l,t.shader.uniforms.queryScale.value.x=0==s?-1:1;var c=t.cubeLods[s].width;t.shader.uniforms.mapSize.value=c,t.renderToCubeMapTarget(e,t.cubeLods[s]),s<5&&(t.shader.uniforms.envMap.value=t.cubeLods[s].texture)}e.setRenderTarget(o),e.toneMapping=n,e.toneMappingExposure=a,e.gammaInput=r,e.gammaOutput=i},renderToCubeMapTarget:function(e,t){for(var r=this,i=0;i<6;i++)r.renderToCubeMapTargetFace(e,t,i)},renderToCubeMapTargetFace:function(e,t,r){t.activeCubeFace=r,this.shader.uniforms.faceIndex.value=r,e.render(this.scene,this.camera,t,!0)},getShader:function(){var e=new pe({defines:{SAMPLES_PER_LEVEL:20},uniforms:{faceIndex:{value:0},roughness:{value:.5},mapSize:{value:.5},envMap:{value:null},queryScale:{value:new i(1,1,1)},testColor:{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:"#include <common>\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<r;t++)e.cubeLods[t].dispose();this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}};var Gv={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 texel = texture2D( tDiffuse, vUv );","gl_FragColor = opacity * texel;","}"].join("\n")},Wv={uniforms:{tDiffuse:{value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","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 <common>","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<s;++r)i[r]=t(r-a,e),n+=i[r];for(r=0;r<s;++r)i[r]/=n;return i}},Jv=function(e,t,r,i){Tv.call(this),e=void 0!==e?e:1,t=void 0!==t?t:25,r=void 0!==r?r:4,i=void 0!==i?i:256;var n={minFilter:rc,magFilter:rc,format:xc};this.renderTargetX=new ge(i,i,n),this.renderTargetX.texture.name="BloomPass.x",this.renderTargetY=new ge(i,i,n),this.renderTargetY.texture.name="BloomPass.y",void 0===Gv&&console.error("BloomPass relies on CopyShader");var a=Gv;this.copyUniforms=Mu.clone(a.uniforms),this.copyUniforms.opacity.value=e,this.materialCopy=new pe({uniforms:this.copyUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,blending:ol,transparent:!0}),void 0===Qv&&console.error("BloomPass relies on ConvolutionShader");var o=Qv;this.convolutionUniforms=Mu.clone(o.uniforms),this.convolutionUniforms.uImageIncrement.value=Jv.blurX,this.convolutionUniforms.cKernel.value=Qv.buildKernel(r),this.materialConvolution=new pe({uniforms:this.convolutionUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,defines:{KERNEL_SIZE_FLOAT:t.toFixed(1),KERNEL_SIZE_INT:t.toFixed(0)
|
|
}}),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)};Jv.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Jv,render:function(e,t,r,i,n){n&&e.context.disable(e.context.STENCIL_TEST),this.quad.material=this.materialConvolution,this.convolutionUniforms.tDiffuse.value=r.texture,this.convolutionUniforms.uImageIncrement.value=Jv.blurX,e.render(this.scene,this.camera,this.renderTargetX,!0),this.convolutionUniforms.tDiffuse.value=this.renderTargetX.texture,this.convolutionUniforms.uImageIncrement.value=Jv.blurY,e.render(this.scene,this.camera,this.renderTargetY,!0),this.quad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetY.texture,n&&e.context.enable(e.context.STENCIL_TEST),e.render(this.scene,this.camera,r,this.clear)}}),Jv.blurX=new f(.001953125,0),Jv.blurY=new f(0,.001953125);var Zv=function(e,t,r){Tv.call(this),this.scene=e,this.camera=t;var i=void 0!==r.focus?r.focus:1,n=void 0!==r.aspect?r.aspect:t.aspect,a=void 0!==r.aperture?r.aperture:.025,o=void 0!==r.maxblur?r.maxblur:1,s=r.width||Ds.innerWidth||1,l=r.height||Ds.innerHeight||1;this.renderTargetColor=new ge(s,l,{minFilter:rc,magFilter:rc,format:yc}),this.renderTargetColor.texture.name="BokehPass.color",this.renderTargetDepth=this.renderTargetColor.clone(),this.renderTargetDepth.texture.name="BokehPass.depth",this.materialDepth=new Se,this.materialDepth.depthPacking=mu,this.materialDepth.blending=nl,void 0===Cu&&console.error("BokehPass relies on BokehShader");var c=Cu,h=Mu.clone(c.uniforms);h.tDepth.value=this.renderTargetDepth.texture,h.focus.value=i,h.aspect.value=n,h.aperture.value=a,h.maxblur.value=o,h.nearClip.value=t.near,h.farClip.value=t.far,this.materialBokeh=new pe({defines:Object.assign({},c.defines),uniforms:h,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader}),this.uniforms=h,this.needsSwap=!1,this.camera2=new me((-1),1,1,(-1),0,1),this.scene2=new fe,this.quad2=new k(new xe(2,2),null),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2),this.oldClearColor=new u,this.oldClearAlpha=1};Zv.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Zv,render:function(e,t,r,i,n){this.quad2.material=this.materialBokeh,this.scene.overrideMaterial=this.materialDepth,this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();e.autoClear;e.autoClear=!1,e.setClearColor(16777215),e.setClearAlpha(1),e.render(this.scene,this.camera,this.renderTargetDepth,!0),this.uniforms.tColor.value=r.texture,this.uniforms.nearClip.value=this.camera.near,this.uniforms.farClip.value=this.camera.far,this.renderToScreen?e.render(this.scene2,this.camera2):e.render(this.scene2,this.camera2,t,this.clear),this.scene.overrideMaterial=null,e.setClearColor(this.oldClearColor),e.setClearAlpha(this.oldClearAlpha),e.autoClear=this.oldAutoClear}});var Kv=function(e,t){Tv.call(this),this.needsSwap=!1,this.clearColor=void 0!==e?e:0,this.clearAlpha=void 0!==t?t:0};Kv.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Kv,render:function(e,t,r,i,n){var a,o;this.clearColor&&(a=e.getClearColor().getHex(),o=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),e.setRenderTarget(this.renderToScreen?null:r),e.clear(),this.clearColor&&e.setClearColor(a,o)}});var $v=function(e,t,r){Tv.call(this),this.camera=e,this.needsSwap=!1,this.cubeShader=vp.cube,this.cubeMesh=new k(new le(10,10,10),new pe({uniforms:this.cubeShader.uniforms,vertexShader:this.cubeShader.vertexShader,fragmentShader:this.cubeShader.fragmentShader,depthTest:!1,depthWrite:!1,side:Zs})),this.envMap=t,this.opacity=void 0!==r?r:1,this.cubeScene=new fe,this.cubeCamera=new de,this.cubeScene.add(this.cubeMesh)};$v.prototype=Object.assign(Object.create(Tv.prototype),{constructor:$v,render:function(e,t,r,i,n){var a=e.autoClear;e.autoClear=!1,this.cubeCamera.projectionMatrix.copy(this.camera.projectionMatrix),this.cubeCamera.quaternion.setFromRotationMatrix(this.camera.matrixWorld),this.cubeMesh.material.uniforms.tCube.value=this.envMap,this.cubeMesh.material.uniforms.opacity.value=this.opacity,this.cubeMesh.material.transparent=this.opacity<1,e.render(this.cubeScene,this.cubeCamera,this.renderToScreen?null:r,this.clear),e.autoClear=a}});var eg={uniforms:{tDiffuse:{value:null},tSize:{value:new f(256,256)},center:{value:new f(.5,.5)},angle:{value:1.57},scale:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec2 center;","uniform float angle;","uniform float scale;","uniform vec2 tSize;","uniform sampler2D tDiffuse;","varying vec2 vUv;","float pattern() {","float s = sin( angle ), c = cos( angle );","vec2 tex = vUv * tSize - center;","vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;","return ( sin( point.x ) * sin( point.y ) ) * 4.0;","}","void main() {","vec4 color = texture2D( tDiffuse, vUv );","float average = ( color.r + color.g + color.b ) / 3.0;","gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );","}"].join("\n")},tg=function(e,t,r){Tv.call(this),void 0===eg&&console.error("DotScreenPass relies on DotScreenShader");var i=eg;this.uniforms=Mu.clone(i.uniforms),void 0!==e&&this.uniforms.center.value.copy(e),void 0!==t&&(this.uniforms.angle.value=t),void 0!==r&&(this.uniforms.scale.value=r),this.material=new pe({uniforms:this.uniforms,vertexShader:i.vertexShader,fragmentShader:i.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)};tg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:tg,render:function(e,t,r,i,n){this.uniforms.tDiffuse.value=r.texture,this.uniforms.tSize.value.set(r.width,r.height),this.quad.material=this.material,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)}});var rg=function(e,t){Tv.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1};rg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:rg,render:function(e,t,r,i,n){var a=e.context,o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);var s,l;this.inverse?(s=0,l=1):(s=1,l=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),o.buffers.stencil.setFunc(a.ALWAYS,s,4294967295),o.buffers.stencil.setClear(l),e.render(this.scene,this.camera,r,this.clear),e.render(this.scene,this.camera,t,this.clear),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.stencil.setFunc(a.EQUAL,1,4294967295),o.buffers.stencil.setOp(a.KEEP,a.KEEP,a.KEEP)}});var ig=function(){Tv.call(this),this.needsSwap=!1};ig.prototype=Object.create(Tv.prototype),Object.assign(ig.prototype,{render:function(e,t,r,i,n){e.state.buffers.stencil.setTest(!1)}});var ng=function(e,t){if(this.renderer=e,void 0===t){var r={minFilter:rc,magFilter:rc,format:xc,stencilBuffer:!1},i=e.getDrawingBufferSize();t=new ge(i.width,i.height,r),t.texture.name="EffectComposer.rt1"}this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.passes=[],void 0===Gv&&console.error("EffectComposer relies on CopyShader"),void 0===Ev&&console.error("EffectComposer relies on ShaderPass"),this.copyPass=new Ev(Gv)};Object.assign(ng.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},addPass:function(e){this.passes.push(e);var t=this.renderer.getDrawingBufferSize();e.setSize(t.width,t.height)},insertPass:function(e,t){this.passes.splice(t,0,e)},render:function(e){var t,r,i=this,n=!1,a=this.passes.length;for(r=0;r<a;r++)if(t=i.passes[r],t.enabled!==!1){if(t.render(i.renderer,i.writeBuffer,i.readBuffer,e,n),t.needsSwap){if(n){var o=i.renderer.context;o.stencilFunc(o.NOTEQUAL,1,4294967295),i.copyPass.render(i.renderer,i.writeBuffer,i.readBuffer,e),o.stencilFunc(o.EQUAL,1,4294967295)}i.swapBuffers()}void 0!==rg&&(t instanceof rg?n=!0:t instanceof ig&&(n=!1))}},reset:function(e){if(void 0===e){var t=this.renderer.getDrawingBufferSize();e=this.renderTarget1.clone(),e.setSize(t.width,t.height)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(e,t){var r=this;this.renderTarget1.setSize(e,t),this.renderTarget2.setSize(e,t);for(var i=0;i<this.passes.length;i++)r.passes[i].setSize(e,t)}});var ag={uniforms:{tDiffuse:{value:null},time:{value:0},nIntensity:{value:.5},sIntensity:{value:.05},sCount:{value:4096},grayscale:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","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.y<distortion_x+col_s && p.y>distortion_x-col_s*seed) {","if(seed_x>0.){","p.y = 1. - (p.y + distortion_y);","}","else {","p.y = distortion_y;","}","}","if(p.x<distortion_y+col_s && p.x>distortion_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<this.randX/5?(this.uniforms.amount.value=Math.random()/90,this.uniforms.angle.value=Fs.randFloat(-Math.PI,Math.PI),this.uniforms.distortion_x.value=Fs.randFloat(0,1),this.uniforms.distortion_y.value=Fs.randFloat(0,1),this.uniforms.seed_x.value=Fs.randFloat(-.3,.3),this.uniforms.seed_y.value=Fs.randFloat(-.3,.3)):0==this.goWild&&(this.uniforms.byp.value=1),this.curF++,this.quad.material=this.material,this.renderToScreen?e.render(this.scene,this.camera):e.render(this.scene,this.camera,t,this.clear)},generateTrigger:function(){this.randX=Fs.randInt(120,240)},generateHeightmap:function(e){for(var t=new Float32Array(e*e*3),r=e*e,i=0;i<r;i++){var n=Fs.randFloat(0,1);t[3*i+0]=n,t[3*i+1]=n,t[3*i+2]=n}var a=new Mt(t,e,e,yc,hc);return a.needsUpdate=!0,a}});var cg={uniforms:{tDiffuse:{value:null},shape:{value:1},radius:{value:4},rotateR:{value:Math.PI/12*1},rotateG:{value:Math.PI/12*2},rotateB:{value:Math.PI/12*3},scatter:{value:0},width:{value:1},height:{value:1},blending:{value:1},blendingMode:{value:1},greyscale:{value:!1},disable:{value:!1}},vertexShader:["varying vec2 vUV;","void main() {","vUV = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#define SQRT2_MINUS_ONE 0.41421356","#define SQRT2_HALF_MINUS_ONE 0.20710678","#define PI2 6.28318531","#define SHAPE_DOT 1","#define SHAPE_ELLIPSE 2","#define SHAPE_LINE 3","#define SHAPE_SQUARE 4","#define BLENDING_LINEAR 1","#define BLENDING_MULTIPLY 2","#define BLENDING_ADD 3","#define BLENDING_LIGHTER 4","#define BLENDING_DARKER 5","uniform sampler2D tDiffuse;","uniform float radius;","uniform float rotateR;","uniform float rotateG;","uniform float rotateB;","uniform float scatter;","uniform float width;","uniform float height;","uniform int shape;","uniform bool disable;","uniform float blending;","uniform int blendingMode;","varying vec2 vUV;","uniform bool greyscale;","const int samples = 8;","float blend( float a, float b, float t ) {","return a * ( 1.0 - t ) + b * t;","}","float hypot( float x, float y ) {","return sqrt( x * x + y * y );","}","float rand( vec2 seed ){","return fract( sin( dot( seed.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453 );","}","float distanceToDotRadius( float channel, vec2 coord, vec2 normal, vec2 p, float angle, float rad_max ) {","float dist = hypot( coord.x - p.x, coord.y - p.y );","float rad = channel;","if ( shape == SHAPE_DOT ) {","rad = pow( abs( rad ), 1.125 ) * rad_max;","} else if ( shape == SHAPE_ELLIPSE ) {","rad = pow( abs( rad ), 1.125 ) * rad_max;","if ( dist != 0.0 ) {","float dot_p = abs( ( p.x - coord.x ) / dist * normal.x + ( p.y - coord.y ) / dist * normal.y );","dist = ( dist * ( 1.0 - SQRT2_HALF_MINUS_ONE ) ) + dot_p * dist * SQRT2_MINUS_ONE;","}","} else if ( shape == SHAPE_LINE ) {","rad = pow( abs( rad ), 1.5) * rad_max;","float dot_p = ( p.x - coord.x ) * normal.x + ( p.y - coord.y ) * normal.y;","dist = hypot( normal.x * dot_p, normal.y * dot_p );","} else if ( shape == SHAPE_SQUARE ) {","float theta = atan( p.y - coord.y, p.x - coord.x ) - angle;","float sin_t = abs( sin( theta ) );","float cos_t = abs( cos( theta ) );","rad = pow( abs( rad ), 1.4 );","rad = rad_max * ( rad + ( ( sin_t > 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;i<this.selectedObjects.length;i++){var n=r.selectedObjects[i];n.traverse(t)}},changeVisibilityOfNonSelectedObjects:function(e){function t(e){e.isMesh&&n.push(e)}function r(t){if(t.isMesh||t.isLine||t.isSprite){for(var r=!1,i=0;i<n.length;i++){var a=n[i].id;if(a===t.id){r=!0;break}}if(!r){var o=t.visible;e&&!t.bVisible||(t.visible=e),t.bVisible=o}}}for(var i=this,n=[],a=0;a<this.selectedObjects.length;a++){var o=i.selectedObjects[a];o.traverse(t)}this.renderScene.traverse(r)},updateTextureMatrix:function(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)},render:function(e,t,r,i,n){if(this.selectedObjects.length>0){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 <packing>","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 <common>\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 <common>","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 <packing>","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 <common>","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 <common>","#include <packing>","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 <packing>","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<n.length;d++){var p=n[d];i.camera.setViewOffset&&i.camera.setViewOffset(u,h,.0625*p[0],.0625*p[1],u,h);var f=l;if(i.unbiased){var m=-.5+(d+.5)/n.length;f+=c*m}i.copyUniforms.opacity.value=f,e.setClearColor(i.clearColor,i.clearAlpha),e.render(i.scene,i.camera,i.sampleRenderTarget,!0),0===d&&e.setClearColor(0,0),e.render(i.scene2,i.camera2,i.renderToScreen?null:t,0===d)}this.camera.clearViewOffset&&this.camera.clearViewOffset(),e.autoClear=a,e.setClearColor(o,s)}}),wg.JitterVectors=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];var _g={uniforms:{tDiffuse:{value:null},tDepth:{value:null},size:{value:new f(512,512)},cameraNear:{value:1},cameraFar:{value:100},radius:{value:32},onlyAO:{value:0},aoClamp:{value:.25},lumInfluence:{value:.7}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float cameraNear;","uniform float cameraFar;","#ifdef USE_LOGDEPTHBUF","uniform float logDepthBufFC;","#endif","uniform float radius;","uniform bool onlyAO;","uniform vec2 size;","uniform float aoClamp;","uniform float lumInfluence;","uniform sampler2D tDiffuse;","uniform sampler2D tDepth;","varying vec2 vUv;","#define DL 2.399963229728653","#define EULER 2.718281828459045","const int samples = 64;","const bool useNoise = true;","const float noiseAmount = 0.0004;","const float diffArea = 0.4;","const float gDisplace = 0.4;","#include <packing>","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){this.copyUniforms.opacity.value=s,this.copyUniforms.tDiffuse.value=t.texture;for(var l=Math.pow(2,this.sampleLevel),c=0;c<l;c++){var u=n.accumulateIndex,h=a[u];if(n.camera.setViewOffset&&n.camera.setViewOffset(r.width,r.height,.0625*h[0],.0625*h[1],r.width,r.height),e.render(n.scene,n.camera,t,!0),e.render(n.scene2,n.camera2,n.sampleRenderTarget,0===n.accumulateIndex),n.accumulateIndex++,n.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<this.nMips;c++){var h=new ge(s,l,o);h.texture.name="UnrealBloomPass.h"+c,h.texture.generateMipmaps=!1,a.renderTargetsHorizontal.push(h);var h=new ge(s,l,o);h.texture.name="UnrealBloomPass.v"+c,h.texture.generateMipmaps=!1,a.renderTargetsVertical.push(h),s=Math.round(s/2),l=Math.round(l/2)}void 0===Tg&&console.error("UnrealBloomPass relies on LuminosityHighPassShader");var d=Tg;this.highPassUniforms=Mu.clone(d.uniforms),this.highPassUniforms.luminosityThreshold.value=n,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new pe({uniforms:this.highPassUniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,defines:{}}),this.separableBlurMaterials=[];for(var p=[3,5,7,9,11],s=Math.round(this.resolution.x/2),l=Math.round(this.resolution.y/2),c=0;c<this.nMips;c++)a.separableBlurMaterials.push(a.getSeperableBlurMaterial(p[c])),a.separableBlurMaterials[c].uniforms.texSize.value=new f(s,l),s=Math.round(s/2),l=Math.round(l/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;var m=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=m,this.bloomTintColors=[new i(1,1,1),new i(1,1,1),new i(1,1,1),new i(1,1,1),new i(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,void 0===Gv&&console.error("BloomPass relies on CopyShader");var v=Gv;this.copyUniforms=Mu.clone(v.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new pe({uniforms:this.copyUniforms,vertexShader:v.vertexShader,fragmentShader:v.fragmentShader,blending:ol,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.basic=new F,this.quad=new k(new xe(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)};Eg.prototype=Object.assign(Object.create(Tv.prototype),{constructor:Eg,dispose:function(){for(var e=this,t=0;t<this.renderTargetsHorizontal.length;t++)e.renderTargetsHorizontal[t].dispose();for(var t=0;t<this.renderTargetsVertical.length;t++)e.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose()},setSize:function(e,t){var r=this,i=Math.round(e/2),n=Math.round(t/2);this.renderTargetBright.setSize(i,n);for(var a=0;a<this.nMips;a++)r.renderTargetsHorizontal[a].setSize(i,n),r.renderTargetsVertical[a].setSize(i,n),r.separableBlurMaterials[a].uniforms.texSize.value=new f(i,n),i=Math.round(i/2),n=Math.round(n/2)},render:function(e,t,r,i,n){var a=this;this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var o=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),n&&e.context.disable(e.context.STENCIL_TEST),this.renderToScreen&&(this.quad.material=this.basic,this.basic.map=r.texture,e.render(this.scene,this.camera,void 0,!0)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.quad.material=this.materialHighPassFilter,e.render(this.scene,this.camera,this.renderTargetBright,!0);for(var s=this.renderTargetBright,l=0;l<this.nMips;l++)a.quad.material=a.separableBlurMaterials[l],a.separableBlurMaterials[l].uniforms.colorTexture.value=s.texture,a.separableBlurMaterials[l].uniforms.direction.value=Eg.BlurDirectionX,e.render(a.scene,a.camera,a.renderTargetsHorizontal[l],!0),a.separableBlurMaterials[l].uniforms.colorTexture.value=a.renderTargetsHorizontal[l].texture,a.separableBlurMaterials[l].uniforms.direction.value=Eg.BlurDirectionY,e.render(a.scene,a.camera,a.renderTargetsVertical[l],!0),s=a.renderTargetsVertical[l];this.quad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.render(this.scene,this.camera,this.renderTargetsHorizontal[0],!0),this.quad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,n&&e.context.enable(e.context.STENCIL_TEST),this.renderToScreen?e.render(this.scene,this.camera,void 0,!1):e.render(this.scene,this.camera,r,!1),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=o},getSeperableBlurMaterial:function(e){return new pe({defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new f(.5,.5)},direction:{value:new f(.5,.5)}},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 <common>\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(a<i)return!1}return!0},intersectsBox:function(){var e=new i;return function(t){for(var r=this.planes,i=0;i<6;i++){var n=r[i];if(e.x=n.normal.x>0?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<a;n++)e(i[n])}}function t(e){f=a(),f.id=e.id,f.object=e,j.setFromMatrixPosition(e.matrixWorld),j.applyMatrix4(Y),f.z=j.z,f.renderOrder=e.renderOrder,z.objects.push(f)}function n(e,t,r){var i=1/e.w;e.z*=i,e.z>=-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<r)&&(e.lerp(t,r),t.lerp(e,1-i),!0))}var f,g,y,x,b,w,_,S,A,M,T,E=[],C=0,L=[],N=0,O=[],D=0,F=[],R=0,I=[],U=0,z={objects:[],lights:[],elements:[]},j=new i,V=new v,G=new d(new i((-1),(-1),(-1)),new i(1,1,1)),W=new d,X=new Array(3),H=new r,Y=new r,q=new r,Q=new l,J=new In,Z=new v,K=new v;this.projectVector=function(e,t){console.warn("Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pickingRay=function(){console.error("Projector: .pickingRay() is now raycaster.setFromCamera().")};var $=function(){function e(e){x=e,w=x.material,S.getNormalMatrix(x.matrixWorld),m.length=0,v.length=0,g.length=0}function t(e){var t=e.position,r=e.positionWorld,i=e.positionScreen;r.copy(t).applyMatrix4(T),i.copy(r).applyMatrix4(Y);var n=1/i.w;i.x*=n,i.y*=n,i.z*=n,e.visible=i.x>=-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;u<d;u++){var f=l[u].object,v=f.geometry;if(ee.setObject(f),T=f.matrixWorld,x=0,f instanceof k){if(v instanceof P){var y=f.material,A=Array.isArray(y),E=v.attributes,C=v.groups;if(void 0===E.position)continue;for(var N=E.position.array,O=0,D=N.length;O<D;O+=3){var F=N[O],R=N[O+1],I=N[O+2];if(y.morphTargets===!0)for(var U=v.morphAttributes.position,G=f.morphTargetInfluences,W=0,X=U.length;W<X;W++){var $=G[W];if(0!==$){var te=U[W];F+=(te.getX(O/3)-N[O])*$,R+=(te.getY(O/3)-N[O+1])*$,I+=(te.getZ(O/3)-N[O+2])*$}}ee.pushVertex(F,R,I)}if(void 0!==E.normal)for(var re=E.normal.array,O=0,D=re.length;O<D;O+=3)ee.pushNormal(re[O],re[O+1],re[O+2]);if(void 0!==E.color)for(var ie=E.color.array,O=0,D=ie.length;O<D;O+=3)ee.pushColor(ie[O],ie[O+1],ie[O+2]);if(void 0!==E.uv)for(var ne=E.uv.array,O=0,D=ne.length;O<D;O+=2)ee.pushUv(ne[O],ne[O+1]);if(null!==v.index){var ae=v.index.array;if(C.length>0)for(var oe=0;oe<C.length;oe++){var se=C[oe];if(y=A===!0?f.material[se.materialIndex]:f.material,void 0!==y)for(var O=se.start,D=se.start+se.count;O<D;O+=3)ee.pushTriangle(ae[O],ae[O+1],ae[O+2],y)}else for(var O=0,D=ae.length;O<D;O+=3)ee.pushTriangle(ae[O],ae[O+1],ae[O+2],y)}else if(C.length>0)for(var oe=0;oe<C.length;oe++){var se=C[oe];if(y=A===!0?f.material[se.materialIndex]:f.material,void 0!==y)for(var O=se.start,D=se.start+se.count;O<D;O+=3)ee.pushTriangle(O,O+1,O+2,y)}else for(var O=0,D=N.length/3;O<D;O+=3)ee.pushTriangle(O,O+1,O+2,y)}else if(v instanceof m){var le=v.vertices,ce=v.faces,ue=v.faceVertexUvs[0];Q.getNormalMatrix(T);for(var y=f.material,A=Array.isArray(y),he=0,de=le.length;he<de;he++){var pe=le[he];if(j.copy(pe),y.morphTargets===!0)for(var U=v.morphTargets,G=f.morphTargetInfluences,W=0,X=U.length;W<X;W++){var $=G[W];if(0!==$){var te=U[W],fe=te.vertices[he];j.x+=(fe.x-pe.x)*$,j.y+=(fe.y-pe.y)*$,j.z+=(fe.z-pe.z)*$}}ee.pushVertex(j.x,j.y,j.z)}for(var me=0,ve=ce.length;me<ve;me++){var ge=ce[me];if(y=A===!0?f.material[ge.materialIndex]:f.material,void 0!==y){var ye=y.side,xe=L[ge.a],be=L[ge.b],we=L[ge.c];if(ee.checkTriangleVisibility(xe,be,we)!==!1){var _e=ee.checkBackfaceCulling(xe,be,we);if(ye!==Ks){if(ye===Js&&_e===!1)continue;if(ye===Zs&&_e===!0)continue}b=s(),b.id=f.id,b.v1.copy(xe),b.v2.copy(be),b.v3.copy(we),b.normalModel.copy(ge.normal),_e!==!1||ye!==Zs&&ye!==Ks||b.normalModel.negate(),b.normalModel.applyMatrix3(Q).normalize();for(var Se=ge.vertexNormals,Ae=0,Me=Math.min(Se.length,3);Ae<Me;Ae++){var Te=b.vertexNormalsModel[Ae];Te.copy(Se[Ae]),_e!==!1||ye!==Zs&&ye!==Ks||Te.negate(),Te.applyMatrix3(Q).normalize()}b.vertexNormalsLength=Se.length;var Ee=ue[me];if(void 0!==Ee)for(var Ce=0;Ce<3;Ce++)b.uvs[Ce].copy(Ee[Ce]);b.color=ge.color,b.material=y,b.z=(xe.positionScreen.z+be.positionScreen.z+we.positionScreen.z)/3,b.renderOrder=f.renderOrder,z.elements.push(b)}}}}}else if(f instanceof B){if(q.multiplyMatrices(Y,T),v instanceof P){var E=v.attributes;if(void 0!==E.position){for(var N=E.position.array,O=0,D=N.length;O<D;O+=3)ee.pushVertex(N[O],N[O+1],N[O+2]);if(void 0!==E.color)for(var ie=E.color.array,O=0,D=ie.length;O<D;O+=3)ee.pushColor(ie[O],ie[O+1],ie[O+2]);if(null!==v.index)for(var ae=v.index.array,O=0,D=ae.length;O<D;O+=2)ee.pushLine(ae[O],ae[O+1]);else for(var Le=f instanceof Yt?2:1,O=0,D=N.length/3-1;O<D;O+=Le)ee.pushLine(O,O+1)}}else if(v instanceof m){var le=f.geometry.vertices;if(0===le.length)continue;xe=o(),xe.positionScreen.copy(le[0]).applyMatrix4(q);for(var Le=f instanceof Yt?2:1,he=1,de=le.length;he<de;he++)xe=o(),xe.positionScreen.copy(le[he]).applyMatrix4(q),(he+1)%Le>0||(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;he<de;he++){var pe=le[he];V.set(pe.x,pe.y,pe.z,1),V.applyMatrix4(q),n(V,f,r)}else if(v instanceof P){
|
|
var E=v.attributes;if(void 0!==E.position)for(var N=E.position.array,O=0,D=N.length;O<D;O+=3)V.set(N[O],N[O+1],N[O+2],1),V.applyMatrix4(q),n(V,f,r)}}else f instanceof vi&&(V.set(T.elements[12],T.elements[13],T.elements[14],1),V.applyMatrix4(Y),n(V,f,r))}return a===!0&&z.elements.sort(h),z}},Rg=function(e){D.call(this),this.type="SpriteCanvasMaterial",this.color=new u(16777215),this.program=function(){},this.setValues(e)};Rg.prototype=Object.create(D.prototype),Rg.prototype.constructor=Rg,Rg.prototype.isSpriteCanvasMaterial=!0,Rg.prototype.clone=function(){var e=new Rg;return e.copy(this),e.color.copy(this.color),e.program=this.program,e};var Ig=function(e){function t(){xe.setRGB(0,0,0),be.setRGB(0,0,0),we.setRGB(0,0,0);for(var e=0,t=M.length;e<t;e++){var r=M[e],i=r.color;r.isAmbientLight?xe.add(i):r.isDirectionalLight?be.add(i):r.isPointLight&&we.add(i)}}function r(e,t,r){for(var i=0,n=M.length;i<n;i++){var a=M[i];if(fe.copy(a.color),a.isDirectionalLight){var o=_e.setFromMatrixPosition(a.matrixWorld).normalize(),s=t.dot(o);if(s<=0)continue;s*=a.intensity,r.add(fe.multiplyScalar(s))}else if(a.isPointLight){var o=_e.setFromMatrixPosition(a.matrixWorld),s=t.dot(_e.subVectors(o,e).normalize());if(s<=0)continue;if(s*=0==a.distance?1:1-Math.min(e.distanceTo(o)/a.distance,1),0==s)continue;s*=a.intensity,r.add(fe.multiplyScalar(s))}}}function n(e,t,r){m(r.opacity),v(r.blending);var i=t.scale.x*Y,n=t.scale.y*q,a=Math.sqrt(i*i+n*n);if(ye.min.set(e.x-a,e.y-a),ye.max.set(e.x+a,e.y+a),r.isSpriteMaterial){var o=r.map;if(null!==o){var s=me[o.id];if(void 0!==s&&s.version===o.version||(s=d(o),me[o.id]=s),void 0!==s.canvas){w(s.canvas);var l=o.image,c=l.width*o.offset.x,u=l.height*o.offset.y,h=l.width*o.repeat.x,p=l.height*o.repeat.y,f=i/h,g=n/p;ee.save(),ee.translate(e.x,e.y),0!==r.rotation&&ee.rotate(r.rotation),ee.translate(-i/2,-n/2),ee.scale(f,g),ee.translate(-c,-u),ee.fillRect(c,u,h,p),ee.restore()}}else w(r.color.getStyle()),ee.save(),ee.translate(e.x,e.y),0!==r.rotation&&ee.rotate(r.rotation),ee.scale(i,-n),ee.fillRect(-.5,-.5,1,1),ee.restore()}else r.isSpriteCanvasMaterial?(b(r.color.getStyle()),w(r.color.getStyle()),ee.save(),ee.translate(e.x,e.y),0!==r.rotation&&ee.rotate(r.rotation),ee.scale(i,n),r.program(ee),ee.restore()):r.isPointsMaterial&&(w(r.color.getStyle()),ee.save(),ee.translate(e.x,e.y),0!==r.rotation&&ee.rotate(r.rotation),ee.scale(i*r.size,-n*r.size),ee.fillRect(-.5,-.5,1,1),ee.restore())}function a(e,t,r,i){if(m(i.opacity),v(i.blending),ee.beginPath(),ee.moveTo(e.positionScreen.x,e.positionScreen.y),ee.lineTo(t.positionScreen.x,t.positionScreen.y),i.isLineBasicMaterial){if(g(i.linewidth),y(i.linecap),x(i.linejoin),i.vertexColors!==il)b(i.color.getStyle());else{var n=r.vertexColors[0].getStyle(),a=r.vertexColors[1].getStyle();if(n===a)b(n);else{try{var o=ee.createLinearGradient(e.positionScreen.x,e.positionScreen.y,t.positionScreen.x,t.positionScreen.y);o.addColorStop(0,n),o.addColorStop(1,a)}catch(s){o=n}b(o)}}i.isLineDashedMaterial&&_([i.dashSize,i.gapSize]),ee.stroke(),ye.expandByScalar(2*i.linewidth),i.isLineDashedMaterial&&_([])}}function o(e,t,i,n,a,o,l,u){if(V.info.render.vertices+=3,V.info.render.faces++,m(u.opacity),v(u.blending),L=e.positionScreen.x,P=e.positionScreen.y,N=t.positionScreen.x,O=t.positionScreen.y,D=i.positionScreen.x,F=i.positionScreen.y,s(L,P,N,O,D,F),(u.isMeshLambertMaterial||u.isMeshPhongMaterial||u.isMeshStandardMaterial)&&null===u.map)de.copy(u.color),pe.copy(u.emissive),u.vertexColors===rl&&de.multiply(l.color),he.copy(xe),Se.copy(e.positionWorld).add(t.positionWorld).add(i.positionWorld).divideScalar(3),r(Se,l.normalModel,he),he.multiply(de).add(pe),u.wireframe===!0?c(he,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):h(he);else if(u.isMeshBasicMaterial||u.isMeshLambertMaterial||u.isMeshPhongMaterial||u.isMeshStandardMaterial)if(null!==u.map){var d=u.map.mapping;d===Vl&&(R=l.uvs,p(L,P,N,O,D,F,R[n].x,R[n].y,R[a].x,R[a].y,R[o].x,R[o].y,u.map))}else null!==u.envMap?u.envMap.mapping===Yl&&(Ae.copy(l.vertexNormalsModel[n]).applyMatrix3(Me),I=.5*Ae.x+.5,U=.5*Ae.y+.5,Ae.copy(l.vertexNormalsModel[a]).applyMatrix3(Me),k=.5*Ae.x+.5,B=.5*Ae.y+.5,Ae.copy(l.vertexNormalsModel[o]).applyMatrix3(Me),z=.5*Ae.x+.5,j=.5*Ae.y+.5,p(L,P,N,O,D,F,I,U,k,B,z,j,u.envMap)):(he.copy(u.color),u.vertexColors===rl&&he.multiply(l.color),u.wireframe===!0?c(he,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):h(he));else u.isMeshNormalMaterial?(Ae.copy(l.normalModel).applyMatrix3(Me),he.setRGB(Ae.x,Ae.y,Ae.z).multiplyScalar(.5).addScalar(.5),u.wireframe===!0?c(he,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):h(he)):(he.setRGB(1,1,1),u.wireframe===!0?c(he,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):h(he))}function s(e,t,r,i,n,a){ee.beginPath(),ee.moveTo(e,t),ee.lineTo(r,i),ee.lineTo(n,a),ee.closePath()}function c(e,t,r,i){g(t),y(r),x(i),b(e.getStyle()),ee.stroke(),ye.expandByScalar(2*t)}function h(e){w(e.getStyle()),ee.fill()}function d(e){if(0===e.version||e instanceof qt||e instanceof Mt)return{canvas:void 0,version:e.version};var t=e.image;if(t.complete===!1)return{canvas:void 0,version:0};var r=e.wrapS===Jl||e.wrapS===Kl,i=e.wrapT===Jl||e.wrapT===Kl,n=e.wrapS===Kl,a=e.wrapT===Kl,o=document.createElement("canvas");o.width=t.width*(n?2:1),o.height=t.height*(a?2:1);var s=o.getContext("2d");s.setTransform(1,0,0,-1,0,t.height),s.drawImage(t,0,0),n===!0&&(s.setTransform(-1,0,0,-1,t.width,t.height),s.drawImage(t,-t.width,0)),a===!0&&(s.setTransform(1,0,0,1,0,0),s.drawImage(t,0,t.height)),n===!0&&a===!0&&(s.setTransform(-1,0,0,1,t.width,0),s.drawImage(t,-t.width,t.height));var l="no-repeat";r===!0&&i===!0?l="repeat":r===!0?l="repeat-x":i===!0&&(l="repeat-y");var c=ee.createPattern(o,l);return e.onUpdate&&e.onUpdate(e),{canvas:c,version:e.version}}function p(e,t,r,i,n,a,o,s,l,c,u,h,p){var f=me[p.id];if(void 0!==f&&f.version===p.version||(f=d(p),me[p.id]=f),void 0===f.canvas)return w("rgba( 0, 0, 0, 1)"),void ee.fill();w(f.canvas);var m,v,g,y,x,b,_,S,A=p.offset.x/p.repeat.x,M=p.offset.y/p.repeat.y,T=p.image.width*p.repeat.x,E=p.image.height*p.repeat.y;o=(o+A)*T,s=(s+M)*E,l=(l+A)*T,c=(c+M)*E,u=(u+A)*T,h=(h+M)*E,r-=e,i-=t,n-=e,a-=t,l-=o,c-=s,u-=o,h-=s,_=l*h-u*c,0!==_&&(S=1/_,m=(h*r-c*n)*S,v=(h*i-c*a)*S,g=(l*n-u*r)*S,y=(l*a-u*i)*S,x=e-m*o-g*s,b=t-v*o-y*s,ee.save(),ee.transform(m,v,g,y,x,b),ee.fill(),ee.restore())}function f(e,t,r){var i,n=t.x-e.x,a=t.y-e.y,o=n*n+a*a;0!==o&&(i=r/Math.sqrt(o),n*=i,a*=i,t.x+=n,t.y+=a,e.x-=n,e.y-=a)}function m(e){ie!==e&&(ee.globalAlpha=e,ie=e)}function v(e){ne!==e&&(e===al?ee.globalCompositeOperation="source-over":e===ol?ee.globalCompositeOperation="lighter":e===sl?ee.globalCompositeOperation="darker":e===ll&&(ee.globalCompositeOperation="multiply"),ne=e)}function g(e){se!==e&&(ee.lineWidth=e,se=e)}function y(e){le!==e&&(ee.lineCap=e,le=e)}function x(e){ce!==e&&(ee.lineJoin=e,ce=e)}function b(e){ae!==e&&(ee.strokeStyle=e,ae=e)}function w(e){oe!==e&&(ee.fillStyle=e,oe=e)}function _(e){ue.length!==e.length&&(ee.setLineDash(e),ue=e)}console.log("CanvasRenderer",Bs),e=e||{};var S,A,M,T,E,C,L,P,N,O,D,F,R,I,U,k,B,z,j,V=this,G=new Fg,W=void 0!==e.canvas?e.canvas:document.createElement("canvas"),X=W.width,H=W.height,Y=Math.floor(X/2),q=Math.floor(H/2),Q=0,J=0,Z=X,K=H,$=1,ee=W.getContext("2d",{alpha:e.alpha===!0}),te=new u(0),re=e.alpha===!0?0:1,ie=1,ne=0,ae=null,oe=null,se=null,le=null,ce=null,ue=[],he=new u,de=new u,pe=new u,fe=new u,me={},ve=new Tn,ge=new Tn,ye=new Tn,xe=new u,be=new u,we=new u,_e=new i,Se=new i,Ae=new i,Me=new l;void 0===ee.setLineDash&&(ee.setLineDash=function(){}),this.domElement=W,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.info={render:{vertices:0,faces:0}},this.getContext=function(){return ee},this.getContextAttributes=function(){return ee.getContextAttributes()},this.getPixelRatio=function(){return $},this.setPixelRatio=function(e){void 0!==e&&($=e)},this.setSize=function(e,t,r){X=e*$,H=t*$,W.width=X,W.height=H,Y=Math.floor(X/2),q=Math.floor(H/2),r!==!1&&(W.style.width=e+"px",W.style.height=t+"px"),ve.min.set(-Y,-q),ve.max.set(Y,q),ge.min.set(-Y,-q),ge.max.set(Y,q),ie=1,ne=0,ae=null,oe=null,se=null,le=null,ce=null,this.setViewport(0,0,e,t)},this.setViewport=function(e,t,r,i){Q=e*$,J=t*$,Z=r*$,K=i*$},this.setScissor=function(){},this.setScissorTest=function(){},this.setClearColor=function(e,t){te.set(e),re=void 0!==t?t:1,ge.min.set(-Y,-q),ge.max.set(Y,q)},this.setClearColorHex=function(e,t){console.warn("CanvasRenderer: .setClearColorHex() is being removed. Use .setClearColor() instead."),this.setClearColor(e,t)},this.getClearColor=function(){return te},this.getClearAlpha=function(){return re},this.getMaxAnisotropy=function(){return 0},this.clear=function(){ge.isEmpty()===!1&&(ge.intersect(ve),ge.expandByScalar(2),ge.min.x=ge.min.x+Y,ge.min.y=-ge.min.y+q,ge.max.x=ge.max.x+Y,ge.max.y=-ge.max.y+q,re<1&&ee.clearRect(0|ge.min.x,0|ge.max.y,ge.max.x-ge.min.x|0,ge.min.y-ge.max.y|0),re>0&&(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;s<l;s++){var c=A[s],u=c.material;if(void 0!==u&&0!==u.opacity){if(ye.makeEmpty(),c instanceof Dg)T=c,T.x*=Y,T.y*=q,n(T,c,u);else if(c instanceof Og)T=c.v1,E=c.v2,T.positionScreen.x*=Y,T.positionScreen.y*=q,E.positionScreen.x*=Y,E.positionScreen.y*=q,ye.setFromPoints([T.positionScreen,E.positionScreen]),ve.intersectsBox(ye)===!0&&a(T,E,c,u);else if(c instanceof Pg){if(T=c.v1,E=c.v2,C=c.v3,T.positionScreen.z<-1||T.positionScreen.z>1)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;p<f;p++)h(e.children[p],t)},d=function(){var e=new i,t=new i;return function(r,i){return e.setFromMatrixPosition(r.matrixWorld),t.setFromMatrixPosition(i.matrixWorld),e.distanceToSquared(t)}}(),p=function(e){var t=[];return e.traverse(function(e){e instanceof Ug&&t.push(e)}),t},f=function(e){for(var t=p(e).sort(function(e,t){var r=c.objects.get(e).distanceToCameraSquared,i=c.objects.get(t).distanceToCameraSquared;return r-i}),r=t.length,i=0,n=t.length;i<n;i++)t[i].element.style.zIndex=r-i};this.render=function(e,t){e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),s.copy(t.matrixWorldInverse),l.multiplyMatrices(t.projectionMatrix,s),h(e,t),f(e)}},Bg=function(e){c.call(this),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",function(){null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)})};Bg.prototype=Object.create(c.prototype),Bg.prototype.constructor=Bg;var zg=function(e){Bg.call(this,e)};zg.prototype=Object.create(Bg.prototype),zg.prototype.constructor=zg;var jg=function(){function e(e){return Math.abs(e)<1e-10?0:e}function t(t){var r=t.elements;return"matrix3d("+e(r[0])+","+e(-r[1])+","+e(r[2])+","+e(r[3])+","+e(r[4])+","+e(-r[5])+","+e(r[6])+","+e(r[7])+","+e(r[8])+","+e(-r[9])+","+e(r[10])+","+e(r[11])+","+e(r[12])+","+e(-r[13])+","+e(r[14])+","+e(r[15])+")"}function n(t,r){var i=t.elements,n="matrix3d("+e(i[0])+","+e(i[1])+","+e(i[2])+","+e(i[3])+","+e(-i[4])+","+e(-i[5])+","+e(-i[6])+","+e(-i[7])+","+e(i[8])+","+e(i[9])+","+e(i[10])+","+e(i[11])+","+e(i[12])+","+e(i[13])+","+e(i[14])+","+e(i[15])+")";return v?"translate(-50%,-50%)translate("+u+"px,"+h+"px)"+r+n:"translate(-50%,-50%)"+n}function a(e,t,r){if(e instanceof Bg){var i;e instanceof zg?(d.copy(t.matrixWorldInverse),d.transpose(),d.copyPosition(e.matrixWorld),d.scale(e.scale),d.elements[3]=0,d.elements[7]=0,d.elements[11]=0,d.elements[15]=1,i=n(d,r)):i=n(e.matrixWorld,r);var o=e.element,s=p.objects.get(e);if(void 0===s||s!==i){o.style.WebkitTransform=i,o.style.transform=i;var l={style:i};v&&(l.distanceToCameraSquared=g(t,e)),p.objects.set(e,l)}o.parentNode!==m&&m.appendChild(o)}for(var c=0,u=e.children.length;c<u;c++)a(e.children[c],t,r)}function o(e){var t=[];return e.traverse(function(e){e instanceof Bg&&t.push(e)}),t}function s(e){for(var t=o(e).sort(function(e,t){var r=p.objects.get(e).distanceToCameraSquared,i=p.objects.get(t).distanceToCameraSquared;return r-i}),r=t.length,i=0,n=t.length;i<n;i++)t[i].element.style.zIndex=r-i}console.log("CSS3DRenderer",Bs);var l,c,u,h,d=new r,p={camera:{fov:0,style:""},objects:new WeakMap},f=document.createElement("div");f.style.overflow="hidden",this.domElement=f;var m=document.createElement("div");m.style.WebkitTransformStyle="preserve-3d",m.style.transformStyle="preserve-3d",f.appendChild(m);var v=/Trident/i.test(navigator.userAgent);this.getSize=function(){return{width:l,height:c}},this.setSize=function(e,t){l=e,c=t,u=l/2,h=c/2,f.style.width=e+"px",f.style.height=t+"px",m.style.width=e+"px",m.style.height=t+"px"};var g=function(){var e=new i,t=new i;return function(r,i){return e.setFromMatrixPosition(r.matrixWorld),t.setFromMatrixPosition(i.matrixWorld),e.distanceToSquared(t)}}();this.render=function(e,r){var i=r.projectionMatrix.elements[5]*h;p.camera.fov!==i&&(r.isPerspectiveCamera&&(f.style.WebkitPerspective=i+"px",f.style.perspective=i+"px"),p.camera.fov=i),e.updateMatrixWorld(),null===r.parent&&r.updateMatrixWorld();var n=r.isOrthographicCamera?"scale("+i+")"+t(r.matrixWorldInverse):"translateZ("+i+"px)"+t(r.matrixWorldInverse),o=n+"translate("+u+"px,"+h+"px)";p.camera.style===o||v||(m.style.WebkitTransform=o,m.style.transform=o,p.camera.style=o),a(e,r,n),v&&s(e)}},Vg=function(e){function t(e){e.postMessage({init:[n,a],worker:e.id,blockSize:f})}function r(e){if(!m.length)return l=!1,o.dispatchEvent({type:"complete"});var t=m.pop(),r=t%x*f,i=(t/x|0)*f;e.postMessage({render:!0,x:r,y:i,sceneId:g}),h.fillStyle="#"+e.color,h.fillRect(r,i,f,f)}function i(e){var t=e.material;if(t&&!(t.uuid in A)){var r={};for(var i in M)void 0!==t[i]&&(r[i]=t[i]);A[t.uuid]=r}}console.log("RaytracingRenderer",Bs),e=e||{};var n,a,o=this,s=[],l=!1,c=document.createElement("canvas"),h=c.getContext("2d",{alpha:e.alpha===!0}),d=new u(0);this.domElement=c,this.autoClear=!0;var p=e.workers,f=e.blockSize||64;this.randomize=e.randomize;var m=[],v=0,g=0;console.log("%cSpinning off "+p+" Workers ","font-size: 20px; background: black; color: white; font-family: monospace;"),this.setWorkers=function(i){for(p=i||navigator.hardwareConcurrency||4;s.length<p;){var n=new Worker(e.workerPath);n.id=v++,n.onmessage=function(e){var t=e.data;if(t&&t.blockSize&&g==t.sceneId){var i=new ImageData(new Uint8ClampedArray(t.data),t.blockSize,t.blockSize);if(h.putImageData(i,t.blockX,t.blockY),console.log("Worker "+this.id,t.time/1e3,(Date.now()-S)/1e3+" s"),s.length>p)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;c<y;c++)m.push(c);if(o.randomize)for(var c=0;c<y;c++){var u=Math.random()*y|0,d=m[u];m[u]=m[c],m[c]=d}s.forEach(r)}};Object.assign(Vg.prototype,a.prototype);var Gg=function(e){function t(){return e.alpha===!0?k:1}function r(e){for(var r=p*m*4,i=0;i<r;i+=4)T[i]=255*e.r|0,T[i+1]=255*e.g|0,T[i+2]=255*e.b|0,T[i+3]=255*t()|0;O.fillStyle="rgba("+(255*U.r|0)+","+(255*U.g|0)+","+(255*U.b|0)+","+t()+")",O.fillRect(0,0,p,m)}function n(e,t){var r=0,i=0,n=255*e.color.r,a=255*e.color.g,o=255*e.color.b,s=new Uint8Array(768);if(t){for(;r<204;)s[i++]=Math.min(r*n/204,255),s[i++]=Math.min(r*a/204,255),s[i++]=Math.min(r*o/204,255),++r;for(;r<256;)s[i++]=Math.min(n+(r-204)*(255-n)/82,255),s[i++]=Math.min(a+(r-204)*(255-a)/82,255),s[i++]=Math.min(o+(r-204)*(255-o)/82,255),++r}else for(;r<256;)s[i++]=Math.min(r*n/255,255),s[i++]=Math.min(r*a/255,255),s[i++]=Math.min(r*o/255,255),++r;return s}function a(e,t,r,i,n,a,o,s,l){var c=4*r,u=I[l.map.id];if(u.data){var h=u.width,d=l.transparent,p=h-1,f=u.data,m=4*((a*h&p)*h+(n*h&p));if(d){var v=f[m],g=f[m+1],y=f[m+2],x=f[m+3]*l.opacity/255,b=e[c],w=e[c+1],_=e[c+2];e[c]=v*x+b*(1-x),e[c+1]=g*x+w*(1-x),e[c+2]=y*x+_*(1-x),e[c+3]=(l.opacity<<8)-1,255==e[c+3]&&(t[r]=i)}else e[c]=f[m],e[c+1]=f[m+1],e[c+2]=f[m+2],e[c+3]=(l.opacity<<8)-1,t[r]=i}}function o(e,t,r,i,n,a,o,s,l){var c=4*r,u=I[l.map.id];if(u.data){var h=u.width,d=l.transparent,p=3*(o>0?~~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<<j,y=e.x*x+_|0,M=t.x*x+_|0,C=r.x*x+_|0,N=e.y*b+S|0,O=t.y*b+S|0,D=r.y*b+S|0,F=c.vertexNormalsModel&&c.vertexNormalsModel.length,R=n&&a&&o,I=Math.max(Math.sqrt((y-M)*(y-M)+(N-O)*(N-O)),Math.sqrt((M-C)*(M-C)+(O-D)*(O-D)),Math.sqrt((C-y)*(C-y)+(D-N)*(D-N)));if(!(c instanceof Dg)&&I>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<<j,Ue=De<<j,ke=Te*(Ie-y)+Me*(Ue-N),Be=Ce*(Ie-M)+Ee*(Ue-O),ze=Pe*(Ie-C)+Le*(Ue-D);(Te>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<Fe;Nt+=Re){for(;Pt>=Ne&&Pt<Oe&&bt>=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<Ne||Pt>=Oe)break;if(bt<ut){if(Mt<0)break}else if(wt<dt){if(Tt<0)break}else if(_t<ft){if(Et<0)break}else{var Ot=Pt>>G,Dt=Nt>>G,Ft=Ot+Dt*g,Rt=St+mt;if(!(L[Ft]<Rt)){var It=P[Ft];It&z&&h(Ot,Dt),P[Ft]=It&~(B|z);var Ut=Pt+Nt*p;if(bt>=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<Re;Xt++){var Ht,Yt,qt=jt,Qt=Vt,Jt=Gt;R&&(Ht=Bt,Yt=zt);var Zt;F&&(Zt=Wt);for(var Kt=0;Kt<Re;Kt++){var $t=Jt;$t<E[Ut]&&s(T,E,Ut,$t,Ht,Yt,Zt,c,u),qt+=Te,Qt+=Ce,Jt+=We,R&&(Ht+=$e,Yt+=Ye),F&&(Zt+=st),Ut++}jt+=Me,Vt+=Ee,Gt+=Xe,R&&(Bt+=et,zt+=qe),F&&(Wt+=it),Ut+=xt}}else{var Bt,zt,jt=bt,Vt=wt,er=_t,Gt=St;R&&(Bt=Qe,zt=Je);var Wt;F&&(Wt=nt);for(var Xt=0;Xt<Re;Xt++){var Ht,Yt,qt=jt,Qt=Vt,tr=er,Jt=Gt;R&&(Ht=Bt,Yt=zt);var Zt;F&&(Zt=Wt);for(var Kt=0;Kt<Re;Kt++){if((qt|Qt|tr)>=0){var $t=Jt;$t<E[Ut]&&s(T,E,Ut,$t,Ht,Yt,Zt,c,u)}qt+=Te,Qt+=Ce,tr+=Pe,Jt+=We,R&&(Ht+=$e,Yt+=Ye),F&&(Zt+=st),Ut++}jt+=Me,Vt+=Ee,er+=Le,Gt+=Xe,R&&(Bt+=et,zt+=qe),F&&(Wt+=it),Ut+=xt}}}}}bt+=Re*Me,wt+=Re*Ee,_t+=Re*Le,St+=Re*Xe,R&&(Qe+=Re*et,Je+=Re*qe),F&&(nt+=Re*it)}}}function c(e,t,r,i,n,a){if(H||(H=!0,G=0,W=1<<G,ve.setSize(N.width,N.height)),!(e.z<-1||e.z>1||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]<R)){L[ce]=Math.min(L[ce],I);var ue=P[ce];ue&z&&h(se,le),P[ce]=ue&~(B|z);var he=$+ee*p;te<E[he]&&n(T,E,he,te,r,i,a)}}--re}}}function h(e,r){for(var i=e*W+r*W*p,n=4*i,a=p-W,o=4*a,s=0;s<W;s++){for(var l=0;l<W;l++)E[i++]=X,T[n++]=255*U.r|0,T[n++]=255*U.g|0,T[n++]=255*U.b|0,T[n++]=255*t()|0;i+=a,n+=o}}function d(){for(var e=0,t=0;t<y;t++)for(var r=0;r<g;r++)P[e]&z&&(h(r,t),P[e]=B),e++}console.log("SoftwareRenderer",Bs),e=e||{};var p,m,g,y,x,b,w,_,S,A,M,T,E,C,L,P,N=void 0!==e.canvas?e.canvas:document.createElement("canvas"),O=N.getContext("2d",{alpha:e.alpha===!0}),D={},I={},U=new u(0),k=e.alpha===!0?0:1,B=1,z=2,j=4,V=(1<<j)-1,G=3,W=1<<G,X=1<<24,H=!1,Y=new i(0,0,1),q=new i,Q=1/0,J=1/0,Z=0,K=0,$=1/0,ee=1/0,te=0,re=0,ie=new Fg,ne=new v,ae=new v,oe=new v,se=new f,le=new f,ce=new f,ue=[],he=0,de=[],pe=0,fe=[],me=0,ve=this;this.domElement=N,this.autoClear=!0,this.setClearColor=function(e,t){U.set(e),k=t,r(U)},this.setPixelRatio=function(){},this.setSize=function(e,t){g=Math.floor(e/W),y=Math.floor(t/W),p=g*W,m=y*W;var i=1<<j;x=i*p/2,b=-i*m/2,w=X/2,_=i*p/2+.5,S=i*m/2+.5,A=X/2+.5,N.width=p,N.height=m,M=O.getImageData(0,0,p,m),T=M.data,E=new Int32Array(T.length/4),C=g*y,L=new Int32Array(C),P=new Uint8Array(C);for(var n=0,a=E.length;n<a;n++)E[n]=X;for(var n=0;n<C;n++)P[n]=B;r(U)},this.clear=function(){Q=1/0,J=1/0,Z=0,K=0,he=0,pe=0,me=0;for(var e=0;e<C;e++)L[e]=X,P[e]=P[e]&B?B:z},this.render=function(e,t){this.clear();var i=e.background;i&&i.isColor&&r(i);for(var n=ie.projectScene(e,t,!1,!1),a=n.elements,o=0,u=a.length;o<u;o++){var h=a[o],p=h.material,f=s(p);if(f)if(h instanceof Pg)h.uvs?l(h.v1.positionScreen,h.v2.positionScreen,h.v3.positionScreen,h.uvs[0],h.uvs[1],h.uvs[2],f,h,p):l(h.v1.positionScreen,h.v2.positionScreen,h.v3.positionScreen,null,null,null,f,h,p);else if(h instanceof Dg){var m=.5*h.scale.x,v=.5*h.scale.y;ne.copy(h),ne.x-=m,ne.y+=v,ae.copy(h),ae.x-=m,ae.y-=v,oe.copy(h),oe.x+=m,oe.y+=v,p.map?(se.set(0,1),le.set(0,0),ce.set(1,1),l(ne,ae,oe,se,le,ce,f,h,p)):l(ne,ae,oe,null,null,null,f,h,p),ne.copy(h),ne.x+=m,ne.y+=v,ae.copy(h),ae.x-=m,ae.y-=v,oe.copy(h),oe.x+=m,oe.y-=v,p.map?(se.set(1,1),le.set(0,0),ce.set(1,0),l(ne,ae,oe,se,le,ce,f,h,p)):l(ne,ae,oe,null,null,null,f,h,p)}else if(h instanceof Og){var f=s(p);c(h.v1.positionScreen,h.v2.positionScreen,h.vertexColors[0],h.vertexColors[1],f,p)}}d();var g=Math.min(Q,$),y=Math.min(J,ee),x=Math.max(Z,te)-g,b=Math.max(K,re)-y;g!==1/0&&O.putImageData(M,0,0,g,y,x,b),$=Q,ee=J,te=Z,re=K}};Gg.Texture=function(){var e;this.fromImage=function(t){if(!(!t||t.width<=0||t.height<=0)){void 0===e&&(e=document.createElement("canvas"));var r=t.width>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;t<r;t++){var i=e[t],n=i.color;i.isAmbientLight?(R.r+=n.r,R.g+=n.g,R.b+=n.b):i.isDirectionalLight?(I.r+=n.r,I.g+=n.g,I.b+=n.b):i.isPointLight&&(U.r+=n.r,U.g+=n.g,U.b+=n.b)}}function o(e,t,r,i){for(var n=0,a=e.length;n<a;n++){var o=e[n],s=o.color;if(o.isDirectionalLight){var l=z.setFromMatrixPosition(o.matrixWorld).normalize(),c=r.dot(l);if(c<=0)continue;c*=o.intensity,i.r+=s.r*c,i.g+=s.g*c,i.b+=s.b*c}else if(o.isPointLight){var l=z.setFromMatrixPosition(o.matrixWorld),c=r.dot(z.subVectors(l,t).normalize());if(c<=0)continue;if(c*=0==o.distance?1:1-Math.min(t.distanceTo(l)/o.distance,1),0==c)continue;c*=o.intensity,i.r+=s.r*c,i.g+=s.g*c,i.b+=s.b*c}}}function s(e,r,i){var a=r.scale.x*b,o=r.scale.y*w;i.isPointsMaterial&&(a*=i.size,o*=i.size);var s="M"+n(e.x-.5*a)+","+n(e.y-.5*o)+"h"+n(a)+"v"+n(o)+"h"+n(-a)+"z",l="";(i.isSpriteMaterial||i.isPointsMaterial)&&(l="fill:"+t(i.color,i.opacity)),d(l,s)}function c(e,r,i,a){var o="M"+n(e.positionScreen.x)+","+n(e.positionScreen.y)+"L"+n(r.positionScreen.x)+","+n(r.positionScreen.y);if(a.isLineBasicMaterial){var s="fill:none;stroke:"+t(a.color,a.opacity)+";stroke-width:"+a.linewidth+";stroke-linecap:"+a.linecap;a.isLineDashedMaterial&&(s=s+";stroke-dasharray:"+a.dashSize+","+a.gapSize),d(s,o)}}function h(e,r,i,a,s){C.info.render.vertices+=3,C.info.render.faces++;var l="M"+n(e.positionScreen.x)+","+n(e.positionScreen.y)+"L"+n(r.positionScreen.x)+","+n(r.positionScreen.y)+"L"+n(i.positionScreen.x)+","+n(i.positionScreen.y)+"z",c="";s.isMeshBasicMaterial?(D.copy(s.color),s.vertexColors===rl&&D.multiply(a.color)):s.isMeshLambertMaterial||s.isMeshPhongMaterial||s.isMeshStandardMaterial?(F.copy(s.color),
|
|
s.vertexColors===rl&&F.multiply(a.color),D.copy(R),j.copy(e.positionWorld).add(r.positionWorld).add(i.positionWorld).divideScalar(3),o(g,j,a.normalModel,D),D.multiply(F).add(s.emissive)):s.isMeshNormalMaterial&&(V.copy(a.normalModel).applyMatrix3(G),D.setRGB(V.x,V.y,V.z).multiplyScalar(.5).addScalar(.5)),c=s.wireframe?"fill:none;stroke:"+t(D,s.opacity)+";stroke-width:"+s.wireframeLinewidth+";stroke-linecap:"+s.wireframeLinecap+";stroke-linejoin:"+s.wireframeLinejoin:"fill:"+t(D,s.opacity),d(c,l)}function d(e,t){E===e?T+=t:(p(),E=e,T=t)}function p(){T&&(M=f(Y++),M.setAttribute("d",T),M.setAttribute("style",E),P.appendChild(M)),T="",E=""}function f(e){return null==H[e]?(H[e]=document.createElementNS("http://www.w3.org/2000/svg","path"),0==q&&H[e].setAttribute("shape-rendering","crispEdges"),H[e]):H[e]}console.log("SVGRenderer",Bs);var m,v,g,y,x,b,w,_,S,A,M,T,E,C=this,L=new Fg,P=document.createElementNS("http://www.w3.org/2000/svg","svg"),N=new Tn,O=new Tn,D=new u,F=new u,R=new u,I=new u,U=new u,k=new u,B=1,z=new i,j=new i,V=new i,G=new l,W=new r,X=new r,H=[],Y=0,q=1,Q=null;this.domElement=P,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.info={render:{vertices:0,faces:0}},this.setQuality=function(e){switch(e){case"high":q=1;break;case"low":q=0}},this.setClearColor=function(e,t){k.set(e),B=void 0!==t?t:1},this.setPixelRatio=function(){},this.setSize=function(e,t){y=e,x=t,b=y/2,w=x/2,P.setAttribute("viewBox",-b+" "+-w+" "+y+" "+x),P.setAttribute("width",y),P.setAttribute("height",x),N.min.set(-b,-w),N.max.set(b,w)},this.setPrecision=function(e){Q=e},this.clear=function(){e(),P.style.backgroundColor=t(k,B)},this.render=function(r,i){if(i instanceof he==!1)return void console.error("SVGRenderer.render: camera is not an instance of Camera.");var n=r.background;n&&n.isColor?(e(),P.style.backgroundColor=t(n)):this.autoClear===!0&&this.clear(),C.info.render.vertices=0,C.info.render.faces=0,W.copy(i.matrixWorldInverse),X.multiplyMatrices(i.projectionMatrix,W),m=L.projectScene(r,i,this.sortObjects,this.sortElements),v=m.elements,g=m.lights,G.getNormalMatrix(i.matrixWorldInverse),a(g),T="",E="";for(var o=0,l=v.length;o<l;o++){var u=v[o],d=u.material;if(void 0!==d&&0!==d.opacity)if(O.makeEmpty(),u instanceof Dg)_=u,_.x*=b,_.y*=-w,s(_,u,d);else if(u instanceof Og)_=u.v1,S=u.v2,_.positionScreen.x*=b,_.positionScreen.y*=-w,S.positionScreen.x*=b,S.positionScreen.y*=-w,O.setFromPoints([_.positionScreen,S.positionScreen]),N.intersectsBox(O)===!0&&c(_,S,u,d);else if(u instanceof Pg){if(_=u.v1,S=u.v2,A=u.v3,_.positionScreen.z<-1||_.positionScreen.z>1)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;i<n;i++)e.material[i]=t(e.material[i]);else e.material=t(e.material);e.onBeforeRender=r}}function d(e){if(void 0!==e.material)if(Array.isArray(e.material))for(var t=0,r=e.material.length;t<r;t++)e.material[t]=tt[e.material[t].uuid];else e.material=tt[e.material.uuid]}function p(e){h(e,f,g)}function f(e){return u(e,je?qe:Ye,m,v)}function m(e){var t=je?oy.normalDepthShininess:oy.normalDepth;return new pe({uniforms:Object.assign({},t.uniforms),fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,blending:nl})}function v(e,t){void 0!==t.skinning&&(e.skinning=t.skinning),void 0!==t.morphTargets&&(e.morphTargets=t.morphTargets),t.visible===!0?e.visible=!t.transparent:e.visible=!1}function g(e,t,r,i,n,a){if(je){var o=tt[n.uuid];void 0!==o&&void 0!==o.shininess&&(n.uniforms.shininess.value=o.shininess)}}function y(e){h(e,x,_)}function x(e){return u(e,Qe,b,w)}function b(e){var t=oy.color,r=new pe({uniforms:Object.assign({},t.uniforms),fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,blending:nl});return void 0!==e.map&&(r.map=e.map),r}function w(e,t){void 0!==t.map&&(e.map=t.map),void 0!==t.skinning&&(e.skinning=t.skinning),void 0!==t.morphTargets&&(e.morphTargets=t.morphTargets),t.visible===!0?e.visible=!t.transparent:e.visible=!1}function _(e,t,r,i,n,a){var o,s,l=tt[n.uuid],c=n.uniforms;l.isMeshBasicMaterial===!0?s=l.color:(o=l.color,s=l.emissive);var u=l.specular,h=l.shininess,d=l.map;void 0!==o&&c.diffuse.value.copy(o),void 0!==s&&c.emissive.value.copy(s),void 0!==u&&c.specular.value.copy(u),void 0!==h&&void 0!==c.shininess&&(c.shininess.value=h),void 0!==d&&(c.map.value=d)}function S(e){h(e,A,E)}function A(e){return e.transparent===!0?(tt[e.uuid]=e,e):u(e,Je,M,T)}function M(e){var t=oy.reconstruction,r=new pe({uniforms:Object.assign({},t.uniforms),fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,blending:nl});return void 0!==e.map&&(r.map=e.map),r}function T(e,t){w(e,t)}function E(e,t,r,i,n,a){if(n.transparent===!0){var o=rt[this.uuid];return void(o&&o.call(this,e,t,r,i,n,a))}_(e,t,r,i,n,a),n.uniforms.samplerLight.value=Ee.renderTarget2.texture}function C(e){if(void 0!==e.material)if(Array.isArray(e.material))for(var t=0,r=e.material.length;t<r;t++)void 0===it[e.material[t].uuid]&&(it[e.material[t].uuid]=e.material[t].visible,e.material[t].visible=e.material[t].transparent&&e.material[t].visible);else void 0===it[e.material.uuid]&&(it[e.material.uuid]=e.material.visible,e.material.visible=e.material.transparent&&e.material.visible)}function L(e){if(void 0!==e.material)if(Array.isArray(e.material))for(var t=0,r=e.material.length;t<r;t++)e.material[t].visible=it[e.material[t].uuid];else e.material.visible=it[e.material.uuid]}function P(){var e=oy.emissiveLight,t=new pe({uniforms:Object.assign({},e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,blending:nl,depthWrite:!1}),r=new xe(2,2),i=new k(r,t);return i.onBeforeRender=function(e,t,r,i,n,a){n.uniforms.samplerColor.value=be.renderTarget2.texture},i}function N(e){return e.isPointLight?z(e):e.isSpotLight?W(e):e.isDirectionalLight?Y(e):null}function D(e){return e.isPointLight?j():e.isSpotLight?X():e.isDirectionalLight?q():null}function F(e){var t=je?$e:Ke,r=t[e.uuid];return void 0===r&&(r=re(),r.material=D(e.userData.originalLight),t[e.uuid]=r),r.used=!0,r.material}function R(e){var t=e.userData.originalLight;t.isPointLight&&V(e)}function I(e,t){var r=new k(t,Ge);return r.userData.originalLight=e,r}function U(e){var t=new pe({uniforms:Object.assign({},e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,transparent:!0,blending:ol,depthWrite:!1});return je&&(t.premultipliedAlpha=!0),t}function B(e){je?e.samplerNormalDepthShininess.value=Te.renderTarget2.texture:(e.samplerNormalDepth.value=Te.renderTarget2.texture,e.samplerColor.value=be.renderTarget2.texture)}function z(e){var t=I(e,new O(1,16,8));return t.onBeforeRender=G,t}function j(){var e=je?oy.pointLightPre:oy.pointLight,t=U(e);return t.side=Zs,t.depthFunc=Nl,t}function V(e){var t=e.userData.originalLight,r=t.distance;r>0&&(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;t<r;t++)if(e.material[t].visible===!0&&e.material[t].transparent===!0){ze=!0;break}}else e.material.visible===!0&&e.material.transparent===!0&&(ze=!0)}function Z(e){void 0!==e.material&&(e.onBeforeRender=rt[e.uuid])}function K(e){if(e.isLight===!0){var t=Ze[e.uuid];void 0===t&&(t=re(),t.light=N(e),Ze[e.uuid]=t),t.used=!0;var r=t.light;if(null!==r){var i=e.isPointLight===!0?Ie:Ue,n=i.userData.lights;void 0===n[r.uuid]&&(i.add(r),n[r.uuid]={light:r,found:!0}),n[r.uuid].found=!0}}}function $(e){for(var t=e.userData.lights,r=Object.keys(t),i=0,n=r.length;i<n;i++){var a=r[i];if(t[a].found===!1)e.remove(t[a].light),delete t[a];else{var o=t[a].light;o.material=F(o),R(o),t[a].found=!1}}}function ee(e){var t=ay.commonUniforms;t.viewWidth.value=ve,t.viewHeight.value=ye,t.matProjInverse.value.getInverse(e.projectionMatrix)}function te(){je?(_e.renderToScreen=!1,_e.enabled=!1,Se.renderToScreen=!1,Se.enabled=!1,Be?(Oe.renderToScreen=!1,De.renderToScreen=!0,De.enabled=!0):(Oe.renderToScreen=!0,De.renderToScreen=!1,De.enabled=!1)):ze?Be?(Oe.renderToScreen=!1,_e.renderToScreen=!1,_e.enabled=!0,Se.renderToScreen=!1,Se.enabled=!1,De.renderToScreen=!0,De.enabled=!0):(Oe.renderToScreen=!1,_e.renderToScreen=!1,_e.enabled=!0,Se.renderToScreen=!0,Se.enabled=!0,De.renderToScreen=!1,De.enabled=!1):Be?(Oe.renderToScreen=!1,_e.renderToScreen=!1,_e.enabled=!1,Se.renderToScreen=!1,Se.enabled=!1,De.renderToScreen=!0,De.enabled=!0):(Oe.renderToScreen=!0,_e.renderToScreen=!1,_e.enabled=!1,Se.renderToScreen=!1,Se.enabled=!1,De.renderToScreen=!1,De.enabled=!1)}function re(){return{used:!0,keepAlive:Ve,count:0}}function ie(e){for(var t=Object.keys(e),r=0,i=t.length;r<i;r++){var n=t[r];e[n].used===!1?(e[n].count++,e[n].keepAlive===!1&&e[n].count>et&&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<i;r++){var n=t[r];e[n]=void 0}}function ae(){ie(Xe),ie(He),ie(Ye),ie(qe),ie(Qe),ie(Je),ie(Ke),ie($e),ie(Ze),ne(tt),ne(rt),ne(it)}function oe(e,t){e.traverse(p),Le.scene=e,Le.camera=t,ke.renderer.autoClearDepth=!0,ke.renderer.autoClearStencil=!0,de.enable(de.STENCIL_TEST),de.stencilFunc(de.ALWAYS,1,4294967295),de.stencilOp(de.REPLACE,de.REPLACE,de.REPLACE),Te.render(),e.traverse(d)}function se(e,t){e.traverse(y),we.scene=e,we.camera=t,ke.renderer.autoClearDepth=!1,ke.renderer.autoClearStencil=!1,de.stencilFunc(de.EQUAL,1,4294967295),de.stencilOp(de.KEEP,de.KEEP,de.KEEP),be.render(),e.traverse(d)}function le(e,t){e.traverse(K),$(Ie),$(Ue),Pe.scene=Ie,Pe.camera=t,Ne.scene=Ue,ke.renderer.autoClearDepth=!1,ke.renderer.autoClearStencil=!1,Ee.render(),de.disable(de.STENCIL_TEST)}function ce(e,t){e.traverse(K),$(Ie),$(Ue),Pe.scene=Ie,Pe.camera=t,Ne.scene=Ue,ke.renderer.autoClearDepth=!1,ke.renderer.autoClearStencil=!1,de.stencilFunc(de.EQUAL,1,4294967295),de.stencilOp(de.KEEP,de.KEEP,de.KEEP),Ee.render()}function ue(e,t){e.traverse(S),Me.scene=e,Me.camera=t,ke.renderer.autoClearDepth=!1,ke.renderer.autoClearStencil=!1,Ae.render(),de.disable(de.STENCIL_TEST),e.traverse(d)}function he(e,t){!je&&ze&&(e.traverse(C),e.traverse(Z),_e.scene=e,_e.camera=t),te(),ke.renderer.autoClearDepth=!1,ke.renderer.autoClearStencil=!1,Ce.render(),!je&&ze&&e.traverse(L)}e=e||{};var de,ve,ye,be,we,_e,Se,Ae,Me,Te,Ee,Ce,Le,Pe,Ne,Oe,De,Fe,Re,Ie,Ue,ke=this,Be=!1,ze=!1,je=!1,Ve=!1,Ge=new pe({visible:!1}),We=new i,Xe={},He={},Ye={},qe={},Qe={},Je={},Ze={},Ke={},$e={},et=60,tt={},rt={},it={};this.renderer=void 0,this.domElement=void 0,this.forwardRendering=!1,this.setSize=function(e,t){ve=e,ye=t,this.renderer.setSize(ve,ye),Te.setSize(ve,ye),be.setSize(ve,ye),Ee.setSize(ve,ye),Ae.setSize(ve,ye),Ce.setSize(ve,ye),Fe.image.width=ve,Fe.image.height=ye,Fe.needsUpdate=!0,De.uniforms.resolution.value.set(1/ve,1/ye)},this.setAntialias=function(e){Be=e},this.enableLightPrePass=function(e){je=e,Oe.uniforms.samplerResult.value=je?Ae.renderTarget2.texture:Ee.renderTarget2.texture},this.render=function(e,t){if(this.forwardRendering)return void this.renderer.render(e,t);var r=e.autoUpdate,i=this.renderer.autoClearColor,n=this.renderer.autoClearDepth,a=this.renderer.autoClearStencil;Re=t,c(e),e.autoUpdate=!1,e.updateMatrixWorld(),ze=!1,e.traverse(J),ee(t),oe(e,t),je?(ce(e,t),ue(e,t)):(se(e,t),le(e,t)),he(e,t),e.traverse(Z),ae(),e.autoUpdate=r,this.renderer.autoClearColor=i,this.renderer.autoClearDepth=n,this.renderer.autoClearStencil=a},t(e)},ny={packVector3:["float vec3_to_float( vec3 data ) {","\tconst float unit = 255.0/256.0;","\thighp float compressed = fract( data.x * unit ) + floor( data.y * unit * 255.0 ) + floor( data.z * unit * 255.0 ) * 255.0;","\treturn compressed;","}"].join("\n"),unpackFloat:["vec3 float_to_vec3( float data ) {","\tconst float unit = 255.0;","\tvec3 uncompressed;","\tuncompressed.x = fract( data );","\tfloat zInt = floor( data / unit );","\tuncompressed.z = fract( zInt / unit );","\tuncompressed.y = fract( floor( data - ( zInt * unit ) ) / unit );","\treturn uncompressed;","}"].join("\n"),packNormal:["vec2 normal_to_vec2( vec3 normal ) {","\treturn normal.xy / sqrt( normal.z * 8.0 + 8.0 ) + 0.5;","}"].join("\n"),unpackVector2:["vec3 vec2_to_normal( vec2 data ) {","\tvec2 fenc = data * 4.0 - 2.0;","\tfloat f = dot( fenc, fenc );","\tfloat g = sqrt( 1.0 - f / 4.0 );","\tvec3 normal;","\tnormal.xy = fenc * g;","\tnormal.z = 1.0 - f / 2.0;","\treturn normal;","}"].join("\n"),computeTextureCoord:["vec2 texCoord = gl_FragCoord.xy / vec2( viewWidth, viewHeight );"].join("\n"),packNormalDepth:["vec4 packedNormalDepth;","packedNormalDepth.xyz = normal * 0.5 + 0.5;","packedNormalDepth.w = position.z / position.w;"].join("\n"),unpackNormalDepth:["vec4 normalDepthMap = texture2D( samplerNormalDepth, texCoord );","float depth = normalDepthMap.w;","if ( depth == 0.0 ) discard;","vec3 normal = normalDepthMap.xyz * 2.0 - 1.0;"].join("\n"),packNormalDepthShininess:["vec4 packedNormalDepthShininess;","packedNormalDepthShininess.xy = normal_to_vec2( normal );","packedNormalDepthShininess.z = shininess;","packedNormalDepthShininess.w = position.z / position.w;"].join("\n"),unpackNormalDepthShininess:["vec4 normalDepthMap = texture2D( samplerNormalDepthShininess, texCoord );","float depth = normalDepthMap.w;","if ( depth == 0.0 ) discard;","vec3 normal = vec2_to_normal( normalDepthMap.xy );","float shininess = normalDepthMap.z;"].join("\n"),packColor:["vec4 packedColor;","packedColor.x = vec3_to_float( diffuseColor.rgb );","packedColor.y = vec3_to_float( emissiveColor );","packedColor.z = vec3_to_float( specularColor );","packedColor.w = shininess;"].join("\n"),unpackColor:["vec4 colorMap = texture2D( samplerColor, texCoord );","vec3 diffuseColor = float_to_vec3( colorMap.x );","vec3 emissiveColor = float_to_vec3( colorMap.y );","vec3 specularColor = float_to_vec3( colorMap.z );","float shininess = colorMap.w;"].join("\n"),packLight:["vec4 packedLight;","packedLight.xyz = lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * attenuation;","packedLight.w = lightIntensity * specular * max( dot( lightVector, normal ), 0.0 ) * attenuation;"].join("\n"),computeVertexPositionVS:["vec2 xy = texCoord * 2.0 - 1.0;","vec4 vertexPositionProjected = vec4( xy, depth, 1.0 );","vec4 vertexPositionVS = matProjInverse * vertexPositionProjected;","vertexPositionVS.xyz /= vertexPositionVS.w;","vertexPositionVS.w = 1.0;"].join("\n"),computeSpecular:["vec3 halfVector = normalize( lightVector - normalize( vertexPositionVS.xyz ) );","float dotNormalHalf = max( dot( normal, halfVector ), 0.0 );","float specular = 0.31830988618 * ( shininess * 0.5 + 1.0 ) * pow( dotNormalHalf, shininess );"].join("\n"),combine:["gl_FragColor = vec4( lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * ( diffuseColor + specular * specularColor ) * attenuation, 1.0 );"].join("\n")},ay={commonUniforms:{matProjInverse:new ho(new r),viewWidth:new ho(800),viewHeight:new ho(600)}},oy={normalDepth:{uniforms:{},vertexShader:["varying vec3 vNormal;","varying vec4 vPosition;","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","void main() {","#include <begin_vertex>","#include <beginnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","#include <defaultnormal_vertex>","#include <morphtarget_vertex>","#include <skinning_vertex>","#include <project_vertex>","\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 <uv_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","void main() {","#include <uv_vertex>","#include <begin_vertex>","#include <beginnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","#include <defaultnormal_vertex>","#include <morphtarget_vertex>","#include <skinning_vertex>","#include <project_vertex>","}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;","#include <uv_pars_fragment>","#include <map_pars_fragment>",ny.packVector3,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;","#include <map_fragment>",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 <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","void main() {","#include <begin_vertex>","#include <beginnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","#include <defaultnormal_vertex>","#include <morphtarget_vertex>","#include <skinning_vertex>","#include <project_vertex>","\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 <uv_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","void main() {","#include <uv_vertex>","#include <begin_vertex>","#include <beginnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","#include <defaultnormal_vertex>","#include <morphtarget_vertex>","#include <skinning_vertex>","#include <project_vertex>","}"].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 <uv_pars_fragment>","#include <map_pars_fragment>",ny.unpackFloat,"void main() {","\tvec4 diffuseColor = vec4( diffuse, 1.0 );","\tvec3 emissiveColor = emissive;","\tvec3 specularColor = specular;",ny.computeTextureCoord,"\tvec4 light = texture2D( samplerLight, texCoord );","#include <map_fragment>","\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 <common>","#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 <common>","#include <bsdfs>","#include <uv_pars_fragment>","#include <map_pars_fragment>","#include <lights_phong_pars_fragment>","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):A<M?(s=0,l=0,c=1,u=0,h=1,d=1):S<M?(s=0,l=1,c=0,u=0,h=1,d=1):(s=0,l=1,c=0,u=1,h=1,d=0);var T=S-s+y,E=A-l+y,C=M-c+y,L=S-u+2*y,P=A-h+2*y,N=M-d+2*y,O=S-1+3*y,D=A-1+3*y,F=M-1+3*y,R=255&m,I=255&v,U=255&g,k=this.perm[R+this.perm[I+this.perm[U]]]%12,B=this.perm[R+s+this.perm[I+l+this.perm[U+c]]]%12,z=this.perm[R+u+this.perm[I+h+this.perm[U+d]]]%12,j=this.perm[R+1+this.perm[I+1+this.perm[U+1]]]%12,V=.6-S*S-A*A-M*M;V<0?i=0:(V*=V,i=V*V*this.dot3(this.grad3[k],S,A,M));var G=.6-T*T-E*E-C*C;G<0?n=0:(G*=G,n=G*G*this.dot3(this.grad3[B],T,E,C));var W=.6-L*L-P*P-N*N;W<0?a=0:(W*=W,a=W*W*this.dot3(this.grad3[z],L,P,N));var X=.6-O*O-D*D-F*F;return X<0?o=0:(X*=X,o=X*X*this.dot3(this.grad3[j],O,D,F)),32*(i+n+a+o)},zy.prototype.noise4d=function(e,t,r,i){var n,a,o,s,l,c,u,h,d,p,f,m,v,g,y,x,b,w=this.grad4,_=this.simplex,S=this.perm,A=(Math.sqrt(5)-1)/4,M=(5-Math.sqrt(5))/20,T=(e+t+r+i)*A,E=Math.floor(e+T),C=Math.floor(t+T),L=Math.floor(r+T),P=Math.floor(i+T),N=(E+C+L+P)*M,O=E-N,D=C-N,F=L-N,R=P-N,I=e-O,U=t-D,k=r-F,B=i-R,z=I>U?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<t;h++)c=e[r+h],e[r+h]=e[i+h],e[i+h]=c},p=new Float32Array(t),f=new Float32Array(t);;)if(l-s<=25){for(n=s+1;n<=l;n++){for(u=0;u<t;u++)p[u]=e[n*t+u];for(i=n-1;i>=s&&e[i*t+r]>p[r];){for(u=0;u<t;u++)e[(i+1)*t+u]=e[i*t+u];i--}for(u=0;u<t;u++)e[(i+1)*t+u]=p[u]}if(o==-1)break;l=a[o--],s=a[o--]}else{var m=s+l>>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;u<t;u++)f[u]=e[i*t+u];for(;;){do i++;while(e[i*t+r]<f[r]);do n--;while(e[n*t+r]>f[r]);if(n<i)break;d(i,n)}for(u=0;u<t;u++)e[(s+1)*t+u]=e[n*t+u],e[n*t+u]=f[u];l-i+1>=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;u<r;u+=1)u===n.depth%r?f[u]=e[u]:f[u]=n.obj[u];return p=t(f,n.obj),null===n.right&&null===n.left?void((c.size()<i||d<c.peek()[1])&&a(n,d)):(s=null===n.right?n.left:null===n.left?n.right:e[h]<n.obj[h]?n.left:n.right,o(s),(c.size()<i||d<c.peek()[1])&&a(n,d),void((c.size()<i||Math.abs(p)<c.peek()[1])&&(l=s===n.left?n.right:n.left,null!==l&&o(l))))}var s,l,c;if(c=new Vy.Kdtree.BinaryHeap(function(e){return-e[1]}),a)for(s=0;s<i;s+=1)c.push([null,a]);for(o(n.root),l=[],s=0;s<i;s+=1)c.content[s][0]&&l.push([c.content[s][0],c.content[s][1]]);return l}},Vy.Kdtree.prototype.Node=function(e,t,r,i){this.obj=e,this.left=null,this.right=null,this.parent=r,this.depth=t,this.pos=i},Vy.Kdtree.BinaryHeap=function(e){this.content=[],this.scoreFunction=e},Vy.Kdtree.BinaryHeap.prototype={push:function(e){this.content.push(e),this.bubbleUp(this.content.length-1)},pop:function(){var e=this.content[0],t=this.content.pop();return this.content.length>0&&(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;i<r;i++)if(t.content[i]==e){var n=t.content.pop();return void(i!=r-1&&(t.content[i]=n,t.scoreFunction(n)<t.scoreFunction(e)?t.bubbleUp(i):t.sinkDown(i)))}throw new Error("Node not found.")},size:function(){return this.content.length},bubbleUp:function(e){for(var t=this,r=this.content[e];e>0;){var i=Math.floor((e+1)/2)-1,n=t.content[i];if(!(t.scoreFunction(r)<t.scoreFunction(n)))break;t.content[i]=r,t.content[e]=n,e=i}},sinkDown:function(e){for(var t=this,r=this.content.length,i=this.content[e],n=this.scoreFunction(i);;){var a=2*(e+1),o=a-1,s=null;if(o<r){var l=t.content[o],c=t.scoreFunction(l);c<n&&(s=o)}if(a<r){var u=t.content[a],h=t.scoreFunction(u);h<(null===s?n:c)&&(s=a)}if(null===s)break;t.content[e]=t.content[s],t.content[s]=i,e=s}}};var Gy=function(){function e(e,t){for(var r=new Ue,n=[],a=0;a<t.length;a++)n[a]=r.load(e+t[a],i.checkLoadComplete),n[a].mapping=Vl,n[a].name=t[a];return n}function t(e){for(var t=[],r=0;r<e.length;r++)t[r]=new Me({color:15658734,specular:10,map:e[r],skinning:!0,morphTargets:!0});return t}var r,i=this;this.scale=1,this.root=new c,this.numSkins=void 0,this.numMorphs=void 0,this.skins=[],this.materials=[],this.morphs=[],this.mixer=new ae(this.root),this.onLoadComplete=function(){},this.loadCounter=0,this.loadParts=function(n){this.numSkins=n.skins.length,this.numMorphs=n.morphs.length,this.loadCounter=1+n.skins.length,this.skins=e(n.baseUrl+"skins/",n.skins),this.materials=t(this.skins),this.morphs=n.morphs;var a=new Be;console.log(n.baseUrl+n.character),a.load(n.baseUrl+n.character,function(e){e.computeBoundingBox(),e.computeVertexNormals(),r=new Rt(e,[]),r.name=n.character,i.root.add(r);var t=e.boundingBox;i.root.scale.set(n.s,n.s,n.s),i.root.position.set(n.x,n.y-t.min.y*n.s,n.z),r.castShadow=!0,r.receiveShadow=!0,i.mixer.clipAction(e.animations[0],r).play(),i.setSkin(0),i.checkLoadComplete()})},this.setSkin=function(e){r&&i.materials&&(r.material=i.materials[e])},this.updateMorphs=function(e){if(r)for(var t=0;t<i.numMorphs;t++)r.morphTargetInfluences[t]=e[i.morphs[t]]/100},this.checkLoadComplete=function(){i.loadCounter-=1,0===i.loadCounter&&i.onLoadComplete()}},Wy={merge:function(e,t,r){console.warn("GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");var i;t instanceof k&&(t.matrixAutoUpdate&&t.updateMatrix(),i=t.matrix,t=t.geometry),e.merge(t,i,r)},randomPointInTriangle:function(){var e=new i;return function(t,r,n){var a=new i,o=Math.random(),s=Math.random();o+s>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(i<r)return r;var n=r+Math.floor((i-r)/2);return d[n]>e?t(r,n-1):d[n]<e?t(n+1,i):n}var r=t(0,d.length-1);return r}var i,n,a,o,s,l=e.faces,c=e.vertices,u=l.length,h=0,d=[];for(n=0;n<u;n++)i=l[n],a=c[i.a],o=c[i.b],s=c[i.c],i._area=Wy.triangleArea(a,o,s),h+=i._area,d[n]=h;var p,f,m=[];for(n=0;n<t;n++)p=Math.random()*h,f=r(p),m[n]=Wy.randomPointInFace(l[f],e);return m},randomPointsInBufferGeometry:function(e,t){function r(e){function t(r,i){if(i<r)return r;var n=r+Math.floor((i-r)/2);return u[n]>e?t(r,n-1):u[n]<e?t(n+1,i):n}var r=t(0,u.length-1);return r}var n,a,o,s,l=e.attributes.position.array,c=0,u=[];a=new i,o=new i,s=new i;var h=l.length/9;for(n=0;n<h;n++)a.set(l[9*n+0],l[9*n+1],l[9*n+2]),o.set(l[9*n+3],l[9*n+4],l[9*n+5]),s.set(l[9*n+6],l[9*n+7],l[9*n+8]),c+=Wy.triangleArea(a,o,s),u.push(c);var d,p,f=[];for(n=0;n<t;n++)d=Math.random()*c,p=r(d),a.set(l[9*p+0],l[9*p+1],l[9*p+2]),o.set(l[9*p+3],l[9*p+4],l[9*p+5]),s.set(l[9*p+6],l[9*p+7],l[9*p+8]),f[n]=Wy.randomPointInTriangle(a,o,s);return f},triangleArea:function(){var e=new i,t=new i;return function(r,i,n){return e.subVectors(i,r),t.subVectors(n,r),e.cross(t),.5*e.length()}}(),center:function(e){return console.warn("GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),e.center()}},Xy={setQuaternionFromProperEuler:function(e,t,r,i,n){var a=Math.cos,o=Math.sin,s=a(r/2),l=o(r/2),c=a((t+i)/2),u=o((t+i)/2),h=a((t-i)/2),d=o((t-i)/2),p=a((i-t)/2),f=o((i-t)/2);"XYX"===n?e.set(s*u,l*h,l*d,s*c):"YZY"===n?e.set(l*d,s*u,l*h,s*c):"ZXZ"===n?e.set(l*h,l*d,s*u,s*c):"XZX"===n?e.set(s*u,l*f,l*p,s*c):"YXY"===n?e.set(l*p,s*u,l*f,s*c):"ZYZ"===n?e.set(l*f,l*p,s*u,s*c):console.warn("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}},Hy={createMultiMaterialObject:function(e,t){for(var r=new Dt,i=0,n=t.length;i<n;i++)r.add(new k(e,t[i]));return r},detach:function(e,t,r){e.applyMatrix(t.matrixWorld),t.remove(e),r.add(e)},attach:function(e,t,i){e.applyMatrix((new r).getInverse(i.matrixWorld)),t.remove(e),i.add(e)}},Yy=function(e){function t(){i.position.set(i.position.x,i.position.y)}var r,i=this,n=void 0!==e.name&&""!==e.name,a={x:10,y:10,width:256,height:256},o=new me(Ds.innerWidth/-2,Ds.innerWidth/2,Ds.innerHeight/2,Ds.innerHeight/-2,1,10);o.position.set(0,0,2);var s=new fe,l=vg,c=new Mu.clone(l.uniforms),u=new pe({uniforms:c,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader}),h=new xe(a.width,a.height),d=new k(h,u);s.add(d);var p,f;if(n){p=document.createElement("canvas");var m=p.getContext("2d");m.font="Bold 20px Arial";var v=m.measureText(e.name).width;p.width=v,p.height=25,m.font="Bold 20px Arial",m.fillStyle="rgba( 255, 0, 0, 1 )",m.fillText(e.name,0,20);var g=new ve(p);g.magFilter=rc,g.minFilter=rc,g.needsUpdate=!0;var y=new F({map:g,side:Ks});y.transparent=!0;var x=new xe(p.width,p.height);f=new k(x,y),s.add(f)}this.enabled=!0,this.size={width:a.width,height:a.height,set:function(e,r){this.width=e,this.height=r,d.scale.set(this.width/a.width,this.height/a.height,1),t()}},this.position={x:a.x,y:a.y,set:function(e,t){this.x=e,this.y=t;var r=i.size.width,a=i.size.height;d.position.set(-Ds.innerWidth/2+r/2+this.x,Ds.innerHeight/2-a/2-this.y,0),n&&f.position.set(d.position.x,d.position.y-i.size.height/2+p.height/2,0)}},this.render=function(t){this.enabled&&(c.tDiffuse.value=e.shadow.map.texture,r=t.autoClear,t.autoClear=!1,t.clearDepth(),t.render(s,o),t.autoClear=r)},this.updateForWindowResize=function(){this.enabled&&(o.left=Ds.innerWidth/-2,o.right=Ds.innerWidth/2,o.top=Ds.innerHeight/2,o.bottom=Ds.innerHeight/-2,o.updateProjectionMatrix(),this.update())},this.update=function(){this.position.set(this.position.x,this.position.y),this.size.set(this.size.width,this.size.height)},this.update()};Yy.prototype.constructor=Yy,xo.prototype=Object.create(Yt.prototype),xo.prototype.constructor=xo,xo.prototype.updateMatrixWorld=function(){var e=new i,t=new r,n=new r;return function(r){var i=this.bones,a=this.geometry,o=a.getAttribute("position");n.getInverse(this.root.matrixWorld);for(var s=0,l=0;s<i.length;s++){var u=i[s];u.parent&&u.parent.isBone&&(t.multiplyMatrices(n,u.matrixWorld),e.setFromMatrixPosition(t),o.setXYZ(l,e.x,e.y,e.z),t.multiplyMatrices(n,u.parent.matrixWorld),e.setFromMatrixPosition(t),o.setXYZ(l+1,e.x,e.y,e.z),l+=2)}a.getAttribute("position").needsUpdate=!0,c.prototype.updateMatrixWorld.call(this,r)}}();var qy={retarget:function(){var e=new i,t=new n,a=new i,o=new r,s=new r,l=new r;return function(r,i,n){var c=this;n=n||{},n.preserveMatrix=void 0===n.preserveMatrix||n.preserveMatrix,n.preservePosition=void 0===n.preservePosition||n.preservePosition,n.preserveHipPosition=void 0!==n.preserveHipPosition&&n.preserveHipPosition,n.useTargetMatrix=void 0!==n.useTargetMatrix&&n.useTargetMatrix,n.hip=void 0!==n.hip?n.hip:"hip",n.names=n.names||{};var u,h,d,p,f,m,v=i.isObject3D?i.skeleton.bones:this.getBones(i),g=r.isObject3D?r.skeleton.bones:this.getBones(r);if(r.isObject3D?r.skeleton.pose():(n.useTargetMatrix=!0,n.preserveMatrix=!1),n.preservePosition)for(f=[],m=0;m<g.length;m++)f.push(g[m].position.clone());if(n.preserveMatrix)for(r.updateMatrixWorld(),r.matrixWorld.identity(),m=0;m<r.children.length;++m)r.children[m].updateMatrixWorld(!0);if(n.offsets)for(u=[],m=0;m<g.length;++m)h=g[m],d=n.names[h.name]||h.name,n.offsets&&n.offsets[d]&&(h.matrix.multiply(n.offsets[d]),h.matrix.decompose(h.position,h.quaternion,h.scale),h.updateMatrixWorld()),u.push(h.matrixWorld.clone());for(m=0;m<g.length;++m){if(h=g[m],d=n.names[h.name]||h.name,p=c.getBoneByName(d,v),l.copy(h.matrixWorld),p){if(p.updateMatrixWorld(),n.useTargetMatrix?s.copy(p.matrixWorld):(s.getInverse(r.matrixWorld),s.multiply(p.matrixWorld)),a.setFromMatrixScale(s),s.scale(a.set(1/a.x,1/a.y,1/a.z)),l.makeRotationFromQuaternion(t.setFromRotationMatrix(s)),r.isObject3D){var y=g.indexOf(h),x=u?u[y]:o.getInverse(r.skeleton.boneInverses[y]);l.multiply(x)}l.copyPosition(s)}h.parent&&h.parent.isBone?(h.matrix.getInverse(h.parent.matrixWorld),h.matrix.multiply(l)):h.matrix.copy(l),n.preserveHipPosition&&d===n.hip&&h.matrix.setPosition(e.set(0,h.position.y,0)),h.matrix.decompose(h.position,h.quaternion,h.scale),h.updateMatrixWorld()}if(n.preservePosition)for(m=0;m<g.length;++m)h=g[m],d=n.names[h.name]||h.name,d!==n.hip&&h.position.copy(f[m]);n.preserveMatrix&&r.updateMatrixWorld(!0)}}(),retargetClip:function(e,t,r,i){var n=this;i=i||{},i.useFirstFramePosition=void 0!==i.useFirstFramePosition&&i.useFirstFramePosition,i.fps=void 0!==i.fps?i.fps:30,i.names=i.names||[],t.isObject3D||(t=this.getHelperFromSkeleton(t));var a,o,s,l,c,u,h,d=Math.round(r.duration*(i.fps/1e3)*1e3),p=1/i.fps,f=[],m=new ae(t),v=this.getBones(e.skeleton),g=[];for(m.clipAction(r).play(),m.update(0),t.updateMatrixWorld(),u=0;u<d;++u){var y=u*p;for(n.retarget(e,t,i),h=0;h<v.length;++h)c=i.names[v[h].name]||v[h].name,s=n.getBoneByName(c,t.skeleton),s&&(o=v[h],l=g[h]=g[h]||{bone:o},i.hip===c&&(l.pos||(l.pos={times:new Float32Array(d),values:new Float32Array(3*d)}),i.useFirstFramePosition&&(0===u&&(a=o.position.clone()),o.position.sub(a)),l.pos.times[u]=y,o.position.toArray(l.pos.values,3*u)),l.quat||(l.quat={times:new Float32Array(d),values:new Float32Array(4*d)}),l.quat.times[u]=y,o.quaternion.toArray(l.quat.values,4*u));m.update(p),t.updateMatrixWorld()}for(u=0;u<g.length;++u)l=g[u],l&&(l.pos&&f.push(new te(".bones["+l.bone.name+"].position",l.pos.times,l.pos.values)),f.push(new $(".bones["+l.bone.name+"].quaternion",l.quat.times,l.quat.values)));return m.uncacheAction(r),new re(r.name,(-1),f)},getHelperFromSkeleton:function(e){var t=new xo(e.bones[0]);return t.skeleton=e,t},getSkeletonOffsets:function(){var e=new i,t=new i,n=new i,a=new i,s=new f,l=new f;return function(i,c,u){var h=this;u=u||{},u.hip=void 0!==u.hip?u.hip:"hip",u.names=u.names||{},c.isObject3D||(c=this.getHelperFromSkeleton(c));var d,p,m,v,g=Object.keys(u.names),y=Object.values(u.names),x=c.isObject3D?c.skeleton.bones:this.getBones(c),b=i.isObject3D?i.skeleton.bones:this.getBones(i),w=[];for(i.skeleton.pose(),v=0;v<b.length;++v)if(d=b[v],m=u.names[d.name]||d.name,p=h.getBoneByName(m,x),p&&m!==u.hip){var _=h.getNearestBone(d.parent,g),S=h.getNearestBone(p.parent,y);_.updateMatrixWorld(),S.updateMatrixWorld(),e.setFromMatrixPosition(_.matrixWorld),t.setFromMatrixPosition(d.matrixWorld),n.setFromMatrixPosition(S.matrixWorld),a.setFromMatrixPosition(p.matrixWorld),s.subVectors(new f(t.x,t.y),new f(e.x,e.y)).normalize(),l.subVectors(new f(a.x,a.y),new f(n.x,n.y)).normalize();var A=s.angle()-l.angle(),M=(new r).makeRotationFromEuler(new o(0,0,A));d.matrix.multiply(M),d.matrix.decompose(d.position,d.quaternion,d.scale),d.updateMatrixWorld(),w[m]=M}return w}}(),renameBones:function(e,t){for(var r=this.getBones(e),i=0;i<r.length;++i){var n=r[i];t[n.name]&&(n.name=t[n.name])}return this},getBones:function(e){return Array.isArray(e)?e:e.bones},getBoneByName:function(e,t){for(var r=0,i=this.getBones(t);r<i.length;r++)if(e===i[r].name)return i[r]},getNearestBone:function(e,t){for(;e.isBone;){if(t.indexOf(e.name)!==-1)return e;e=e.parent}},findBoneTrackData:function(e,t){for(var r=/\[(.*)\]\.(.*)/,i={name:e},n=0;n<t.length;++n){var a=r.exec(t[n].name);a&&e===a[1]&&(i[a[2]]=n)}return i},getEqualsBonesNames:function(e,t){var r=this.getBones(e),i=this.getBones(t),n=[];e:for(var a=0;a<r.length;a++)for(var o=r[a].name,s=0;s<i.length;s++)if(o===i[s].name){n.push(o);continue e}return n}},Qy=function(e,t){function r(e,t,r){h.beginPath(),n.set(0,0);for(var o=0,s=t.length;o<s;o++){var l=t[o];n.x+=l.x,n.y+=l.y,0===o?h.moveTo(l.x*c,(1-l.y)*u):h.lineTo(l.x*c,(1-l.y)*u)}for(h.closePath(),h.stroke(),n.divideScalar(t.length),h.font="12pt Arial bold",h.fillStyle="rgba( 0, 0, 0, 1.0 )",h.fillText(r,n.x*c,(1-n.y)*u),n.x>.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<s;o++){var l=t[o];a.addVectors(n,l).divideScalar(2);var d=e[o];h.fillText(i[o]+d,a.x*c,(1-a.y)*u),a.x>.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<v;m++){var s=d[m],g=p[m];s[0]=s.a,s[1]=s.b,s[2]=s.c,o[0].copy(g[0]),o[1].copy(g[1]),o[2].copy(g[2]),r(s,o,m)}else{var y=e.index,x=e.attributes.uv;if(y)for(var m=0,v=y.count;m<v;m+=3)s[0]=y.getX(m),s[1]=y.getX(m+1),s[2]=y.getX(m+2),o[0].fromBufferAttribute(x,s[0]),o[1].fromBufferAttribute(x,s[1]),o[2].fromBufferAttribute(x,s[2]),r(s,o,m);else for(var m=0,v=x.count;m<v;m+=3)s[0]=m,s[1]=m+1,s[2]=m+2,o[0].fromBufferAttribute(x,s[0]),o[1].fromBufferAttribute(x,s[1]),o[2].fromBufferAttribute(x,s[2]),r(s,o,m)}return l},Jy=function(e,t,r){var i=this;this.volume=e,t=t||0,Object.defineProperty(this,"index",{get:function(){return t},set:function(e){return t=e,i.geometryNeedsUpdate=!0,t}}),this.axis=r||"z",this.canvas=document.createElement("canvas"),this.canvasBuffer=document.createElement("canvas"),this.updateGeometry();var n=new ve(this.canvas);n.minFilter=rc,n.wrapS=n.wrapT=Zl;var a=new F({map:n,side:Ks,transparent:!0});this.mesh=new k(this.geometry,a),this.geometryNeedsUpdate=!0,this.repaint()};Jy.prototype={constructor:Jy,repaint:function(){var e=this;this.geometryNeedsUpdate&&this.updateGeometry();var t=this.iLength,r=this.jLength,i=this.sliceAccess,n=this.volume,a=this.canvasBuffer,o=this.ctxBuffer,s=o.getImageData(0,0,t,r),l=s.data,c=n.data,u=n.upperThreshold,h=n.lowerThreshold,d=n.windowLow,p=n.windowHigh,f=0;if("label"===n.dataType)for(var m=0;m<r;m++)for(var v=0;v<t;v++){var g=c[i(v,m)];g=g>=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<r;m++)for(var v=0;v<t;v++){var x=c[i(v,m)],b=255;b=u>=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;r<t.length;r++){var n=t[r];if(n&&("OpenVR Gamepad"===n.id||n.id.startsWith("Oculus Touch")||n.id.startsWith("Spatial Controller"))){if(i===e)return n;i++}}}c.call(this);var i,n=this,a=[0,0],o=!1,s=!1,l=!1,u=!1;this.matrixAutoUpdate=!1,this.standingMatrix=new r,this.getGamepad=function(){return i},this.getButtonState=function(e){return"thumbpad"===e?o:"trigger"===e?s:"grips"===e?l:"menu"===e?u:void 0},this.update=function(){if(i=t(e),void 0!==i&&void 0!==i.pose){if(null===i.pose)return;var r=i.pose;null!==r.position&&n.position.fromArray(r.position),null!==r.orientation&&n.quaternion.fromArray(r.orientation),n.matrix.compose(n.position,n.quaternion,n.scale),n.matrix.premultiply(n.standingMatrix),n.matrixWorldNeedsUpdate=!0,n.visible=!0,a[0]===i.axes[0]&&a[1]===i.axes[1]||(a[0]=i.axes[0],a[1]=i.axes[1],n.dispatchEvent({type:"axischanged",axes:a})),o!==i.buttons[0].pressed&&(o=i.buttons[0].pressed,n.dispatchEvent({type:o?"thumbpaddown":"thumbpadup",axes:a})),s!==i.buttons[1].pressed&&(s=i.buttons[1].pressed,n.dispatchEvent({type:s?"triggerdown":"triggerup"})),l!==i.buttons[2].pressed&&(l=i.buttons[2].pressed,n.dispatchEvent({type:l?"gripsdown":"gripsup"})),u!==i.buttons[3].pressed&&(u=i.buttons[3].pressed,n.dispatchEvent({type:u?"menudown":"menuup"}))}else n.visible=!1}};$y.prototype=Object.create(c.prototype),$y.prototype.constructor=$y,bo.prototype=Object.create(m.prototype),bo.prototype.constructor=bo,wo.prototype=Object.create(P.prototype),wo.prototype.constructor=wo,_o.prototype=Object.create(m.prototype),_o.prototype.constructor=_o,So.prototype=Object.create(He.prototype),So.prototype.constructor=So,Ao.prototype=Object.create(m.prototype),Ao.prototype.constructor=Ao,Ao.prototype.toJSON=function(){var e=m.prototype.toJSON.call(this),t=this.parameters.shapes;return To(t,e)},Mo.prototype=Object.create(P.prototype),Mo.prototype.constructor=Mo,Mo.prototype.toJSON=function(){var e=P.prototype.toJSON.call(this),t=this.parameters.shapes;return To(t,e)};var ex=function(e){function t(){var e=document.createElement("canvas");e.width=256,e.height=256;for(var t=e.getContext("2d"),r=t.getImageData(0,0,256,256),i=r.data,n=new u,o=0,s=0;o<i.length;o+=4,s++){var l=s%256/256-.5,c=Math.floor(s/256)/256-.5;n.setHSL(Math.atan2(c,l)/a,1,2*(.5-Math.sqrt(l*l+c*c))),i[o+0]=256*n.r,i[o+1]=256*n.g,i[o+2]=256*n.b,i[o+3]=256}return t.putImageData(r,0,0),new mi(e)}function r(e){if(this.getButtonState("thumbpad")!==!1){var t=e.axes[0]/2,r=-e.axes[1]/2;if(s===o.COLOR&&(l.setHSL(Math.atan2(r,t)/a,1,2*(.5-Math.sqrt(t*t+r*r))),f.position.set(e.axes[0],e.axes[1],0)),s===o.SIZE){var n=.5-r;c=2*n,i(y.geometry,n)}}}function i(e,t){var r=0,i=0,n=.75,a=1.5,o=Math.atan(n/2/a),s=i-a/2,l=a*t,c=Math.tan(o)*l*2,u=e.attributes.position;u.setXYZ(0,r,s,0),u.setXYZ(1,r+c/2,s+l,0),u.setXYZ(2,r-c/2,s+l,0),u.needsUpdate=!0}function n(){return s===o.COLOR?(s=o.SIZE,p.visible=!1,void(m.visible=!0)):s===o.SIZE?(s=o.COLOR,p.visible=!0,void(m.visible=!1)):void 0}$y.call(this,e);var a=2*Math.PI,o={COLOR:0,SIZE:1},s=o.COLOR,l=new u(1,1,1),c=1,h=new wo(1,32),d=new F({map:t()}),p=new k(h,d);p.position.set(0,.005,.0495),p.rotation.x=-1.45,p.scale.setScalar(.02),this.add(p);var h=new So(.1,2),d=new F;d.color=l;var f=new k(h,d);p.add(f);var m=new Dt;m.position.set(0,.005,.0495),m.rotation.x=-1.45,m.scale.setScalar(.02),this.add(m);var v=new Ir;v.moveTo(0,-1),v.lineTo(1,1),v.lineTo(-1,1);var h=new Mo(v),d=new F({color:2236962,wireframe:!0}),g=new k(h,d);g.position.z=.001,i(g.geometry,1),m.add(g);var h=new Mo(v),d=new F({side:Ks});d.color=l;var y=new k(h,d);y.position.z=.0011,i(y.geometry,.5),m.add(y),m.visible=!1,this.getColor=function(){return l},this.getSize=function(){return c},this.addEventListener("axischanged",r),this.addEventListener("gripsdown",n)};ex.prototype=Object.create($y.prototype),ex.prototype.constructor=ex;var tx={createButton:function(e,t){function r(t){o.style.display="",o.style.cursor="pointer",o.style.left="calc(50% - 50px)",o.style.width="100px",o.textContent="ENTER VR",o.onmouseenter=function(){o.style.opacity="1.0"},o.onmouseleave=function(){o.style.opacity="0.5"},o.onclick=function(){t.isPresenting?t.exitPresent():t.requestPresent([{source:e.domElement}])},e.vr.setDevice(t)}function i(t){function r(t){t.addEventListener("end",i),e.vr.setSession(t),o.textContent="EXIT VR",n=t}function i(t){n.removeEventListener("end",i),e.vr.setSession(null),o.textContent="ENTER VR",n=null}var n=null;o.style.display="",o.style.cursor="pointer",o.style.left="calc(50% - 50px)",o.style.width="100px",o.textContent="ENTER VR",o.onmouseenter=function(){o.style.opacity="1.0"},o.onmouseleave=function(){o.style.opacity="0.5"},o.onclick=function(){null===n?t.requestSession({immersive:!0,exclusive:!0}).then(r):n.end()},e.vr.setDevice(t)}function n(){o.style.display="",o.style.cursor="auto",o.style.left="calc(50% - 75px)",o.style.width="150px",o.textContent="VR NOT FOUND",o.onmouseenter=null,o.onmouseleave=null,o.onclick=null,e.vr.setDevice(null)}function a(e){e.style.position="absolute",e.style.bottom="20px",e.style.padding="12px 6px",e.style.border="1px solid #fff",e.style.borderRadius="4px",e.style.background="rgba(0,0,0,0.1)",e.style.color="#fff",e.style.font="normal 13px sans-serif",e.style.textAlign="center",e.style.opacity="0.5",e.style.outline="none",e.style.zIndex="999"}if(t&&t.frameOfReferenceType&&e.vr.setFrameOfReferenceType(t.frameOfReferenceType),"xr"in navigator){var o=document.createElement("button");return o.style.display="none",a(o),navigator.xr.requestDevice().then(function(e){e.supportsSession({immersive:!0,exclusive:!0}).then(function(){i(e)})["catch"](n)})["catch"](n),o}if("getVRDisplays"in navigator){var o=document.createElement("button");return o.style.display="none",a(o),Ds.addEventListener("vrdisplayconnect",function(e){r(e.display)},!1),Ds.addEventListener("vrdisplaydisconnect",function(e){n()},!1),Ds.addEventListener("vrdisplaypresentchange",function(e){o.textContent=e.display.isPresenting?"EXIT VR":"ENTER VR"},!1),Ds.addEventListener("vrdisplayactivate",function(t){t.display.requestPresent([{source:e.domElement}])},!1),navigator.getVRDisplays().then(function(e){e.length>0?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<i){c=t[f];var g=--i,y=t[g];n[y.uuid]=f,t[f]=y,n[p]=g,t[g]=d;for(var m=0,v=l;m!==v;++m){var x=s[m],b=x[g],w=x[f];x[f]=b,void 0===w&&(w=new W(d,a[m],o[m])),x[g]=w}}else t[f]!==c&&console.error("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=i},remove:function(){for(var e=arguments,t=this._objects,r=this.nCachedObjects_,i=this._indicesByUUID,n=this._bindings,a=n.length,o=0,s=arguments.length;o!==s;++o){var l=e[o],c=l.uuid,u=i[c];if(void 0!==u&&u>=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],h<i){var d=--i,p=t[d],f=--r,m=t[f];n[p.uuid]=h,t[h]=p,n[m.uuid]=d,t[d]=m,t.pop();for(var v=0,g=o;v!==g;++v){var y=a[v],x=y[d],b=y[f];y[h]=x,y[d]=b,y.pop()}}else{var f=--r,m=t[f];n[m.uuid]=h,t[h]=m,t.pop();for(var v=0,g=o;v!==g;++v){var y=a[v];y[h]=y[f],y.pop()}}}this.nCachedObjects_=i},subscribe_:function(e,t){var r=this._bindingsIndicesByPath,i=r[e],n=this._bindings;if(void 0!==i)return n[i];var a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);i=n.length,r[e]=i,a.push(e),o.push(t),n.push(u);for(var h=c,d=s.length;h!==d;++h){var p=s[h];u[h]=new W(p,e,t)}return u},unsubscribe_:function(e){var t=this._bindingsIndicesByPath,r=t[e];if(void 0!==r){var i=this._paths,n=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o],l=e[o];t[l]=r,a[r]=s,a.pop(),n[r]=n[o],n.pop(),i[r]=i[o],i.pop()}}}),Co.prototype=Object.assign(Object.create(c.prototype),{constructor:Co,getOutput:function(){return this.gain},setNodeSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},setMediaElementSource:function(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this},setBuffer:function(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(this.isPlaying===!0)return void console.warn("Audio: Audio is already playing.");if(this.hasPlaybackControl===!1)return void console.warn("Audio: this Audio has no playback control.");var e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.onended=this.onEnded.bind(this),e.playbackRate.setValueAtTime(this.playbackRate,this.startTime),this.startTime=this.context.currentTime,e.start(this.startTime,this.offset),this.isPlaying=!0,this.source=e,this.connect()},pause:function(){return this.hasPlaybackControl===!1?void console.warn("Audio: this Audio has no playback control."):(this.isPlaying===!0&&(this.source.stop(),this.source.onended=null,this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this)},stop:function(){return this.hasPlaybackControl===!1?void console.warn("Audio: this Audio has no playback control."):(this.source.stop(),this.source.onended=null,this.offset=0,this.isPlaying=!1,this)},connect:function(){var e=this;if(this.filters.length>0){this.source.connect(this.filters[0]);for(var t=1,r=this.filters.length;t<r;t++)e.filters[t-1].connect(e.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){var e=this;if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var t=1,r=this.filters.length;t<r;t++)e.filters[t-1].disconnect(e.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(e){return e||(e=[]),this.isPlaying===!0?(this.disconnect(),this.filters=e,this.connect()):this.filters=e,this},getFilter:function(){return this.getFilters()[0]},setFilter:function(e){return this.setFilters(e?[e]:[])},setPlaybackRate:function(e){return this.hasPlaybackControl===!1?void console.warn("Audio: this Audio has no playback control."):(this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this)},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return this.hasPlaybackControl===!1?(console.warn("Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(e){return this.hasPlaybackControl===!1?void console.warn("Audio: this Audio has no playback control."):(this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this)},getVolume:function(){return this.gain.gain.value},setVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),
|
|
this}}),Object.assign(Lo.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var e=0,t=this.getFrequencyData(),r=0;r<t.length;r++)e+=t[r];return e/t.length}});var rx,ix={getContext:function(){return void 0===rx&&(rx=new(Ds.AudioContext||Ds.webkitAudioContext)),rx},setContext:function(e){rx=e}};Po.prototype=Object.assign(Object.create(c.prototype),{constructor:Po,getInput:function(){return this.gain},removeFilter:function(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this},getFilter:function(){return this.filter},setFilter:function(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this},updateMatrixWorld:function(){var e=new i,t=new n,r=new i,a=new i;return function(i){c.prototype.updateMatrixWorld.call(this,i);var n=this.context.listener,o=this.up;this.matrixWorld.decompose(e,t,r),a.set(0,0,-1).applyQuaternion(t),n.positionX?(n.positionX.setValueAtTime(e.x,this.context.currentTime),n.positionY.setValueAtTime(e.y,this.context.currentTime),n.positionZ.setValueAtTime(e.z,this.context.currentTime),n.forwardX.setValueAtTime(a.x,this.context.currentTime),n.forwardY.setValueAtTime(a.y,this.context.currentTime),n.forwardZ.setValueAtTime(a.z,this.context.currentTime),n.upX.setValueAtTime(o.x,this.context.currentTime),n.upY.setValueAtTime(o.y,this.context.currentTime),n.upZ.setValueAtTime(o.z,this.context.currentTime)):(n.setPosition(e.x,e.y,e.z),n.setOrientation(a.x,a.y,a.z,o.x,o.y,o.z))}}()}),No.prototype=Object.assign(Object.create(Co.prototype),{constructor:No,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(e){return this.panner.refDistance=e,this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(e){return this.panner.rolloffFactor=e,this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(e){return this.panner.distanceModel=e,this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(e){return this.panner.maxDistance=e,this},setDirectionalCone:function(e,t,r){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=r,this},updateMatrixWorld:function(){var e=new i,t=new n,r=new i,a=new i;return function(i){c.prototype.updateMatrixWorld.call(this,i);var n=this.panner;this.matrixWorld.decompose(e,t,r),a.set(0,0,1).applyQuaternion(t),n.setPosition(e.x,e.y,e.z),n.setOrientation(a.x,a.y,a.z)}}()}),Oo.prototype=Object.create(c.prototype),Oo.prototype.constructor=Oo,Do.prototype=Object.assign(Object.create(g.prototype),{constructor:Do,isInstancedBufferAttribute:!0,copy:function(e){return g.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}}),Object.assign(Fo.prototype,{isFont:!0,generateShapes:function(e,t){void 0===t&&(t=100);for(var r=[],i=Ro(e,t,this.data),n=0,a=i.length;n<a;n++)Array.prototype.push.apply(r,i[n].toShapes());return r}}),Uo.prototype=Object.create(ce.prototype),Uo.prototype.constructor=Uo,ko.prototype=Object.create(ue.prototype),ko.prototype.constructor=ko,Bo.prototype=Object.create(m.prototype),Bo.prototype.constructor=Bo,zo.prototype=Object.create(He.prototype),zo.prototype.constructor=zo,jo.prototype=Object.create(P.prototype),jo.prototype.constructor=jo,Vo.prototype=Object.create(m.prototype),Vo.prototype.constructor=Vo,Vo.prototype.toJSON=function(){var e=m.prototype.toJSON.call(this),t=this.parameters.shapes,r=this.parameters.options;return Wo(t,r,e)},Go.prototype=Object.create(P.prototype),Go.prototype.constructor=Go,Go.prototype.toJSON=function(){var e=P.prototype.toJSON.call(this),t=this.parameters.shapes,r=this.parameters.options;return Wo(t,r,e)};var nx={generateTopUV:function(e,t,r,i,n){var a=t[3*r],o=t[3*r+1],s=t[3*i],l=t[3*i+1],c=t[3*n],u=t[3*n+1];return[new f(a,o),new f(s,l),new f(c,u)]},generateSideWallUV:function(e,t,r,i,n,a){var o=t[3*r],s=t[3*r+1],l=t[3*r+2],c=t[3*i],u=t[3*i+1],h=t[3*i+2],d=t[3*n],p=t[3*n+1],m=t[3*n+2],v=t[3*a],g=t[3*a+1],y=t[3*a+2];return Math.abs(s-u)<.01?[new f(o,1-l),new f(c,1-h),new f(d,1-m),new f(v,1-y)]:[new f(s,1-l),new f(u,1-h),new f(p,1-m),new f(g,1-y)]}};Xo.prototype=Object.create(m.prototype),Xo.prototype.constructor=Xo,Ho.prototype=Object.create(P.prototype),Ho.prototype.constructor=Ho,Yo.prototype=Object.create(m.prototype),Yo.prototype.constructor=Yo,qo.prototype=Object.create(P.prototype),qo.prototype.constructor=qo,Qo.prototype=Object.create(m.prototype),Qo.prototype.constructor=Qo,Jo.prototype=Object.create(P.prototype),Jo.prototype.constructor=Jo,Zo.prototype=Object.create(m.prototype),Zo.prototype.constructor=Zo,Ko.prototype=Object.create(He.prototype),Ko.prototype.constructor=Ko,$o.prototype=Object.create(m.prototype),$o.prototype.constructor=$o,es.prototype=Object.create(Go.prototype),es.prototype.constructor=es,ts.prototype=Object.create(m.prototype),ts.prototype.constructor=ts,rs.prototype=Object.create(P.prototype),rs.prototype.constructor=rs,is.prototype=Object.create(m.prototype),is.prototype.constructor=is,ns.prototype=Object.create(P.prototype),ns.prototype.constructor=ns;var ax,ox;as.prototype=Object.create(c.prototype),as.prototype.constructor=as,as.prototype.setDirection=function(){var e,t=new i;return function(r){r.y>.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;u<h;u++)c.setXYZ(l[u],n.x,n.y,n.z)}var t,r,n=new i,a=new he;return function(){t=this.geometry,r=this.pointMap;var i=1,n=1;a.projectionMatrix.copy(this.camera.projectionMatrix),e("c",0,0,-1),e("t",0,0,1),e("n1",-i,-n,-1),e("n2",i,-n,-1),e("n3",-i,n,-1),e("n4",i,n,-1),e("f1",-i,-n,1),e("f2",i,-n,1),e("f3",-i,n,1),e("f4",i,n,1),e("u1",.7*i,1.1*n,-1),e("u2",.7*-i,1.1*n,-1),e("u3",0,2*n,-1),e("cf1",-i,0,1),e("cf2",i,0,1),e("cf3",0,-n,1),e("cf4",0,n,1),e("cn1",-i,0,-1),e("cn2",i,0,-1),e("cn3",0,-n,-1),e("cn4",0,n,-1),t.getAttribute("position").needsUpdate=!0}}(),cs.prototype=Object.create(c.prototype),cs.prototype.constructor=cs,cs.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},cs.prototype.update=function(){var e=new i,t=new i,r=new i;return function(){e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),r.subVectors(t,e),this.lightPlane.lookAt(r),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(r),this.targetLine.scale.z=r.length()}}(),us.prototype=Object.create(Yt.prototype),us.prototype.constructor=us,us.prototype.update=function(){var e=new i,t=new i,r=new l;return function(){var i=this;this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);for(var n=this.object.matrixWorld,a=this.geometry.attributes.position,o=this.object.geometry,s=o.vertices,l=o.faces,c=0,u=0,h=l.length;u<h;u++){var d=l[u],p=d.normal;e.copy(s[d.a]).add(s[d.b]).add(s[d.c]).divideScalar(3).applyMatrix4(n),t.copy(p).applyMatrix3(r).normalize().multiplyScalar(i.size).add(e),a.setXYZ(c,e.x,e.y,e.z),c+=1,a.setXYZ(c,t.x,t.y,t.z),c+=1}a.needsUpdate=!0}}(),hs.prototype=Object.create(Yt.prototype),hs.prototype.constructor=hs,ds.prototype=Object.create(c.prototype),ds.prototype.constructor=ds,ds.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},ds.prototype.update=function(){var e=new i,t=new u,r=new u;return function(){var i=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var n=i.geometry.getAttribute("color");t.copy(this.light.color),r.copy(this.light.groundColor);for(var a=0,o=n.count;a<o;a++){var s=a<o/2?t:r;n.setXYZ(a,s.r,s.g,s.b)}n.needsUpdate=!0}i.lookAt(e.setFromMatrixPosition(this.light.matrixWorld).negate())}}(),ps.prototype=Object.create(B.prototype),ps.prototype.constructor=ps,ps.prototype.updateMatrixWorld=function(e){var t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?Zs:Js,this.lookAt(this.plane.normal),c.prototype.updateMatrixWorld.call(this,e)},fs.prototype=Object.create(k.prototype),fs.prototype.constructor=fs,fs.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},fs.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)},ms.prototype=Object.create(Yt.prototype),ms.prototype.constructor=ms,vs.prototype=Object.create(c.prototype),vs.prototype.constructor=vs,vs.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},vs.prototype.update=function(){var e=.5*this.light.width,t=.5*this.light.height,r=this.line.geometry.attributes.position,i=r.array;i[0]=e,i[1]=-t,i[2]=0,i[3]=e,i[4]=t,i[5]=0,i[6]=-e,i[7]=t,i[8]=0,i[9]=-e,i[10]=-t,i[11]=0,i[12]=e,i[13]=-t,i[14]=0,r.needsUpdate=!0,void 0!==this.color?this.line.material.color.set(this.color):this.line.material.color.copy(this.light.color)},gs.prototype=Object.create(c.prototype),gs.prototype.constructor=gs,gs.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},gs.prototype.update=function(){var e=new i,t=new i;return function(){this.light.updateMatrixWorld();var r=this.light.distance?this.light.distance:1e3,i=r*Math.tan(this.light.angle);this.cone.scale.set(i,i,r),e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(t.sub(e)),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}(),ys.prototype=Object.create(Yt.prototype),ys.prototype.constructor=ys,ys.prototype.update=function(){var e=new i,t=new i,r=new l;return function(){var i=this,n=["a","b","c"];this.object.updateMatrixWorld(!0),r.getNormalMatrix(this.object.matrixWorld);var a=this.object.matrixWorld,o=this.geometry.attributes.position,s=this.object.geometry;if(s&&s.isGeometry)for(var l=s.vertices,c=s.faces,u=0,h=0,d=c.length;h<d;h++)for(var p=c[h],f=0,m=p.vertexNormals.length;f<m;f++){var v=l[p[n[f]]],g=p.vertexNormals[f];e.copy(v).applyMatrix4(a),t.copy(g).applyMatrix3(r).normalize().multiplyScalar(i.size).add(e),o.setXYZ(u,e.x,e.y,e.z),u+=1,o.setXYZ(u,t.x,t.y,t.z),u+=1}else if(s&&s.isBufferGeometry)for(var y=s.attributes.position,x=s.attributes.normal,u=0,f=0,m=y.count;f<m;f++)e.set(y.getX(f),y.getY(f),y.getZ(f)).applyMatrix4(a),t.set(x.getX(f),x.getY(f),x.getZ(f)),t.applyMatrix3(r).normalize().multiplyScalar(i.size).add(e),o.setXYZ(u,e.x,e.y,e.z),u+=1,o.setXYZ(u,t.x,t.y,t.z),u+=1;o.needsUpdate=!0}}(),xs.prototype=Object.assign(Object.create(kt.prototype),{constructor:xs,isRectAreaLight:!0,copy:function(e){return kt.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){var t=kt.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}}),Object.assign(bs.prototype,{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,t){for(var r=[],i=0;i<e.length;i++){var n=re.parse(e[i]);r.push(n)}t(r)}}),Object.assign(ws.prototype,{load:function(e,t,r,i){var n=new we(this.manager);n.setResponseType("arraybuffer"),n.load(e,function(e){var r=e.slice(0),i=ix.getContext();i.decodeAudioData(r,function(e){t(e)})},r,i)}}),Object.assign(_s.prototype,{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){var t=new P,r=e.data.index;if(void 0!==r){var n=new sx[r.type](r.array);t.setIndex(new g(n,1))}var a=e.data.attributes;for(var o in a){var s=a[o],n=new sx[s.type](s.array);t.addAttribute(o,new g(n,s.itemSize,s.normalized))}var l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(var c=0,u=l.length;c!==u;++c){var h=l[c];t.addGroup(h.start,h.count,h.materialIndex)}var d=e.data.boundingSphere;if(void 0!==d){var f=new i;void 0!==d.center&&f.fromArray(d.center),t.boundingSphere=new p(f,d.radius)}return t}});var sx={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};Object.assign(Ss.prototype,{crossOrigin:"anonymous",load:function(e,t,r,i){function n(r){o.load(e[r],function(e){a.images[r]=e,s++,6===s&&(a.needsUpdate=!0,t&&t(a))},void 0,i)}var a=new $t,o=new Ie(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);for(var s=0,l=0;l<e.length;++l)n(l);return a},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(As.prototype,{load:function(e,t,r,i){var n=this,a=new we(this.manager);a.setPath(this.path),a.load(e,function(e){var r;try{r=JSON.parse(e)}catch(i){console.warn("FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),r=JSON.parse(e.substring(65,e.length-2))}var a=n.parse(r);t&&t(a)},r,i)},parse:function(e){return new Fo(e)},setPath:function(e){return this.path=e,this}}),Ms.prototype={constructor:Ms,setOptions:function(e){return this.options=e,this},load:function(e,t,r,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);var n=this,a=Ou.get(e);return void 0!==a?(n.manager.itemStart(e),setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0),a):void fetch(e).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,n.options)}).then(function(r){Ou.add(e,r),t&&t(r),n.manager.itemEnd(e)})["catch"](function(t){i&&i(t),n.manager.itemEnd(e),n.manager.itemError(e)})},setCrossOrigin:function(){return this},setPath:function(e){return this.path=e,this}},Ts.prototype=Object.assign(Object.create(c.prototype),{constructor:Ts,copy:function(e){var t=this;c.prototype.copy.call(this,e,!1);for(var r=e.levels,i=0,n=r.length;i<n;i++){var a=r[i];t.addLevel(a.object.clone(),a.distance)}return this},addLevel:function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var r=this.levels,i=0;i<r.length&&!(t<r[i].distance);i++);r.splice(i,0,{distance:t,object:e}),this.add(e)},getObjectForDistance:function(e){for(var t=this.levels,r=1,i=t.length;r<i&&!(e<t[r].distance);r++);return t[r-1].object},raycast:function(){var e=new i;return function(t,r){e.setFromMatrixPosition(this.matrixWorld);var i=t.ray.origin.distanceTo(e);this.getObjectForDistance(i).raycast(t,r)}}(),update:function(){var e=new i,t=new i;return function(r){var i=this.levels;if(i.length>1){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<o&&n>=i[a].distance;a++)i[a-1].object.visible=!1,i[a].object.visible=!0;for(;a<o;a++)i[a].object.visible=!1}}}(),toJSON:function(e){var t=c.prototype.toJSON.call(this,e);t.object.levels=[];for(var r=this.levels,i=0,n=r.length;i<n;i++){var a=r[i];t.object.levels.push({object:a.object.uuid,distance:a.distance})}return t}}),Es.prototype.isFog=!0,Es.prototype.clone=function(){return new Es(this.color,this.near,this.far)},Es.prototype.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},Cs.prototype.isFogExp2=!0,Cs.prototype.clone=function(){return new Cs(this.color,this.density)},Cs.prototype.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}};var lx={WireframeGeometry:Ot,TetrahedronGeometry:Zo,TetrahedronBufferGeometry:Ko,OctahedronGeometry:Ye,OctahedronBufferGeometry:qe,IcosahedronGeometry:_o,IcosahedronBufferGeometry:So,DodecahedronGeometry:Bo,DodecahedronBufferGeometry:zo,PolyhedronGeometry:Xe,PolyhedronBufferGeometry:He,TubeGeometry:is,TubeBufferGeometry:ns,TorusKnotGeometry:ts,TorusGeometry:Qe,TorusBufferGeometry:Je,TextGeometry:$o,TextBufferGeometry:es,SphereGeometry:N,SphereBufferGeometry:O,RingGeometry:Qo,RingBufferGeometry:Jo,PlaneGeometry:ye,PlaneBufferGeometry:xe,LatheGeometry:Xo,LatheBufferGeometry:Ho,ShapeGeometry:Ao,ShapeBufferGeometry:Mo,ExtrudeGeometry:Vo,ExtrudeBufferGeometry:Go,EdgesGeometry:jo,ConeGeometry:Uo,ConeBufferGeometry:ko,CylinderGeometry:ce,CylinderBufferGeometry:ue,CircleGeometry:bo,CircleBufferGeometry:wo,BoxGeometry:se,BoxBufferGeometry:le};Object.assign(Ls.prototype,{crossOrigin:"anonymous",load:function(e,t,r,i){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var n=this,a=new we(n.manager);a.load(e,function(r){var a=null;try{a=JSON.parse(r)}catch(o){return void 0!==i&&i(o),void console.error("THREE:ObjectLoader: Can't parse "+e+".",o.message)}var s=a.metadata;return void 0===s||void 0===s.type||"geometry"===s.type.toLowerCase()?void console.error("ObjectLoader: Can't load "+e+". Use JSONLoader instead."):void n.parse(a,t)},r,i)},setTexturePath:function(e){return this.texturePath=e,this},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){var r=this.parseShape(e.shapes),i=this.parseGeometries(e.geometries,r),n=this.parseImages(e.images,function(){void 0!==t&&t(s)}),a=this.parseTextures(e.textures,n),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,i,o);return e.animations&&(s.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(s),s},parseShape:function(e){var t={};if(void 0!==e)for(var r=0,i=e.length;r<i;r++){var n=(new Ir).fromJSON(e[r]);t[n.uuid]=n}return t},parseGeometries:function(e,t){var r=this,i={};if(void 0!==e)for(var n=new Be,a=new _s,o=0,s=e.length;o<s;o++){var l,c=e[o];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":l=new lx[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":l=new lx[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":l=new lx[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":l=new lx[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":l=new lx[c.type](c.radius,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":l=new lx[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":l=new lx[c.type](c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":l=new lx[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":l=new lx[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":l=new lx[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"LatheGeometry":case"LatheBufferGeometry":l=new lx[c.type](c.points,c.segments,c.phiStart,c.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":l=new lx[c.type](c.vertices,c.indices,c.radius,c.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":for(var u=[],h=0,d=c.shapes.length;h<d;h++){var p=t[c.shapes[h]];u.push(p)}l=new lx[c.type](u,c.curveSegments);break;case"ExtrudeGeometry":case"ExtrudeBufferGeometry":for(var u=[],h=0,d=c.shapes.length;h<d;h++){var p=t[c.shapes[h]];u.push(p)}var f=c.options.extrudePath;void 0!==f&&(c.options.extrudePath=(new Curves[f.type]).fromJSON(f)),l=new lx[c.type](u,c.options);break;case"BufferGeometry":l=a.parse(c);break;case"Geometry":l=n.parse(c,r.texturePath).geometry;break;default:console.warn('ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}l.uuid=c.uuid,void 0!==c.name&&(l.name=c.name),l.isBufferGeometry===!0&&void 0!==c.userData&&(l.userData=c.userData),i[c.uuid]=l}return i},parseMaterials:function(e,t){var r={};if(void 0!==e){var i=new Re;i.setTextures(t);for(var n=0,a=e.length;n<a;n++){var o=e[n];if("MultiMaterial"===o.type){for(var s=[],l=0;l<o.materials.length;l++)s.push(i.parse(o.materials[l]));r[o.uuid]=s}else r[o.uuid]=i.parse(o)}}return r},parseAnimations:function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r],n=re.parse(i);void 0!==i.uuid&&(n.uuid=i.uuid),t.push(n)}return t},parseImages:function(e,t){function r(e){return i.manager.itemStart(e),o.load(e,function(){i.manager.itemEnd(e)},void 0,function(){i.manager.itemEnd(e),i.manager.itemError(e)})}var i=this,n={};if(void 0!==e&&e.length>0){var a=new be(t),o=new Ie(a);o.setCrossOrigin(this.crossOrigin);for(var s=0,l=e.length;s<l;s++){var c=e[s],u=c.url;if(Array.isArray(u)){n[c.uuid]=[];for(var h=0,d=u.length;h<d;h++){var p=u[h],f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(p)?p:i.texturePath+p;n[c.uuid].push(r(f))}}else{var f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c.url)?c.url:i.texturePath+c.url;n[c.uuid]=r(f)}}}return n},parseTextures:function(e,t){function r(e,t){return"number"==typeof e?e:(console.warn("ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var i={};if(void 0!==e)for(var n=0,a=e.length;n<a;n++){var o=e[n];void 0===o.image&&console.warn('ObjectLoader: No "image" specified for',o.uuid),void 0===t[o.image]&&console.warn("ObjectLoader: Undefined image",o.image);var s;s=Array.isArray(t[o.image])?new $t(t[o.image]):new ve(t[o.image]),s.needsUpdate=!0,s.uuid=o.uuid,void 0!==o.name&&(s.name=o.name),void 0!==o.mapping&&(s.mapping=r(o.mapping,cx)),void 0!==o.offset&&s.offset.fromArray(o.offset),void 0!==o.repeat&&s.repeat.fromArray(o.repeat),void 0!==o.center&&s.center.fromArray(o.center),void 0!==o.rotation&&(s.rotation=o.rotation),void 0!==o.wrap&&(s.wrapS=r(o.wrap[0],ux),s.wrapT=r(o.wrap[1],ux)),void 0!==o.format&&(s.format=o.format),void 0!==o.minFilter&&(s.minFilter=r(o.minFilter,hx)),void 0!==o.magFilter&&(s.magFilter=r(o.magFilter,hx)),void 0!==o.anisotropy&&(s.anisotropy=o.anisotropy),void 0!==o.flipY&&(s.flipY=o.flipY),i[o.uuid]=s}return i},parseObject:function(e,t,r){function i(e){return void 0===t[e]&&console.warn("ObjectLoader: Undefined geometry",e),t[e]}function n(e){if(void 0!==e){if(Array.isArray(e)){for(var t=[],i=0,n=e.length;i<n;i++){var a=e[i];void 0===r[a]&&console.warn("ObjectLoader: Undefined material",a),t.push(r[a])}return t}return void 0===r[e]&&console.warn("ObjectLoader: Undefined material",e),r[e]}}var a,o=this;switch(e.type){case"Scene":a=new fe,void 0!==e.background&&Number.isInteger(e.background)&&(a.background=new u(e.background)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new Es(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new Cs(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":a=new de(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(a.focus=e.focus),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.filmGauge&&(a.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(a.filmOffset=e.filmOffset),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new me(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Ht(e.color,e.intensity);break;case"DirectionalLight":a=new Vt(e.color,e.intensity);break;case"PointLight":a=new zt(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new xs(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Wt(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new Xt(e.color,e.groundColor,e.intensity);break;case"SkinnedMesh":console.warn("ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var s=i(e.geometry),l=n(e.material);a=s.bones&&s.bones.length>0?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<h.length;d++)a.add(o.parseObject(h[d],t,r));if("LOD"===e.type)for(var p=e.levels,f=0;f<p.length;f++){var m=p[f],v=a.getObjectByProperty("uuid",m.object);void 0!==v&&a.addLevel(v,m.distance)}return a}});var cx={UVMapping:Vl,CubeReflectionMapping:Gl,CubeRefractionMapping:Wl,EquirectangularReflectionMapping:Xl,EquirectangularRefractionMapping:Hl,SphericalReflectionMapping:Yl,CubeUVReflectionMapping:ql,CubeUVRefractionMapping:Ql},ux={RepeatWrapping:Jl,ClampToEdgeWrapping:Zl,MirroredRepeatWrapping:Kl},hx={NearestFilter:$l,NearestMipMapNearestFilter:ec,NearestMipMapLinearFilter:tc,LinearFilter:rc,LinearMipMapNearestFilter:ic,LinearMipMapLinearFilter:nc};Object.assign(Ps.prototype,{set:function(e,t,r){return this.radius=e,this.theta=t,this.y=r,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,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+r*r),this.theta=Math.atan2(e,r),this.y=t,this}}),Os.prototype=Object.assign(Object.create(ve.prototype),{constructor:Os,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=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<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=t("js/core/props"),c=(i(l),function(e){function t(){n(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));e.radius=1;var r=new THREE.MeshStandardMaterial({color:"#FFFFFF"}),i=new THREE.SphereGeometry(e.radius,20,20);return e.mesh=new THREE.Mesh(i,r),e.mesh.castShadow=!0,e.mesh.receiveShadow=!0,e.add(e.mesh),e.position.z+=e.radius/2+.01,e.onUpdate=e.onUpdate.bind(e),e}return o(t,e),s(t,[{key:"onUpdate",value:function(e){this.position.y=.01*Math.sin(2*Math.PI*e/20)+.01*Math.sin(2*Math.PI*e/70),this.position.x=.1*Math.sin(2*Math.PI*e/5300),this.position.z=.1*Math.cos(2*Math.PI*e/5300)}}]),t}(THREE.Object3D));r.exports=c}),require.register("js/components/Clouds.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<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=t("js/core/props"),c=(i(l),function(e){function t(){n(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=new THREE.TextureLoader;e.cloudTexture=r.load("textures/clouds.png"),e.cloudTexture.wrapS=e.cloudTexture.wrapT=THREE.RepeatWrapping,e.cloudTexture.repeat.set(3,3),e.material=new THREE.MeshBasicMaterial({map:e.cloudTexture,transparent:!0,side:THREE.DoubleSide});var i=new THREE.PlaneBufferGeometry(200,200),o=new THREE.Mesh(i,e.material);return o.customDepthMaterial=new THREE.MeshDepthMaterial({depthPacking:THREE.RGBADepthPacking,map:e.cloudTexture,alphaTest:.3}),o.rotation.x=-Math.PI/2,o.position.y=10,o.castShadow=!0,e.add(o),e.onUpdate=e.onUpdate.bind(e),e}return o(t,e),s(t,[{key:"onUpdate",value:function(e){this.cloudTexture.offset.x=e/1e3%200,this.cloudTexture.offset.y=e/5e3%400}}]),t}(THREE.Object3D));r.exports=c}),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<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=t("js/core/props"),c=i(l),u=t("../shaders/example-vert"),h=i(u),d=t("../shaders/example-frag"),p=i(d),f=function(e){function t(){n(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=new THREE.ShaderMaterial({uniforms:{color:{type:"v4",value:new THREE.Vector4(.9,.715,.072,1)}},vertexShader:h["default"],fragmentShader:p["default"],wireframe:!0}),i=new THREE.BoxGeometry(1,1,1);return e.exampleMesh=new THREE.Mesh(i,r),e.add(e.exampleMesh),e.onUpdate=e.onUpdate.bind(e),e}return o(t,e),s(t,[{key:"onUpdate",value:function(){this.rotation.x+=c["default"].rotation,this.rotation.y+=c["default"].rotation}}]),t}(THREE.Object3D);r.exports=f}),require.register("js/components/Eyeball.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<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=t("js/core/props"),c=(i(l),function(e){function t(){n(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=new THREE.GLTFLoader;return r.load("blue_eyeball/scene.gltf",function(t){e.add(t.scene)},function(e){console.log(e.loaded/e.total*100+"% loaded")},function(e){console.log({error:e})}),e.onUpdate=e.onUpdate.bind(e),e}return o(t,e),s(t,[{key:"onUpdate",value:function(){}}]),t}(THREE.Object3D));r.exports=c}),require.register("js/components/Ground.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=t("js/core/props"),l=(i(s),function(e){function t(){n(this,t);var e=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=new THREE.MeshPhongMaterial({color:16777215,specular:328965});r.color.setHSL(.095,.4,.5);var i=new THREE.PlaneBufferGeometry(1e4,1e4),o=new THREE.Mesh(i,r);return o.rotation.x=-Math.PI/2,o.position.y=-1,o.receiveShadow=!0,e.add(o),e}return o(t,e),t}(THREE.Object3D));r.exports=l}),require.register("js/components/Light.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")}function n(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 a(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 o=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),s=function(e){function t(){i(this,t);var e=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=new THREE.DirectionalLight(16777215,1);r.color.setHSL(.095,1,.95),r.position.set(-1,1.75,1),r.position.multiplyScalar(20),r.castShadow=!0,r.shadow.mapSize.width=2048,r.shadow.mapSize.height=2048,r.shadow.radius=2;var a=100;r.shadow.camera.left=-a,r.shadow.camera.right=a,r.shadow.camera.top=a,r.shadow.camera.bottom=-a,r.shadow.camera.far=3500,e.add(r);var o=new THREE.HemisphereLight(16777215,16777215,.6);return o.color.setHSL(.6,1,.6),o.groundColor.setHSL(.095,1,.6),o.position.set(0,4,0),e.add(o),e.onUpdate=e.onUpdate.bind(e),e}return a(t,e),o(t,[{key:"onUpdate",value:function(){}}]),t}(THREE.Object3D);r.exports=s}),require.register("js/core/Loop.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")}var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(){function e(){i(this,e),this._idRAF=-1,this._count=0,this._time=(new Date).getTime(),this._listeners=[],this._binds={},this._binds.update=this._update.bind(this)}return n(e,[{key:"_update",value:function(){var e=null,t=this._count;for(this._time=(new Date).getTime();--t>=0;)e=this._listeners[t],e&&e.apply(this,[this._time]);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<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),a=function(){function e(t,r){i(this,e),this.scene=new THREE.Scene;var n=(new THREE.Color).setHSL(.6,1,.6);this.scene.background=n,this.scene.fog=new THREE.Fog(n,.0025,100),this.camera=new THREE.PerspectiveCamera(50,t/r,.1,1e3),this.camera.position.z=10,this._renderer=new THREE.WebGLRenderer({antialias:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.gammaInput=!0,this._renderer.gammaOutput=!0,this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=THREE.PCFSoftShadowMap,this.dom=this._renderer.domElement,this.usePostprocessing=!0,this._passes=[new THREE.RenderPass(this.scene,this.camera)],this.initPostprocessing(),this.onResize(t,r),this.onUpdate=this.onUpdate.bind(this),this.onResize=this.onResize.bind(this),this._controls=new THREE.OrbitControls(this.camera,this._renderer.domElement),this._controls.enableDamping=!0,this._controls.dampingFactor=.25,this._controls.screenSpacePanning=!1,this._controls.minDistance=3,this._controls.maxDistance=50,this._controls.maxPolarAngle=Math.PI/2}return n(e,[{key:"initPostprocessing",value:function(){var e=this;if(this.usePostprocessing){this._composer=new THREE.EffectComposer(this._renderer);var t=THREE.SSAOShader;t.uniforms.onlyAO=!0,this._passes.forEach(function(t,r){r==e._passes.length-1&&(t.renderToScreen=!0),e._composer.addPass(t)})}}},{key:"add",value:function(e){this.scene.add(e)}},{key:"onUpdate",value:function(){this._controls.update(),this.usePostprocessing?this._composer.render(this.scene,this.camera):this._renderer.render(this.scene,this.camera)}},{key:"onResize",value:function(e,t){this.width=e,this.height=t,this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this._renderer.setSize(e,t),this.usePostprocessing&&this._composer.setSize(e,t)}}]),e}();e["default"]=a}),require.register("js/core/props.js",function(e,t,r){"use strict";var i={rotation:.01};r.exports=i}),require.register("js/shaders/depthShader-frag.glsl",function(e,t,r){r.exports="#define GLSLIFY 1\nuniform sampler2D texture;\nvarying vec2 vUV;\n\nvec4 pack_depth(const in float depth) {\n const vec4 bit_shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n vec4 res = fract(depth * bit_shift);\n res -= res.xxyz * bit_mask;\n return res;\n}\n\nvoid main() {\n vec4 pixel = texture2D(texture, vUV);\n if (pixel.a < 0.5) discard;\n gl_FragData[0] = pack_depth(gl_FragCoord.z);\n}\n"}),require.register("js/shaders/depthShader-vert.glsl",function(e,t,r){r.exports="#define GLSLIFY 1\nvarying vec2 vUV;\n\nvoid main() {\n vUV = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"}),require.register("js/shaders/example-frag.glsl",function(e,t,r){r.exports="#define GLSLIFY 1\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = color;\n}\n"}),require.register("js/shaders/example-vert.glsl",function(e,t,r){r.exports="#define GLSLIFY 1\nvoid main() {\n gl_Position = projectionMatrix *\n modelViewMatrix *\n vec4(position, 1.0);\n}\n"}),require.register("main.js",function(e,t,r){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function n(){var e=window.innerWidth,t=window.innerHeight;x.onResize(e,t)}var a=t("js/core/Webgl"),o=i(a),s=t("js/core/Loop"),l=i(s),c=t("js/core/props"),u=i(c),h=t("js/components/Bean"),d=i(h),p=t("js/components/Ground"),f=i(p),m=t("js/components/Clouds"),v=i(m),g=t("js/components/Light"),y=i(g),x=new o["default"](window.innerWidth,window.innerHeight);document.body.appendChild(x.dom),l["default"].add(x.onUpdate);var b=new dat.GUI;b.add(u["default"],"rotation",.01,1),b.close(),x.add(new f["default"]);var w=new v["default"];x.add(w),l["default"].add(w.onUpdate);var _=new y["default"];x.add(_),l["default"].add(_.onUpdate);var S=new d["default"];x.add(S),l["default"].add(S.onUpdate),l["default"].start(),window.addEventListener("resize",n),window.addEventListener("orientationchange",n)}),require.alias("buffer/index.js","buffer"),require.alias("process/browser.js","process"),require.alias("three-full/builds/Three.cjs.js","three-full"),e=require("process"),require.register("___globals___",function(e,t,r){window.THREE=t("three-full"),window.dat=t("dat-gui")})}(),require("___globals___"); |