(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AFRAME = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function byteLength(o){var r=getLens(o),e=r[0],t=r[1];return 3*(e+t)/4-t}function _byteLength(o,r,e){return 3*(r+e)/4-e}function toByteArray(o){for(var r,e=getLens(o),t=e[0],n=e[1],u=new Arr(_byteLength(o,t,n)),p=0,a=n>0?t-4:t,h=0;h>16&255,u[p++]=r>>8&255,u[p++]=255&r;return 2===n&&(r=revLookup[o.charCodeAt(h)]<<2|revLookup[o.charCodeAt(h+1)]>>4,u[p++]=255&r),1===n&&(r=revLookup[o.charCodeAt(h)]<<10|revLookup[o.charCodeAt(h+1)]<<4|revLookup[o.charCodeAt(h+2)]>>2,u[p++]=r>>8&255,u[p++]=255&r),u}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,n=[],u=r;up?p:u+16383));return 1===t?(r=o[e-1],n.push(lookup[r>>2]+lookup[r<<4&63]+"==")):2===t&&(r=(o[e-2]<<8)+o[e-1],n.push(lookup[r>>10]+lookup[r>>4&63]+lookup[r<<2&63]+"=")),n.join("")}exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|t}function SlowBuffer(t){return+t!=t&&(t=0),Buffer.alloc(+t)}function byteLength(t,e){if(Buffer.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return utf8ToBytes(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(t).length;default:if(n)return utf8ToBytes(t).length;e=(""+e).toLowerCase(),n=!0}}function slowToString(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return hexSlice(this,e,r);case"utf8":case"utf-8":return utf8Slice(this,e,r);case"ascii":return asciiSlice(this,e,r);case"latin1":case"binary":return latin1Slice(this,e,r);case"base64":return base64Slice(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function swap(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function bidirectionalIndexOf(t,e,r,n,f){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=f?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(f)return-1;r=t.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:arrayIndexOf(t,e,r,n,f);if("number"==typeof e)return e&=255,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):arrayIndexOf(t,[e],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(t,e,r,n,f){function i(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}var o=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,u/=2,s/=2,r/=2}var a;if(f){var h=-1;for(a=r;au&&(r=u-s),a=r;a>=0;a--){for(var c=!0,l=0;lf&&(n=f):n=f;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var o=0;o239?4:i>223?3:i>191?2:1;if(f+u<=r){var s,a,h,c;switch(u){case 1:i<128&&(o=i);break;case 2:s=t[f+1],128==(192&s)&&(c=(31&i)<<6|63&s)>127&&(o=c);break;case 3:s=t[f+1],a=t[f+2],128==(192&s)&&128==(192&a)&&(c=(15&i)<<12|(63&s)<<6|63&a)>2047&&(c<55296||c>57343)&&(o=c);break;case 4:s=t[f+1],a=t[f+2],h=t[f+3],128==(192&s)&&128==(192&a)&&128==(192&h)&&(c=(15&i)<<18|(63&s)<<12|(63&a)<<6|63&h)>65535&&c<1114112&&(o=c)}}null===o?(o=65533,u=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),f+=u}return decodeCodePointsArray(n)}function decodeCodePointsArray(t){var e=t.length;if(e<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn)&&(r=n);for(var f="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(t,e,r,n,f,i){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>f||et.length)throw new RangeError("Index out of range")}function objectWriteUInt16(t,e,r,n){e<0&&(e=65535+e+1);for(var f=0,i=Math.min(t.length-r,2);f>>8*(n?f:1-f)}function objectWriteUInt32(t,e,r,n){e<0&&(e=4294967295+e+1);for(var f=0,i=Math.min(t.length-r,4);f>>8*(n?f:3-f)&255}function checkIEEE754(t,e,r,n,f,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(t,e,r,n,f){return f||checkIEEE754(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(t,e,r,n,23,4),r+4}function writeDouble(t,e,r,n,f){return f||checkIEEE754(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(t,e,r,n,52,8),r+8}function base64clean(t){if(t=stringtrim(t).replace(INVALID_BASE64_RE,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function stringtrim(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function toHex(t){return t<16?"0"+t.toString(16):t.toString(16)}function utf8ToBytes(t,e){e=e||1/0;for(var r,n=t.length,f=null,i=[],o=0;o55295&&r<57344){if(!f){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(e-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(t){for(var e=[],r=0;r>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(t){return base64.toByteArray(base64clean(t))}function blitBuffer(t,e,r,n){for(var f=0;f=e.length||f>=t.length);++f)e[f+r]=t[f];return f}function isnan(t){return t!==t}var base64=_dereq_("base64-js"),ieee754=_dereq_("ieee754"),isArray=_dereq_("isarray");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50,Buffer.TYPED_ARRAY_SUPPORT=void 0!==global.TYPED_ARRAY_SUPPORT?global.TYPED_ARRAY_SUPPORT:typedArraySupport(),exports.kMaxLength=kMaxLength(),Buffer.poolSize=8192,Buffer._augment=function(t){return t.__proto__=Buffer.prototype,t},Buffer.from=function(t,e,r){return from(null,t,e,r)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0})),Buffer.alloc=function(t,e,r){return alloc(null,t,e,r)},Buffer.allocUnsafe=function(t){return allocUnsafe(null,t)},Buffer.allocUnsafeSlow=function(t){return allocUnsafe(null,t)},Buffer.isBuffer=function(t){return!(null==t||!t._isBuffer)},Buffer.compare=function(t,e){if(!Buffer.isBuffer(t)||!Buffer.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,f=0,i=Math.min(r,n);f0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},Buffer.prototype.compare=function(t,e,r,n,f){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),e<0||r>t.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&e>=r)return 0;if(n>=f)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,f>>>=0,this===t)return 0;for(var i=f-n,o=r-e,u=Math.min(i,o),s=this.slice(n,f),a=t.slice(e,r),h=0;hf)&&(r=f),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,t,e,r);case"utf8":case"utf-8":return utf8Write(this,t,e,r);case"ascii":return asciiWrite(this,t,e,r);case"latin1":case"binary":return latin1Write(this,t,e,r);case"base64":return base64Write(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(f*=256);)n+=this[t+--e]*f;return n},Buffer.prototype.readUInt8=function(t,e){return e||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return e||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return e||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return e||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return e||checkOffset(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||checkOffset(t,e,this.length);for(var n=this[t],f=1,i=0;++i=f&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||checkOffset(t,e,this.length);for(var n=e,f=1,i=this[t+--n];n>0&&(f*=256);)i+=this[t+--n]*f;return f*=128,i>=f&&(i-=Math.pow(2,8*e)),i},Buffer.prototype.readInt8=function(t,e){return e||checkOffset(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){e||checkOffset(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){e||checkOffset(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return e||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return e||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return e||checkOffset(t,4,this.length),ieee754.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return e||checkOffset(t,4,this.length),ieee754.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return e||checkOffset(t,8,this.length),ieee754.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return e||checkOffset(t,8,this.length),ieee754.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){checkInt(this,t,e,r,Math.pow(2,8*r)-1,0)}var f=1,i=0;for(this[e]=255&t;++i=0&&(i*=256);)this[e+f]=t/i&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):objectWriteUInt16(this,t,e,!0),e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):objectWriteUInt16(this,t,e,!1),e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):objectWriteUInt32(this,t,e,!0),e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):objectWriteUInt32(this,t,e,!1),e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,t,e,r,f-1,-f)}var i=0,o=1,u=0;for(this[e]=255&t;++i>0)-u&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,t,e,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/o>>0)-u&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):objectWriteUInt16(this,t,e,!0),e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):objectWriteUInt16(this,t,e,!1),e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):objectWriteUInt32(this,t,e,!0),e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||checkInt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):objectWriteUInt32(this,t,e,!1),e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return writeFloat(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return writeFloat(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return writeDouble(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return writeDouble(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--f)t[f+e]=this[f+r];else if(i<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(f=0;f>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var i;if("number"==typeof t)for(i=e;i=31}function formatArgs(){var o=arguments,e=this.useColors;if(o[0]=(e?"%c":"")+this.namespace+(e?" %c":" ")+o[0]+(e?"%c ":" "),!e)return o;var r="color: "+this.color;o=[o[0],r,"color: inherit"].concat(Array.prototype.slice.call(o,1));var t=0,s=0;return o[0].replace(/%[a-z%]/g,function(o){"%%"!==o&&(t++,"%c"===o&&(s=t))}),o.splice(s,0,r),o}function log(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function save(o){try{null==o?exports.storage.removeItem("debug"):exports.storage.debug=o}catch(o){}}function load(){var o;try{o=exports.storage.debug}catch(o){}return o}function localstorage(){try{return window.localStorage}catch(o){}}exports=module.exports=_dereq_("./debug"),exports.log=log,exports.formatArgs=formatArgs,exports.save=save,exports.load=load,exports.useColors=useColors,exports.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:localstorage(),exports.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],exports.formatters.j=function(o){return JSON.stringify(o)},exports.enable(load()); },{"./debug":9}],9:[function(_dereq_,module,exports){ function selectColor(){return exports.colors[prevColor++%exports.colors.length]}function debug(e){function r(){}function o(){var e=o;null==e.useColors&&(e.useColors=exports.useColors()),null==e.color&&e.useColors&&(e.color=selectColor());var r=Array.prototype.slice.call(arguments);r[0]=exports.coerce(r[0]),"string"!=typeof r[0]&&(r=["%o"].concat(r));var s=0;r[0]=r[0].replace(/%([a-z%])/g,function(o,t){if("%%"===o)return o;s++;var n=exports.formatters[t];if("function"==typeof n){var l=r[s];o=n.call(e,l),r.splice(s,1),s--}return o}),"function"==typeof exports.formatArgs&&(r=exports.formatArgs.apply(e,r)),(o.log||exports.log||console.log.bind(console)).apply(e,r)}r.enabled=!1,o.enabled=!0;var s=exports.enabled(e)?o:r;return s.namespace=e,s}function enable(e){exports.save(e);for(var r=(e||"").split(/[\s,]+/),o=r.length,s=0;s2?arguments[2]:{},o=keys(r);hasSymbols&&(o=concat.call(o,Object.getOwnPropertySymbols(r)));for(var n=0;n>0),L="attached",T="detached",M="extends",F="ADDITION",V="MODIFICATION",I="REMOVAL",D="DOMAttrModified",P="DOMContentLoaded",R="DOMSubtreeModified",_="<",k="=",q=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,S=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],U=[],H=[],x="",Z=r.documentElement,G=U.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},j=n.prototype,z=j.hasOwnProperty,K=j.isPrototypeOf,W=n.defineProperty,X=n.getOwnPropertyDescriptor,Y=n.getOwnPropertyNames,$=n.getPrototypeOf,B=n.setPrototypeOf,J=!!n.__proto__,Q=n.create||function e(t){return t?(e.prototype=t,new e):this},ee=B||(J?function(e,t){return e.__proto__=t,e}:Y&&X?function(){function e(e,t){for(var r,n=Y(t),a=0,l=n.length;a1&&"boolean"!=typeof r)throw new TypeError('"allowMissing" argument must be a boolean');var t="$ "+e;if(!(t in INTRINSICS))throw new SyntaxError("intrinsic "+e+" does not exist!");if(void 0===INTRINSICS[t]&&!r)throw new TypeError("intrinsic "+e+" exists, but is not available. Please file an issue!");return INTRINSICS[t]}; },{}],15:[function(_dereq_,module,exports){ "use strict";var GetIntrinsic=_dereq_("./GetIntrinsic"),$Object=GetIntrinsic("%Object%"),$TypeError=GetIntrinsic("%TypeError%"),$String=GetIntrinsic("%String%"),assertRecord=_dereq_("./helpers/assertRecord"),$isNaN=_dereq_("./helpers/isNaN"),$isFinite=_dereq_("./helpers/isFinite"),sign=_dereq_("./helpers/sign"),mod=_dereq_("./helpers/mod"),IsCallable=_dereq_("is-callable"),toPrimitive=_dereq_("es-to-primitive/es5"),has=_dereq_("has"),ES5={ToPrimitive:toPrimitive,ToBoolean:function(e){return!!e},ToNumber:function(e){return+e},ToInteger:function(e){var r=this.ToNumber(e);return $isNaN(r)?0:0!==r&&$isFinite(r)?sign(r)*Math.floor(Math.abs(r)):r},ToInt32:function(e){return this.ToNumber(e)>>0},ToUint32:function(e){return this.ToNumber(e)>>>0},ToUint16:function(e){var r=this.ToNumber(e);if($isNaN(r)||0===r||!$isFinite(r))return 0;var t=sign(r)*Math.floor(Math.abs(r));return mod(t,65536)},ToString:function(e){return $String(e)},ToObject:function(e){return this.CheckObjectCoercible(e),$Object(e)},CheckObjectCoercible:function(e,r){if(null==e)throw new $TypeError(r||"Cannot call method on "+e);return e},IsCallable:IsCallable,SameValue:function(e,r){return e===r?0!==e||1/e==1/r:$isNaN(e)&&$isNaN(r)},Type:function(e){return null===e?"Null":void 0===e?"Undefined":"function"==typeof e||"object"==typeof e?"Object":"number"==typeof e?"Number":"boolean"==typeof e?"Boolean":"string"==typeof e?"String":void 0},IsPropertyDescriptor:function(e){if("Object"!==this.Type(e))return!1;var r={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var t in e)if(has(e,t)&&!r[t])return!1;var i=has(e,"[[Value]]"),o=has(e,"[[Get]]")||has(e,"[[Set]]");if(i&&o)throw new $TypeError("Property Descriptors may not be both accessor and data descriptors");return!0},IsAccessorDescriptor:function(e){return void 0!==e&&(assertRecord(this,"Property Descriptor","Desc",e),!(!has(e,"[[Get]]")&&!has(e,"[[Set]]")))},IsDataDescriptor:function(e){return void 0!==e&&(assertRecord(this,"Property Descriptor","Desc",e),!(!has(e,"[[Value]]")&&!has(e,"[[Writable]]")))},IsGenericDescriptor:function(e){return void 0!==e&&(assertRecord(this,"Property Descriptor","Desc",e),!this.IsAccessorDescriptor(e)&&!this.IsDataDescriptor(e))},FromPropertyDescriptor:function(e){if(void 0===e)return e;if(assertRecord(this,"Property Descriptor","Desc",e),this.IsDataDescriptor(e))return{value:e["[[Value]]"],writable:!!e["[[Writable]]"],enumerable:!!e["[[Enumerable]]"],configurable:!!e["[[Configurable]]"]};if(this.IsAccessorDescriptor(e))return{get:e["[[Get]]"],set:e["[[Set]]"],enumerable:!!e["[[Enumerable]]"],configurable:!!e["[[Configurable]]"]};throw new $TypeError("FromPropertyDescriptor must be called with a fully populated Property Descriptor")},ToPropertyDescriptor:function(e){if("Object"!==this.Type(e))throw new $TypeError("ToPropertyDescriptor requires an object");var r={};if(has(e,"enumerable")&&(r["[[Enumerable]]"]=this.ToBoolean(e.enumerable)),has(e,"configurable")&&(r["[[Configurable]]"]=this.ToBoolean(e.configurable)),has(e,"value")&&(r["[[Value]]"]=e.value),has(e,"writable")&&(r["[[Writable]]"]=this.ToBoolean(e.writable)),has(e,"get")){var t=e.get;if(void 0!==t&&!this.IsCallable(t))throw new TypeError("getter must be a function");r["[[Get]]"]=t}if(has(e,"set")){var i=e.set;if(void 0!==i&&!this.IsCallable(i))throw new $TypeError("setter must be a function");r["[[Set]]"]=i}if((has(r,"[[Get]]")||has(r,"[[Set]]"))&&(has(r,"[[Value]]")||has(r,"[[Writable]]")))throw new $TypeError("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return r}};module.exports=ES5; },{"./GetIntrinsic":14,"./helpers/assertRecord":16,"./helpers/isFinite":17,"./helpers/isNaN":18,"./helpers/mod":19,"./helpers/sign":20,"es-to-primitive/es5":21,"has":28,"is-callable":32}],16:[function(_dereq_,module,exports){ "use strict";var GetIntrinsic=_dereq_("../GetIntrinsic"),$TypeError=GetIntrinsic("%TypeError%"),$SyntaxError=GetIntrinsic("%SyntaxError%"),has=_dereq_("has"),predicates={"Property Descriptor":function(r,e){if("Object"!==r.Type(e))return!1;var t={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var n in e)if(has(e,n)&&!t[n])return!1;var o=has(e,"[[Value]]"),a=has(e,"[[Get]]")||has(e,"[[Set]]");if(o&&a)throw new $TypeError("Property Descriptors may not be both accessor and data descriptors");return!0}};module.exports=function(r,e,t,n){var o=predicates[e];if("function"!=typeof o)throw new $SyntaxError("unknown record type: "+e);if(!o(r,n))throw new $TypeError(t+" must be a "+e);console.log(o(r,n),n)}; },{"../GetIntrinsic":14,"has":28}],17:[function(_dereq_,module,exports){ var $isNaN=Number.isNaN||function(e){return e!==e};module.exports=Number.isFinite||function(e){return"number"==typeof e&&!$isNaN(e)&&e!==1/0&&e!==-1/0}; },{}],18:[function(_dereq_,module,exports){ module.exports=Number.isNaN||function(e){return e!==e}; },{}],19:[function(_dereq_,module,exports){ module.exports=function(o,r){var t=o%r;return Math.floor(t>=0?t:t+r)}; },{}],20:[function(_dereq_,module,exports){ module.exports=function(e){return e>=0?1:-1}; },{}],21:[function(_dereq_,module,exports){ "use strict";var toStr=Object.prototype.toString,isPrimitive=_dereq_("./helpers/isPrimitive"),isCallable=_dereq_("is-callable"),ES5internalSlots={"[[DefaultValue]]":function(e){var t;if((t=arguments.length>1?arguments[1]:"[object Date]"===toStr.call(e)?String:Number)===String||t===Number){var r,i,l=t===String?["toString","valueOf"]:["valueOf","toString"];for(i=0;i1?ES5internalSlots["[[DefaultValue]]"](e,arguments[1]):ES5internalSlots["[[DefaultValue]]"](e)}; },{"./helpers/isPrimitive":22,"is-callable":32}],22:[function(_dereq_,module,exports){ module.exports=function(o){return null===o||"function"!=typeof o&&"object"!=typeof o}; },{}],23:[function(_dereq_,module,exports){ function flattenVertexData(e,t,r){if(!e)throw new TypeError("must specify data as first parameter");if(r=0|+(r||0),Array.isArray(e)&&e[0]&&"number"==typeof e[0][0]){var n,a,l,o,f=e[0].length,s=e.length*f;t&&"string"!=typeof t||(t=new(dtype(t||"float32"))(s+r));var i=t.length-r;if(s!==i)throw new Error("source length "+s+" ("+f+"x"+e.length+") does not match destination length "+i);for(n=0,l=r;n=3&&(o=a),"[object Array]"===toStr.call(r)?forEachArray(r,t,o):"string"==typeof r?forEachString(r,t,o):forEachObject(r,t,o)};module.exports=forEach; },{"is-callable":32}],25:[function(_dereq_,module,exports){ "use strict";var ERROR_MESSAGE="Function.prototype.bind called on incompatible ",slice=Array.prototype.slice,toStr=Object.prototype.toString,funcType="[object Function]";module.exports=function(t){var n=this;if("function"!=typeof n||toStr.call(n)!==funcType)throw new TypeError(ERROR_MESSAGE+n);for(var o,e=slice.call(arguments,1),r=function(){if(this instanceof o){var r=n.apply(this,e.concat(slice.call(arguments)));return Object(r)===r?r:this}return n.apply(t,e.concat(slice.call(arguments)))},c=Math.max(0,n.length-e.length),i=[],p=0;p>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),o+=p+N>=1?n/f:n*Math.pow(2,1-N),o*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l}; },{}],30:[function(_dereq_,module,exports){ "function"==typeof Object.create?module.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:module.exports=function(t,e){if(e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}}; },{}],31:[function(_dereq_,module,exports){ function isBuffer(f){return!!f.constructor&&"function"==typeof f.constructor.isBuffer&&f.constructor.isBuffer(f)}function isSlowBuffer(f){return"function"==typeof f.readFloatLE&&"function"==typeof f.slice&&isBuffer(f.slice(0,0))}module.exports=function(f){return null!=f&&(isBuffer(f)||isSlowBuffer(f)||!!f._isBuffer)}; },{}],32:[function(_dereq_,module,exports){ "use strict";var fnToStr=Function.prototype.toString,constructorRegex=/^\s*class\b/,isES6ClassFn=function(t){try{var n=fnToStr.call(t);return constructorRegex.test(n)}catch(t){return!1}},tryFunctionObject=function(t){try{return!isES6ClassFn(t)&&(fnToStr.call(t),!0)}catch(t){return!1}},toStr=Object.prototype.toString,fnClass="[object Function]",genClass="[object GeneratorFunction]",hasToStringTag="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;module.exports=function(t){if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if("function"==typeof t&&!t.prototype)return!0;if(hasToStringTag)return tryFunctionObject(t);if(isES6ClassFn(t))return!1;var n=toStr.call(t);return n===fnClass||n===genClass}; },{}],33:[function(_dereq_,module,exports){ function isFunction(o){var t=toString.call(o);return"[object Function]"===t||"function"==typeof o&&"[object RegExp]"!==t||"undefined"!=typeof window&&(o===window.setTimeout||o===window.alert||o===window.confirm||o===window.prompt)}module.exports=isFunction;var toString=Object.prototype.toString; },{}],34:[function(_dereq_,module,exports){ "use strict";module.exports=function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}; },{}],35:[function(_dereq_,module,exports){ var toString={}.toString;module.exports=Array.isArray||function(r){return"[object Array]"==toString.call(r)}; },{}],36:[function(_dereq_,module,exports){ function TextLayout(t){this.glyphs=[],this._measure=this.computeMetrics.bind(this),this.update(t)}function addGetter(t){Object.defineProperty(TextLayout.prototype,t,{get:wrapper(t),configurable:!0})}function wrapper(t){return new Function(["return function "+t+"() {"," return this._"+t,"}"].join("\n"))()}function getGlyphById(t,e){if(!t.chars||0===t.chars.length)return null;var r=findChar(t.chars,e);return r>=0?t.chars[r]:null}function getXHeight(t){for(var e=0;e=0)return t.chars[n].height}return 0}function getMGlyph(t){for(var e=0;e=0)return t.chars[n]}return 0}function getCapHeight(t){for(var e=0;e=0)return t.chars[n].height}return 0}function getKerning(t,e,r){if(!t.kernings||0===t.kernings.length)return 0;for(var n=t.kernings,i=0;i=n||f>=n)break;s=f,c=d,a=i}u++}return a&&(c+=a.xoffset),{start:e,end:e+u,width:c}},["width","height","descender","ascender","xHeight","baseline","capHeight","lineHeight"].forEach(addGetter); },{"as-number":2,"word-wrapper":68,"xtend":71}],37:[function(_dereq_,module,exports){ (function (Buffer){ function isArrayBuffer(r){return"[object ArrayBuffer]"===Object.prototype.toString.call(r)}function getBinaryOpts(r){if(xml2)return xtend(r,{responseType:"arraybuffer"});if(void 0===self.XMLHttpRequest)throw new Error("your browser does not support XHR loading");var e=new self.XMLHttpRequest;return e.overrideMimeType("text/plain; charset=x-user-defined"),xtend({xhr:e},r)}var xhr=_dereq_("xhr"),noop=function(){},parseASCII=_dereq_("parse-bmfont-ascii"),parseXML=_dereq_("parse-bmfont-xml"),readBinary=_dereq_("parse-bmfont-binary"),isBinaryFormat=_dereq_("./lib/is-binary"),xtend=_dereq_("xtend"),xml2=function(){return self.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}();module.exports=function(r,e){e="function"==typeof e?e:noop,"string"==typeof r?r={uri:r}:r||(r={}),r.binary&&(r=getBinaryOpts(r)),xhr(r,function(t,n,i){if(t)return e(t);if(!/^2/.test(n.statusCode))return e(new Error("http status code: "+n.statusCode));if(!i)return e(new Error("no body result"));var o=!1;if(isArrayBuffer(i)){var a=new Uint8Array(i);i=new Buffer(a,"binary")}isBinaryFormat(i)&&(o=!0,"string"==typeof i&&(i=new Buffer(i,"binary"))),o||(Buffer.isBuffer(i)&&(i=i.toString(r.encoding)),i=i.trim());var s;try{var u=n.headers["content-type"];s=o?readBinary(i):/json/.test(u)||"{"===i.charAt(0)?JSON.parse(i):/xml/.test(u)||"<"===i.charAt(0)?parseXML(i):parseASCII(i)}catch(r){e(new Error("error parsing font "+r.message)),e=noop}e(null,s)})}; }).call(this,_dereq_("buffer").Buffer) },{"./lib/is-binary":38,"buffer":6,"parse-bmfont-ascii":43,"parse-bmfont-binary":44,"parse-bmfont-xml":45,"xhr":69,"xtend":71}],38:[function(_dereq_,module,exports){ (function (Buffer){ var equal=_dereq_("buffer-equal"),HEADER=new Buffer([66,77,70,3]);module.exports=function(e){return"string"==typeof e?"BMF"===e.substring(0,3):e.length>4&&equal(e.slice(0,4),HEADER)}; }).call(this,_dereq_("buffer").Buffer) },{"buffer":6,"buffer-equal":5}],39:[function(_dereq_,module,exports){ "use strict";function toObject(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function shouldUseNative(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var r={},t=0;t<10;t++)r["_"+String.fromCharCode(t)]=t;if("0123456789"!==Object.getOwnPropertyNames(r).map(function(e){return r[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}var getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;module.exports=shouldUseNative()?Object.assign:function(e,r){for(var t,n,o=toObject(e),a=1;a0&&!has.call(t,0))for(var a=0;a0)for(var l=0;l=0&&"[object Function]"===toStr.call(t.callee)),o}; },{}],43:[function(_dereq_,module,exports){ function splitLine(e,r){if(!(e=e.replace(/\t+/g," ").trim()))return null;var t=e.indexOf(" ");if(-1===t)throw new Error("no named row at line "+r);var a=e.substring(0,t);e=e.substring(t+1),e=e.replace(/letter=[\'\"]\S+[\'\"]/gi,""),e=e.split("="),e=e.map(function(e){return e.trim().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)});for(var n=[],i=0;ie.length-1)return 0;var a=e.readUInt8(n++),t=e.readInt32LE(n);switch(n+=4,a){case 1:r.info=readInfo(e,n);break;case 2:r.common=readCommon(e,n);break;case 3:r.pages=readPages(e,n,t);break;case 4:r.chars=readChars(e,n,t);break;case 5:r.kernings=readKernings(e,n,t)}return 5+t}function readInfo(r,e){var n={};n.size=r.readInt16LE(e);var a=r.readUInt8(e+2);return n.smooth=a>>7&1,n.unicode=a>>6&1,n.italic=a>>5&1,n.bold=a>>4&1,a>>3&1&&(n.fixedHeight=1),n.charset=r.readUInt8(e+3)||"",n.stretchH=r.readUInt16LE(e+4),n.aa=r.readUInt8(e+6),n.padding=[r.readInt8(e+7),r.readInt8(e+8),r.readInt8(e+9),r.readInt8(e+10)],n.spacing=[r.readInt8(e+11),r.readInt8(e+12)],n.outline=r.readUInt8(e+13),n.face=readStringNT(r,e+14),n}function readCommon(r,e){var n={};n.lineHeight=r.readUInt16LE(e),n.base=r.readUInt16LE(e+2),n.scaleW=r.readUInt16LE(e+4),n.scaleH=r.readUInt16LE(e+6),n.pages=r.readUInt16LE(e+8);r.readUInt8(e+10);return n.packed=0,n.alphaChnl=r.readUInt8(e+11),n.redChnl=r.readUInt8(e+12),n.greenChnl=r.readUInt8(e+13),n.blueChnl=r.readUInt8(e+14),n}function readPages(r,e,n){for(var a=[],t=readNameNT(r,e),d=t.length+1,o=n/d,i=0;i3)throw new Error("Only supports BMFont Binary v3 (BMFont App v1.10)");for(var n={kernings:[],chars:[]},a=0;a<5;a++)e+=readBlock(n,r,e);return n}; },{}],45:[function(_dereq_,module,exports){ function getAttribs(e){return getAttribList(e).reduce(function(e,t){return e[mapName(t.nodeName)]=t.nodeValue,e},{})}function getAttribList(e){for(var t=[],r=0;r element");for(var n=a.getElementsByTagName("page"),i=0;i1)for(var r=1;r-1}function applyArguments(e,t){return e.apply(null,t)}function parseEasingParameters(e){var t=easingFunctionRegex.exec(e);return t?t[1].split(",").map(function(e){return parseFloat(e)}):[]}function spring(e,t){function n(e){var n=t?t*e/1e3:e;return n=l<1?Math.exp(-n*l*c)*(f*Math.cos(g*n)+p*Math.sin(g*n)):(f+p*n)*Math.exp(-n*c),0===e||1===e?e:1-n}function r(){var t=cache.springs[e];if(t)return t;for(var r=0,a=0;;)if(r+=1/6,1===n(r)){if(++a>=16)break}else a=0;var i=r*(1/6)*1e3;return cache.springs[e]=i,i}var a=parseEasingParameters(e),i=minMax(is.und(a[0])?1:a[0],.1,100),s=minMax(is.und(a[1])?100:a[1],.1,100),o=minMax(is.und(a[2])?10:a[2],.1,100),u=minMax(is.und(a[3])?0:a[3],.1,100),c=Math.sqrt(s/i),l=o/(2*Math.sqrt(s*i)),g=l<1?c*Math.sqrt(1-l*l):0,f=1,p=l<1?(l*c-u)/g:-u+c;return t?n:r}function elastic(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var n=minMax(e,1,10),r=minMax(t,.1,2);return function(e){return 0===e||1===e?e:-n*Math.pow(2,10*(e-1))*Math.sin((e-1-r/(2*Math.PI)*Math.asin(1/n))*(2*Math.PI)/r)}}function steps(e){return void 0===e&&(e=10),function(t){return Math.round(t*e)*(1/e)}}function parseEasings(e,t){if(is.fnc(e))return e;var n=e.split("(")[0],r=penner[n],a=parseEasingParameters(e);switch(n){case"spring":return spring(e,t);case"cubicBezier":return applyArguments(bezier,a);case"steps":return applyArguments(steps,a);default:return is.fnc(r)?applyArguments(r,a):applyArguments(bezier,r)}}function selectString(e){try{return document.querySelectorAll(e)}catch(e){return}}function filterArray(e,t){for(var n=auxArrayFilter,r=e.length,a=arguments.length>=2?arguments[1]:void 0,i=0;i1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var n,r,a,i=hslToRgbaHsl1Regex.exec(e)||hslToRgbaHsl2Regex.exec(e),s=parseInt(i[1],10)/360,o=parseInt(i[2],10)/100,u=parseInt(i[3],10)/100,c=i[4]||1;if(0==o)n=r=a=u;else{var l=u<.5?u*(1+o):u+o-u*o,g=2*u-l;n=t(g,l,s+1/3),r=t(g,l,s),a=t(g,l,s-1/3)}return"rgba("+255*n+","+255*r+","+255*a+","+c+")"}function colorToRgb(e){return is.rgb(e)?rgbToRgba(e):is.hex(e)?hexToRgba(e):is.hsl(e)?hslToRgba(e):void 0}function getUnit(e){var t=unitRegex.exec(e);if(t)return t[2]}function getTransformUnit(e){return stringContains(e,"translate")||"perspective"===e?"px":stringContains(e,"rotate")||stringContains(e,"skew")?"deg":void 0}function getFunctionValue(e,t){return is.fnc(e)?e(t.target,t.id,t.total):e}function getAttribute(e,t){return e.getAttribute(t)}function convertPxToUnit(e,t,n){if(arrayContains([n,"deg","rad","turn"],getUnit(t)))return t;var r=cache.CSS[t+n];if(!is.und(r))return r;var a=document.createElement(e.tagName),i=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;i.appendChild(a),a.style.position="absolute",a.style.width=100+n;var s=100/a.offsetWidth;i.removeChild(a);var o=s*parseFloat(t);return cache.CSS[t+n]=o,o}function getCSSValue(e,t,n){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),a=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return n?convertPxToUnit(e,a,n):a}}function getAnimationType(e,t){return is.dom(e)&&!is.inp(e)&&(getAttribute(e,t)||is.svg(e)&&e[t])?"attribute":is.dom(e)&&arrayContains(validTransforms,t)?"transform":is.dom(e)&&"transform"!==t&&getCSSValue(e,t)?"css":null!=e[t]?"object":void 0}function getElementTransforms(e){if(is.dom(e)){for(var t,n=e.style.transform||"",r=new Map;t=transformRegex.exec(n);)r.set(t[1],t[2]);return r}}function getTransformValue(e,t,n,r){var a=stringContains(t,"scale")?1:0+getTransformUnit(t),i=getElementTransforms(e).get(t)||a;return n&&(n.transforms.list.set(t,i),n.transforms.last=t),r?convertPxToUnit(e,i,r):i}function getOriginalTargetValue(e,t,n,r){switch(getAnimationType(e,t)){case"transform":return getTransformValue(e,t,r,n);case"css":return getCSSValue(e,t,n);case"attribute":return getAttribute(e,t);default:return e[t]||0}}function getRelativeValue(e,t){var n=operatorRegex.exec(e);if(!n)return e;var r=getUnit(e)||0,a=parseFloat(t),i=parseFloat(e.replace(n[0],""));switch(n[0][0]){case"+":return a+i+r;case"-":return a-i+r;case"*":return a*i+r}}function validateValue(e,t){if(is.col(e))return colorToRgb(e);var n=getUnit(e),r=n?e.substr(0,e.length-n.length):e;return t&&!whitespaceRegex.test(e)?r+t:r}function getDistance(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function getCircleLength(e){return 2*Math.PI*getAttribute(e,"r")}function getRectLength(e){return 2*getAttribute(e,"width")+2*getAttribute(e,"height")}function getLineLength(e){return getDistance({x:getAttribute(e,"x1"),y:getAttribute(e,"y1")},{x:getAttribute(e,"x2"),y:getAttribute(e,"y2")})}function getPolylineLength(e){for(var t,n=e.points,r=0,a=0;a0&&(r+=getDistance(t,i)),t=i}return r}function getPolygonLength(e){var t=e.points;return getPolylineLength(e)+getDistance(t.getItem(t.numberOfItems-1),t.getItem(0))}function getTotalLength(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return getCircleLength(e);case"rect":return getRectLength(e);case"line":return getLineLength(e);case"polyline":return getPolylineLength(e);case"polygon":return getPolygonLength(e)}}function setDashoffset(e){var t=getTotalLength(e);return e.setAttribute("stroke-dasharray",t),t}function getParentSvgEl(e){for(var t=e.parentNode;is.svg(t)&&(t=t.parentNode,is.svg(t.parentNode)););return t}function getParentSvg(e,t){var n=t||{},r=n.el||getParentSvgEl(e),a=r.getBoundingClientRect(),i=getAttribute(r,"viewBox"),s=a.width,o=a.height,u=n.viewBox||(i?i.split(" "):[0,0,s,o]);return{el:r,viewBox:u,x:u[0]/1,y:u[1]/1,w:s/u[2],h:o/u[3]}}function getPath(e,t){var n=is.str(e)?selectString(e)[0]:e,r=t||100;return function(e){return{property:e,el:n,svg:getParentSvg(n),totalLength:getTotalLength(n)*(r/100)}}}function getPathProgress(e,t){function n(n){void 0===n&&(n=0);var r=t+n>=1?t+n:0;return e.el.getPointAtLength(r)}var r=getParentSvg(e.el,e.svg),a=n(),i=n(-1),s=n(1);switch(e.property){case"x":return(a.x-r.x)*r.w;case"y":return(a.y-r.y)*r.h;case"angle":return 180*Math.atan2(s.y-i.y,s.x-i.x)/Math.PI}}function decomposeValue(e,t){var n=validateValue(is.pth(e)?e.totalLength:e,t)+"";return{original:n,numbers:n.match(valueRegex)?n.match(valueRegex).map(Number):[0],strings:is.str(e)||t?n.split(valueRegex):[]}}function parseTargets(e){return filterArray(e?flattenArray(is.arr(e)?e.map(toArray):toArray(e)):[],function(e,t,n){return n.indexOf(e)===t})}function getAnimatables(e){var t=parseTargets(e);return t.map(function(e,n){return{target:e,id:n,total:t.length,transforms:{list:getElementTransforms(e)}}})}function normalizePropertyTweens(e,t){var n=cloneObject(t);if(springRegex.test(n.easing)&&(n.duration=spring(n.easing)),is.arr(e)){var r=e.length;2===r&&!is.obj(e[0])?e={value:e}:is.fnc(t.duration)||(n.duration=t.duration/r)}var a=is.arr(e)?e:[e];return a.map(function(e,n){var r=is.obj(e)&&!is.pth(e)?e:{value:e};return is.und(r.delay)&&(r.delay=n?0:t.delay),is.und(r.endDelay)&&(r.endDelay=n===a.length-1?t.endDelay:0),r}).map(function(e){return mergeObjects(e,n)})}function flattenKeyframes(e){for(var t=filterArray(flattenArray(e.map(function(e){return Object.keys(e)})),function(e){return is.key(e)}).reduce(function(e,t){return e.indexOf(t)<0&&e.push(t),e},[]),n={},r=0;r2||(h=Math.round(h*f)/f)),p.push(h)}var T=g.length;if(T){d=g[0];for(var A=0;A0&&(y.began=!0,u("begin"),u("loopBegin")),d<=i&&0!==y.currentTime&&o(0),(d>=l&&y.currentTime!==a||!a)&&o(a),d>i&&d=a&&(p=0,c(),y.remaining?(f=m,u("loopComplete"),u("loopBegin"),"alternate"===y.direction&&n()):(y.paused=!0,y.completed||(y.completed=!0,u("loopComplete"),u("complete"),"Promise"in window&&(v(),h=t()))))}void 0===e&&(e={});var g,f=0,p=0,m=0,d=0,v=null,h=t(),y=createNewInstance(e);return y.reset=function(){var e=y.direction;y.passThrough=!1,y.currentTime=0,y.progress=0,y.paused=!0,y.began=!1,y.changeBegan=!1,y.completed=!1,y.changeCompleted=!1,y.reversePlayback=!1,y.reversed="reverse"===e,y.remaining=y.loop,g=y.children,d=g.length;for(var t=d;t--;)y.children[t].reset();(y.reversed&&!0!==y.loop||"alternate"===e&&1===y.loop)&&y.remaining++,o(0)},y.set=function(e,t){return setTargetsValue(e,t),y},y.tick=function(e){m=e,f||(f=m),l((m+(p-f))*anime.speed)},y.seek=function(e){l(r(e))},y.pause=function(){y.paused=!0,a()},y.play=function(){y.paused&&(y.paused=!1,activeInstances.push(y),a(),raf||engine())},y.reverse=function(){n(),a()},y.restart=function(){y.reset(),y.play()},y.finished=h,y.reset(),y.autoplay&&y.play(),y}function removeTargetsFromAnimations(e,t){for(var n=t.length;n--;)arrayContains(e,t[n].animatable.target)&&t.splice(n,1)}function removeTargets(e){for(var t=parseTargets(e),n=activeInstances.length;n--;){var r=activeInstances[n],a=r.animations,i=r.children;removeTargetsFromAnimations(t,a);for(var s=i.length;s--;){var o=i[s],u=o.animations;removeTargetsFromAnimations(t,u),u.length||o.children.length||i.splice(s,1)}a.length||i.length||r.pause()}}function stagger(e,t){void 0===t&&(t={});var n=t.direction||"normal",r=t.easing?parseEasings(t.easing):null,a=t.grid,i=t.axis,s=t.from||0,o="first"===s,u="center"===s,c="last"===s,l=is.arr(e),g=l?parseFloat(e[0]):parseFloat(e),f=l?parseFloat(e[1]):0,p=getUnit(l?e[1]:e)||0,m=t.start||0+(l?g:0),d=[],v=0;return function(e,t,h){if(o&&(s=0),u&&(s=(h-1)/2),c&&(s=h-1),!d.length){for(var y=0;y-1&&activeInstances.splice(i,1);for(var o=0;o0?n=o:t=o}while(Math.abs(s)>1e-7&&++u<10);return o}function s(e,t,n,i){for(var s=0;s<4;++s){var o=a(t,n,i);if(0===o)return t;t-=(r(t,n,i)-e)/o}return t}function o(e,t,n,o){function l(t){for(var r=0,o=1,l=u-1;o!==l&&g[o]<=t;++o)r+=c;--o;var f=(t-g[o])/(g[o+1]-g[o]),p=r+f*c,m=a(p,e,n);return m>=.001?s(t,p,e,n):0===m?p:i(t,r,r+c,e,n)}if(0<=e&&e<=1&&0<=n&&n<=1){var g=new Float32Array(u);if(e!==t||n!==o)for(var f=0;f-1&&(activeInstances.splice(i,1),n=activeInstances.length)}else a.tick(t);r++}e()}else raf=cancelAnimationFrame(raf)}return e}();document.addEventListener("visibilitychange",handleVisibilityChange),anime.version="3.0.0",anime.speed=1,anime.running=activeInstances,anime.remove=removeTargets,anime.get=getOriginalTargetValue,anime.set=setTargetsValue,anime.convertPx=convertPxToUnit,anime.path=getPath,anime.setDashoffset=setDashoffset,anime.stagger=stagger,anime.timeline=timeline,anime.easing=parseEasings,anime.penner=penner,anime.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e},module.exports=anime; },{}],57:[function(_dereq_,module,exports){ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):(t=t||self,e(t.THREE={}))}(this,function(t){"use strict";function e(){}function r(t,e){this.x=t||0,this.y=e||0}function n(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==n?n:1}function i(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0}function a(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function o(t,e,n,i,s,c,l,h,u,p){Object.defineProperty(this,"id",{value:dl++}),this.uuid=sl.generateUUID(),this.name="",this.image=void 0!==t?t:o.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:o.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:Vs,this.wrapT=void 0!==i?i:Vs,this.magFilter=void 0!==s?s:Xs,this.minFilter=void 0!==c?c:Zs,this.anisotropy=void 0!==u?u:1,this.format=void 0!==l?l:hc,this.type=void 0!==h?h:Js,this.offset=new r(0,0),this.repeat=new r(1,1),this.center=new r(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new a,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==p?p:Wc,this.version=0,this.onUpdate=null}function s(t,e,r,n){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==n?n:1}function c(t,e,r){this.width=t,this.height=e,this.scissor=new s(0,0,t,e),this.scissorTest=!1,this.viewport=new s(0,0,t,e),r=r||{},this.texture=new o(void 0,void 0,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==r.generateMipmaps&&r.generateMipmaps,this.texture.minFilter=void 0!==r.minFilter?r.minFilter:Xs,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 l(t,e,r){c.call(this,t,e,r),this.samples=4}function h(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function u(t,e,r,n){this._x=t||0,this._y=e||0,this._z=r||0,this._order=n||u.DefaultOrder}function p(){this.mask=1}function d(){function t(){s.setFromEuler(o,!1)}function e(){o.setFromQuaternion(s,void 0,!1)}Object.defineProperty(this,"id",{value:Ml++}),this.uuid=sl.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=d.DefaultUp.clone();var r=new i,o=new u,s=new n,c=new i(1,1,1);o._onChange(t),s._onChange(e),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:r},rotation:{configurable:!0,enumerable:!0,value:o},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:c},modelViewMatrix:{value:new h},normalMatrix:{value:new a}}),this.matrix=new h,this.matrixWorld=new h,this.matrixAutoUpdate=d.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new p,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function f(){d.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function m(t,e){this.min=void 0!==t?t:new i(1/0,1/0,1/0),this.max=void 0!==e?e:new i(-1/0,-1/0,-1/0)}function v(t,e,r,n,i){var a,o;for(a=0,o=t.length-3;a<=o;a+=3){Xl.fromArray(t,a);var s=i.x*Math.abs(Xl.x)+i.y*Math.abs(Xl.y)+i.z*Math.abs(Xl.z),c=e.dot(Xl),l=r.dot(Xl),h=n.dot(Xl);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>s)return!1}return!0}function g(t,e){this.center=void 0!==t?t:new i,this.radius=void 0!==e?e:0}function y(t,e){this.origin=void 0!==t?t:new i,this.direction=void 0!==e?e:new i}function x(t,e,r){this.a=void 0!==t?t:new i,this.b=void 0!==e?e:new i,this.c=void 0!==r?r:new i}function b(t,e,r){return void 0===e&&void 0===r?this.set(t):this.setRGB(t,e,r)}function w(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t}function _(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function M(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function S(t,e,r,n,a,o){this.a=t,this.b=e,this.c=r,this.normal=n&&n.isVector3?n:new i,this.vertexNormals=Array.isArray(n)?n:[],this.color=a&&a.isColor?a:new b,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=void 0!==o?o:0}function T(){Object.defineProperty(this,"id",{value:mh++}),this.uuid=sl.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=Jo,this.side=jo,this.flatShading=!1,this.vertexTangents=!1,this.vertexColors=qo,this.opacity=1,this.transparent=!1,this.blendSrc=hs,this.blendDst=us,this.blendEquation=es,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=bs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=il,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=nl,this.stencilZFail=nl,this.stencilZPass=nl,this.stencilWrite=!1,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.visible=!0,this.toneMapped=!0,this.userData={},this.needsUpdate=!0}function E(t){T.call(this),this.type="MeshBasicMaterial",this.color=new b(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=Ts,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(t)}function A(t,e,r){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===r,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function L(t,e,r){A.call(this,new Int8Array(t),e,r)}function R(t,e,r){A.call(this,new Uint8Array(t),e,r)}function P(t,e,r){A.call(this,new Uint8ClampedArray(t),e,r)}function C(t,e,r){A.call(this,new Int16Array(t),e,r)}function O(t,e,r){A.call(this,new Uint16Array(t),e,r)}function D(t,e,r){A.call(this,new Int32Array(t),e,r)}function I(t,e,r){A.call(this,new Uint32Array(t),e,r)}function N(t,e,r){A.call(this,new Float32Array(t),e,r)}function z(t,e,r){A.call(this,new Float64Array(t),e,r)}function B(){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 F(t){if(0===t.length)return-1/0;for(var e=t[0],r=1,n=t.length;re&&(e=t[r]);return e}function G(){Object.defineProperty(this,"id",{value:vh+=2}),this.uuid=sl.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 U(t,e){d.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new G,this.material=void 0!==e?e:new E({color:16777215*Math.random()}),this.drawMode=Vc,this.updateMorphTargets()}function H(t,e,r,n,i,a,o,s){if(null===(e.side===ko?n.intersectTriangle(o,a,i,!0,s):n.intersectTriangle(i,a,o,e.side!==Wo,s)))return null;Gh.copy(s),Gh.applyMatrix4(t.matrixWorld);var c=r.ray.origin.distanceTo(Gh);return cr.far?null:{distance:c,point:Gh.clone(),object:t}}function V(t,e,n,i,a,o,s,c,l,h,u){Eh.fromBufferAttribute(a,l),Ah.fromBufferAttribute(a,h),Lh.fromBufferAttribute(a,u);var p=t.morphTargetInfluences;if(e.morphTargets&&o&&p){Oh.set(0,0,0),Dh.set(0,0,0),Ih.set(0,0,0);for(var d=0,f=o.length;d0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a,o="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext,s=void 0!==r.precision?r.precision:"highp",c=i(s);c!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",c,"instead."),s=c);var l=!0===r.logarithmicDepthBuffer,h=t.getParameter(34930),u=t.getParameter(35660),p=t.getParameter(3379),d=t.getParameter(34076),f=t.getParameter(34921),m=t.getParameter(36347),v=t.getParameter(36348),g=t.getParameter(36349),y=u>0,x=o||!!e.get("OES_texture_float"),b=y&&x,w=o?t.getParameter(36183):0,_=e.get("OVR_multiview2"),M=o&&!!_&&!t.getContextAttributes().antialias;return{isWebGL2:o,getMaxAnisotropy:n,getMaxPrecision:i,precision:s,logarithmicDepthBuffer:l,maxTextures:h,maxVertexTextures:u,maxTextureSize:p,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:g,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:b,maxSamples:w,multiview:M,maxMultiviewViews:M?t.getParameter(_.MAX_VIEWS_OVR):0}}function st(){function t(){h.value!==n&&(h.value=n,h.needsUpdate=i>0),r.numPlanes=i,r.numIntersection=0}function e(t,e,n,i){var a=null!==t?t.length:0,o=null;if(0!==a){if(o=h.value,!0!==i||null===o){var s=n+4*a,u=e.matrixWorldInverse;l.getNormalMatrix(u),(null===o||o.length65535?I:O)(r,1);d.version=a,e.update(d,34963);var f=l.get(t);f&&e.remove(f),l.set(t,d)}function s(t){var e=l.get(t);if(e){var r=t.index;null!==r&&e.version0)return t;var i=e*r,a=lu[i];if(void 0===a&&(a=new Float32Array(i),lu[i]=a),0!==e){n.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=r,t[o].toArray(a,s)}return a}function xt(t,e){if(t.length!==e.length)return!1;for(var r=0,n=t.length;r");return ge(r)}var r=/^[ \t]*#include +<([\w\d.\/]+)>/gm;return t.replace(r,e)}function ye(t){function e(t,e,r,n){for(var i="",a=parseInt(e);a0?t.gammaFactor:1,y=o.isWebGL2?"":ue(n.extensions,a,e),x=pe(h),b=l.createProgram(),w=t.getRenderTarget(),_=w&&w.isWebGLMultiviewRenderTarget?w.numViews:0;if(n.isRawShaderMaterial?(s=[x].filter(fe).join("\n"),s.length>0&&(s+="\n"),c=[y,x].filter(fe).join("\n"),c.length>0&&(c+="\n")):(s=[xe(a),"#define SHADER_NAME "+i.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.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+m:"",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.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_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.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+d:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform vec3 cameraPosition;",_>0?["uniform mat4 modelViewMatrices["+_+"];","uniform mat3 normalMatrices["+_+"];","uniform mat4 viewMatrices["+_+"];","uniform mat4 projectionMatrices["+_+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]"].join("\n"):["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),"attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#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(fe).join("\n"),c=[y,xe(a),"#define SHADER_NAME "+i.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.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+f:"",a.envMap?"#define "+m:"",a.envMap?"#define "+v:"",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.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",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 "+d:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensions&&n.extensions.shaderTextureLOD||a.envMap)&&(o.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform vec3 cameraPosition;",_>0?["uniform mat4 viewMatrices["+_+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n"):"uniform mat4 viewMatrix;",a.toneMapping!==Ls?"#define TONE_MAPPING":"",a.toneMapping!==Ls?ru.tonemapping_pars_fragment:"",a.toneMapping!==Ls?he("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?ru.encodings_pars_fragment:"",a.mapEncoding?ce("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?ce("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?ce("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?ce("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?le("linearToOutputTexel",a.outputEncoding):"",a.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(fe).join("\n")),u=ge(u),u=me(u,a),u=ve(u,a),p=ge(p),p=me(p,a),p=ve(p,a),u=ye(u),p=ye(p),o.isWebGL2&&!n.isRawShaderMaterial){var M=!1,S=/^\s*#version\s+300\s+es\s*\n/;n.isShaderMaterial&&null!==u.match(S)&&null!==p.match(S)&&(M=!0,u=u.replace(S,""),p=p.replace(S,"")),s=["#version 300 es\n",_>0?["#extension GL_OVR_multiview2 : require","layout(num_views = "+_+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"):"","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+s,c=["#version 300 es\n",_>0?["#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"):"","#define varying in",M?"":"out highp vec4 pc_fragColor;",M?"":"#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"+c}var T=s+u,E=c+p,A=ie(l,35633,T),L=ie(l,35632,E);if(l.attachShader(b,A),l.attachShader(b,L),void 0!==n.index0AttributeName?l.bindAttribLocation(b,0,n.index0AttributeName):!0===a.morphTargets&&l.bindAttribLocation(b,0,"position"),l.linkProgram(b),t.debug.checkShaderErrors){var R=l.getProgramInfoLog(b).trim(),P=l.getShaderInfoLog(A).trim(),C=l.getShaderInfoLog(L).trim(),O=!0,D=!0;if(!1===l.getProgramParameter(b,35714)){O=!1;var I=se(l,A,"vertex"),N=se(l,L,"fragment");console.error("THREE.WebGLProgram: shader error: ",l.getError(),"35715",l.getProgramParameter(b,35715),"gl.getProgramInfoLog",R,I,N)}else""!==R?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",R):""!==P&&""!==C||(D=!1);D&&(this.diagnostics={runnable:O,material:n,programLog:R,vertexShader:{log:P,prefix:s},fragmentShader:{log:C,prefix:c}})}l.deleteShader(A),l.deleteShader(L);var z;this.getUniforms=function(){return void 0===z&&(z=new ne(l,b)),z};var B;return this.getAttributes=function(){return void 0===B&&(B=de(l,b)),B},this.destroy=function(){l.deleteProgram(b),this.program=void 0},this.name=i.name,this.id=mu++,this.code=r,this.usedTimes=1,this.program=b,this.vertexShader=A,this.fragmentShader=L,this.numMultiviewViews=_,this}function Te(t,e,r){function n(t){var e=t.skeleton,n=e.bones;if(r.floatVertexTextures)return 1024;var i=r.maxVertexUniforms,a=Math.floor((i-20)/4),o=Math.min(a,n.length);return o0,maxBones:d,useVertexTexture:r.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numClippingPlanes:l,numClipIntersection:h,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&s.length>0,shadowMapType:t.shadowMap.type,toneMapping:e.toneMapped?t.toneMapping:Ls,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===Wo,flipSided:e.side===ko,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,r){var n=[];if(r.shaderID?n.push(r.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)n.push(i),n.push(e.defines[i]);for(var a=0;a1&&s.sort(Ae),c.length>1&&c.sort(Le)}var a=[],o=0,s=[],c=[],l={id:-1};return{opaque:s,transparent:c,init:t,push:r,unshift:n,sort:i}}function Pe(){function t(e){var r=e.target;r.removeEventListener("dispose",t),n.delete(r)}function e(e,r){var i,a=n.get(e);return void 0===a?(i=new Re,n.set(e,new WeakMap),n.get(e).set(r,i),e.addEventListener("dispose",t)):void 0===(i=a.get(r))&&(i=new Re,a.set(r,i)),i}function r(){n=new WeakMap}var n=new WeakMap;return{get:e,dispose:r}}function Ce(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var n;switch(e.type){case"DirectionalLight":n={direction:new i,color:new b,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r};break;case"SpotLight":n={position:new i,direction:new i,color:new b,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r};break;case"PointLight":n={position:new i,color:new b,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new r,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new i,skyColor:new b,groundColor:new b};break;case"RectAreaLight":n={color:new b,position:new i,halfWidth:new i,halfHeight:new i}}return t[e.id]=n,n}}}function Oe(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function De(){function t(t,n,i){for(var c=0,l=0,h=0,u=0;u<9;u++)r.probe[u].set(0,0,0);var p=0,d=0,f=0,m=0,v=0,g=0,y=0,x=0,b=i.matrixWorldInverse;t.sort(Oe);for(var u=0,w=t.length;u0:s&&s.isGeometry&&(u=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&!1===r.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var p=e.isSkinnedMesh&&r.skinning,m=0;u&&(m|=d),p&&(m|=f),c=l[m]}if(t.localClippingEnabled&&!0===r.clipShadows&&0!==r.clippingPlanes.length){var b=c.uuid,w=r.uuid,_=y[b];void 0===_&&(_={},y[b]=_);var M=_[w];void 0===M&&(M=c.clone(),_[w]=M),c=M}return c.visible=r.visible,c.wireframe=r.wireframe,c.side=o===Vo?null!=r.shadowSide?r.shadowSide:r.side:null!=r.shadowSide?r.shadowSide:x[r.side],c.clipShadows=r.clipShadows,c.clippingPlanes=r.clippingPlanes,c.clipIntersection=r.clipIntersection,c.wireframeLinewidth=r.wireframeLinewidth,c.linewidth=r.linewidth,n.isPointLight&&c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(n.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function o(r,n,i,s,c){if(!1!==r.visible){if(r.layers.test(n.layers)&&(r.isMesh||r.isLine||r.isPoints)&&(r.castShadow||r.receiveShadow&&c===Vo)&&(!r.frustumCulled||l.intersectsObject(r))){r.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,r.matrixWorld);var h=e.update(r),u=r.material;if(Array.isArray(u))for(var p=h.groups,d=0,f=p.length;dn||h.y>n)&&(console.warn("THREE.WebGLShadowMap:",y,"has shadow exceeding max texture size, reducing"),h.x>n&&(u.x=Math.floor(n/b.x),h.x=u.x*b.x,x.mapSize.x=u.x),h.y>n&&(u.y=Math.floor(n/b.y),h.y=u.y*b.y,x.mapSize.y=u.y)),null===x.map&&!x.isPointLightShadow&&this.type===Vo){var w={minFilter:Xs,magFilter:Xs,format:hc};x.map=new c(h.x,h.y,w),x.map.texture.name=y.name+".shadowMap",x.mapPass=new c(h.x,h.y,w),x.camera.updateProjectionMatrix()}if(null===x.map){var w={minFilter:ks,magFilter:ks,format:hc};x.map=new c(h.x,h.y,w),x.map.texture.name=y.name+".shadowMap",x.camera.updateProjectionMatrix()}t.setRenderTarget(x.map),t.clear();for(var _=x.getViewportCount(),M=0;M<_;M++){var S=x.getViewport(M);p.set(u.x*S.x,u.y*S.y,u.x*S.z,u.y*S.w),m.viewport(p),x.updateMatrices(y,a,M),l=x.getFrustum(),o(r,a,x.camera,y,this.type)}x.isPointLightShadow||this.type!==Vo||i(x,a)}else console.warn("THREE.WebGLShadowMap:",y,"has no shadow.")}P.needsUpdate=!1,t.setRenderTarget(s,d,f)}}}function Ge(t,e,r,n){function i(){var e=!1,r=new s,n=null,i=new s(0,0,0,0);return{setMask:function(r){n===r||e||(t.colorMask(r,r,r,r),n=r)},setLocked:function(t){e=t},setClear:function(e,n,a,o,s){!0===s&&(e*=o,n*=o,a*=o),r.set(e,n,a,o),!1===i.equals(r)&&(t.clearColor(e,n,a,o),i.copy(r))},reset:function(){e=!1,n=null,i.set(-1,0,0,0)}}}function a(){var e=!1,r=null,n=null,i=null;return{setTest:function(t){t?d(2929):f(2929)},setMask:function(n){r===n||e||(t.depthMask(n),r=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case gs:t.depthFunc(512);break;case ys:t.depthFunc(519);break;case xs:t.depthFunc(513);break;case bs:t.depthFunc(515);break;case ws:t.depthFunc(514);break;case _s:t.depthFunc(518);break;case Ms:t.depthFunc(516);break;case Ss:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);n=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,r=null,n=null,i=null}}}function o(){var e=!1,r=null,n=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){e||(t?d(2960):f(2960))},setMask:function(n){r===n||e||(t.stencilMask(n),r=n)},setFunc:function(e,r,o){n===e&&i===r&&a===o||(t.stencilFunc(e,r,o),n=e,i=r,a=o)},setOp:function(e,r,n){o===e&&s===r&&c===n||(t.stencilOp(e,r,n),o=e,s=r,c=n)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,r=null,n=null,i=null,a=null,o=null,s=null,c=null,l=null}}}function c(e,r,n){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;o=1):-1!==at.indexOf("OpenGL ES")&&(it=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(at)[1]),nt=it>=2);var ot=null,st={},ct=new s,lt=new s,ht={};return ht[3553]=c(3553,3553,1),ht[34067]=c(34067,34069,6),O.setClear(0,0,0,1),D.setClear(1),I.setClear(0),d(2929),D.setFunc(bs),x(!1),b(Fo),d(2884),g(Zo),{buffers:{color:O,depth:D,stencil:I},initAttributes:l,enableAttribute:h,enableAttributeAndDivisor:u,disableUnusedAttributes:p,enable:d,disable:f,getCompressedTextureFormats:m,useProgram:v,setBlending:g,setMaterial:y,setFlipSided:x,setCullFace:b,setLineWidth:w,setPolygonOffset:_,setScissorTest:M,activeTexture:S,bindTexture:T,compressedTexImage2D:E,texImage2D:A,texImage3D:L,scissor:R,viewport:P,reset:C}}function Ue(t,e,r,n,i,a,o){function s(t,e){return V?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function c(t,e,r,n){var i=1;if((t.width>n||t.height>n)&&(i=n/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var a=e?sl.floorPowerOfTwo:Math.floor,o=a(i*t.width),c=a(i*t.height);void 0===U&&(U=s(o,c));var l=r?s(o,c):U;l.width=o,l.height=c;return l.getContext("2d").drawImage(t,0,0,o,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+c+")."),l}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function l(t){return sl.isPowerOfTwo(t.width)&&sl.isPowerOfTwo(t.height)}function h(t){return!i.isWebGL2&&(t.wrapS!==Vs||t.wrapT!==Vs||t.minFilter!==ks&&t.minFilter!==Xs)}function u(t,e){return t.generateMipmaps&&e&&t.minFilter!==ks&&t.minFilter!==Xs}function p(e,r,i,a){t.generateMipmap(e),n.get(r).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function d(t,r){if(!i.isWebGL2)return t;var n=t;return 6403===t&&(5126===r&&(n=33326),5131===r&&(n=33325),5121===r&&(n=33321)),6407===t&&(5126===r&&(n=34837),5131===r&&(n=34843),5121===r&&(n=32849)),6408===t&&(5126===r&&(n=34836),5131===r&&(n=34842),5121===r&&(n=32856)),33325===n||33326===n||34842===n||34836===n?e.get("EXT_color_buffer_float"):34843!==n&&34837!==n||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),n}function f(t){return t===ks||t===Ws||t===qs?9728:9729}function m(t){var e=t.target;e.removeEventListener("dispose",m),g(e),e.isVideoTexture&&H.delete(e),o.memory.textures--}function v(t){var e=t.target;e.removeEventListener("dispose",v),y(e),o.memory.textures--}function g(e){var r=n.get(e);void 0!==r.__webglInit&&(t.deleteTexture(r.__webglTexture),n.remove(e))}function y(e){var r=n.get(e),i=n.get(e.texture);if(e){if(void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(r.__webglFramebuffer[a]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[a]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){t.deleteTexture(r.__webglColorTexture),t.deleteTexture(r.__webglDepthStencilTexture),o.memory.textures-=2;for(var a=0,s=r.__webglViewFramebuffers.length;a=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+i.maxTextures),j+=1,t}function w(t,e){var i=n.get(t);if(t.isVideoTexture&&B(t),t.version>0&&i.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void L(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}r.activeTexture(33984+e),r.bindTexture(3553,i.__webglTexture)}function _(t,e){var i=n.get(t);if(t.version>0&&i.__version!==t.version)return void L(i,t,e);r.activeTexture(33984+e),r.bindTexture(35866,i.__webglTexture)}function M(t,e){var i=n.get(t);if(t.version>0&&i.__version!==t.version)return void L(i,t,e);r.activeTexture(33984+e),r.bindTexture(32879,i.__webglTexture)}function S(e,o){if(6===e.image.length){var s=n.get(e);if(e.version>0&&s.__version!==e.version){A(s,e),r.activeTexture(33984+o),r.bindTexture(34067,s.__webglTexture),t.pixelStorei(37440,e.flipY);for(var h=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,m=[],v=0;v<6;v++)m[v]=h||f?f?e.image[v].image:e.image[v]:c(e.image[v],!1,!0,i.maxCubemapSize);var g=m[0],y=l(g)||i.isWebGL2,x=a.convert(e.format),b=a.convert(e.type),w=d(x,b);E(34067,e,y);var _;if(h){for(var v=0;v<6;v++){_=m[v].mipmaps;for(var M=0;M<_.length;M++){var S=_[M];e.format!==hc&&e.format!==lc?r.getCompressedTextureFormats().indexOf(x)>-1?r.compressedTexImage2D(34069+v,M,w,S.width,S.height,0,S.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):r.texImage2D(34069+v,M,w,S.width,S.height,0,x,b,S.data)}}s.__maxMipLevel=_.length-1}else{_=e.mipmaps;for(var v=0;v<6;v++)if(f){r.texImage2D(34069+v,0,w,m[v].width,m[v].height,0,x,b,m[v].data);for(var M=0;M<_.length;M++){var S=_[M],T=S.image[v].image;r.texImage2D(34069+v,M+1,w,T.width,T.height,0,x,b,T.data)}}else{r.texImage2D(34069+v,0,w,x,b,m[v]);for(var M=0;M<_.length;M++){var S=_[M];r.texImage2D(34069+v,M+1,w,x,b,S.image[v])}}s.__maxMipLevel=_.length}u(e,y)&&p(34067,e,g.width,g.height),s.__version=e.version,e.onUpdate&&e.onUpdate(e)}else r.activeTexture(33984+o),r.bindTexture(34067,s.__webglTexture)}}function T(t,e){r.activeTexture(33984+e),r.bindTexture(34067,n.get(t).__webglTexture)}function E(r,o,s){var c;if(s?(t.texParameteri(r,10242,a.convert(o.wrapS)),t.texParameteri(r,10243,a.convert(o.wrapT)),32879!==r&&35866!==r||t.texParameteri(r,32882,a.convert(o.wrapR)),t.texParameteri(r,10240,a.convert(o.magFilter)),t.texParameteri(r,10241,a.convert(o.minFilter))):(t.texParameteri(r,10242,33071),t.texParameteri(r,10243,33071),32879!==r&&35866!==r||t.texParameteri(r,32882,33071),o.wrapS===Vs&&o.wrapT===Vs||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(r,10240,f(o.magFilter)),t.texParameteri(r,10241,f(o.minFilter)),o.minFilter!==ks&&o.minFilter!==Xs&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),c=e.get("EXT_texture_filter_anisotropic")){if(o.type===rc&&null===e.get("OES_texture_float_linear"))return;if(o.type===nc&&null===(i.isWebGL2||e.get("OES_texture_half_float_linear")))return;(o.anisotropy>1||n.get(o).__currentAnisotropy)&&(t.texParameterf(r,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,i.getMaxAnisotropy())),n.get(o).__currentAnisotropy=o.anisotropy)}}function A(e,r){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",m),e.__webglTexture=t.createTexture(),o.memory.textures++)}function L(e,n,o){var s=3553;n.isDataTexture2DArray&&(s=35866),n.isDataTexture3D&&(s=32879),A(e,n),r.activeTexture(33984+o),r.bindTexture(s,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment);var f=h(n)&&!1===l(n.image),m=c(n.image,f,!1,i.maxTextureSize),v=l(m)||i.isWebGL2,g=a.convert(n.format),y=a.convert(n.type),x=d(g,y);E(s,n,v);var b,w=n.mipmaps;if(n.isDepthTexture){if(x=6402,n.type===rc){if(!i.isWebGL2)throw new Error("Float Depth Texture only supported in WebGL2.0");x=36012}else i.isWebGL2&&(x=33189);n.format===fc&&6402===x&&n.type!==$s&&n.type!==ec&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=$s,y=a.convert(n.type)),n.format===mc&&(x=34041,n.type!==sc&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=sc,y=a.convert(n.type))),r.texImage2D(3553,0,x,m.width,m.height,0,g,y,null)}else if(n.isDataTexture)if(w.length>0&&v){for(var _=0,M=w.length;_-1?r.compressedTexImage2D(3553,_,x,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texImage2D(3553,_,x,b.width,b.height,0,g,y,b.data);e.__maxMipLevel=w.length-1}else if(n.isDataTexture2DArray)r.texImage3D(35866,0,x,m.width,m.height,m.depth,0,g,y,m.data),e.__maxMipLevel=0;else if(n.isDataTexture3D)r.texImage3D(32879,0,x,m.width,m.height,m.depth,0,g,y,m.data),e.__maxMipLevel=0;else if(w.length>0&&v){for(var _=0,M=w.length;_M)return!1;for(var r=1,n=e.length;r=0){var c=n[o];if(void 0!==c){var l=c.normalized,h=c.itemSize,u=jt.get(c);if(void 0===u)continue;var p=u.buffer,d=u.type,f=u.bytesPerElement;if(c.isInterleavedBufferAttribute){var m=c.data,v=m.stride,g=c.offset;m&&m.isInstancedInterleavedBuffer?(Gt.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=m.meshPerAttribute*m.count)):Gt.enableAttribute(s),Z.bindBuffer(34962,p),Z.vertexAttribPointer(s,h,d,l,v*f,g*f)}else c.isInstancedBufferAttribute?(Gt.enableAttributeAndDivisor(s,c.meshPerAttribute),void 0===r.maxInstancedCount&&(r.maxInstancedCount=c.meshPerAttribute*c.count)):Gt.enableAttribute(s),Z.bindBuffer(34962,p),Z.vertexAttribPointer(s,h,d,l,0,0)}else if(void 0!==a){var y=a[o];if(void 0!==y)switch(y.length){case 2:Z.vertexAttrib2fv(s,y);break;case 3:Z.vertexAttrib3fv(s,y);break;case 4:Z.vertexAttrib4fv(s,y);break;default:Z.vertexAttrib1fv(s,y)}}}}Gt.disableUnusedAttributes()}function f(t){te.isPresenting()||ie&&ie(t)}function m(t,e,r,n){if(!1!==t.visible){if(t.layers.test(e.layers))if(t.isGroup)r=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)Y.pushLight(t),t.castShadow&&Y.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||Pt.intersectsSprite(t)){n&&Nt.setFromMatrixPosition(t.matrixWorld).applyMatrix4(It);var i=Wt.update(t),a=t.material;a.visible&&X.push(t,i,a,r,Nt.z,null)}}else if(t.isImmediateRenderObject)n&&Nt.setFromMatrixPosition(t.matrixWorld).applyMatrix4(It),X.push(t,null,t.material,r,Nt.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||Pt.intersectsObject(t))){n&&Nt.setFromMatrixPosition(t.matrixWorld).applyMatrix4(It);var i=Wt.update(t),a=t.material;if(Array.isArray(a))for(var o=i.groups,s=0,c=o.length;s=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var m=0;m=0&&t.numSupportedMorphNormals++}var v=n.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=Ct.numPlanes,n.numIntersection=Ct.numIntersection,v.clippingPlanes=Ct.uniform),n.fog=e,n.lightsStateVersion=o,t.lights&&(v.ambientLightColor.value=i.state.ambient,v.lightProbe.value=i.state.probe,v.directionalLights.value=i.state.directional,v.spotLights.value=i.state.spot,v.rectAreaLights.value=i.state.rectArea,v.pointLights.value=i.state.point,v.hemisphereLights.value=i.state.hemi,v.directionalShadowMap.value=i.state.directionalShadowMap,v.directionalShadowMatrix.value=i.state.directionalShadowMatrix,v.spotShadowMap.value=i.state.spotShadowMap,v.spotShadowMatrix.value=i.state.spotShadowMatrix,v.pointShadowMap.value=i.state.pointShadowMap,v.pointShadowMatrix.value=i.state.pointShadowMatrix);var g=n.program.getUniforms(),y=ne.seqWithValue(g.seq,v);n.uniformsList=y}function x(t,e,r,n){Vt.resetTextureUnits();var i=Ht.get(r),a=Y.state.lights;if(Ot&&(Dt||t!==xt)){var o=t===xt&&r.id===gt;Ct.setState(r.clippingPlanes,r.clipIntersection,r.clipShadows,t,i,o)}!1===r.needsUpdate&&(void 0===i.program?r.needsUpdate=!0:r.fog&&i.fog!==e?r.needsUpdate=!0:r.lights&&i.lightsStateVersion!==a.state.version?r.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===Ct.numPlanes&&i.numIntersection===Ct.numIntersection||(r.needsUpdate=!0)),r.needsUpdate&&(y(r,e,n),r.needsUpdate=!1);var s=!1,c=!1,l=!1,h=i.program,u=h.getUniforms(),p=i.shader.uniforms;if(Gt.useProgram(h.program)&&(s=!0,c=!0,l=!0),r.id!==gt&&(gt=r.id,c=!0),s||xt!==t){if(h.numMultiviewViews>0?ee.updateCameraProjectionMatricesUniform(t,u):u.setValue(Z,"projectionMatrix",t.projectionMatrix),Ft.logarithmicDepthBuffer&&u.setValue(Z,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),xt!==t&&(xt=t,c=!0,l=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshStandardMaterial||r.envMap){var d=u.map.cameraPosition;void 0!==d&&d.setValue(Z,Nt.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.skinning)&&(h.numMultiviewViews>0?ee.updateCameraViewMatricesUniform(t,u):u.setValue(Z,"viewMatrix",t.matrixWorldInverse))}if(r.skinning){u.setOptional(Z,n,"bindMatrix"),u.setOptional(Z,n,"bindMatrixInverse");var f=n.skeleton;if(f){var m=f.bones;if(Ft.floatVertexTextures){if(void 0===f.boneTexture){var v=Math.sqrt(4*m.length);v=sl.ceilPowerOfTwo(v),v=Math.max(v,4);var g=new Float32Array(v*v*4);g.set(f.boneMatrices);var x=new Q(g,v,v,hc,rc);f.boneMatrices=g,f.boneTexture=x,f.boneTextureSize=v}u.setValue(Z,"boneTexture",f.boneTexture,Vt),u.setValue(Z,"boneTextureSize",f.boneTextureSize)}else u.setOptional(Z,f,"boneMatrices")}}return(c||i.receiveShadow!==n.receiveShadow)&&(i.receiveShadow=n.receiveShadow,u.setValue(Z,"receiveShadow",n.receiveShadow)),c&&(u.setValue(Z,"toneMappingExposure",J.toneMappingExposure),u.setValue(Z,"toneMappingWhitePoint",J.toneMappingWhitePoint),r.lights&&N(p,l),e&&r.fog&&T(p,e),r.isMeshBasicMaterial?b(p,r):r.isMeshLambertMaterial?(b(p,r),E(p,r)):r.isMeshPhongMaterial?(b(p,r),r.isMeshToonMaterial?L(p,r):A(p,r)):r.isMeshStandardMaterial?(b(p,r),r.isMeshPhysicalMaterial?P(p,r):R(p,r)):r.isMeshMatcapMaterial?(b(p,r),C(p,r)):r.isMeshDepthMaterial?(b(p,r),O(p,r)):r.isMeshDistanceMaterial?(b(p,r),D(p,r)):r.isMeshNormalMaterial?(b(p,r),I(p,r)):r.isLineBasicMaterial?(w(p,r),r.isLineDashedMaterial&&_(p,r)):r.isPointsMaterial?M(p,r):r.isSpriteMaterial?S(p,r):r.isShadowMaterial&&(p.color.value.copy(r.color),p.opacity.value=r.opacity),void 0!==p.ltc_1&&(p.ltc_1.value=nu.LTC_1),void 0!==p.ltc_2&&(p.ltc_2.value=nu.LTC_2),ne.upload(Z,i.uniformsList,p,Vt)),r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(ne.upload(Z,i.uniformsList,p,Vt),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&u.setValue(Z,"center",n.center),h.numMultiviewViews>0?ee.updateObjectMatricesUniforms(n,t,u):(u.setValue(Z,"modelViewMatrix",n.modelViewMatrix),u.setValue(Z,"normalMatrix",n.normalMatrix)),u.setValue(Z,"modelMatrix",n.matrixWorld),h}function b(t,e){t.opacity.value=e.opacity,e.color&&t.diffuse.value.copy(e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=Ht.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var r;e.map?r=e.map:e.specularMap?r=e.specularMap:e.displacementMap?r=e.displacementMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.roughnessMap?r=e.roughnessMap:e.metalnessMap?r=e.metalnessMap:e.alphaMap?r=e.alphaMap:e.emissiveMap&&(r=e.emissiveMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}function w(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}function _(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function M(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*Et,t.scale.value=.5*Tt,t.map.value=e.map,null!==e.map&&(!0===e.map.matrixAutoUpdate&&e.map.updateMatrix(),t.uvTransform.value.copy(e.map.matrix))}function S(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,t.map.value=e.map,null!==e.map&&(!0===e.map.matrixAutoUpdate&&e.map.updateMatrix(),t.uvTransform.value.copy(e.map.matrix))}function T(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function E(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function A(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===ko&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===ko&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function L(t,e){A(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function R(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===ko&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===ko&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function P(t,e){R(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===ko&&t.clearcoatNormalScale.value.negate()),t.transparency.value=e.transparency}function C(t,e){e.matcap&&(t.matcap.value=e.matcap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===ko&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===ko&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function O(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function D(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}function I(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===ko&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===ko&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function N(t,e){t.ambientLightColor.needsUpdate=e,t.lightProbe.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}t=t||{};var z=void 0!==t.canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),B=void 0!==t.context?t.context:null,F=void 0!==t.alpha&&t.alpha,G=void 0===t.depth||t.depth,U=void 0===t.stencil||t.stencil,H=void 0!==t.antialias&&t.antialias,V=void 0===t.premultipliedAlpha||t.premultipliedAlpha,j=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,W=void 0!==t.powerPreference?t.powerPreference:"default",q=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat,X=null,Y=null;this.domElement=z,this.debug={checkShaderErrors:!0},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=Rs,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var Z,J=this,K=!1,rt=null,nt=0,pt=0,mt=null,vt=null,gt=-1,yt={geometry:null,program:null,wireframe:!1},xt=null,bt=null,wt=new s,_t=new s,Mt=null,St=z.width,Tt=z.height,Et=1,At=new s(0,0,St,Tt),Lt=new s(0,0,St,Tt),Rt=!1,Pt=new $,Ct=new st,Ot=!1,Dt=!1,It=new h,Nt=new i;try{var zt={alpha:F,depth:G,stencil:U,antialias:H,premultipliedAlpha:V,preserveDrawingBuffer:j,powerPreference:W,failIfMajorPerformanceCaveat:q,xrCompatible:!0};if(z.addEventListener("webglcontextlost",a,!1),z.addEventListener("webglcontextrestored",o,!1),null===(Z=B||z.getContext("webgl",zt)||z.getContext("experimental-webgl",zt)))throw null!==z.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===Z.getShaderPrecisionFormat&&(Z.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}var Bt,Ft,Gt,Ut,Ht,Vt,jt,kt,Wt,qt,Xt,Yt,Zt,Jt,Qt,Kt,$t;n();var te="undefined"!=typeof navigator&&"xr"in navigator&&"supportsSession"in navigator.xr?new Ye(J,Z):new Xe(J);this.vr=te;var ee=new je(J,Z),re=new Fe(J,Wt,Ft.maxTextureSize);this.shadowMap=re,this.getContext=function(){return Z},this.getContextAttributes=function(){return Z.getContextAttributes()},this.forceContextLoss=function(){var t=Bt.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=Bt.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return Et},this.setPixelRatio=function(t){void 0!==t&&(Et=t,this.setSize(St,Tt,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new r),t.set(St,Tt)},this.setSize=function(t,e,r){if(te.isPresenting())return void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");St=t,Tt=e,z.width=Math.floor(t*Et),z.height=Math.floor(e*Et),!1!==r&&(z.style.width=t+"px",z.style.height=e+"px"),this.setViewport(0,0,t,e)},this.getDrawingBufferSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),t=new r),t.set(St*Et,Tt*Et).floor()},this.setDrawingBufferSize=function(t,e,r){St=t,Tt=e,Et=r,z.width=Math.floor(t*r),z.height=Math.floor(e*r),this.setViewport(0,0,t,e)},this.getCurrentViewport=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),t=new s),t.copy(wt)},this.getViewport=function(t){return t.copy(At)},this.setViewport=function(t,e,r,n){t.isVector4?At.set(t.x,t.y,t.z,t.w):At.set(t,e,r,n),Gt.viewport(wt.copy(At).multiplyScalar(Et).floor())},this.getScissor=function(t){return t.copy(Lt)},this.setScissor=function(t,e,r,n){t.isVector4?Lt.set(t.x,t.y,t.z,t.w):Lt.set(t,e,r,n),Gt.scissor(_t.copy(Lt).multiplyScalar(Et).floor())},this.getScissorTest=function(){return Rt},this.setScissorTest=function(t){Gt.setScissorTest(Rt=t)},this.getClearColor=function(){return Zt.getClearColor()},this.setClearColor=function(){Zt.setClearColor.apply(Zt,arguments)},this.getClearAlpha=function(){return Zt.getClearAlpha()},this.setClearAlpha=function(){Zt.setClearAlpha.apply(Zt,arguments)},this.clear=function(t,e,r){var n=0;(void 0===t||t)&&(n|=16384),(void 0===e||e)&&(n|=256),(void 0===r||r)&&(n|=1024),Z.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){z.removeEventListener("webglcontextlost",a,!1),z.removeEventListener("webglcontextrestored",o,!1),Xt.dispose(),Yt.dispose(),Ht.dispose(),Wt.dispose(),te.dispose(),ae.stop()},this.renderBufferImmediate=function(t,e){Gt.initAttributes();var r=Ht.get(t);t.hasPositions&&!r.position&&(r.position=Z.createBuffer()),t.hasNormals&&!r.normal&&(r.normal=Z.createBuffer()),t.hasUvs&&!r.uv&&(r.uv=Z.createBuffer()),t.hasColors&&!r.color&&(r.color=Z.createBuffer());var n=e.getAttributes();t.hasPositions&&(Z.bindBuffer(34962,r.position),Z.bufferData(34962,t.positionArray,35048),Gt.enableAttribute(n.position),Z.vertexAttribPointer(n.position,3,5126,!1,0,0)),t.hasNormals&&(Z.bindBuffer(34962,r.normal),Z.bufferData(34962,t.normalArray,35048),Gt.enableAttribute(n.normal),Z.vertexAttribPointer(n.normal,3,5126,!1,0,0)),t.hasUvs&&(Z.bindBuffer(34962,r.uv),Z.bufferData(34962,t.uvArray,35048),Gt.enableAttribute(n.uv),Z.vertexAttribPointer(n.uv,2,5126,!1,0,0)),t.hasColors&&(Z.bindBuffer(34962,r.color),Z.bufferData(34962,t.colorArray,35048),Gt.enableAttribute(n.color),Z.vertexAttribPointer(n.color,3,5126,!1,0,0)),Gt.disableUnusedAttributes(),Z.drawArrays(4,0,t.count),t.count=0},this.renderBufferDirect=function(t,r,n,i,a,o){var s=a.isMesh&&a.matrixWorld.determinant()<0;Gt.setMaterial(i,s);var c=x(t,r,i,a),l=!1;yt.geometry===n.id&&yt.program===c.id&&yt.wireframe===(!0===i.wireframe)||(yt.geometry=n.id,yt.program=c.id,yt.wireframe=!0===i.wireframe,l=!0),a.morphTargetInfluences&&(Jt.update(a,n,i,c),l=!0);var h=n.index,u=n.attributes.position,p=1;!0===i.wireframe&&(h=kt.getWireframeAttribute(n),p=2);var f,m=Qt;null!==h&&(f=jt.get(h),m=Kt,m.setIndex(f)),l&&(d(i,c,n),null!==h&&Z.bindBuffer(34963,f.buffer));var v=1/0;null!==h?v=h.count:void 0!==u&&(v=u.count);var g=n.drawRange.start*p,y=n.drawRange.count*p,b=null!==o?o.start*p:0,w=null!==o?o.count*p:1/0,_=Math.max(g,b),M=Math.min(v,g+y,b+w)-1,S=Math.max(0,M-_+1);if(0!==S){if(a.isMesh)if(!0===i.wireframe)Gt.setLineWidth(i.wireframeLinewidth*e()),m.setMode(1);else switch(a.drawMode){case Vc:m.setMode(4);break;case jc:m.setMode(5);break;case kc:m.setMode(6)}else if(a.isLine){var T=i.linewidth;void 0===T&&(T=1),Gt.setLineWidth(T*e()),a.isLineSegments?m.setMode(1):a.isLineLoop?m.setMode(2):m.setMode(3)}else a.isPoints?m.setMode(0):a.isSprite&&m.setMode(4);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&m.renderInstances(n,_,S):m.render(_,S)}},this.compile=function(t,e){Y=Yt.get(t,e),Y.init(),t.traverse(function(t){t.isLight&&(Y.pushLight(t),t.castShadow&&Y.pushShadow(t))}),Y.setupLights(e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var r=0;r=0&&e<=t.width-n&&r>=0&&r<=t.height-i&&Z.readPixels(e,r,n,i,$t.convert(h),$t.convert(u),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&Z.bindFramebuffer(36160,vt)}}},this.copyFramebufferToTexture=function(t,e,r){var n=e.image.width,i=e.image.height,a=$t.convert(e.format);Vt.setTexture2D(e,0),Z.copyTexImage2D(3553,r||0,a,t.x,t.y,n,i,0)},this.copyTextureToTexture=function(t,e,r,n){var i=e.image.width,a=e.image.height,o=$t.convert(r.format),s=$t.convert(r.type);Vt.setTexture2D(r,0),e.isDataTexture?Z.texSubImage2D(3553,n||0,t.x,t.y,i,a,o,s,e.image.data):Z.texSubImage2D(3553,n||0,t.x,t.y,o,s,e.image)},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Je(t,e){this.name="",this.color=new b(t),this.density=void 0!==e?e:25e-5}function Qe(t,e,r){this.name="",this.color=new b(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3}function Ke(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function $e(t,e,r,n){this.data=t,this.itemSize=e,this.offset=r,this.normalized=!0===n}function tr(t){T.call(this),this.type="SpriteMaterial",this.color=new b(16777215),this.map=null,this.rotation=0,this.sizeAttenuation=!0,this.lights=!1,this.transparent=!0,this.setValues(t)}function er(t){if(d.call(this),this.type="Sprite",void 0===wu){wu=new G;var e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Ke(e,5);wu.setIndex([0,1,2,0,2,3]),wu.addAttribute("position",new $e(n,3,0,!1)),wu.addAttribute("uv",new $e(n,2,3,!1))}this.geometry=wu,this.material=void 0!==t?t:new tr,this.center=new r(.5,.5)}function rr(t,e,r,n,i,a){Tu.subVectors(t,r).addScalar(.5).multiply(n),void 0!==i?(Eu.x=a*Tu.x-i*Tu.y,Eu.y=i*Tu.x+a*Tu.y):Eu.copy(Tu),t.copy(e),t.x+=Eu.x,t.y+=Eu.y,t.applyMatrix4(Au)}function nr(){d.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function ir(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),U.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new h,this.bindMatrixInverse=new h}function ar(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var r=0,n=this.bones.length;ra.far)return;o.push({distance:h,distanceToRay:Math.sqrt(c),point:l,index:e,face:null,object:s})}}function fr(t,e,r,n,i,a,s,c,l){o.call(this,t,e,r,n,i,a,s,c,l),this.format=void 0!==s?s:lc,this.minFilter=void 0!==a?a:Xs,this.magFilter=void 0!==i?i:Xs,this.generateMipmaps=!1}function mr(t,e,r,n,i,a,s,c,l,h,u,p){o.call(this,null,a,s,c,l,h,n,i,u,p),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function vr(t,e,r,n,i,a,s,c,l){o.call(this,t,e,r,n,i,a,s,c,l),this.needsUpdate=!0}function gr(t,e,r,n,i,a,s,c,l,h){if((h=void 0!==h?h:fc)!==fc&&h!==mc)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===r&&h===fc&&(r=$s),void 0===r&&h===mc&&(r=sc),o.call(this,null,n,i,a,s,c,h,r,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:ks,this.minFilter=void 0!==c?c:ks,this.flipY=!1,this.generateMipmaps=!1}function yr(t){G.call(this),this.type="WireframeGeometry";var e,r,n,a,o,s,c,l,h,u,p=[],d=[0,0],f={},m=["a","b","c"];if(t&&t.isGeometry){var v=t.faces;for(e=0,n=v.length;e=0?(t(g-1e-5,v,p),d.subVectors(u,p)):(t(g+1e-5,v,p),d.subVectors(p,u)),v-1e-5>=0?(t(g,v-1e-5,p),f.subVectors(u,p)):(t(g,v+1e-5,p),f.subVectors(p,u)),h.crossVectors(d,f).normalize(),c.push(h.x,h.y,h.z),l.push(g,v)}}for(n=0;n.9&&a<.1&&(e<.2&&(m[t+0]+=1),r<.2&&(m[t+2]+=1),n<.2&&(m[t+4]+=1))}}function c(t){f.push(t.x,t.y,t.z)}function l(e,r){var n=3*e;r.x=t[n+0],r.y=t[n+1],r.z=t[n+2]}function h(){for(var t=new i,e=new i,n=new i,a=new i,o=new r,s=new r,c=new r,l=0,h=0;l0)for(a=e;a=e;a-=n)o=cn(a,t[a],t[a+1],o);return o&&en(o,o.next)&&(ln(o),o=o.next),o}function Fr(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!en(n,n.next)&&0!==tn(n.prev,n,n.next))n=n.next;else{if(ln(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function Gr(t,e,r,n,i,a,o){if(t){!o&&a&&Yr(t,n,i,a);for(var s,c,l=t;t.prev!==t.next;)if(s=t.prev,c=t.next,a?Hr(t,n,i,a):Ur(t))e.push(s.i/r),e.push(t.i/r),e.push(c.i/r),ln(t),t=c.next,l=c.next;else if((t=c)===l){o?1===o?(t=Vr(t,e,r),Gr(t,e,r,n,i,a,2)):2===o&&jr(t,e,r,n,i,a):Gr(Fr(t),e,r,n,i,a,1);break}}}function Ur(t){var e=t.prev,r=t,n=t.next;if(tn(e,r,n)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Kr(e.x,e.y,r.x,r.y,n.x,n.y,i.x,i.y)&&tn(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Hr(t,e,r,n){var i=t.prev,a=t,o=t.next;if(tn(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,h=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,u=Jr(s,c,e,r,n),p=Jr(l,h,e,r,n),d=t.prevZ,f=t.nextZ;d&&d.z>=u&&f&&f.z<=p;){if(d!==t.prev&&d!==t.next&&Kr(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&tn(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==t.prev&&f!==t.next&&Kr(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&tn(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=u;){if(d!==t.prev&&d!==t.next&&Kr(i.x,i.y,a.x,a.y,o.x,o.y,d.x,d.y)&&tn(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&Kr(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&tn(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Vr(t,e,r){var n=t;do{var i=n.prev,a=n.next.next;!en(i,a)&&rn(i,n,n.next,a)&&an(i,a)&&an(a,i)&&(e.push(i.i/r),e.push(n.i/r),e.push(a.i/r),ln(n),ln(n.next),n=t=a),n=n.next}while(n!==t);return n}function jr(t,e,r,n,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&$r(o,s)){var c=sn(o,s);return o=Fr(o,o.next),c=Fr(c,c.next),Gr(o,e,r,n,i,a),void Gr(c,e,r,n,i,a)}s=s.next}o=o.next}while(o!==t)}function kr(t,e,r,n){var i,a,o,s,c,l=[];for(i=0,a=e.length;i=n.next.y&&n.next.y!==n.y){var s=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(a===n.y)return n;if(a===n.next.y)return n.next}r=n.x=n.x&&n.x>=h&&i!==n.x&&Kr(ar.x)&&an(n,t)&&(r=n,p=c),n=n.next;return r}function Yr(t,e,r,n){var i=t;do{null===i.z&&(i.z=Jr(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,Zr(i)}function Zr(t){var e,r,n,i,a,o,s,c,l=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,s=0,e=0;e0||c>0&&n;)0!==s&&(0===c||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,c--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;r=n}a.nextZ=null,l*=2}while(o>1);return t}function Jr(t,e,r,n,i){return t=32767*(t-r)*i,e=32767*(e-n)*i,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function Qr(t){var e=t,r=t;do{(e.x=0&&(t-o)*(n-s)-(r-o)*(e-s)>=0&&(r-o)*(a-s)-(i-o)*(n-s)>=0}function $r(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!nn(t,e)&&an(t,e)&&an(e,t)&&on(t,e)}function tn(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function en(t,e){return t.x===e.x&&t.y===e.y}function rn(t,e,r,n){return!!(en(t,r)&&en(e,n)||en(t,n)&&en(r,e))||tn(t,e,r)>0!=tn(t,e,n)>0&&tn(r,n,t)>0!=tn(r,n,e)>0}function nn(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&rn(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function an(t,e){return tn(t.prev,t,t.next)<0?tn(t,e,t.next)>=0&&tn(t,t.prev,e)>=0:tn(t,e,t.prev)<0||tn(t,t.next,e)<0}function on(t,e){var r=t,n=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}function sn(t,e){var r=new hn(t.i,t.x,t.y),n=new hn(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function cn(t,e,r,n){var i=new hn(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function ln(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function hn(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function un(t,e,r,n){for(var i=0,a=e,o=r-n;a2&&t[e-1].equals(t[0])&&t.pop()}function dn(t,e){for(var r=0;rNumber.EPSILON){var d=Math.sqrt(u),f=Math.sqrt(l*l+h*h),m=e.x-c/d,v=e.y+s/d,g=n.x-h/f,y=n.y+l/f,x=((g-m)*h-(y-v)*l)/(s*h-c*l);i=m+s*x-t.x,a=v+c*x-t.y;var b=i*i+a*a;if(b<=2)return new r(i,a);o=Math.sqrt(b/2)}else{var w=!1;s>Number.EPSILON?l>Number.EPSILON&&(w=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(w=!0):Math.sign(c)===Math.sign(h)&&(w=!0),w?(i=-c,a=s,o=Math.sqrt(u)):(i=s,a=c,o=Math.sqrt(u/2))}return new r(i/o,a/o)}function l(t,e){var r,n;for(Z=t.length;--Z>=0;){r=Z,(n=Z-1)<0&&(n=t.length-1);var i=0,a=g+2*M;for(i=0;i=0;U--){for(V=U/M,j=b*Math.cos(V*Math.PI/2),H=w*Math.sin(V*Math.PI/2)+_,Z=0,J=G.length;Z0)&&m.push(M,S,E),(l!==r-1||h0&&h(!0),e>0&&h(!1)),this.setIndex(p),this.addAttribute("position",new N(d,3)),this.addAttribute("normal",new N(f,3)),this.addAttribute("uv",new N(m,2))}function Cn(t,e,r,n,i,a,o){Rn.call(this,0,t,e,r,n,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:a,thetaLength:o}}function On(t,e,r,n,i,a,o){Pn.call(this,0,t,e,r,n,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:r,heightSegments:n,openEnded:i,thetaStart:a,thetaLength:o}}function Dn(t,e,r,n){j.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:n},this.fromBufferGeometry(new In(t,e,r,n)),this.mergeVertices()}function In(t,e,n,a){G.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:a},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,a=void 0!==a?a:2*Math.PI;var o,s,c=[],l=[],h=[],u=[],p=new i,d=new r;for(l.push(0,0,0),h.push(0,0,1),u.push(.5,.5),s=0,o=3;s<=e;s++,o+=3){var f=n+s/e*a;p.x=t*Math.cos(f),p.y=t*Math.sin(f),l.push(p.x,p.y,p.z),h.push(0,0,1),d.x=(l[o]/t+1)/2,d.y=(l[o+1]/t+1)/2,u.push(d.x,d.y)}for(o=1;o<=e;o++)c.push(o,o+1,0);this.setIndex(c),this.addAttribute("position",new N(l,3)),this.addAttribute("normal",new N(h,3)),this.addAttribute("uv",new N(u,2))}function Nn(t){T.call(this),this.type="ShadowMaterial",this.color=new b(0),this.transparent=!0,this.setValues(t)}function zn(t){q.call(this,t),this.type="RawShaderMaterial"}function Bn(t){T.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new b(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 b(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=el,this.normalScale=new r(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(t)}function Fn(t){Bn.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new r(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(t)}function Gn(t){T.call(this),this.type="MeshPhongMaterial",this.color=new b(16777215),this.specular=new b(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new b(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=el,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ts,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(t)}function Un(t){Gn.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Hn(t){T.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=el,this.normalScale=new r(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(t)}function Vn(t){T.call(this),this.type="MeshLambertMaterial",this.color=new b(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new b(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ts,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(t)}function jn(t){T.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new b(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=el,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.lights=!1,this.setValues(t)}function kn(t){sr.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}function Wn(t,e,r,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(r),this.sampleValues=e,this.valueSize=r}function qn(t,e,r,n){Wn.call(this,t,e,r,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Xn(t,e,r,n){Wn.call(this,t,e,r,n)}function Yn(t,e,r,n){Wn.call(this,t,e,r,n)}function Zn(t,e,r,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=tp.convertArray(e,this.TimeBufferType),this.values=tp.convertArray(r,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}function Jn(t,e,r){Zn.call(this,t,e,r)}function Qn(t,e,r,n){Zn.call(this,t,e,r,n)}function Kn(t,e,r,n){Zn.call(this,t,e,r,n)}function $n(t,e,r,n){Wn.call(this,t,e,r,n)}function ti(t,e,r,n){Zn.call(this,t,e,r,n)}function ei(t,e,r,n){Zn.call(this,t,e,r,n)}function ri(t,e,r,n){Zn.call(this,t,e,r,n)}function ni(t,e,r){this.name=t,this.tracks=r,this.duration=void 0!==e?e:-1,this.uuid=sl.generateUUID(),this.duration<0&&this.resetDuration()}function ii(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Kn;case"vector":case"vector2":case"vector3":case"vector4":return ri;case"color":return Qn;case"quaternion":return ti;case"bool":case"boolean":return Jn;case"string":return ei}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}function ai(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var e=ii(t.type);if(void 0===t.times){var r=[],n=[];tp.flattenJSON(t.keys,r,n,"value"),t.times=r,t.values=n}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}function oi(t,e,r){var n=this,i=!1,a=0,o=0,s=void 0,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){o++,!1===i&&void 0!==n.onStart&&n.onStart(t,a,o),i=!0},this.itemEnd=function(t){a++,void 0!==n.onProgress&&n.onProgress(t,a,o),a===o&&(i=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this},this.addHandler=function(t,e){return c.push(t,e),this},this.removeHandler=function(t){var e=c.indexOf(t);return-1!==e&&c.splice(e,2),this},this.getHandler=function(t){for(var e=0,r=c.length;e0?1:+t}),"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&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),r=1;r>8&255]+al[t>>16&255]+al[t>>24&255]+"-"+al[255&e]+al[e>>8&255]+"-"+al[e>>16&15|64]+al[e>>24&255]+"-"+al[63&r|128]+al[r>>8&255]+"-"+al[r>>16&255]+al[r>>24&255]+al[255&n]+al[n>>8&255]+al[n>>16&255]+al[n>>24&255]).toUpperCase()},clamp:function(t,e,r){return Math.max(e,Math.min(r,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,r,n,i){return n+(t-e)*(i-n)/(r-e)},lerp:function(t,e,r){return(1-r)*t+r*e},smoothstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:t>=r?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*sl.DEG2RAD},radToDeg:function(t){return t*sl.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}};Object.defineProperties(r.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(r.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,r=this.y,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6],this.y=n[1]*e+n[4]*r+n[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.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 t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var r=Math.cos(e),n=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*r-a*n+t.x,this.y=i*n+a*r+t.y,this}}),Object.assign(n,{slerp:function(t,e,r,n){return r.copy(t).slerp(e,n)},slerpFlat:function(t,e,r,n,i,a,o){var s=r[n+0],c=r[n+1],l=r[n+2],h=r[n+3],u=i[a+0],p=i[a+1],d=i[a+2],f=i[a+3];if(h!==f||s!==u||c!==p||l!==d){var m=1-o,v=s*u+c*p+l*d+h*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+u*w,c=c*m+p*w,l=l*m+d*w,h=h*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+h*h);s*=_,c*=_,l*=_,h*=_}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=h}}),Object.defineProperties(n.prototype,{x:{get:function(){ return this._x},set:function(t){this._x=t,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()}}}),Object.assign(n.prototype,{isQuaternion:!0,set:function(t,e,r,n){return this._x=t,this._y=e,this._z=r,this._w=n,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=t._x,n=t._y,i=t._z,a=t.order,o=Math.cos,s=Math.sin,c=o(r/2),l=o(n/2),h=o(i/2),u=s(r/2),p=s(n/2),d=s(i/2);return"XYZ"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h-u*p*d):"YXZ"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h+u*p*d):"ZXY"===a?(this._x=u*l*h-c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h-u*p*d):"ZYX"===a?(this._x=u*l*h-c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h+u*p*d):"YZX"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h-u*p*d):"XZY"===a&&(this._x=u*l*h-c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h+u*p*d),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,n=Math.sin(r);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(r),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,n=r[0],i=r[4],a=r[8],o=r[1],s=r[5],c=r[9],l=r[2],h=r[6],u=r[10],p=n+s+u;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(h-c)*e,this._y=(a-l)*e,this._z=(o-i)*e):n>s&&n>u?(e=2*Math.sqrt(1+n-s-u),this._w=(h-c)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(a+l)/e):s>u?(e=2*Math.sqrt(1+s-n-u),this._w=(a-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(c+h)/e):(e=2*Math.sqrt(1+u-n-s),this._w=(o-i)/e,this._x=(a+l)/e,this._y=(c+h)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var r=t.dot(e)+1;return r<1e-6?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(sl.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var r=this.angleTo(t);if(0===r)return this;var n=Math.min(1,e/r);return this.slerp(t,n),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var r=t._x,n=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=r*l+a*o+n*c-i*s,this._y=n*l+a*s+i*o-r*c,this._z=i*l+a*c+r*s-n*o,this._w=a*l-r*o-n*s-i*c,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,n=this._y,i=this._z,a=this._w,o=a*t._w+r*t._x+n*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=r,this._y=n,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-e;return this._w=c*a+e*this._w,this._x=c*r+e*this._x,this._y=c*n+e*this._y,this._z=c*i+e*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),h=Math.atan2(l,o),u=Math.sin((1-e)*h)/l,p=Math.sin(e*h)/l;return this._w=a*u+this._w*p,this._x=r*u+this._x*p,this._y=n*u+this._y*p,this._z=i*u+this._z*p,this._onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},_onChange:function(t){return this._onChangeCallback=t,this},_onChangeCallback:function(){}});var cl=new i,ll=new n;Object.assign(i.prototype,{isVector3:!0,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(ll.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(ll.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6]*n,this.y=i[1]*e+i[4]*r+i[7]*n,this.z=i[2]*e+i[5]*r+i[8]*n,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements,a=1/(i[3]*e+i[7]*r+i[11]*n+i[15]);return this.x=(i[0]*e+i[4]*r+i[8]*n+i[12])*a,this.y=(i[1]*e+i[5]*r+i[9]*n+i[13])*a,this.z=(i[2]*e+i[6]*r+i[10]*n+i[14])*a,this},applyQuaternion:function(t){var e=this.x,r=this.y,n=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*n-o*r,l=s*r+o*e-i*n,h=s*n+i*r-a*e,u=-i*e-a*r-o*n;return this.x=c*s+u*-i+l*-o-h*-a,this.y=l*s+u*-a+h*-i-c*-o,this.z=h*s+u*-o+c*-a-l*-i,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,r=this.y,n=this.z,i=t.elements;return this.x=i[0]*e+i[4]*r+i[8]*n,this.y=i[1]*e+i[5]*r+i[9]*n,this.z=i[2]*e+i[6]*r+i[10]*n,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var r=t.x,n=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=n*s-i*o,this.y=i*a-r*s,this.z=r*o-n*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return cl.copy(this).projectOnVector(t),this.sub(cl)},reflect:function(t){return this.sub(cl.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(sl.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,n=this.z-t.z;return e*e+r*r+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,r){var n=Math.sin(e)*t;return this.x=n*Math.sin(r),this.y=Math.cos(e)*t,this.z=n*Math.cos(r),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=n,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var hl=new i;Object.assign(a.prototype,{isMatrix3:!0,set:function(t,e,r,n,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=n,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=r,l[7]=a,l[8]=c,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(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(t){for(var e=0,r=t.count;e2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},dl=0;o.DEFAULT_IMAGE=void 0,o.DEFAULT_MAPPING=300,o.prototype=Object.assign(Object.create(e.prototype),{constructor:o,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(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){var e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var n=this.image;if(void 0===n.uuid&&(n.uuid=sl.generateUUID()),!e&&void 0===t.images[n.uuid]){var i;if(Array.isArray(n)){i=[];for(var a=0,o=n.length;a1)switch(this.wrapS){case Hs:t.x=t.x-Math.floor(t.x);break;case Vs:t.x=t.x<0?0:1;break;case js:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case Hs:t.y=t.y-Math.floor(t.y);break;case Vs:t.y=t.y<0?0:1;break;case js:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(o.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.defineProperties(s.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(s.prototype,{isVector4:!0,set:function(t,e,r,n){return this.x=t,this.y=e,this.z=r,this.w=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){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: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,n=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*r+a[8]*n+a[12]*i,this.y=a[1]*e+a[5]*r+a[9]*n+a[13]*i,this.z=a[2]*e+a[6]*r+a[10]*n+a[14]*i,this.w=a[3]*e+a[7]*r+a[11]*n+a[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,n,i,a=t.elements,o=a[0],s=a[4],c=a[8],l=a[1],h=a[5],u=a[9],p=a[2],d=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-p)<.01&&Math.abs(u-d)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+p)<.1&&Math.abs(u+d)<.1&&Math.abs(o+h+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,v=(h+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+p)/4,b=(u+d)/4;return m>v&&m>g?m<.01?(r=0,n=.707106781,i=.707106781):(r=Math.sqrt(m),n=y/r,i=x/r):v>g?v<.01?(r=.707106781,n=0,i=.707106781):(n=Math.sqrt(v),r=y/n,i=b/n):g<.01?(r=.707106781,n=.707106781,i=0):(i=Math.sqrt(g),r=x/i,n=b/i),this.set(r,n,i,e),this}var w=Math.sqrt((d-u)*(d-u)+(c-p)*(c-p)+(l-s)*(l-s));return Math.abs(w)<.001&&(w=1),this.x=(d-u)/w,this.y=(c-p)/w,this.z=(l-s)/w,this.w=Math.acos((o+h+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},clampLength:function(t,e){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,r){return this.subVectors(e,t).multiplyScalar(r).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,r){return void 0!==r&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),c.prototype=Object.assign(Object.create(e.prototype),{constructor:c,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),l.prototype=Object.assign(Object.create(c.prototype),{constructor:l,isWebGLMultisampleRenderTarget:!0,copy:function(t){return c.prototype.copy.call(this,t),this.samples=t.samples,this}});var fl=new i,ml=new h,vl=new i(0,0,0),gl=new i(1,1,1),yl=new i,xl=new i,bl=new i;Object.assign(h.prototype,{isMatrix4:!0,set:function(t,e,r,n,i,a,o,s,c,l,h,u,p,d,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=r,v[12]=n,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=h,v[14]=u,v[3]=p,v[7]=d,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 h).fromArray(this.elements)},copy:function(t){var e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractBasis:function(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,r=t.elements,n=1/fl.setFromMatrixColumn(t,0).length(),i=1/fl.setFromMatrixColumn(t,1).length(),a=1/fl.setFromMatrixColumn(t,2).length();return e[0]=r[0]*n,e[1]=r[1]*n,e[2]=r[2]*n,e[3]=0,e[4]=r[4]*i,e[5]=r[5]*i,e[6]=r[6]*i,e[7]=0,e[8]=r[8]*a,e[9]=r[9]*a,e[10]=r[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,r=t.x,n=t.y,i=t.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(n),c=Math.sin(n),l=Math.cos(i),h=Math.sin(i);if("XYZ"===t.order){var u=a*l,p=a*h,d=o*l,f=o*h;e[0]=s*l,e[4]=-s*h,e[8]=c,e[1]=p+d*c,e[5]=u-f*c,e[9]=-o*s,e[2]=f-u*c,e[6]=d+p*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,v=s*h,g=c*l,y=c*h;e[0]=m+y*o,e[4]=g*o-v,e[8]=a*c,e[1]=a*h,e[5]=a*l,e[9]=-o,e[2]=v*o-g,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){var m=s*l,v=s*h,g=c*l,y=c*h;e[0]=m-y*o,e[4]=-a*h,e[8]=g+v*o,e[1]=v+g*o,e[5]=a*l,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){var u=a*l,p=a*h,d=o*l,f=o*h;e[0]=s*l,e[4]=d*c-p,e[8]=u*c+f,e[1]=s*h,e[5]=f*c+u,e[9]=p*c-d,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=_-x*h,e[8]=w*h+b,e[1]=h,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=b*h+w,e[10]=x-_*h}else if("XZY"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=-h,e[8]=c*l,e[1]=x*h+_,e[5]=a*l,e[9]=b*h-w,e[2]=w*h-b,e[6]=o*l,e[10]=_*h+x}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){return this.compose(vl,t,gl)},lookAt:function(t,e,r){var n=this.elements;return bl.subVectors(t,e),0===bl.lengthSq()&&(bl.z=1),bl.normalize(),yl.crossVectors(r,bl),0===yl.lengthSq()&&(1===Math.abs(r.z)?bl.x+=1e-4:bl.z+=1e-4,bl.normalize(),yl.crossVectors(r,bl)),yl.normalize(),xl.crossVectors(bl,yl),n[0]=yl.x,n[4]=xl.x,n[8]=bl.x,n[1]=yl.y,n[5]=xl.y,n[9]=bl.y,n[2]=yl.z,n[6]=xl.z,n[10]=bl.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var r=t.elements,n=e.elements,i=this.elements,a=r[0],o=r[4],s=r[8],c=r[12],l=r[1],h=r[5],u=r[9],p=r[13],d=r[2],f=r[6],m=r[10],v=r[14],g=r[3],y=r[7],x=r[11],b=r[15],w=n[0],_=n[4],M=n[8],S=n[12],T=n[1],E=n[5],A=n[9],L=n[13],R=n[2],P=n[6],C=n[10],O=n[14],D=n[3],I=n[7],N=n[11],z=n[15];return i[0]=a*w+o*T+s*R+c*D,i[4]=a*_+o*E+s*P+c*I,i[8]=a*M+o*A+s*C+c*N,i[12]=a*S+o*L+s*O+c*z,i[1]=l*w+h*T+u*R+p*D,i[5]=l*_+h*E+u*P+p*I,i[9]=l*M+h*A+u*C+p*N,i[13]=l*S+h*L+u*O+p*z,i[2]=d*w+f*T+m*R+v*D,i[6]=d*_+f*E+m*P+v*I,i[10]=d*M+f*A+m*C+v*N,i[14]=d*S+f*L+m*O+v*z,i[3]=g*w+y*T+x*R+b*D,i[7]=g*_+y*E+x*P+b*I,i[11]=g*M+y*A+x*C+b*N,i[15]=g*S+y*L+x*O+b*z,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(t){for(var e=0,r=t.count;e1){for(var e=0;e1){for(var e=0;e0){a.children=[];for(var c=0;c0&&(i.geometries=p),d.length>0&&(i.materials=d),f.length>0&&(i.textures=f),m.length>0&&(i.images=m),s.length>0&&(i.shapes=s)}return i.object=a,i},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var r=0;ri&&(i=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(e,r,n),this.max.set(i,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;si&&(i=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(e,r,n),this.max.set(i,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new i),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,Bl),Bl.distanceToSquared(t.center)<=t.radius*t.radius},intersectsPlane:function(t){var e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant},intersectsTriangle:function(t){if(this.isEmpty())return!1;this.getCenter(kl),Wl.subVectors(this.max,kl),Fl.subVectors(t.a,kl),Gl.subVectors(t.b,kl),Ul.subVectors(t.c,kl),Hl.subVectors(Gl,Fl),Vl.subVectors(Ul,Gl),jl.subVectors(Fl,Ul);var e=[0,-Hl.z,Hl.y,0,-Vl.z,Vl.y,0,-jl.z,jl.y,Hl.z,0,-Hl.x,Vl.z,0,-Vl.x,jl.z,0,-jl.x,-Hl.y,Hl.x,0,-Vl.y,Vl.x,0,-jl.y,jl.x,0];return!!v(e,Fl,Gl,Ul,Wl)&&(e=[1,0,0,0,1,0,0,0,1],!!v(e,Fl,Gl,Ul,Wl)&&(ql.crossVectors(Hl,Vl),e=[ql.x,ql.y,ql.z],v(e,Fl,Gl,Ul,Wl)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new i),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return Bl.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(Bl).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()?this:(zl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),zl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),zl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),zl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),zl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),zl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),zl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),zl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(zl),this)},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var Yl=new m;Object.assign(g.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var r=this.center;void 0!==e?r.copy(e):Yl.setFromPoints(t).getCenter(r);for(var n=0,i=0,a=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new m),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var Zl=new i,Jl=new i,Ql=new i,Kl=new i,$l=new i,th=new i,eh=new i;Object.assign(y.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new i),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,Zl)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new i),e.subVectors(t,this.origin);var r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=Zl.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Zl.copy(this.direction).multiplyScalar(e).add(this.origin),Zl.distanceToSquared(t))},distanceSqToSegment:function(t,e,r,n){Jl.copy(t).add(e).multiplyScalar(.5),Ql.copy(e).sub(t).normalize(),Kl.copy(this.origin).sub(Jl);var i,a,o,s,c=.5*t.distanceTo(e),l=-this.direction.dot(Ql),h=Kl.dot(this.direction),u=-Kl.dot(Ql),p=Kl.lengthSq(),d=Math.abs(1-l*l);if(d>0)if(i=l*u-h,a=l*h-u,s=c*d,i>=0)if(a>=-s)if(a<=s){var f=1/d;i*=f,a*=f,o=i*(i+l*a+2*h)+a*(l*i+a+2*u)+p}else a=c,i=Math.max(0,-(l*a+h)),o=-i*i+a*(a+2*u)+p;else a=-c,i=Math.max(0,-(l*a+h)),o=-i*i+a*(a+2*u)+p;else a<=-s?(i=Math.max(0,-(-l*c+h)),a=i>0?-c:Math.min(Math.max(-c,-u),c),o=-i*i+a*(a+2*u)+p):a<=s?(i=0,a=Math.min(Math.max(-c,-u),c),o=a*(a+2*u)+p):(i=Math.max(0,-(l*c+h)),a=i>0?c:Math.min(Math.max(-c,-u),c),o=-i*i+a*(a+2*u)+p);else a=l>0?-c:c,i=Math.max(0,-(l*a+h)),o=-i*i+a*(a+2*u)+p;return r&&r.copy(this.direction).multiplyScalar(i).add(this.origin),n&&n.copy(Ql).multiplyScalar(a).add(Jl),o},intersectSphere:function(t,e){Zl.subVectors(t.center,this.origin);var r=Zl.dot(this.direction),n=Zl.dot(Zl)-r*r,i=t.radius*t.radius;if(n>i)return null;var a=Math.sqrt(i-n),o=r-a,s=r+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var r,n,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(r=(t.min.x-u.x)*c,n=(t.max.x-u.x)*c):(r=(t.max.x-u.x)*c,n=(t.min.x-u.x)*c),l>=0?(i=(t.min.y-u.y)*l,a=(t.max.y-u.y)*l):(i=(t.max.y-u.y)*l,a=(t.min.y-u.y)*l),r>a||i>n?null:((i>r||r!==r)&&(r=i),(a=0?(o=(t.min.z-u.z)*h,s=(t.max.z-u.z)*h):(o=(t.max.z-u.z)*h,s=(t.min.z-u.z)*h),r>s||o>n?null:((o>r||r!==r)&&(r=o),(s=0?r:n,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,Zl)},intersectTriangle:function(t,e,r,n,i){$l.subVectors(e,t),th.subVectors(r,t),eh.crossVectors($l,th);var a,o=this.direction.dot(eh);if(o>0){if(n)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Kl.subVectors(this.origin,t);var s=a*this.direction.dot(th.crossVectors(Kl,th));if(s<0)return null;var c=a*this.direction.dot($l.cross(Kl));if(c<0)return null;if(s+c>o)return null;var l=-a*Kl.dot(eh);return l<0?null:this.at(l/o,i)},applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}});var rh=new i,nh=new i,ih=new i,ah=new i,oh=new i,sh=new i,ch=new i,lh=new i,hh=new i,uh=new i;Object.assign(x,{getNormal:function(t,e,r,n){void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new i),n.subVectors(r,e),rh.subVectors(t,e),n.cross(rh);var a=n.lengthSq();return a>0?n.multiplyScalar(1/Math.sqrt(a)):n.set(0,0,0)},getBarycoord:function(t,e,r,n,a){rh.subVectors(n,e),nh.subVectors(r,e),ih.subVectors(t,e);var o=rh.dot(rh),s=rh.dot(nh),c=rh.dot(ih),l=nh.dot(nh),h=nh.dot(ih),u=o*l-s*s;if(void 0===a&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),a=new i),0===u)return a.set(-2,-1,-1);var p=1/u,d=(l*c-s*h)*p,f=(o*h-s*c)*p;return a.set(1-d-f,f,d)},containsPoint:function(t,e,r,n){return x.getBarycoord(t,e,r,n,ah),ah.x>=0&&ah.y>=0&&ah.x+ah.y<=1},getUV:function(t,e,r,n,i,a,o,s){return this.getBarycoord(t,e,r,n,ah),s.set(0,0),s.addScaledVector(i,ah.x),s.addScaledVector(a,ah.y),s.addScaledVector(o,ah.z),s},isFrontFacing:function(t,e,r,n){return rh.subVectors(r,e),nh.subVectors(t,e),rh.cross(nh).dot(n)<0}}),Object.assign(x.prototype,{set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,n){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return rh.subVectors(this.c,this.b),nh.subVectors(this.a,this.b),.5*rh.cross(nh).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new i),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return x.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new i),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return x.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,r,n,i){return x.getUV(t,this.a,this.b,this.c,e,r,n,i)},containsPoint:function(t){return x.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return x.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new i);var r,n,a=this.a,o=this.b,s=this.c;oh.subVectors(o,a),sh.subVectors(s,a),lh.subVectors(t,a);var c=oh.dot(lh),l=sh.dot(lh);if(c<=0&&l<=0)return e.copy(a);hh.subVectors(t,o);var h=oh.dot(hh),u=sh.dot(hh);if(h>=0&&u<=h)return e.copy(o);var p=c*u-h*l;if(p<=0&&c>=0&&h<=0)return r=c/(c-h),e.copy(a).addScaledVector(oh,r);uh.subVectors(t,s);var d=oh.dot(uh),f=sh.dot(uh);if(f>=0&&d<=f)return e.copy(s);var m=d*l-c*f;if(m<=0&&l>=0&&f<=0)return n=l/(l-f),e.copy(a).addScaledVector(sh,n);var v=h*f-d*u;if(v<=0&&u-h>=0&&d-f>=0)return ch.subVectors(s,o),n=(u-h)/(u-h+(d-f)),e.copy(o).addScaledVector(ch,n);var g=1/(v+m+p);return r=m*g,n=p*g,e.copy(a).addScaledVector(oh,r).addScaledVector(sh,n)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var ph={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},dh={h:0,s:0,l:0},fh={h:0,s:0,l:0};Object.assign(b.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(t,e,r){if(t=sl.euclideanModulo(t,1),e=sl.clamp(e,0,1), r=sl.clamp(r,0,1),0===e)this.r=this.g=this.b=r;else{var n=r<=.5?r*(1+e):r+e-r*e,i=2*r-n;this.r=w(i,n,t+1/3),this.g=w(i,n,t),this.b=w(i,n,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var n,i=r[1],a=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,e(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,e(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,c=parseInt(n[3],10)/100;return e(n[5]),this.setHSL(o,s,c)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=r[1],h=l.length;if(3===h)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===h)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}if(t&&t.length>0){var l=ph[t];void 0!==l?this.setHex(l):console.warn("THREE.Color: Unknown color "+t)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var r=e>0?1/e:1;return this.r=Math.pow(t.r,r),this.g=Math.pow(t.g,r),this.b=Math.pow(t.b,r),this},convertGammaToLinear:function(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=_(t.r),this.g=_(t.g),this.b=_(t.b),this},copyLinearToSRGB:function(t){return this.r=M(t.r),this.g=M(t.g),this.b=M(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(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,r,n=this.r,i=this.g,a=this.b,o=Math.max(n,i,a),s=Math.min(n,i,a),c=(s+o)/2;if(s===o)e=0,r=0;else{var l=o-s;switch(r=c<=.5?l/(o+s):l/(2-o-s),o){case n:e=(i-a)/l+(i0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),r){var i=e(t.textures),a=e(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWrite=t.stencilWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,r=null;if(null!==e){var n=e.length;r=new Array(n);for(var i=0;i!==n;++i)r[i]=e[i].clone()}return this.clippingPlanes=r,this.shadowSide=t.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),E.prototype=Object.create(T.prototype),E.prototype.constructor=E,E.prototype.isMeshBasicMaterial=!0,E.prototype.copy=function(t){return T.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},Object.defineProperty(A.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(A.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.dynamic=t.dynamic,this},copyAt:function(t,e,r){t*=this.itemSize,r*=e.itemSize;for(var n=0,i=this.itemSize;n0,s=a[1]&&a[1].length>0,c=t.morphTargets,l=c.length;if(l>0){e=[];for(var h=0;h0){u=[];for(var h=0;h0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var h=0;h65535?I:O)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(t,new A(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,r){this.groups.push({start:t,count:e,materialIndex:void 0!==r?r:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){var n=(new a).getNormalMatrix(t);n.applyToBufferAttribute(r),r.needsUpdate=!0}var i=this.attributes.tangent;if(void 0!==i){var n=(new a).getNormalMatrix(t);n.applyToBufferAttribute(i),i.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return gh.makeRotationX(t),this.applyMatrix(gh),this},rotateY:function(t){return gh.makeRotationY(t),this.applyMatrix(gh),this},rotateZ:function(t){return gh.makeRotationZ(t),this.applyMatrix(gh),this},translate:function(t,e,r){return gh.makeTranslation(t,e,r),this.applyMatrix(gh),this},scale:function(t,e,r){return gh.makeScale(t,e,r),this.applyMatrix(gh),this},lookAt:function(t){return yh.lookAt(t),yh.updateMatrix(),this.applyMatrix(yh.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(xh).negate(),this.translate(xh.x,xh.y,xh.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var r=new N(3*e.vertices.length,3),n=new N(3*e.colors.length,3);if(this.addAttribute("position",r.copyVector3sArray(e.vertices)),this.addAttribute("color",n.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new N(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],r=0,n=t.length;r0){var r=new Float32Array(3*t.normals.length);this.addAttribute("normal",new A(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var n=new Float32Array(3*t.colors.length);this.addAttribute("color",new A(n,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new A(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new A(a,2).copyVector2sArray(t.uvs2))}this.groups=t.groups;for(var o in t.morphTargets){for(var s=[],c=t.morphTargets[o],l=0,h=c.length;l0){var d=new N(4*t.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new N(4*t.skinWeights.length,4);this.addAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new m);var t=this.attributes.position,e=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var r=0,n=e.length;r0&&(t.userData=this.userData),void 0!==this.parameters){var e=this.parameters;for(var r in e)void 0!==e[r]&&(t[r]=e[r]);return t}t.data={attributes:{}};var n=this.index;null!==n&&(t.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});var i=this.attributes;for(var r in i){var a=i[r],o=a.toJSON();""!==a.name&&(o.name=a.name),t.data.attributes[r]=o}var s={},c=!1;for(var r in this.morphAttributes){for(var l=this.morphAttributes[r],h=[],u=0,p=l.length;u0&&(s[r]=h,c=!0)}c&&(t.data.morphAttributes=s);var d=this.groups;d.length>0&&(t.data.groups=JSON.parse(JSON.stringify(d)));var f=this.boundingSphere;return null!==f&&(t.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),t},clone:function(){return(new G).copy(this)},copy:function(t){var e,r,n;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var a=t.attributes;for(e in a){var o=a[e];this.addAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(r=0,n=l.length;r0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var n=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===n.boundingSphere&&n.computeBoundingSphere(),Th.copy(n.boundingSphere),Th.applyMatrix4(a),!1!==t.ray.intersectsSphere(Th)&&(Mh.getInverse(a),Sh.copy(t.ray).applyMatrix4(Mh),null===n.boundingBox||!1!==Sh.intersectsBox(n.boundingBox)))){var o;if(n.isBufferGeometry){var s,c,l,h,u,p,d,f,m,v,g,y=n.index,b=n.attributes.position,w=n.morphAttributes.position,_=n.attributes.uv,M=n.attributes.uv2,S=n.groups,T=n.drawRange;if(null!==y)if(Array.isArray(i))for(h=0,p=S.length;h0&&(R=D);for(var I=0,N=O.length;I0)for(var p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,r;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,r,n,a;for(r=0,n=this.faces.length;r=0;r--){var f=p[r];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,b=g.vertexNormals.length>0,w=1!==g.color.r||1!==g.color.g||1!==g.color.b,_=g.vertexColors.length>0,M=0;if(M=t(M,0,0),M=t(M,1,!0),M=t(M,2,!1),M=t(M,3,y),M=t(M,4,x),M=t(M,5,b),M=t(M,6,w),M=t(M,7,_),h.push(M),h.push(g.a,g.b,g.c),h.push(g.materialIndex),y){var S=this.faceVertexUvs[0][c];h.push(n(S[0]),n(S[1]),n(S[2]))}if(x&&h.push(e(g.normal)),b){var T=g.vertexNormals;h.push(e(T[0]),e(T[1]),e(T[2]))}if(w&&h.push(r(g.color)),_){var E=g.vertexColors;h.push(r(E[0]),r(E[1]),r(E[2]))}}return i.data={},i.data.vertices=s,i.data.normals=u,d.length>0&&(i.data.colors=d),m.length>0&&(i.data.uvs=[m]),i.data.faces=h,i},clone:function(){return(new j).copy(this)},copy:function(t){var e,r,n,i,a,o;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=t.name;var s=t.vertices;for(e=0,r=s.length;e0?1:-1,p.push(P.x,P.y,P.z),d.push(x/v),d.push(1-b/g),L+=1}}for(b=0;b0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var a={};for(var o in this.extensions)!0===this.extensions[o]&&(a[o]=!0);return Object.keys(a).length>0&&(e.extensions=a),e},X.prototype=Object.assign(Object.create(d.prototype),{constructor:X,isCamera:!0,copy:function(t,e){return d.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new i),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){d.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),Y.prototype=Object.assign(Object.create(X.prototype),{constructor:Y,isPerspectiveCamera:!0,copy:function(t,e){return X.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*sl.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*sl.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*sl.RAD2DEG*Math.atan(Math.tan(.5*sl.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(t,e,r,n,i,a){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=r,this.view.offsetY=n,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*sl.DEG2RAD*this.fov)/this.zoom,r=2*e,n=this.aspect*r,i=-.5*n,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*n/o,e-=a.offsetY*r/s,n*=a.width/o,r*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+n,e,e-r,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=d.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});var Zh=90,Jh=1;Z.prototype=Object.create(d.prototype),Z.prototype.constructor=Z,J.prototype=Object.create(c.prototype),J.prototype.constructor=J,J.prototype.isWebGLRenderTargetCube=!0,J.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=e.format,this.texture.encoding=e.encoding;var r=new f,n={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new q({type:"CubemapFromEquirect",uniforms:k(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ko,blending:Zo});i.uniforms.tEquirect.value=e;var a=new U(new Wh(5,5,5),i);r.add(a);var o=new Z(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(t,r),a.geometry.dispose(),a.material.dispose(),this},Q.prototype=Object.create(o.prototype),Q.prototype.constructor=Q,Q.prototype.isDataTexture=!0;var Qh=new i,Kh=new i,$h=new a;Object.assign(K.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,r,n){return this.normal.set(t,e,r),this.constant=n,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,r){var n=Qh.subVectors(r,e).cross(Kh.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new i),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new i);var r=t.delta(Qh),n=this.normal.dot(r);if(0!==n){var a=-(t.start.dot(this.normal)+this.constant)/n;if(!(a<0||a>1))return e.copy(r).multiplyScalar(a).add(t.start)}else if(0===this.distanceToPoint(t.start))return e.copy(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&r>0||r<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new i),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var r=e||$h.getNormalMatrix(t),n=this.coplanarPoint(Qh).applyMatrix4(t),i=this.normal.applyMatrix3(r).normalize();return this.constant=-n.dot(i),this},translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}});var tu=new g,eu=new i;Object.assign($.prototype,{set:function(t,e,r,n,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(r),o[3].copy(n),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,n=r[0],i=r[1],a=r[2],o=r[3],s=r[4],c=r[5],l=r[6],h=r[7],u=r[8],p=r[9],d=r[10],f=r[11],m=r[12],v=r[13],g=r[14],y=r[15];return e[0].setComponents(o-n,h-s,f-u,y-m).normalize(),e[1].setComponents(o+n,h+s,f+u,y+m).normalize(),e[2].setComponents(o+i,h+c,f+p,y+v).normalize(),e[3].setComponents(o-i,h-c,f-p,y-v).normalize(),e[4].setComponents(o-a,h-l,f-d,y-g).normalize(),e[5].setComponents(o+a,h+l,f+d,y+g).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),tu.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(tu)},intersectsSprite:function(t){return tu.center.set(0,0,0),tu.radius=.7071067811865476,tu.applyMatrix4(t.matrixWorld),this.intersectsSphere(tu)},intersectsSphere:function(t){for(var e=this.planes,r=t.center,n=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(r)0?t.max.x:t.min.x,eu.y=n.normal.y>0?t.max.y:t.min.y,eu.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(eu)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0}});var ru={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#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( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif", bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\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\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\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}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( 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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\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#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( 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",clipping_planes_fragment:"#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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#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 whiteComplement(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}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\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}\nbool isPerspectiveMatrix( mat4 projectionMatrix ) {\n return projectionMatrix[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#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",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\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 = cLogLuvM * value.rgb;\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 = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\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 roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, 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, roughness );\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",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\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",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\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",fog_pars_fragment:"#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",gradientmap_pars_fragment:"#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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"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 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = 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\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif", lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\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)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\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 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? 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 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\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",lights_fragment_maps:"#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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 1.0 ? log2( vFragDepth ) * logDepthBufFC * 0.5 : gl_FragCoord.z;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#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",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#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",morphtarget_pars_vertex:"#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",morphtarget_vertex:"#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",normal_fragment_begin:"#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\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvec3 NfromST = cross( S, T );\n\t\t\tif( dot( NfromST, N ) > 0.0 ) {\n\t\t\t\tS *= -1.0;\n\t\t\t\tT *= -1.0;\n\t\t\t}\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float 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}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif", shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat 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 ) + 0.5 ) * texelSize;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat 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#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp 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",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n\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}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\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\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}", meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},nu={common:{diffuse:{value:new b(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new a},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 r(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 b(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 b(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new a}},sprite:{diffuse:{value:new b(15658734)},opacity:{value:1},center:{value:new r(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new a}}},iu={basic:{uniforms:W([nu.common,nu.specularmap,nu.envmap,nu.aomap,nu.lightmap,nu.fog]),vertexShader:ru.meshbasic_vert,fragmentShader:ru.meshbasic_frag},lambert:{uniforms:W([nu.common,nu.specularmap,nu.envmap,nu.aomap,nu.lightmap,nu.emissivemap,nu.fog,nu.lights,{emissive:{value:new b(0)}}]),vertexShader:ru.meshlambert_vert,fragmentShader:ru.meshlambert_frag},phong:{uniforms:W([nu.common,nu.specularmap,nu.envmap,nu.aomap,nu.lightmap,nu.emissivemap,nu.bumpmap,nu.normalmap,nu.displacementmap,nu.gradientmap,nu.fog,nu.lights,{emissive:{value:new b(0)},specular:{value:new b(1118481)},shininess:{value:30}}]),vertexShader:ru.meshphong_vert,fragmentShader:ru.meshphong_frag},standard:{uniforms:W([nu.common,nu.envmap,nu.aomap,nu.lightmap,nu.emissivemap,nu.bumpmap,nu.normalmap,nu.displacementmap,nu.roughnessmap,nu.metalnessmap,nu.fog,nu.lights,{emissive:{value:new b(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:ru.meshphysical_vert,fragmentShader:ru.meshphysical_frag},matcap:{uniforms:W([nu.common,nu.bumpmap,nu.normalmap,nu.displacementmap,nu.fog,{matcap:{value:null}}]),vertexShader:ru.meshmatcap_vert,fragmentShader:ru.meshmatcap_frag},points:{uniforms:W([nu.points,nu.fog]),vertexShader:ru.points_vert,fragmentShader:ru.points_frag},dashed:{uniforms:W([nu.common,nu.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ru.linedashed_vert,fragmentShader:ru.linedashed_frag},depth:{uniforms:W([nu.common,nu.displacementmap]),vertexShader:ru.depth_vert,fragmentShader:ru.depth_frag},normal:{uniforms:W([nu.common,nu.bumpmap,nu.normalmap,nu.displacementmap,{opacity:{value:1}}]),vertexShader:ru.normal_vert,fragmentShader:ru.normal_frag},sprite:{uniforms:W([nu.sprite,nu.fog]),vertexShader:ru.sprite_vert,fragmentShader:ru.sprite_frag},background:{uniforms:{uvTransform:{value:new a},t2D:{value:null}},vertexShader:ru.background_vert,fragmentShader:ru.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ru.cube_vert,fragmentShader:ru.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ru.equirect_vert,fragmentShader:ru.equirect_frag},distanceRGBA:{uniforms:W([nu.common,nu.displacementmap,{referencePosition:{value:new i},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ru.distanceRGBA_vert,fragmentShader:ru.distanceRGBA_frag},shadow:{uniforms:W([nu.lights,nu.fog,{color:{value:new b(0)},opacity:{value:1}}]),vertexShader:ru.shadow_vert,fragmentShader:ru.shadow_frag}};iu.physical={uniforms:W([iu.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new b(0)},clearcoatNormalScale:{value:new r(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:ru.meshphysical_vert,fragmentShader:ru.meshphysical_frag},rt.prototype=Object.create(j.prototype),rt.prototype.constructor=rt,nt.prototype=Object.create(G.prototype),nt.prototype.constructor=nt,mt.prototype=Object.create(o.prototype),mt.prototype.constructor=mt,mt.prototype.isCubeTexture=!0,Object.defineProperty(mt.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}}),vt.prototype=Object.create(o.prototype),vt.prototype.constructor=vt,vt.prototype.isDataTexture2DArray=!0,gt.prototype=Object.create(o.prototype),gt.prototype.constructor=gt,gt.prototype.isDataTexture3D=!0;var au=new o,ou=new vt,su=new gt,cu=new mt,lu=[],hu=[],uu=new Float32Array(16),pu=new Float32Array(9),du=new Float32Array(4);$t.prototype.updateCache=function(t){var e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),bt(e,t)},te.prototype.setValue=function(t,e,r){for(var n=this.seq,i=0,a=n.length;i!==a;++i){var o=n[i];o.setValue(t,e[o.id],r)}};var fu=/([\w\d_]+)(\])?(\[|\.)?/g;ne.prototype.setValue=function(t,e,r,n){var i=this.map[e];void 0!==i&&i.setValue(t,r,n)},ne.prototype.setOptional=function(t,e,r){var n=e[r];void 0!==n&&this.setValue(t,r,n)},ne.upload=function(t,e,r,n){for(var i=0,a=e.length;i!==a;++i){var o=e[i],s=r[o.id];!1!==s.needsUpdate&&o.setValue(t,s.value,n)}},ne.seqWithValue=function(t,e){for(var r=[],n=0,i=t.length;n!==i;++n){var a=t[n];a.id in e&&r.push(a)}return r};var mu=0,vu=0;ze.prototype=Object.create(T.prototype),ze.prototype.constructor=ze,ze.prototype.isMeshDepthMaterial=!0,ze.prototype.copy=function(t){return T.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},Be.prototype=Object.create(T.prototype),Be.prototype.constructor=Be,Be.prototype.isMeshDistanceMaterial=!0,Be.prototype.copy=function(t){return T.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this};var gu="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n float mean = 0.0;\n float squared_mean = 0.0;\n \n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n #ifdef HORIZONAL_PASS\n vec2 distribution = decodeHalfRGBA ( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n float std_dev = pow( squared_mean - mean * mean, 0.5 );\n gl_FragColor = encodeHalfRGBA( vec2( mean, std_dev ) );\n}",yu="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";Ve.prototype=Object.assign(Object.create(c.prototype),{constructor:Ve,isWebGLMultiviewRenderTarget:!0,copy:function(t){return c.prototype.copy.call(this,t),this.numViews=t.numViews,this},setNumViews:function(t){return this.numViews!==t&&(this.numViews=t,this.dispose()),this}}),ke.prototype=Object.assign(Object.create(d.prototype),{constructor:ke,isGroup:!0}),We.prototype=Object.assign(Object.create(Y.prototype),{constructor:We,isArrayCamera:!0});var xu=new i,bu=new i;Object.assign(Xe.prototype,e.prototype),Object.assign(Ye.prototype,e.prototype),Object.assign(Je.prototype,{isFogExp2:!0,clone:function(){return new Je(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(Qe.prototype,{isFog:!0,clone:function(){return new Qe(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Ke.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ke.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.dynamic=t.dynamic,this},copyAt:function(t,e,r){t*=this.stride,r*=e.stride;for(var n=0,i=this.stride;nt.far||e.push({distance:c,point:_u.clone(),uv:x.getUV(_u,Lu,Ru,Pu,Cu,Ou,Du,new r),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return d.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}});var Iu=new i,Nu=new i;nr.prototype=Object.assign(Object.create(d.prototype),{constructor:nr,isLOD:!0,copy:function(t){d.prototype.copy.call(this,t,!1);for(var e=t.levels,r=0,n=e.length;r1){Iu.setFromMatrixPosition(t.matrixWorld),Nu.setFromMatrixPosition(this.matrixWorld);var r=Iu.distanceTo(Nu);e[0].object.visible=!0;for(var n=1,i=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(;ns)){u.applyMatrix4(this.matrixWorld);var _=t.ray.origin.distanceTo(u);_t.far||e.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}else for(var g=0,y=m.length/3-1;gs)){u.applyMatrix4(this.matrixWorld);var _=t.ray.origin.distanceTo(u);_t.far||e.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}}else if(n.isGeometry)for(var M=n.vertices,S=M.length,g=0;gs)){u.applyMatrix4(this.matrixWorld);var _=t.ray.origin.distanceTo(u);_t.far||e.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var ju=new i,ku=new i;lr.prototype=Object.assign(Object.create(cr.prototype),{constructor:lr,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,r=[],n=0,i=e.count;n0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fr.prototype=Object.assign(Object.create(o.prototype),{constructor:fr,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),mr.prototype=Object.create(o.prototype),mr.prototype.constructor=mr,mr.prototype.isCompressedTexture=!0,vr.prototype=Object.create(o.prototype),vr.prototype.constructor=vr,vr.prototype.isCanvasTexture=!0,gr.prototype=Object.create(o.prototype),gr.prototype.constructor=gr,gr.prototype.isDepthTexture=!0,yr.prototype=Object.create(G.prototype),yr.prototype.constructor=yr,xr.prototype=Object.create(j.prototype),xr.prototype.constructor=xr,br.prototype=Object.create(G.prototype),br.prototype.constructor=br,wr.prototype=Object.create(j.prototype),wr.prototype.constructor=wr,_r.prototype=Object.create(G.prototype),_r.prototype.constructor=_r,Mr.prototype=Object.create(j.prototype),Mr.prototype.constructor=Mr,Sr.prototype=Object.create(_r.prototype),Sr.prototype.constructor=Sr,Tr.prototype=Object.create(j.prototype),Tr.prototype.constructor=Tr,Er.prototype=Object.create(_r.prototype),Er.prototype.constructor=Er,Ar.prototype=Object.create(j.prototype),Ar.prototype.constructor=Ar,Lr.prototype=Object.create(_r.prototype),Lr.prototype.constructor=Lr,Rr.prototype=Object.create(j.prototype),Rr.prototype.constructor=Rr,Pr.prototype=Object.create(_r.prototype),Pr.prototype.constructor=Pr,Cr.prototype=Object.create(j.prototype),Cr.prototype.constructor=Cr,Or.prototype=Object.create(G.prototype),Or.prototype.constructor=Or,Or.prototype.toJSON=function(){var t=G.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},Dr.prototype=Object.create(j.prototype),Dr.prototype.constructor=Dr,Ir.prototype=Object.create(G.prototype),Ir.prototype.constructor=Ir,Nr.prototype=Object.create(j.prototype),Nr.prototype.constructor=Nr,zr.prototype=Object.create(G.prototype),zr.prototype.constructor=zr;var Zu={triangulate:function(t,e,r){r=r||2;var n=e&&e.length,i=n?e[0]*r:t.length,a=Br(t,0,i,r,!0),o=[];if(!a||a.next===a.prev)return o;var s,c,l,h,u,p,d;if(n&&(a=kr(t,e,a,r)),t.length>80*r){s=l=t[0],c=h=t[1];for(var f=r;fl&&(l=u),p>h&&(h=p);d=Math.max(l-s,h-c),d=0!==d?1/d:0}return Gr(a,o,r,s,c,d),o}},Ju={area:function(t){for(var e=t.length,r=0,n=e-1,i=0;i=i)break t;var s=e[1];t=i)break e}a=r,r=0}}for(;r>>1;te;)--a;if(++a,0!==i||a!==n){i>=a&&(a=Math.max(a,1),i=a-1);var o=this.getValueSize();this.times=tp.arraySlice(r,i,a),this.values=tp.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var r=this.times,n=this.values,i=r.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=r[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==n&&tp.isTypedArray(n))for(var o=0,c=n.length;o!==c;++o){var l=n[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,r=this.getValueSize(),n=2302===this.getInterpolation(),i=1,a=t.length-1,o=1;o0){t[i]=t[a];for(var f=a*r,m=i*r,p=0;p!==r;++p)e[m+p]=e[f+p];++i}return i!==t.length&&(this.times=tp.arraySlice(t,0,i),this.values=tp.arraySlice(e,0,i*r)),this},clone:function(){var t=tp.arraySlice(this.times,0),e=tp.arraySlice(this.values,0),r=this.constructor,n=new r(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}),Jn.prototype=Object.assign(Object.create(Zn.prototype),{constructor:Jn,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Qn.prototype=Object.assign(Object.create(Zn.prototype),{constructor:Qn,ValueTypeName:"color"}),Kn.prototype=Object.assign(Object.create(Zn.prototype),{constructor:Kn,ValueTypeName:"number"}),$n.prototype=Object.assign(Object.create(Wn.prototype),{constructor:$n,interpolate_:function(t,e,r,i){for(var a=this.resultBuffer,o=this.sampleValues,s=this.valueSize,c=t*s,l=(r-e)/(i-e),h=c+s;c!==h;c+=4)n.slerpFlat(a,0,o,c-s,o,c,l);return a}}),ti.prototype=Object.assign(Object.create(Zn.prototype),{constructor:ti,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(t){return new $n(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),ei.prototype=Object.assign(Object.create(Zn.prototype),{constructor:ei,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ri.prototype=Object.assign(Object.create(Zn.prototype),{constructor:ri,ValueTypeName:"vector"}),Object.assign(ni,{parse:function(t){for(var e=[],r=t.tracks,n=1/(t.fps||1),i=0,a=r.length;i!==a;++i)e.push(ai(r[i]).scale(n));return new ni(t.name,t.duration,e)},toJSON:function(t){for(var e=[],r=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},i=0,a=r.length;i!==a;++i)e.push(Zn.toJSON(r[i]));return n},CreateFromMorphTargetSequence:function(t,e,r,n){for(var i=e.length,a=[],o=0;o1){var l=c[1],h=n[l];h||(n[l]=h=[]),h.push(s)}}var u=[];for(var l in n)u.push(ni.CreateFromMorphTargetSequence(l,n[l],e,r));return u},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var r=function(t,e,r,n,i){if(0!==r.length){var a=[],o=[];tp.flattenJSON(r,a,o,n),0!==a.length&&i.push(new t(e,a,o))}},n=[],i=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c0||0===t.search(/^data\:image\/jpeg/);i.format=n?lc:hc,i.needsUpdate=!0,void 0!==e&&e(i)},r,n),i}}),Object.assign(mi.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var r=this.getUtoTmapping(t);return this.getPoint(r,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],r=0;r<=t;r++)e.push(this.getPoint(r/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,r,n=[],i=this.getPoint(0),a=0;for(n.push(0),r=1;r<=t;r++)e=this.getPoint(r/t),a+=e.distanceTo(i),n.push(a),i=e;return this.cacheArcLengths=n,n},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var r,n=this.getLengths(),i=0,a=n.length;r=e||t*n[a-1];for(var o,s=0,c=a-1;s<=c;)if(i=Math.floor(s+(c-s)/2),(o=n[i]-r)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(i=c,n[i]===r)return i/(a-1);var l=n[i];return(i+(r-l)/(n[i+1]-l))/(a-1)},getTangent:function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),r>1&&(r=1);var n=this.getPoint(e);return this.getPoint(r).clone().sub(n).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var r,n,a,o=new i,s=[],c=[],l=[],u=new i,p=new h;for(r=0;r<=t;r++)n=r/t,s[r]=this.getTangentAt(n),s[r].normalize();c[0]=new i,l[0]=new i;var d=Number.MAX_VALUE,f=Math.abs(s[0].x),m=Math.abs(s[0].y),v=Math.abs(s[0].z);for(f<=d&&(d=f,o.set(1,0,0)),m<=d&&(d=m,o.set(0,1,0)),v<=d&&o.set(0,0,1),u.crossVectors(s[0],o).normalize(),c[0].crossVectors(s[0],u),l[0].crossVectors(s[0],c[0]),r=1;r<=t;r++)c[r]=c[r-1].clone(),l[r]=l[r-1].clone(),u.crossVectors(s[r-1],s[r]),u.length()>Number.EPSILON&&(u.normalize(),a=Math.acos(sl.clamp(s[r-1].dot(s[r]),-1,1)),c[r].applyMatrix4(p.makeRotationAxis(u,a))),l[r].crossVectors(s[r],c[r]);if(!0===e)for(a=Math.acos(sl.clamp(c[0].dot(c[t]),-1,1)),a/=t,s[0].dot(u.crossVectors(c[0],c[t]))>0&&(a=-a),r=1;r<=t;r++)c[r].applyMatrix4(p.makeRotationAxis(s[r],a*r)),l[r].crossVectors(s[r],c[r]);return{tangents:s,normals:c,binormals:l}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){var t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),vi.prototype=Object.create(mi.prototype),vi.prototype.constructor=vi,vi.prototype.isEllipseCurve=!0,vi.prototype.getPoint=function(t,e){for(var n=e||new r,i=2*Math.PI,a=this.aEndAngle-this.aStartAngle,o=Math.abs(a)i;)a-=i;a0?0:(Math.floor(Math.abs(s)/a)+1)*a:0===c&&s===a-1&&(s=a-2,c=1);var l,h,u,p;if(this.closed||s>0?l=n[(s-1)%a]:(ip.subVectors(n[0],n[1]).add(n[0]),l=ip),h=n[s%a],u=n[(s+1)%a],this.closed||s+2i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(bi(s,c.x,l.x,h.x,u.x),bi(s,c.y,l.y,h.y,u.y)),n},zi.prototype.copy=function(t){mi.prototype.copy.call(this,t),this.points=[];for(var e=0,r=t.points.length;e=e){var i=r[n]-e,a=this.curves[n],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}n++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,r=0,n=this.curves.length;r1&&!r[r.length-1].equals(r[0])&&r.push(r[0]),r},copy:function(t){mi.prototype.copy.call(this,t),this.curves=[];for(var e=0,r=t.curves.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var h=c.getPoint(1);this.currentPoint.copy(h)},copy:function(t){return Bi.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Bi.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Bi.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Gi.prototype=Object.assign(Object.create(Fi.prototype),{constructor:Gi,getPointsHoles:function(t){for(var e=[],r=0,n=this.holes.length;r0){var a=new oi(e),o=new pi(a);o.setCrossOrigin(this.crossOrigin);for(var s=0,c=t.length;s0?new ir(o,s):new U(o,s),void 0!==t.drawMode&&a.setDrawMode(t.drawMode);break;case"LOD":a=new nr;break;case"Line":a=new cr(n(t.geometry),i(t.material),t.mode);break;case"LineLoop":a=new hr(n(t.geometry),i(t.material));break;case"LineSegments":a=new lr(n(t.geometry),i(t.material));break;case"PointCloud":case"Points":a=new pr(n(t.geometry),i(t.material));break;case"Sprite":a=new er(i(t.material));break;case"Group":a=new ke;break;default:a=new d}if(a.uuid=t.uuid,void 0!==t.name&&(a.name=t.name),void 0!==t.matrix?(a.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(a.matrixAutoUpdate=t.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==t.position&&a.position.fromArray(t.position),void 0!==t.rotation&&a.rotation.fromArray(t.rotation),void 0!==t.quaternion&&a.quaternion.fromArray(t.quaternion),void 0!==t.scale&&a.scale.fromArray(t.scale)),void 0!==t.castShadow&&(a.castShadow=t.castShadow),void 0!==t.receiveShadow&&(a.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(a.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(a.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&a.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(a.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(a.visible=t.visible),void 0!==t.frustumCulled&&(a.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(a.renderOrder=t.renderOrder),void 0!==t.userData&&(a.userData=t.userData),void 0!==t.layers&&(a.layers.mask=t.layers),void 0!==t.children)for(var c=t.children,l=0;l1){for(var g=!1,y=[],x=0,b=p.length;xNumber.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var h=l*(t.x-o.x)-c*(t.y-o.y);if(0===h)return!0;if(h<0)continue;n=!n}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return n})(M.p,p[T].p)&&(x!==T&&y.push({froms:x,tos:T,hole:_}),S?(S=!1,u[T].push(M)):g=!0);S&&u[x].push(M)}y.length>0&&(g||(d=u))}for(var E,m=0,A=p.length;m0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==i;++a)t[e+a]=t[r+a]},_slerp:function(t,e,r,i){n.slerpFlat(t,e,t,e,t,r,i)},_lerp:function(t,e,r,n,i){for(var a=1-n,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[r+o]*n}}});var Ep="\\[\\]\\.:\\/",Ap=new RegExp("["+Ep+"]","g"),Lp="[^"+Ep+"]",Rp="[^"+Ep.replace("\\.","")+"]",Pp=/((?:WC+[\/:])*)/.source.replace("WC",Lp),Cp=/(WCOD+)?/.source.replace("WCOD",Rp),Op=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Lp),Dp=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Lp),Ip=new RegExp("^"+Pp+Cp+Op+Dp+"$"),Np=["material","materials","bones"];Object.assign(wa.prototype,{getValue:function(t,e){this.bind();var r=this._targetGroup.nCachedObjects_,n=this._bindings[r];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){for(var r=this._bindings,n=this._targetGroup.nCachedObjects_,i=r.length;n!==i;++n)r[n].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,r=t.length;e!==r;++e)t[e].unbind()}}),Object.assign(_a,{Composite:wa,create:function(t,e,r){return t&&t.isAnimationObjectGroup?new _a.Composite(t,e,r):new _a(t,e,r)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Ap,"")},parseTrackName:function(t){var e=Ip.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var r={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=r.nodeName&&r.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){var i=r.nodeName.substring(n+1);-1!==Np.indexOf(i)&&(r.nodeName=r.nodeName.substring(0,n),r.objectName=i)}if(null===r.propertyName||0===r.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return r},findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var r=t.skeleton.getBoneByName(e);if(void 0!==r)return r}if(t.children){var n=function(t){for(var r=0;r=e){ var h=e++,u=t[h];r[u.uuid]=l,t[l]=u,r[c]=h,t[h]=s;for(var p=0,d=i;p!==d;++p){var f=n[p],m=f[h],v=f[l];f[l]=m,f[h]=v}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,r=this.nCachedObjects_,n=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,h=n[l];if(void 0!==h)if(delete n[l],h0)for(var c=this._interpolants,l=this._propertyBindings,h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulate(n,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var r=this._weightInterpolant;if(null!==r){var n=r.evaluate(t)[0];e*=n,t>r.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var r=this._timeScaleInterpolant;if(null!==r){e*=r.evaluate(t)[0],t>r.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t,r=this._clip.duration,n=this.loop,i=this._loopCount,a=2202===n;if(0===t)return-1===i?e:a&&1==(1&i)?r-e:e;if(2200===n){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=r)e=r;else{if(!(e<0)){this.time=e;break t}e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=r||e<0){var o=Math.floor(e/r);e-=r*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?r:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=e;if(a&&1==(1&i))return r-e}return e},_setEndings:function(t,e,r){var n=this._interpolantSettings;r?(n.endingStart=2401,n.endingEnd=2401):(n.endingStart=t?this.zeroSlopeAtStart?2401:Hc:2402,n.endingEnd=e?this.zeroSlopeAtEnd?2401:Hc:2402)},_scheduleFading:function(t,e,r){var n=this._mixer,i=n.time,a=this._weightInterpolant;null===a&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=r,this}}),Ta.prototype=Object.assign(Object.create(e.prototype),{constructor:Ta,_bindAction:function(t,e){var r=t._localRoot||this._root,n=t._clip.tracks,i=n.length,a=t._propertyBindings,o=t._interpolants,s=r.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var h=0;h!==i;++h){var u=n[h],p=u.name,d=l[p];if(void 0!==d)a[h]=d;else{if(void 0!==(d=a[h])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=e&&e._propertyBindings[h].binding.parsedPath;d=new ba(_a.create(r,p,f),u.ValueTypeName,u.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,s,p),a[h]=d}o[h].resultBuffer=d.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,r=t._clip.uuid,n=this._actionsByClip[r];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,r,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,r=0,n=e.length;r!==n;++r){var i=e[r];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new r),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new r),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return zp.copy(t).clamp(this.min,this.max).sub(t).length()},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}});var Bp=new i,Fp=new i;Object.assign(Ia.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new i),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new i),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new i),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){Bp.subVectors(t,this.start),Fp.subVectors(this.end,this.start);var r=Fp.dot(Fp),n=Fp.dot(Bp),i=n/r;return e&&(i=sl.clamp(i,0,1)),i},closestPointToPoint:function(t,e,r){var n=this.closestPointToPointParameter(t,e);return void 0===r&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),r=new i),this.delta(r).multiplyScalar(n).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Na.prototype=Object.create(d.prototype),Na.prototype.constructor=Na,Na.prototype.isImmediateRenderObject=!0;var Gp=new i,Up=new i,Hp=new a,Vp=["a","b","c"];za.prototype=Object.create(lr.prototype),za.prototype.constructor=za,za.prototype.update=function(){this.object.updateMatrixWorld(!0),Hp.getNormalMatrix(this.object.matrixWorld);var t=this.object.matrixWorld,e=this.geometry.attributes.position,r=this.object.geometry;if(r&&r.isGeometry)for(var n=r.vertices,i=r.faces,a=0,o=0,s=i.length;o1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}},Ha.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var Xp=new i,Yp=new b,Zp=new b;Va.prototype=Object.create(d.prototype),Va.prototype.constructor=Va,Va.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},Va.prototype.update=function(){var t=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var e=t.geometry.getAttribute("color");Yp.copy(this.light.color),Zp.copy(this.light.groundColor);for(var r=0,n=e.count;r.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{sd.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(sd,e)}},to.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},to.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},to.prototype.copy=function(t){return d.prototype.copy.call(this,t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this},to.prototype.clone=function(){return(new this.constructor).copy(this)},eo.prototype=Object.create(lr.prototype),eo.prototype.constructor=eo;mi.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(mi.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Bi.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var e=new j,r=0,n=t.length;r { var taskConfig = { attributeIDs: this.defaultAttributeIDs, attributeTypes: this.defaultAttributeTypes, useUniqueIDs: false }; this.decodeGeometry( buffer, taskConfig ) .then( onLoad ) .catch( onError ); }, onProgress, onError ); }, /** @deprecated Kept for backward-compatibility with previous DRACOLoader versions. */ decodeDracoFile: function ( buffer, callback, attributeIDs, attributeTypes ) { var taskConfig = { attributeIDs: attributeIDs || this.defaultAttributeIDs, attributeTypes: attributeTypes || this.defaultAttributeTypes, useUniqueIDs: !! attributeIDs }; this.decodeGeometry( buffer, taskConfig ).then( callback ); }, decodeGeometry: function ( buffer, taskConfig ) { var worker; var taskID = this.workerNextTaskID ++; var taskCost = buffer.byteLength; // TODO: For backward-compatibility, support 'attributeTypes' objects containing // references (rather than names) to typed array constructors. These must be // serialized before sending them to the worker. for ( var attribute in taskConfig.attributeTypes ) { var type = taskConfig.attributeTypes[ attribute ]; if ( type.BYTES_PER_ELEMENT !== undefined ) { taskConfig.attributeTypes[ attribute ] = type.name; } } // Obtain a worker and assign a task, and construct a geometry instance // when the task completes. var geometryPending = this._getWorker( taskID, taskCost ) .then( ( _worker ) => { worker = _worker; return new Promise( ( resolve, reject ) => { worker._callbacks[ taskID ] = { resolve, reject }; worker.postMessage( { type: 'decode', id: taskID, taskConfig, buffer }, [ buffer ] ); // this.debug(); } ); } ) .then( ( message ) => this._createGeometry( message.geometry ) ); // Remove task from the task list. geometryPending .finally( () => { if ( worker && taskID ) { this._releaseTask( worker, taskID ); // this.debug(); } } ); return geometryPending; }, _createGeometry: function ( geometryData ) { var geometry = new THREE.BufferGeometry(); if ( geometryData.index ) { geometry.setIndex( new THREE.BufferAttribute( geometryData.index.array, 1 ) ); } for ( var i = 0; i < geometryData.attributes.length; i ++ ) { var attribute = geometryData.attributes[ i ]; var name = attribute.name; var array = attribute.array; var itemSize = attribute.itemSize; geometry.addAttribute( name, new THREE.BufferAttribute( array, itemSize ) ); } return geometry; }, _loadLibrary: function ( url, responseType ) { var loader = new THREE.FileLoader( this.manager ); loader.setPath( this.decoderPath ); loader.setResponseType( responseType ); return new Promise( ( resolve, reject ) => { loader.load( url, resolve, undefined, reject ); } ); }, _initDecoder: function () { if ( this.decoderPending ) return this.decoderPending; var useJS = typeof WebAssembly !== 'object' || this.decoderConfig.type === 'js'; var librariesPending = []; if ( useJS ) { librariesPending.push( this._loadLibrary( 'draco_decoder.js', 'text' ) ); } else { librariesPending.push( this._loadLibrary( 'draco_wasm_wrapper.js', 'text' ) ); librariesPending.push( this._loadLibrary( 'draco_decoder.wasm', 'arraybuffer' ) ); } this.decoderPending = Promise.all( librariesPending ) .then( ( libraries ) => { var jsContent = libraries[ 0 ]; if ( ! useJS ) { this.decoderConfig.wasmBinary = libraries[ 1 ]; } var fn = THREE.DRACOLoader.DRACOWorker.toString(); var body = [ '/* draco decoder */', jsContent, '', '/* worker */', fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) ) ].join( '\n' ); this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) ); } ); return this.decoderPending; }, _getWorker: function ( taskID, taskCost ) { return this._initDecoder().then( () => { if ( this.workerPool.length < this.workerLimit ) { var worker = new Worker( this.workerSourceURL ); worker._callbacks = {}; worker._taskCosts = {}; worker._taskLoad = 0; worker.postMessage( { type: 'init', decoderConfig: this.decoderConfig } ); worker.onmessage = function ( e ) { var message = e.data; switch ( message.type ) { case 'decode': worker._callbacks[ message.id ].resolve( message ); break; case 'error': worker._callbacks[ message.id ].reject( message ); break; default: console.error( 'THREE.DRACOLoader: Unexpected message, "' + message.type + '"' ); } }; this.workerPool.push( worker ); } else { this.workerPool.sort( function ( a, b ) { return a._taskLoad > b._taskLoad ? - 1 : 1; } ); } var worker = this.workerPool[ this.workerPool.length - 1 ]; worker._taskCosts[ taskID ] = taskCost; worker._taskLoad += taskCost; return worker; } ); }, _releaseTask: function ( worker, taskID ) { worker._taskLoad -= worker._taskCosts[ taskID ]; delete worker._callbacks[ taskID ]; delete worker._taskCosts[ taskID ]; }, debug: function () { console.log( 'Task load: ', this.workerPool.map( ( worker ) => worker._taskLoad ) ); }, dispose: function () { for ( var i = 0; i < this.workerPool.length; ++ i ) { this.workerPool[ i ].terminate(); } this.workerPool.length = 0; return this; } } ); /* WEB WORKER */ THREE.DRACOLoader.DRACOWorker = function () { var decoderConfig; var decoderPending; onmessage = function ( e ) { var message = e.data; switch ( message.type ) { case 'init': decoderConfig = message.decoderConfig; decoderPending = new Promise( function ( resolve/*, reject*/ ) { decoderConfig.onModuleLoaded = function ( draco ) { // Module is Promise-like. Wrap before resolving to avoid loop. resolve( { draco: draco } ); }; DracoDecoderModule( decoderConfig ); } ); break; case 'decode': var buffer = message.buffer; var taskConfig = message.taskConfig; decoderPending.then( ( module ) => { var draco = module.draco; var decoder = new draco.Decoder(); var decoderBuffer = new draco.DecoderBuffer(); decoderBuffer.Init( new Int8Array( buffer ), buffer.byteLength ); try { var geometry = decodeGeometry( draco, decoder, decoderBuffer, taskConfig ); var buffers = geometry.attributes.map( ( attr ) => attr.array.buffer ); if ( geometry.index ) buffers.push( geometry.index.array.buffer ); self.postMessage( { type: 'decode', id: message.id, geometry }, buffers ); } catch ( error ) { console.error( error ); self.postMessage( { type: 'error', id: message.id, error: error.message } ); } finally { draco.destroy( decoderBuffer ); draco.destroy( decoder ); } } ); break; } }; function decodeGeometry( draco, decoder, decoderBuffer, taskConfig ) { var attributeIDs = taskConfig.attributeIDs; var attributeTypes = taskConfig.attributeTypes; var dracoGeometry; var decodingStatus; var geometryType = decoder.GetEncodedGeometryType( decoderBuffer ); if ( geometryType === draco.TRIANGULAR_MESH ) { dracoGeometry = new draco.Mesh(); decodingStatus = decoder.DecodeBufferToMesh( decoderBuffer, dracoGeometry ); } else if ( geometryType === draco.POINT_CLOUD ) { dracoGeometry = new draco.PointCloud(); decodingStatus = decoder.DecodeBufferToPointCloud( decoderBuffer, dracoGeometry ); } else { throw new Error( 'THREE.DRACOLoader: Unexpected geometry type.' ); } if ( ! decodingStatus.ok() || dracoGeometry.ptr === 0 ) { throw new Error( 'THREE.DRACOLoader: Decoding failed: ' + decodingStatus.error_msg() ); } var geometry = { index: null, attributes: [] }; // Gather all vertex attributes. for ( var attributeName in attributeIDs ) { var attributeType = self[ attributeTypes[ attributeName ] ]; var attribute; var attributeID; // A Draco file may be created with default vertex attributes, whose attribute IDs // are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively, // a Draco file may contain a custom set of attributes, identified by known unique // IDs. glTF files always do the latter, and `.drc` files typically do the former. if ( taskConfig.useUniqueIDs ) { attributeID = attributeIDs[ attributeName ]; attribute = decoder.GetAttributeByUniqueId( dracoGeometry, attributeID ); } else { attributeID = decoder.GetAttributeId( dracoGeometry, draco[ attributeIDs[ attributeName ] ] ); if ( attributeID === -1 ) continue; attribute = decoder.GetAttribute( dracoGeometry, attributeID ); } geometry.attributes.push( decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) ); } // Add index. if ( geometryType === draco.TRIANGULAR_MESH ) { // Generate mesh faces. var numFaces = dracoGeometry.num_faces(); var numIndices = numFaces * 3; var index = new Uint32Array( numIndices ); var indexArray = new draco.DracoInt32Array(); for ( var i = 0; i < numFaces; ++ i ) { decoder.GetFaceFromMesh( dracoGeometry, i, indexArray ); for ( var j = 0; j < 3; ++ j ) { index[ i * 3 + j ] = indexArray.GetValue( j ); } } geometry.index = { array: index, itemSize: 1 }; draco.destroy( indexArray ); } draco.destroy( dracoGeometry ); return geometry; } function decodeAttribute( draco, decoder, dracoGeometry, attributeName, attributeType, attribute ) { var numComponents = attribute.num_components(); var numPoints = dracoGeometry.num_points(); var numValues = numPoints * numComponents; var dracoArray; var array; switch ( attributeType ) { case Float32Array: dracoArray = new draco.DracoFloat32Array(); decoder.GetAttributeFloatForAllPoints( dracoGeometry, attribute, dracoArray ); array = new Float32Array( numValues ); break; case Int8Array: dracoArray = new draco.DracoInt8Array(); decoder.GetAttributeInt8ForAllPoints( dracoGeometry, attribute, dracoArray ); array = new Int8Array( numValues ); break; case Int16Array: dracoArray = new draco.DracoInt16Array(); decoder.GetAttributeInt16ForAllPoints( dracoGeometry, attribute, dracoArray ); array = new Int16Array( numValues ); break; case Int32Array: dracoArray = new draco.DracoInt32Array(); decoder.GetAttributeInt32ForAllPoints( dracoGeometry, attribute, dracoArray ); array = new Int32Array( numValues ); break; case Uint8Array: dracoArray = new draco.DracoUInt8Array(); decoder.GetAttributeUInt8ForAllPoints( dracoGeometry, attribute, dracoArray ); array = new Uint8Array( numValues ); break; case Uint16Array: dracoArray = new draco.DracoUInt16Array(); decoder.GetAttributeUInt16ForAllPoints( dracoGeometry, attribute, dracoArray ); array = new Uint16Array( numValues ); break; case Uint32Array: dracoArray = new draco.DracoUInt32Array(); decoder.GetAttributeUInt32ForAllPoints( dracoGeometry, attribute, dracoArray ); array = new Uint32Array( numValues ); break; default: throw new Error( 'THREE.DRACOLoader: Unexpected attribute type.' ); } for ( var i = 0; i < numValues; i ++ ) { array[ i ] = dracoArray.GetValue( i ); } draco.destroy( dracoArray ); return { name: attributeName, array: array, itemSize: numComponents }; } }; /** Deprecated static methods */ /** @deprecated */ THREE.DRACOLoader.setDecoderPath = function () { console.warn( 'THREE.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.' ); }; /** @deprecated */ THREE.DRACOLoader.setDecoderConfig = function () { console.warn( 'THREE.DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.' ); }; /** @deprecated */ THREE.DRACOLoader.releaseDecoderModule = function () { console.warn( 'THREE.DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.' ); }; /** @deprecated */ THREE.DRACOLoader.getDecoderModule = function () { console.warn( 'THREE.DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.' ); }; },{}],59:[function(_dereq_,module,exports){ THREE.GLTFLoader=function(){function e(e){THREE.Loader.call(this,e),this.dracoLoader=null,this.ddsLoader=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 r(e){if(!e)throw new Error("THREE.GLTFLoader: Attempting to load .dds texture without importing THREE.DDSLoader");this.name=M.MSFT_TEXTURE_DDS,this.ddsLoader=e}function a(e){this.name=M.KHR_LIGHTS_PUNCTUAL;var t=e.extensions&&e.extensions[M.KHR_LIGHTS_PUNCTUAL]||{};this.lightDefs=t.lights||[]}function n(){this.name=M.KHR_MATERIALS_UNLIT}function s(e){this.name=M.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,L);if(this.header={magic:THREE.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==S)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.");for(var r=new DataView(e,L),a=0;a",i).replace("#include ",o).replace("#include ",l).replace("#include ",p).replace("#include ",u);delete s.roughness,delete s.metalness,delete s.roughnessMap,delete s.metalnessMap,s.specular={value:(new THREE.Color).setHex(1118481)},s.glossiness={value:.5},s.specularMap={value:null},s.glossinessMap={value:null},e.vertexShader=n.vertexShader,e.fragmentShader=c,e.uniforms=s,e.defines={STANDARD:""},e.color=new THREE.Color(1,1,1),e.opacity=1;var d=[];if(Array.isArray(a.diffuseFactor)){var h=a.diffuseFactor;e.color.fromArray(h),e.opacity=h[3]}if(void 0!==a.diffuseTexture&&d.push(r.assignTexture(e,"map",a.diffuseTexture)),e.emissive=new THREE.Color(0,0,0),e.glossiness=void 0!==a.glossinessFactor?a.glossinessFactor:1,e.specular=new THREE.Color(1,1,1),Array.isArray(a.specularFactor)&&e.specular.fromArray(a.specularFactor),void 0!==a.specularGlossinessTexture){var f=a.specularGlossinessTexture;d.push(r.assignTexture(e,"glossinessMap",f)),d.push(r.assignTexture(e,"specularMap",f))}return Promise.all(d)},createMaterial:function(e){var t=new THREE.ShaderMaterial({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,a=0,n=r.length;a=2&&(a[s++]=e.getY(n)),r>=3&&(a[s++]=e.getZ(n)),r>=4&&(a[s++]=e.getW(n));return new THREE.BufferAttribute(a,r,e.normalized)}return e.clone()}function g(e,r,a){this.json=e||{},this.extensions=r||{},this.options=a||{},this.cache=new t,this.primitiveCache={},this.textureLoader=new THREE.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new THREE.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}function R(e,t,r){var a=t.attributes,n=[];for(var s in a){var i=I[s]||s.toLowerCase();i in e.attributes||n.push(function(t,a){return r.getDependency("accessor",t).then(function(t){e.addAttribute(a,t)})}(a[s],i))}if(void 0!==t.indices&&!e.index){var o=r.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});n.push(o)}return h(e,t),Promise.all(n).then(function(){return void 0!==t.targets?f(e,t.targets,r):e})}e.prototype=Object.assign(Object.create(THREE.Loader.prototype),{constructor:e,load:function(e,t,r,a){var n,s=this;n=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:THREE.LoaderUtils.extractUrlBase(e),s.manager.itemStart(e);var i=function(t){a?a(t):console.error(t),s.manager.itemError(e),s.manager.itemEnd(e)},o=new THREE.FileLoader(s.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),"use-credentials"===s.crossOrigin&&o.setWithCredentials(!0),o.load(e,function(r){try{s.parse(r,n,function(r){t(r),s.manager.itemEnd(e)},i)}catch(e){i(e)}},r,i)},setDRACOLoader:function(e){return this.dracoLoader=e,this},setDDSLoader:function(e){return this.ddsLoader=e,this},parse:function(e,t,p,u){var c,d={};if("string"==typeof e)c=e;else{if(THREE.LoaderUtils.decodeText(new Uint8Array(e,0,4))===S){try{d[M.KHR_BINARY_GLTF]=new s(e)}catch(e){return void(u&&u(e))}c=d[M.KHR_BINARY_GLTF].content}else c=THREE.LoaderUtils.decodeText(new Uint8Array(e))}var h=JSON.parse(c);if(void 0===h.asset||h.asset.version[0]<2)return void(u&&u(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.")));if(h.extensionsUsed)for(var f=0;f=0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}new g(h,d,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager}).parse(p,u)}});var M={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",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};a.prototype.loadLight=function(e){var t,r=this.lightDefs[e],a=new THREE.Color(16777215);void 0!==r.color&&a.fromArray(r.color);var n=void 0!==r.range?r.range:0;switch(r.type){case"directional":t=new THREE.DirectionalLight(a),t.target.position.set(0,0,-1),t.add(t.target);break;case"point":t=new THREE.PointLight(a),t.distance=n;break;case"spot":t=new THREE.SpotLight(a),t.distance=n,r.spot=r.spot||{},r.spot.innerConeAngle=void 0!==r.spot.innerConeAngle?r.spot.innerConeAngle:0,r.spot.outerConeAngle=void 0!==r.spot.outerConeAngle?r.spot.outerConeAngle:Math.PI/4,t.angle=r.spot.outerConeAngle,t.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,t.target.position.set(0,0,-1),t.add(t.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+r.type+'".')}return t.position.set(0,0,0),t.decay=2,void 0!==r.intensity&&(t.intensity=r.intensity),t.name=r.name||"light_"+e,Promise.resolve(t)},n.prototype.getMaterialType=function(){return THREE.MeshBasicMaterial},n.prototype.extendParams=function(e,t,r){var a=[];e.color=new THREE.Color(1,1,1),e.opacity=1;var n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){var s=n.baseColorFactor;e.color.fromArray(s),e.opacity=s[3]}void 0!==n.baseColorTexture&&a.push(r.assignTexture(e,"map",n.baseColorTexture))}return Promise.all(a)};var S="glTF",L=12,y={JSON:1313821514,BIN:5130562};i.prototype.decodePrimitive=function(e,t){var r=this.json,a=this.dracoLoader,n=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,i={},o={},l={};for(var p in s){var u=I[p]||p.toLowerCase();i[u]=s[p]}for(p in e.attributes){var u=I[p]||p.toLowerCase();if(void 0!==s[p]){var c=r.accessors[e.attributes[p]],d=H[c.componentType];l[u]=d,o[u]=!0===c.normalized}}return t.getDependency("bufferView",n).then(function(e){return new Promise(function(t){a.decodeDracoFile(e,function(e){for(var r in e.attributes){var a=e.attributes[r],n=o[r];void 0!==n&&(a.normalized=n)}t(e)},i,l)})})},o.prototype.extendTexture=function(e,t){return e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),e.needsUpdate=!0,e},p.prototype=Object.create(THREE.Interpolant.prototype),p.prototype.constructor=p,p.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,r=this.sampleValues,a=this.valueSize,n=e*a*3+a,s=0;s!==a;s++)t[s]=r[n+s];return t},p.prototype.beforeStart_=p.prototype.copySampleValue_,p.prototype.afterEnd_=p.prototype.copySampleValue_,p.prototype.interpolate_=function(e,t,r,a){for(var n=this.resultBuffer,s=this.sampleValues,i=this.valueSize,o=2*i,l=3*i,p=a-t,u=(r-t)/p,c=u*u,d=c*u,h=e*l,f=h-l,m=-2*d+3*c,E=d-c,v=1-m,T=E-c+u,g=0;g!==i;g++){var R=s[f+g+i],M=s[f+g+o]*p,S=s[h+g+i],L=s[h+g]*p;n[g]=v*R+T*M+m*S+E*L}return n};var A,_={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},H={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},w={9728:THREE.NearestFilter,9729:THREE.LinearFilter,9984:THREE.NearestMipmapNearestFilter,9985:THREE.LinearMipmapNearestFilter,9986:THREE.NearestMipmapLinearFilter,9987:THREE.LinearMipmapLinearFilter},x={33071:THREE.ClampToEdgeWrapping,33648:THREE.MirroredRepeatWrapping,10497:THREE.RepeatWrapping},b={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},I={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},P={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},F={CUBICSPLINE:void 0,LINEAR:THREE.InterpolateLinear,STEP:THREE.InterpolateDiscrete},N={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},U={"image/png":THREE.RGBAFormat,"image/jpeg":THREE.RGBFormat};return g.prototype.parse=function(e,t){var r=this,a=this.json,n=this.extensions;this.cache.removeAll(),this.markDefs(),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then(function(t){var s={scene:t[0][a.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:a.asset,parser:r,userData:{}};d(n,s,a),h(s,a),e(s)}).catch(t)},g.prototype.markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[],a={},n={},s=0,i=t.length;s=2&&s.setY(A,S[L*o+1]),o>=3&&s.setZ(A,S[L*o+2]),o>=4&&s.setW(A,S[L*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return s})},g.prototype.loadTexture=function(e){var t,r=this,a=this.json,n=this.options,s=this.textureLoader,i=window.URL||window.webkitURL,o=a.textures[e],l=o.extensions||{};t=l[M.MSFT_TEXTURE_DDS]?a.images[l[M.MSFT_TEXTURE_DDS].source]:a.images[o.source];var p=t.uri,c=!1;return void 0!==t.bufferView&&(p=r.getDependency("bufferView",t.bufferView).then(function(e){c=!0;var r=new Blob([e],{type:t.mimeType});return p=i.createObjectURL(r)})),Promise.resolve(p).then(function(e){var t=n.manager.getHandler(e);return t||(t=l[M.MSFT_TEXTURE_DDS]?r.extensions[M.MSFT_TEXTURE_DDS].ddsLoader:s),new Promise(function(r,a){t.load(u(e,n.path),r,void 0,a)})}).then(function(e){!0===c&&i.revokeObjectURL(p),e.flipY=!1,void 0!==o.name&&(e.name=o.name),t.mimeType in U&&(e.format=U[t.mimeType]);var r=a.samplers||{},n=r[o.sampler]||{};return e.magFilter=w[n.magFilter]||THREE.LinearFilter,e.minFilter=w[n.minFilter]||THREE.LinearMipmapLinearFilter,e.wrapS=x[n.wrapS]||THREE.RepeatWrapping,e.wrapT=x[n.wrapT]||THREE.RepeatWrapping,e})},g.prototype.assignTexture=function(e,t,r){var a=this;return this.getDependency("texture",r.index).then(function(n){if(!n.isCompressedTexture)switch(t){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":n.format=THREE.RGBFormat}if(a.extensions[M.KHR_TEXTURE_TRANSFORM]){var s=void 0!==r.extensions?r.extensions[M.KHR_TEXTURE_TRANSFORM]:void 0;s&&(n=a.extensions[M.KHR_TEXTURE_TRANSFORM].extendTexture(n,s))}e[t]=n})},g.prototype.assignFinalMaterial=function(e){var t=e.geometry,r=e.material,a=this.extensions,n=void 0!==t.attributes.tangent,s=void 0!==t.attributes.color,i=void 0===t.attributes.normal,o=!0===e.isSkinnedMesh,l=Object.keys(t.morphAttributes).length>0,p=l&&void 0!==t.morphAttributes.normal;if(e.isPoints){var u="PointsMaterial:"+r.uuid,c=this.cache.get(u);c||(c=new THREE.PointsMaterial,THREE.Material.prototype.copy.call(c,r),c.color.copy(r.color),c.map=r.map,c.lights=!1,c.sizeAttenuation=!1,this.cache.add(u,c)),r=c}else if(e.isLine){var u="LineBasicMaterial:"+r.uuid,d=this.cache.get(u);d||(d=new THREE.LineBasicMaterial,THREE.Material.prototype.copy.call(d,r),d.color.copy(r.color),d.lights=!1,this.cache.add(u,d)),r=d}if(n||s||i||o||l){var u="ClonedMaterial:"+r.uuid+":";r.isGLTFSpecularGlossinessMaterial&&(u+="specular-glossiness:"),o&&(u+="skinning:"),n&&(u+="vertex-tangents:"),s&&(u+="vertex-colors:"),i&&(u+="flat-shading:"),l&&(u+="morph-targets:"),p&&(u+="morph-normals:");var h=this.cache.get(u);h||(h=r.isGLTFSpecularGlossinessMaterial?a[M.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].cloneMaterial(r):r.clone(),o&&(h.skinning=!0),n&&(h.vertexTangents=!0),s&&(h.vertexColors=THREE.VertexColors),i&&(h.flatShading=!0),l&&(h.morphTargets=!0),p&&(h.morphNormals=!0),this.cache.add(u,h)),r=h}r.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&(console.log("THREE.GLTFLoader: Duplicating UVs to support aoMap."),t.addAttribute("uv2",new THREE.BufferAttribute(t.attributes.uv.array,2))),r.isGLTFSpecularGlossinessMaterial&&(e.onBeforeRender=a[M.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].refreshUniforms),e.material=r},g.prototype.loadMaterial=function(e){var t,r=this,a=this.json,n=this.extensions,s=a.materials[e],i={},o=s.extensions||{},l=[];if(o[M.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var p=n[M.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=p.getMaterialType(),l.push(p.extendParams(i,s,r))}else if(o[M.KHR_MATERIALS_UNLIT]){var u=n[M.KHR_MATERIALS_UNLIT];t=u.getMaterialType(),l.push(u.extendParams(i,s,r))}else{t=THREE.MeshStandardMaterial;var c=s.pbrMetallicRoughness||{};if(i.color=new THREE.Color(1,1,1),i.opacity=1,Array.isArray(c.baseColorFactor)){var f=c.baseColorFactor;i.color.fromArray(f),i.opacity=f[3]}void 0!==c.baseColorTexture&&l.push(r.assignTexture(i,"map",c.baseColorTexture)),i.metalness=void 0!==c.metallicFactor?c.metallicFactor:1,i.roughness=void 0!==c.roughnessFactor?c.roughnessFactor:1,void 0!==c.metallicRoughnessTexture&&(l.push(r.assignTexture(i,"metalnessMap",c.metallicRoughnessTexture)),l.push(r.assignTexture(i,"roughnessMap",c.metallicRoughnessTexture)))}!0===s.doubleSided&&(i.side=THREE.DoubleSide);var m=s.alphaMode||N.OPAQUE;return m===N.BLEND?i.transparent=!0:(i.transparent=!1,m===N.MASK&&(i.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&t!==THREE.MeshBasicMaterial&&(l.push(r.assignTexture(i,"normalMap",s.normalTexture)),i.normalScale=new THREE.Vector2(1,1),void 0!==s.normalTexture.scale&&i.normalScale.set(s.normalTexture.scale,s.normalTexture.scale)),void 0!==s.occlusionTexture&&t!==THREE.MeshBasicMaterial&&(l.push(r.assignTexture(i,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(i.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&t!==THREE.MeshBasicMaterial&&(i.emissive=(new THREE.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&t!==THREE.MeshBasicMaterial&&l.push(r.assignTexture(i,"emissiveMap",s.emissiveTexture)),Promise.all(l).then(function(){var e;return e=t===THREE.ShaderMaterial?n[M.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(i):new t(i),void 0!==s.name&&(e.name=s.name),e.map&&(e.map.encoding=THREE.sRGBEncoding),e.emissiveMap&&(e.emissiveMap.encoding=THREE.sRGBEncoding),e.specularMap&&(e.specularMap.encoding=THREE.sRGBEncoding),h(e,s),s.extensions&&d(n,e,s),e})},g.prototype.loadGeometries=function(e){for(var t=this,r=this.extensions,a=this.primitiveCache,n=[],s=0,i=e.length;s0&&m(p,a),p.name=a.name||"mesh_"+e,s.length>1&&(p.name+="_"+o),h(p,a),t.assignFinalMaterial(p),i.push(p)}if(1===i.length)return i[0];for(var f=new THREE.Group,o=0,l=i.length;o1){var r=s[i.mesh]++;t=e.clone(),t.name+="_instance_"+r,t.onBeforeRender=e.onBeforeRender;for(var a=0,o=t.children.length;a1?new THREE.Group:1===e.length?e[0]:new THREE.Object3D)!==e[0])for(var a=0,n=e.length;a=0?n.substring(0,p):n;l=l.toLowerCase();var c=p>=0?n.substring(p+1):"";if(c=c.trim(),"newmtl"===l)e={name:c},i[c]=e;else if("ka"===l||"kd"===l||"ks"===l||"ke"===l){var h=c.split(s,3);e[l]=[parseFloat(h[0]),parseFloat(h[1]),parseFloat(h[2])]}else e[l]=c}}var u=new THREE.MTLLoader.MaterialCreator(this.resourcePath||t,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(i),u}}),THREE.MTLLoader.MaterialCreator=function(a,t){this.baseUrl=a||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,crossOrigin:"anonymous",setCrossOrigin:function(a){return this.crossOrigin=a,this},setManager:function(a){this.manager=a},setMaterials:function(a){this.materialsInfo=this.convert(a),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(a){if(!this.options)return a;var t={};for(var r in a){var e=a[r],s={};t[r]=s;for(var i in e){var o=!0,n=e[i],p=i.toLowerCase();switch(p){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(o=!1)}o&&(s[p]=n)}}return t},preload:function(){for(var a in this.materialsInfo)this.create(a)},getIndex:function(a){return this.nameLookup[a]},getAsArray:function(){var a=0;for(var t in this.materialsInfo)this.materialsArray[a]=this.create(t),this.nameLookup[t]=a,a++;return this.materialsArray},create:function(a){return void 0===this.materials[a]&&this.createMaterial_(a),this.materials[a]},createMaterial_:function(a){function t(a,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:a+t}function r(a,r){if(!i[a]){var s=e.getTextureParams(r,i),o=e.loadTexture(t(e.baseUrl,s.url));o.repeat.copy(s.scale),o.offset.copy(s.offset),o.wrapS=e.wrap,o.wrapT=e.wrap,i[a]=o}}var e=this,s=this.materialsInfo[a],i={name:a,side:this.side};for(var o in s){var n,p=s[o];if(""!==p)switch(o.toLowerCase()){case"kd":i.color=(new THREE.Color).fromArray(p);break;case"ks":i.specular=(new THREE.Color).fromArray(p);break;case"ke":i.emissive=(new THREE.Color).fromArray(p);break;case"map_kd":r("map",p);break;case"map_ks":r("specularMap",p);break;case"map_ke":r("emissiveMap",p);break;case"norm":r("normalMap",p);break;case"map_bump":case"bump":r("bumpMap",p);break;case"map_d":r("alphaMap",p),i.transparent=!0;break;case"ns":i.shininess=parseFloat(p);break;case"d":n=parseFloat(p),n<1&&(i.opacity=n,i.transparent=!0);break;case"tr":n=parseFloat(p),this.options&&this.options.invertTrProperty&&(n=1-n),n>0&&(i.opacity=1-n,i.transparent=!0)}}return this.materials[a]=new THREE.MeshPhongMaterial(i),this.materials[a]},getTextureParams:function(a,t){var r,e={scale:new THREE.Vector2(1,1),offset:new THREE.Vector2(0,0)},s=a.split(/\s+/);return r=s.indexOf("-bm"),r>=0&&(t.bumpScale=parseFloat(s[r+1]),s.splice(r,2)),r=s.indexOf("-s"),r>=0&&(e.scale.set(parseFloat(s[r+1]),parseFloat(s[r+2])),s.splice(r,4)),r=s.indexOf("-o"),r>=0&&(e.offset.set(parseFloat(s[r+1]),parseFloat(s[r+2])),s.splice(r,4)),e.url=s.join(" ").trim(),e},loadTexture:function(a,t,r,e,s){var i,o=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager,n=o.getHandler(a);return null===n&&(n=new THREE.TextureLoader(o)),n.setCrossOrigin&&n.setCrossOrigin(this.crossOrigin),i=n.load(a,r,e,s),void 0!==t&&(i.mapping=t),i}}; },{}],61:[function(_dereq_,module,exports){ THREE.OBJLoader=function(){function t(){var t={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materialLibraries:[],startObject:function(t,e){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=t,void(this.object.fromDeclaration=!1!==e);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:t||"",fromDeclaration:!1!==e,geometry:{vertices:[],normals:[],colors:[],uvs:[]},materials:[],smooth:!0,startMaterial:function(t,e){var r=this._finalize(!1);r&&(r.inherited||r.groupCount<=0)&&this.materials.splice(r.index,1);var i={index:this.materials.length,name:t||"",mtllib:Array.isArray(e)&&e.length>0?e[e.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(t){var e={index:"number"==typeof t?t:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return e.clone=this.clone.bind(e),e}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(t){var e=this.currentMaterial();if(e&&-1===e.groupEnd&&(e.groupEnd=this.geometry.vertices.length/3,e.groupCount=e.groupEnd-e.groupStart,e.inherited=!1),t&&this.materials.length>1)for(var r=this.materials.length-1;r>=0;r--)this.materials[r].groupCount<=0&&this.materials.splice(r,1);return t&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),e}},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(t,e){var r=parseInt(t,10);return 3*(r>=0?r-1:r+e/3)},parseNormalIndex:function(t,e){var r=parseInt(t,10);return 3*(r>=0?r-1:r+e/3)},parseUVIndex:function(t,e){var r=parseInt(t,10);return 2*(r>=0?r-1:r+e/2)},addVertex:function(t,e,r){var i=this.vertices,s=this.object.geometry.vertices;s.push(i[t+0],i[t+1],i[t+2]),s.push(i[e+0],i[e+1],i[e+2]),s.push(i[r+0],i[r+1],i[r+2])},addVertexPoint:function(t){var e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addVertexLine:function(t){var e=this.vertices;this.object.geometry.vertices.push(e[t+0],e[t+1],e[t+2])},addNormal:function(t,e,r){var i=this.normals,s=this.object.geometry.normals;s.push(i[t+0],i[t+1],i[t+2]),s.push(i[e+0],i[e+1],i[e+2]),s.push(i[r+0],i[r+1],i[r+2])},addColor:function(t,e,r){var i=this.colors,s=this.object.geometry.colors;s.push(i[t+0],i[t+1],i[t+2]),s.push(i[e+0],i[e+1],i[e+2]),s.push(i[r+0],i[r+1],i[r+2])},addUV:function(t,e,r){var i=this.uvs,s=this.object.geometry.uvs;s.push(i[t+0],i[t+1]),s.push(i[e+0],i[e+1]),s.push(i[r+0],i[r+1])},addUVLine:function(t){var e=this.uvs;this.object.geometry.uvs.push(e[t+0],e[t+1])},addFace:function(t,e,r,i,s,a,o,n,l){var h=this.vertices.length,c=this.parseVertexIndex(t,h),u=this.parseVertexIndex(e,h),p=this.parseVertexIndex(r,h);if(this.addVertex(c,u,p),void 0!==i&&""!==i){var m=this.uvs.length;c=this.parseUVIndex(i,m),u=this.parseUVIndex(s,m),p=this.parseUVIndex(a,m),this.addUV(c,u,p)}if(void 0!==o&&""!==o){var d=this.normals.length;c=this.parseNormalIndex(o,d),u=o===n?c:this.parseNormalIndex(n,d),p=o===l?c:this.parseNormalIndex(l,d),this.addNormal(c,u,p)}this.colors.length>0&&this.addColor(c,u,p)},addPointGeometry:function(t){this.object.geometry.type="Points";for(var e=this.vertices.length,r=0,i=t.length;r=7&&a.colors.push(parseFloat(m[4]),parseFloat(m[5]),parseFloat(m[6]));break;case"vn":a.normals.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3]));break;case"vt":a.uvs.push(parseFloat(m[1]),parseFloat(m[2]))}}else if("f"===l){for(var d=n.substr(1).trim(),f=d.split(/\s+/),v=[],g=0,b=f.length;g0){var j=E.split("/");v.push(j)}}for(var x=v[0],g=1,b=v.length-1;g1){var A=h[1].trim().toLowerCase();a.object.smooth="0"!==A&&"off"!==A}else a.object.smooth=!0;var P=a.object.currentMaterial();P&&(P.smooth=a.object.smooth)}a.finalize();var z=new THREE.Group;z.materialLibraries=[].concat(a.materialLibraries);for(var u=0,p=a.objects.length;u0?S.addAttribute("normal",new THREE.Float32BufferAttribute(C.normals,3)):S.computeVertexNormals(),C.colors.length>0&&(G=!0,S.addAttribute("color",new THREE.Float32BufferAttribute(C.colors,3))),C.uvs.length>0&&S.addAttribute("uv",new THREE.Float32BufferAttribute(C.uvs,2));for(var _=[],J=0,D=O.length;J1){for(var J=0,D=O.length;J0});this.visibleGlyphs=s;var n=vertices.positions(s),u=vertices.uvs(s,r,o,t),a=createIndices({clockwise:!0,type:"uint16",count:s.length});if(buffer.index(this,a,1,"uint16"),buffer.attr(this,"position",n,2),buffer.attr(this,"uv",u,2),!e.multipage&&"page"in this.attributes)this.removeAttribute("page");else if(e.multipage){var h=vertices.pages(s);buffer.attr(this,"page",h,1)}},TextGeometry.prototype.computeBoundingSphere=function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var e=this.attributes.position.array,t=this.attributes.position.itemSize;if(!e||!t||e.length<2)return this.boundingSphere.radius=0,void this.boundingSphere.center.set(0,0,0);utils.computeSphere(e,this.boundingSphere),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.')},TextGeometry.prototype.computeBoundingBox=function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var e=this.boundingBox,t=this.attributes.position.array,i=this.attributes.position.itemSize;if(!t||!i||t.length<2)return void e.makeEmpty();utils.computeBox(t,e)}; },{"./lib/utils":63,"./lib/vertices":64,"inherits":30,"layout-bmfont-text":36,"object-assign":39,"quad-indices":51,"three-buffer-vertex-data":65}],63:[function(_dereq_,module,exports){ function bounds(x){var m=x.length/itemSize;box.min[0]=x[0],box.min[1]=x[1],box.max[0]=x[0],box.max[1]=x[1];for(var o=0;o=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},exports.setImmediate="function"==typeof setImmediate?setImmediate:function(e){var t=nextImmediateId++,i=!(arguments.length<2)&&slice.call(arguments,1);return immediateIds[t]=!0,nextTick(function(){immediateIds[t]&&(i?e.apply(null,i):e.call(null),exports.clearImmediate(t))}),t},exports.clearImmediate="function"==typeof clearImmediate?clearImmediate:function(e){delete immediateIds[e]}; }).call(this,_dereq_("timers").setImmediate,_dereq_("timers").clearImmediate) },{"process/browser.js":49,"timers":66}],67:[function(_dereq_,module,exports){ (function (global){ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.WebVRPolyfill=t()}(this,function(){"use strict";function e(e){this.config=n(n({},a),e),this.polyfillDisplays=[],this.enabled=!1,this.hasNative="getVRDisplays"in navigator,this.native={},this.native.getVRDisplays=navigator.getVRDisplays,this.native.VRFrameData=window.VRFrameData,this.native.VRDisplay=window.VRDisplay,(!this.hasNative||this.config.PROVIDE_MOBILE_VRDISPLAY&&i())&&(this.enable(),this.getVRDisplays().then(function(e){e&&e[0]&&e[0].fireVRDisplayConnect_&&e[0].fireVRDisplayConnect_()}))}var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i=function(){return/Android/i.test(navigator.userAgent)||/iPhone|iPad|iPod/i.test(navigator.userAgent)},r=function(e,t){for(var i=0,r=e.length;ie.TEXTURE31){console.error("TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit"),r.push(null,null);break}n||(n=e.getParameter(e.ACTIVE_TEXTURE)),e.activeTexture(a),r.push(e.getParameter(s),null);break;case e.ACTIVE_TEXTURE:n=e.getParameter(e.ACTIVE_TEXTURE),r.push(null);break;default:r.push(e.getParameter(s))}}i(e);for(var A=0;Ae.TEXTURE31)break;e.activeTexture(a),e.bindTexture(e.TEXTURE_2D,o);break;case e.TEXTURE_BINDING_CUBE_MAP:var a=t[++A];if(ae.TEXTURE31)break;e.activeTexture(a),e.bindTexture(e.TEXTURE_CUBE_MAP,o);break;case e.VIEWPORT:e.viewport(o[0],o[1],o[2],o[3]);break;case e.BLEND:case e.CULL_FACE:case e.DEPTH_TEST:case e.SCISSOR_TEST:case e.STENCIL_TEST:o?e.enable(s):e.disable(s);break;default:console.log("No GL restore behavior for 0x"+s.toString(16))}n&&e.activeTexture(n)}}function i(e,t,i,r){this.gl=e,this.cardboardUI=t,this.bufferScale=i,this.dirtySubmitFrameBindings=r,this.ctxAttribs=e.getContextAttributes(),this.meshWidth=20,this.meshHeight=20,this.bufferWidth=e.drawingBufferWidth,this.bufferHeight=e.drawingBufferHeight,this.realBindFramebuffer=e.bindFramebuffer,this.realEnable=e.enable,this.realDisable=e.disable,this.realColorMask=e.colorMask,this.realClearColor=e.clearColor,this.realViewport=e.viewport,M()||(this.realCanvasWidth=Object.getOwnPropertyDescriptor(e.canvas.__proto__,"width"),this.realCanvasHeight=Object.getOwnPropertyDescriptor(e.canvas.__proto__,"height")),this.isPatched=!1,this.lastBoundFramebuffer=null,this.cullFace=!1,this.depthTest=!1,this.blend=!1,this.scissorTest=!1,this.stencilTest=!1,this.viewport=[0,0,0,0],this.colorMask=[!0,!0,!0,!0],this.clearColor=[0,0,0,0],this.attribs={position:0,texCoord:1},this.program=G(e,J,q,this.attribs),this.uniforms=O(e,this.program),this.viewportOffsetScale=new Float32Array(8),this.setTextureBounds(),this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),this.indexCount=0,this.renderTarget=e.createTexture(),this.framebuffer=e.createFramebuffer(),this.depthStencilBuffer=null,this.depthBuffer=null,this.stencilBuffer=null,this.ctxAttribs.depth&&this.ctxAttribs.stencil?this.depthStencilBuffer=e.createRenderbuffer():this.ctxAttribs.depth?this.depthBuffer=e.createRenderbuffer():this.ctxAttribs.stencil&&(this.stencilBuffer=e.createRenderbuffer()),this.patch(),this.onResize()}function r(e){this.gl=e,this.attribs={position:0},this.program=G(e,$,ee,this.attribs),this.uniforms=O(e,this.program),this.vertexBuffer=e.createBuffer(),this.gearOffset=0,this.gearVertexCount=0,this.arrowOffset=0,this.arrowVertexCount=0,this.projMat=new Float32Array(16),this.listener=null,this.onResize()}function n(e){this.coefficients=e}function A(e){this.width=e.width||x(),this.height=e.height||L(),this.widthMeters=e.widthMeters,this.heightMeters=e.heightMeters,this.bevelMeters=e.bevelMeters}function s(e,t){this.viewer=le.CardboardV2,this.updateDeviceParams(e),this.distortion=new n(this.viewer.distortionCoefficients);for(var i=0;i=200&&i.status<=299?(r.dpdb=JSON.parse(i.response),r.recalculateDeviceParams_()):console.error("Error loading online DPDB!")}),i.send()}}function l(e){this.xdpi=e.xdpi,this.ydpi=e.ydpi,this.bevelMm=e.bevelMm}function c(e,t){this.set(e,t)}function h(e,t){this.kFilter=e,this.isDebug=t,this.currentAccelMeasurement=new c,this.currentGyroMeasurement=new c,this.previousGyroMeasurement=new c,M()?this.filterQ=new se(-1,0,0,1):this.filterQ=new se(1,0,0,1),this.previousFilterQ=new se,this.previousFilterQ.copy(this.filterQ),this.accelQ=new se,this.isOrientationInitialized=!1,this.estimatedGravity=new Ae,this.measuredGravity=new Ae,this.gyroIntegralQ=new se}function d(e,t){this.predictionTimeS=e,this.isDebug=t,this.previousQ=new se,this.previousTimestampS=null,this.deltaQ=new se,this.outQ=new se}function u(e,t,i,r){this.yawOnly=i,this.accelerometer=new Ae,this.gyroscope=new Ae,this.filter=new h(e,r),this.posePredictor=new d(t,r),this.isFirefoxAndroid=T(),this.isIOS=M();var n=F();this.isDeviceMotionInRadians=!this.isIOS&&n&&n<66,this.isWithoutDeviceMotion=R(),this.filterToWorldQ=new se,M()?this.filterToWorldQ.setFromAxisAngle(new Ae(1,0,0),Math.PI/2):this.filterToWorldQ.setFromAxisAngle(new Ae(1,0,0),-Math.PI/2),this.inverseWorldToScreenQ=new se,this.worldToScreenQ=new se,this.originalPoseAdjustQ=new se,this.originalPoseAdjustQ.setFromAxisAngle(new Ae(0,0,1),-window.orientation*Math.PI/180),this.setScreenTransform_(),S()&&this.filterToWorldQ.multiply(this.inverseWorldToScreenQ),this.resetQ=new se,this.orientationOut_=new Float32Array(4),this.start()}function p(){this.loadIcon_();var e=document.createElement("div"),t=e.style;t.position="fixed",t.top=0,t.right=0,t.bottom=0,t.left=0,t.backgroundColor="gray",t.fontFamily="sans-serif",t.zIndex=1e6;var i=document.createElement("img");i.src=this.icon;var t=i.style;t.marginLeft="25%",t.marginTop="25%",t.width="50%",e.appendChild(i);var r=document.createElement("div"),t=r.style;t.textAlign="center",t.fontSize="16px",t.lineHeight="24px",t.margin="24px 25%",t.width="50%",r.innerHTML="Place your phone into your Cardboard viewer.",e.appendChild(r);var n=document.createElement("div"),t=n.style;t.backgroundColor="#CFD8DC",t.position="fixed",t.bottom=0,t.width="100%",t.height="48px",t.padding="14px 24px",t.boxSizing="border-box",t.color="#656A6B",e.appendChild(n);var A=document.createElement("div");A.style.float="left",A.innerHTML="No Cardboard viewer?";var s=document.createElement("a");s.href="https://www.google.com/get/cardboard/get-cardboard/",s.innerHTML="get one",s.target="_blank";var t=s.style;t.float="right",t.fontWeight=600,t.textTransform="uppercase",t.borderLeft="1px solid gray",t.paddingLeft="24px",t.textDecoration="none",t.color="#656A6B",n.appendChild(A),n.appendChild(s),this.overlay=e,this.text=r,this.hide()}function f(e){try{this.selectedKey=localStorage.getItem(ve)}catch(e){console.error("Failed to load viewer profile: %s",e)}this.selectedKey||(this.selectedKey=e||me),this.dialog=this.createDialog_(s.Viewers),this.root=null,this.onChangeCallbacks_=[]}function m(){this.leftProjectionMatrix=new Float32Array(16),this.leftViewMatrix=new Float32Array(16),this.rightProjectionMatrix=new Float32Array(16),this.rightViewMatrix=new Float32Array(16),this.pose=null}function v(e){Object.defineProperties(this,{hasPosition:{writable:!1,enumerable:!0,value:e.hasPosition},hasExternalDisplay:{writable:!1,enumerable:!0,value:e.hasExternalDisplay},canPresent:{writable:!1,enumerable:!0,value:e.canPresent},maxLayers:{writable:!1,enumerable:!0,value:e.maxLayers},hasOrientation:{enumerable:!0,get:function(){return j("VRDisplayCapabilities.prototype.hasOrientation","VRDisplay.prototype.getFrameData"),e.hasOrientation}}})}function g(e){e=e||{};var t=!("wakelock"in e)||e.wakelock;this.isPolyfilled=!0,this.displayId=ye++,this.displayName="",this.depthNear=.01,this.depthFar=1e4,this.isPresenting=!1,Object.defineProperty(this,"isConnected",{get:function(){return j("VRDisplay.prototype.isConnected","VRDisplayCapabilities.prototype.hasExternalDisplay"),!1}}),this.capabilities=new v({hasPosition:!1,hasOrientation:!1,hasExternalDisplay:!1,canPresent:!1,maxLayers:1}),this.stageParameters=null,this.waitingForPresent_=!1,this.layer_=null,this.originalParent_=null,this.fullscreenElement_=null,this.fullscreenWrapper_=null,this.fullscreenElementCachedStyle_=null,this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null,t&&k()&&(this.wakelock_=new we)}function w(e){var t=V({},Me);e=V(t,e||{}),g.call(this,{wakelock:e.MOBILE_WAKE_LOCK}),this.config=e,this.displayName="Cardboard VRDisplay",this.capabilities=new v({hasPosition:!1,hasOrientation:!0,hasExternalDisplay:!1,canPresent:!0,maxLayers:1}),this.stageParameters=null,this.bufferScale_=this.config.BUFFER_SCALE,this.poseSensor_=new fe(this.config),this.distorter_=null,this.cardboardUI_=null,this.dpdb_=new o(this.config.DPDB_URL,this.onDeviceParamsUpdated_.bind(this)),this.deviceInfo_=new s(this.dpdb_.getDeviceParams(),e.ADDITIONAL_VIEWERS),this.viewerSelector_=new f(e.DEFAULT_VIEWER),this.viewerSelector_.onChange(this.onViewerChanged_.bind(this)),this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()),this.config.ROTATE_INSTRUCTIONS_DISABLED||(this.rotateInstructions_=new p),M()&&window.addEventListener("resize",this.onResize_.bind(this))}var y=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},E=function(){function e(e,t){for(var i=0;i1))},x=function(){return Math.max(window.screen.width,window.screen.height)*window.devicePixelRatio},L=function(){return Math.min(window.screen.width,window.screen.height)*window.devicePixelRatio},P=function(e){if(B())return!1;if(e.requestFullscreen)e.requestFullscreen();else if(e.webkitRequestFullscreen)e.webkitRequestFullscreen();else if(e.mozRequestFullScreen)e.mozRequestFullScreen();else{if(!e.msRequestFullscreen)return!1;e.msRequestFullscreen()}return!0},N=function(){if(document.exitFullscreen)document.exitFullscreen();else if(document.webkitExitFullscreen)document.webkitExitFullscreen();else if(document.mozCancelFullScreen)document.mozCancelFullScreen();else{if(!document.msExitFullscreen)return!1;document.msExitFullscreen()}return!0},Q=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},G=function(e,t,i,r){var n=e.createShader(e.VERTEX_SHADER);e.shaderSource(n,t),e.compileShader(n);var A=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(A,i),e.compileShader(A);var s=e.createProgram();e.attachShader(s,n),e.attachShader(s,A);for(var a in r)e.bindAttribLocation(s,r[a],a);return e.linkProgram(s),e.deleteShader(n),e.deleteShader(A),s},O=function(e,t){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n="",A=0;A1?(console.warn("getQuaternionAngle: w > 1"),0):2*Math.acos(e.w)},Z=function(){var e={};return function(t,i){void 0===e[t]&&(console.warn("webvr-polyfill: "+i),e[t]=!0)}}(),j=function(e,t){Z(e,e+" has been deprecated. This may not work on native WebVR displays. "+(t?"Please use "+t+" instead.":""))},K=e,J=["attribute vec2 position;","attribute vec3 texCoord;","varying vec2 vTexCoord;","uniform vec4 viewportOffsetScale[2];","void main() {"," vec4 viewport = viewportOffsetScale[int(texCoord.z)];"," vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;"," gl_Position = vec4( position, 1.0, 1.0 );","}"].join("\n"),q=["precision mediump float;","uniform sampler2D diffuse;","varying vec2 vTexCoord;","void main() {"," gl_FragColor = texture2D(diffuse, vTexCoord);","}"].join("\n");i.prototype.destroy=function(){var e=this.gl;this.unpatch(),e.deleteProgram(this.program),e.deleteBuffer(this.vertexBuffer),e.deleteBuffer(this.indexBuffer),e.deleteTexture(this.renderTarget),e.deleteFramebuffer(this.framebuffer),this.depthStencilBuffer&&e.deleteRenderbuffer(this.depthStencilBuffer),this.depthBuffer&&e.deleteRenderbuffer(this.depthBuffer),this.stencilBuffer&&e.deleteRenderbuffer(this.stencilBuffer),this.cardboardUI&&this.cardboardUI.destroy()},i.prototype.onResize=function(){var e=this.gl,t=this,i=[e.RENDERBUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0];K(e,i,function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.framebuffer),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.texImage2D(e.TEXTURE_2D,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,t.bufferWidth,t.bufferHeight,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.renderTarget,0),t.ctxAttribs.depth&&t.ctxAttribs.stencil?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t.depthStencilBuffer)):t.ctxAttribs.depth?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t.depthBuffer)):t.ctxAttribs.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,t.stencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.STENCIL_INDEX8,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.STENCIL_ATTACHMENT,e.RENDERBUFFER,t.stencilBuffer)),!e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer incomplete!"),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),t.realClearColor.apply(e,t.clearColor)}),this.cardboardUI&&this.cardboardUI.onResize()},i.prototype.patch=function(){if(!this.isPatched){var e=this,t=this.gl.canvas,i=this.gl;M()||(t.width=x()*this.bufferScale,t.height=L()*this.bufferScale,Object.defineProperty(t,"width",{configurable:!0,enumerable:!0,get:function(){return e.bufferWidth},set:function(i){e.bufferWidth=i,e.realCanvasWidth.set.call(t,i),e.onResize()}}),Object.defineProperty(t,"height",{configurable:!0,enumerable:!0,get:function(){return e.bufferHeight},set:function(i){e.bufferHeight=i,e.realCanvasHeight.set.call(t,i),e.onResize()}})),this.lastBoundFramebuffer=i.getParameter(i.FRAMEBUFFER_BINDING),null==this.lastBoundFramebuffer&&(this.lastBoundFramebuffer=this.framebuffer,this.gl.bindFramebuffer(i.FRAMEBUFFER,this.framebuffer)),this.gl.bindFramebuffer=function(t,r){e.lastBoundFramebuffer=r||e.framebuffer,e.realBindFramebuffer.call(i,t,e.lastBoundFramebuffer)},this.cullFace=i.getParameter(i.CULL_FACE),this.depthTest=i.getParameter(i.DEPTH_TEST),this.blend=i.getParameter(i.BLEND),this.scissorTest=i.getParameter(i.SCISSOR_TEST),this.stencilTest=i.getParameter(i.STENCIL_TEST),i.enable=function(t){switch(t){case i.CULL_FACE:e.cullFace=!0;break;case i.DEPTH_TEST:e.depthTest=!0;break;case i.BLEND:e.blend=!0;break;case i.SCISSOR_TEST:e.scissorTest=!0;break;case i.STENCIL_TEST:e.stencilTest=!0}e.realEnable.call(i,t)},i.disable=function(t){switch(t){case i.CULL_FACE:e.cullFace=!1;break;case i.DEPTH_TEST:e.depthTest=!1;break;case i.BLEND:e.blend=!1;break;case i.SCISSOR_TEST:e.scissorTest=!1;break;case i.STENCIL_TEST:e.stencilTest=!1}e.realDisable.call(i,t)},this.colorMask=i.getParameter(i.COLOR_WRITEMASK),i.colorMask=function(t,r,n,A){e.colorMask[0]=t,e.colorMask[1]=r,e.colorMask[2]=n,e.colorMask[3]=A,e.realColorMask.call(i,t,r,n,A)},this.clearColor=i.getParameter(i.COLOR_CLEAR_VALUE),i.clearColor=function(t,r,n,A){e.clearColor[0]=t,e.clearColor[1]=r,e.clearColor[2]=n,e.clearColor[3]=A,e.realClearColor.call(i,t,r,n,A)},this.viewport=i.getParameter(i.VIEWPORT),i.viewport=function(t,r,n,A){e.viewport[0]=t,e.viewport[1]=r,e.viewport[2]=n,e.viewport[3]=A,e.realViewport.call(i,t,r,n,A)},this.isPatched=!0,z(t)}},i.prototype.unpatch=function(){if(this.isPatched){var e=this.gl,t=this.gl.canvas;M()||(Object.defineProperty(t,"width",this.realCanvasWidth),Object.defineProperty(t,"height",this.realCanvasHeight)),t.width=this.bufferWidth,t.height=this.bufferHeight,e.bindFramebuffer=this.realBindFramebuffer,e.enable=this.realEnable,e.disable=this.realDisable,e.colorMask=this.realColorMask,e.clearColor=this.realClearColor,e.viewport=this.realViewport,this.lastBoundFramebuffer==this.framebuffer&&e.bindFramebuffer(e.FRAMEBUFFER,null),this.isPatched=!1,setTimeout(function(){z(t)},1)}},i.prototype.setTextureBounds=function(e,t){e||(e=[0,0,.5,1]),t||(t=[.5,0,.5,1]),this.viewportOffsetScale[0]=e[0],this.viewportOffsetScale[1]=e[1],this.viewportOffsetScale[2]=e[2],this.viewportOffsetScale[3]=e[3],this.viewportOffsetScale[4]=t[0],this.viewportOffsetScale[5]=t[1],this.viewportOffsetScale[6]=t[2],this.viewportOffsetScale[7]=t[3]},i.prototype.submitFrame=function(){var e=this.gl,t=this,i=[];if(this.dirtySubmitFrameBindings||i.push(e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING,e.ELEMENT_ARRAY_BUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0),K(e,i,function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null),t.cullFace&&t.realDisable.call(e,e.CULL_FACE),t.depthTest&&t.realDisable.call(e,e.DEPTH_TEST),t.blend&&t.realDisable.call(e,e.BLEND),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realDisable.call(e,e.STENCIL_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),(t.ctxAttribs.alpha||M())&&(t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT)),e.useProgram(t.program),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.indexBuffer),e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.enableVertexAttribArray(t.attribs.position),e.enableVertexAttribArray(t.attribs.texCoord),e.vertexAttribPointer(t.attribs.position,2,e.FLOAT,!1,20,0),e.vertexAttribPointer(t.attribs.texCoord,3,e.FLOAT,!1,20,8),e.activeTexture(e.TEXTURE0),e.uniform1i(t.uniforms.diffuse,0),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.uniform4fv(t.uniforms.viewportOffsetScale,t.viewportOffsetScale),e.drawElements(e.TRIANGLES,t.indexCount,e.UNSIGNED_SHORT,0),t.cardboardUI&&t.cardboardUI.renderNoState(),t.realBindFramebuffer.call(t.gl,e.FRAMEBUFFER,t.framebuffer),t.ctxAttribs.preserveDrawingBuffer||(t.realClearColor.call(e,0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)),t.dirtySubmitFrameBindings||t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.cullFace&&t.realEnable.call(e,e.CULL_FACE),t.depthTest&&t.realEnable.call(e,e.DEPTH_TEST),t.blend&&t.realEnable.call(e,e.BLEND),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realEnable.call(e,e.STENCIL_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),!t.ctxAttribs.alpha&&t.ctxAttribs.preserveDrawingBuffer||t.realClearColor.apply(e,t.clearColor)}),M()){var r=e.canvas;r.width==t.bufferWidth&&r.height==t.bufferHeight||(t.bufferWidth=r.width,t.bufferHeight=r.height,t.onResize())}},i.prototype.updateDeviceInfo=function(e){var t=this.gl,i=this,r=[t.ARRAY_BUFFER_BINDING,t.ELEMENT_ARRAY_BUFFER_BINDING];K(t,r,function(t){var r=i.computeMeshVertices_(i.meshWidth,i.meshHeight,e);if(t.bindBuffer(t.ARRAY_BUFFER,i.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW),!i.indexCount){var n=i.computeMeshIndices_(i.meshWidth,i.meshHeight);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,i.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,n,t.STATIC_DRAW),i.indexCount=n.length}})},i.prototype.computeMeshVertices_=function(e,t,i){for(var r=new Float32Array(2*e*t*5),n=i.getLeftEyeVisibleTanAngles(),A=i.getLeftEyeNoLensTanAngles(),s=i.getLeftEyeVisibleScreenRect(A),a=0,o=0;o<2;o++){for(var l=0;ln-42&&r.clientXi.clientHeight-42?e(r):r.clientX<42&&r.clientY<42&&t(r)},i.addEventListener("click",this.listener,!1)},r.prototype.onResize=function(){var e=this.gl,t=this,i=[e.ARRAY_BUFFER_BINDING];K(e,i,function(e){function i(e,t){var i=(90-e)*te,r=Math.cos(i),s=Math.sin(i);n.push(ie*r*h+A,ie*s*h+h),n.push(t*r*h+A,t*s*h+h)}function r(t,i){n.push(d+t,e.drawingBufferHeight-d-i)}var n=[],A=e.drawingBufferWidth/2,s=Math.max(screen.width,screen.height)*window.devicePixelRatio,a=e.drawingBufferWidth/s,o=a*window.devicePixelRatio,l=4*o/2,c=42*o,h=28*o/2,d=14*o;n.push(A-l,c),n.push(A-l,e.drawingBufferHeight),n.push(A+l,c),n.push(A+l,e.drawingBufferHeight),t.gearOffset=n.length/2;for(var u=0;u<=6;u++){var p=60*u;i(p,1),i(p+12,1),i(p+20,.75),i(p+40,.75),i(p+48,1)}t.gearVertexCount=n.length/2-t.gearOffset,t.arrowOffset=n.length/2;var f=l/Math.sin(45*te);r(0,h),r(h,0),r(h+f,f),r(f,h+f),r(f,h-f),r(0,h),r(h,2*h),r(h+f,2*h-f),r(f,h-f),r(0,h),r(f,h-l),r(28*o,h-l),r(f,h+l),r(28*o,h+l),t.arrowVertexCount=n.length/2-t.arrowOffset,e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array(n),e.STATIC_DRAW)})},r.prototype.render=function(){var e=this.gl,t=this,i=[e.CULL_FACE,e.DEPTH_TEST,e.BLEND,e.SCISSOR_TEST,e.STENCIL_TEST,e.COLOR_WRITEMASK,e.VIEWPORT,e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING];K(e,i,function(e){e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.BLEND),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.colorMask(!0,!0,!0,!0),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.renderNoState()})},r.prototype.renderNoState=function(){var e=this.gl;e.useProgram(this.program),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.enableVertexAttribArray(this.attribs.position),e.vertexAttribPointer(this.attribs.position,2,e.FLOAT,!1,8,0),e.uniform4f(this.uniforms.color,1,1,1,1),U(this.projMat,0,e.drawingBufferWidth,0,e.drawingBufferHeight,.1,1024), e.uniformMatrix4fv(this.uniforms.projectionMat,!1,this.projMat),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.drawArrays(e.TRIANGLE_STRIP,this.gearOffset,this.gearVertexCount),e.drawArrays(e.TRIANGLE_STRIP,this.arrowOffset,this.arrowVertexCount)},n.prototype.distortInverse=function(e){for(var t=0,i=1,r=e-this.distort(t);Math.abs(i-t)>1e-4;){var n=e-this.distort(i),A=i-n*((i-t)/(n-r));t=i,i=A,r=n}return i},n.prototype.distort=function(e){for(var t=e*e,i=0,r=0;r=1)return this.w=A,this.x=i,this.y=r,this.z=n,this;var a=Math.acos(s),o=Math.sqrt(1-s*s);if(Math.abs(o)<.001)return this.w=.5*(A+this.w),this.x=.5*(i+this.x),this.y=.5*(r+this.y),this.z=.5*(n+this.z),this;var l=Math.sin((1-t)*a)/o,c=Math.sin(t*a)/o;return this.w=A*l+this.w*c,this.x=i*l+this.x*c,this.y=r*l+this.y*c,this.z=n*l+this.z*c,this},setFromUnitVectors:function(){var e,t;return function(i,r){return void 0===e&&(e=new Ae),t=i.dot(r)+1,t<1e-6?(t=0,Math.abs(i.x)>Math.abs(i.z)?e.set(-i.y,i.x,0):e.set(0,-i.z,i.y)):e.crossVectors(i,r),this.x=e.x,this.y=e.y,this.z=e.z,this.w=t,this.normalize(),this}}()};var ae=new A({widthMeters:.11,heightMeters:.062,bevelMeters:.004}),oe=new A({widthMeters:.1038,heightMeters:.0584,bevelMeters:.004}),le={CardboardV1:new a({id:"CardboardV1",label:"Cardboard I/O 2014",fov:40,interLensDistance:.06,baselineLensDistance:.035,screenLensDistance:.042,distortionCoefficients:[.441,.156],inverseCoefficients:[-.4410035,.42756155,-.4804439,.5460139,-.58821183,.5733938,-.48303202,.33299083,-.17573841,.0651772,-.01488963,.001559834]}),CardboardV2:new a({id:"CardboardV2",label:"Cardboard I/O 2015",fov:60,interLensDistance:.064,baselineLensDistance:.035,screenLensDistance:.039,distortionCoefficients:[.34,.55],inverseCoefficients:[-.33836704,-.18162185,.862655,-1.2462051,1.0560602,-.58208317,.21609078,-.05444823,.009177956,-.0009904169,6183535e-11,-16981803e-13]})};s.prototype.updateDeviceParams=function(e){this.device=this.determineDevice_(e)||this.device},s.prototype.getDevice=function(){return this.device},s.prototype.setViewer=function(e){this.viewer=e,this.distortion=new n(this.viewer.distortionCoefficients)},s.prototype.determineDevice_=function(e){if(!e)return M()?(console.warn("Using fallback iOS device measurements."),oe):(console.warn("Using fallback Android device measurements."),ae);var t=.0254/e.xdpi,i=.0254/e.ydpi;return new A({widthMeters:t*x(),heightMeters:i*L(),bevelMeters:.001*e.bevelMm})},s.prototype.getDistortedFieldOfViewLeftEye=function(){var e=this.viewer,t=this.device,i=this.distortion,r=e.screenLensDistance,n=(t.widthMeters-e.interLensDistance)/2,A=e.interLensDistance/2,s=e.baselineLensDistance-t.bevelMeters,a=t.heightMeters-s,o=ne*Math.atan(i.distort(n/r)),l=ne*Math.atan(i.distort(A/r)),c=ne*Math.atan(i.distort(s/r)),h=ne*Math.atan(i.distort(a/r));return{leftDegrees:Math.min(o,e.fov),rightDegrees:Math.min(l,e.fov),downDegrees:Math.min(c,e.fov),upDegrees:Math.min(h,e.fov)}},s.prototype.getLeftEyeVisibleTanAngles=function(){var e=this.viewer,t=this.device,i=this.distortion,r=Math.tan(-re*e.fov),n=Math.tan(re*e.fov),A=Math.tan(re*e.fov),s=Math.tan(-re*e.fov),a=t.widthMeters/4,o=t.heightMeters/2,l=e.baselineLensDistance-t.bevelMeters-o,c=e.interLensDistance/2-a,h=-l,d=e.screenLensDistance,u=i.distort((c-a)/d),p=i.distort((h+o)/d),f=i.distort((c+a)/d),m=i.distort((h-o)/d),v=new Float32Array(4);return v[0]=Math.max(r,u),v[1]=Math.min(n,p),v[2]=Math.min(A,f),v[3]=Math.max(s,m),v},s.prototype.getLeftEyeNoLensTanAngles=function(){var e=this.viewer,t=this.device,i=this.distortion,r=new Float32Array(4),n=i.distortInverse(Math.tan(-re*e.fov)),A=i.distortInverse(Math.tan(re*e.fov)),s=i.distortInverse(Math.tan(re*e.fov)),a=i.distortInverse(Math.tan(-re*e.fov)),o=t.widthMeters/4,l=t.heightMeters/2,c=e.baselineLensDistance-t.bevelMeters-l,h=e.interLensDistance/2-o,d=-c,u=e.screenLensDistance,p=(h-o)/u,f=(d+l)/u,m=(h+o)/u,v=(d-l)/u;return r[0]=Math.max(n,p),r[1]=Math.min(A,f),r[2]=Math.min(s,m),r[3]=Math.max(a,v),r},s.prototype.getLeftEyeVisibleScreenRect=function(e){var t=this.viewer,i=this.device,r=t.screenLensDistance,n=(i.widthMeters-t.interLensDistance)/2,A=t.baselineLensDistance-i.bevelMeters,s=(e[0]*r+n)/i.widthMeters,a=(e[1]*r+A)/i.heightMeters,o=(e[2]*r+n)/i.widthMeters,l=(e[3]*r+A)/i.heightMeters;return{x:s,y:l,width:o-s,height:a-l}},s.prototype.getFieldOfViewLeftEye=function(e){return e?this.getUndistortedFieldOfViewLeftEye():this.getDistortedFieldOfViewLeftEye()},s.prototype.getFieldOfViewRightEye=function(e){var t=this.getFieldOfViewLeftEye(e);return{leftDegrees:t.rightDegrees,rightDegrees:t.leftDegrees,upDegrees:t.upDegrees,downDegrees:t.downDegrees}},s.prototype.getUndistortedFieldOfViewLeftEye=function(){var e=this.getUndistortedParams_();return{leftDegrees:ne*Math.atan(e.outerDist),rightDegrees:ne*Math.atan(e.innerDist),downDegrees:ne*Math.atan(e.bottomDist),upDegrees:ne*Math.atan(e.topDist)}},s.prototype.getUndistortedViewportLeftEye=function(){var e=this.getUndistortedParams_(),t=this.viewer,i=this.device,r=t.screenLensDistance,n=i.widthMeters/r,A=i.heightMeters/r,s=i.width/n,a=i.height/A,o=Math.round((e.eyePosX-e.outerDist)*s),l=Math.round((e.eyePosY-e.bottomDist)*a);return{x:o,y:l,width:Math.round((e.eyePosX+e.innerDist)*s)-o,height:Math.round((e.eyePosY+e.topDist)*a)-l}},s.prototype.getUndistortedParams_=function(){var e=this.viewer,t=this.device,i=this.distortion,r=e.screenLensDistance,n=e.interLensDistance/2/r,A=t.widthMeters/r,s=t.heightMeters/r,a=A/2-n,o=(e.baselineLensDistance-t.bevelMeters)/r,l=e.fov,c=i.distortInverse(Math.tan(re*l)),h=Math.min(a,c),d=Math.min(n,c),u=Math.min(o,c);return{outerDist:h,innerDist:d,topDist:Math.min(s-o,c),bottomDist:u,eyePosX:a,eyePosY:o}},s.Viewers=le;var ce=[{type:"android",rules:[{mdmh:"asus/*/Nexus 7/*"},{ua:"Nexus 7"}],dpi:[320.8,323],bw:3,ac:500},{type:"android",rules:[{mdmh:"asus/*/ASUS_Z00AD/*"},{ua:"ASUS_Z00AD"}],dpi:[403,404.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Google/*/Pixel 2 XL/*"},{ua:"Pixel 2 XL"}],dpi:537.9,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Google/*/Pixel 3 XL/*"},{ua:"Pixel 3 XL"}],dpi:[558.5,553.8],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Google/*/Pixel XL/*"},{ua:"Pixel XL"}],dpi:[537.9,533],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Google/*/Pixel 3/*"},{ua:"Pixel 3"}],dpi:442.4,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Google/*/Pixel 2/*"},{ua:"Pixel 2"}],dpi:441,bw:3,ac:500},{type:"android",rules:[{mdmh:"Google/*/Pixel/*"},{ua:"Pixel"}],dpi:[432.6,436.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"HTC/*/HTC6435LVW/*"},{ua:"HTC6435LVW"}],dpi:[449.7,443.3],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"HTC/*/HTC One XL/*"},{ua:"HTC One XL"}],dpi:[315.3,314.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"htc/*/Nexus 9/*"},{ua:"Nexus 9"}],dpi:289,bw:3,ac:500},{type:"android",rules:[{mdmh:"HTC/*/HTC One M9/*"},{ua:"HTC One M9"}],dpi:[442.5,443.3],bw:3,ac:500},{type:"android",rules:[{mdmh:"HTC/*/HTC One_M8/*"},{ua:"HTC One_M8"}],dpi:[449.7,447.4],bw:3,ac:500},{type:"android",rules:[{mdmh:"HTC/*/HTC One/*"},{ua:"HTC One"}],dpi:472.8,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Huawei/*/Nexus 6P/*"},{ua:"Nexus 6P"}],dpi:[515.1,518],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Huawei/*/BLN-L24/*"},{ua:"HONORBLN-L24"}],dpi:480,bw:4,ac:500},{type:"android",rules:[{mdmh:"Huawei/*/BKL-L09/*"},{ua:"BKL-L09"}],dpi:403,bw:3.47,ac:500},{type:"android",rules:[{mdmh:"LENOVO/*/Lenovo PB2-690Y/*"},{ua:"Lenovo PB2-690Y"}],dpi:[457.2,454.713],bw:3,ac:500},{type:"android",rules:[{mdmh:"LGE/*/Nexus 5X/*"},{ua:"Nexus 5X"}],dpi:[422,419.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LGMS345/*"},{ua:"LGMS345"}],dpi:[221.7,219.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"LGE/*/LG-D800/*"},{ua:"LG-D800"}],dpi:[422,424.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"LGE/*/LG-D850/*"},{ua:"LG-D850"}],dpi:[537.9,541.9],bw:3,ac:500},{type:"android",rules:[{mdmh:"LGE/*/VS985 4G/*"},{ua:"VS985 4G"}],dpi:[537.9,535.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/Nexus 5/*"},{ua:"Nexus 5 B"}],dpi:[442.4,444.8],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/Nexus 4/*"},{ua:"Nexus 4"}],dpi:[319.8,318.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LG-P769/*"},{ua:"LG-P769"}],dpi:[240.6,247.5],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LGMS323/*"},{ua:"LGMS323"}],dpi:[206.6,204.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"LGE/*/LGLS996/*"},{ua:"LGLS996"}],dpi:[403.4,401.5],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Micromax/*/4560MMX/*"},{ua:"4560MMX"}],dpi:[240,219.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Micromax/*/A250/*"},{ua:"Micromax A250"}],dpi:[480,446.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Micromax/*/Micromax AQ4501/*"},{ua:"Micromax AQ4501"}],dpi:240,bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/G5/*"},{ua:"Moto G (5) Plus"}],dpi:[403.4,403],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/DROID RAZR/*"},{ua:"DROID RAZR"}],dpi:[368.1,256.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT830C/*"},{ua:"XT830C"}],dpi:[254,255.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1021/*"},{ua:"XT1021"}],dpi:[254,256.7],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1023/*"},{ua:"XT1023"}],dpi:[254,256.7],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1028/*"},{ua:"XT1028"}],dpi:[326.6,327.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1034/*"},{ua:"XT1034"}],dpi:[326.6,328.4],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1053/*"},{ua:"XT1053"}],dpi:[315.3,316.1],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1562/*"},{ua:"XT1562"}],dpi:[403.4,402.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/Nexus 6/*"},{ua:"Nexus 6 B"}],dpi:[494.3,489.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1063/*"},{ua:"XT1063"}],dpi:[295,296.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/XT1064/*"},{ua:"XT1064"}],dpi:[295,295.6],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1092/*"},{ua:"XT1092"}],dpi:[422,424.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"motorola/*/XT1095/*"},{ua:"XT1095"}],dpi:[422,423.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"motorola/*/G4/*"},{ua:"Moto G (4)"}],dpi:401,bw:4,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/A0001/*"},{ua:"A0001"}],dpi:[403.4,401],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/ONE E1005/*"},{ua:"ONE E1005"}],dpi:[442.4,441.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/ONE A2005/*"},{ua:"ONE A2005"}],dpi:[391.9,405.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/ONEPLUS A5000/*"},{ua:"ONEPLUS A5000 "}],dpi:[403.411,399.737],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"OnePlus/*/ONE A5010/*"},{ua:"ONEPLUS A5010"}],dpi:[403,400],bw:2,ac:1e3},{type:"android",rules:[{mdmh:"OPPO/*/X909/*"},{ua:"X909"}],dpi:[442.4,444.1],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9082/*"},{ua:"GT-I9082"}],dpi:[184.7,185.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G360P/*"},{ua:"SM-G360P"}],dpi:[196.7,205.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/Nexus S/*"},{ua:"Nexus S"}],dpi:[234.5,229.8],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9300/*"},{ua:"GT-I9300"}],dpi:[304.8,303.9],bw:5,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-T230NU/*"},{ua:"SM-T230NU"}],dpi:216,bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SGH-T399/*"},{ua:"SGH-T399"}],dpi:[217.7,231.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SGH-M919/*"},{ua:"SGH-M919"}],dpi:[440.8,437.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N9005/*"},{ua:"SM-N9005"}],dpi:[386.4,387],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SAMSUNG-SM-N900A/*"},{ua:"SAMSUNG-SM-N900A"}],dpi:[386.4,387.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9500/*"},{ua:"GT-I9500"}],dpi:[442.5,443.3],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/GT-I9505/*"},{ua:"GT-I9505"}],dpi:439.4,bw:4,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G900F/*"},{ua:"SM-G900F"}],dpi:[415.6,431.6],bw:5,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G900M/*"},{ua:"SM-G900M"}],dpi:[415.6,431.6],bw:5,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G800F/*"},{ua:"SM-G800F"}],dpi:326.8,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G906S/*"},{ua:"SM-G906S"}],dpi:[562.7,572.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9300/*"},{ua:"GT-I9300"}],dpi:[306.7,304.8],bw:5,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-T535/*"},{ua:"SM-T535"}],dpi:[142.6,136.4],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-N920C/*"},{ua:"SM-N920C"}],dpi:[515.1,518.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N920P/*"},{ua:"SM-N920P"}],dpi:[386.3655,390.144],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N920W8/*"},{ua:"SM-N920W8"}],dpi:[515.1,518.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9300I/*"},{ua:"GT-I9300I"}],dpi:[304.8,305.8],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-I9195/*"},{ua:"GT-I9195"}],dpi:[249.4,256.7],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SPH-L520/*"},{ua:"SPH-L520"}],dpi:[249.4,255.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SAMSUNG-SGH-I717/*"},{ua:"SAMSUNG-SGH-I717"}],dpi:285.8,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SPH-D710/*"},{ua:"SPH-D710"}],dpi:[217.7,204.2],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/GT-N7100/*"},{ua:"GT-N7100"}],dpi:265.1,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SCH-I605/*"},{ua:"SCH-I605"}],dpi:265.1,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/Galaxy Nexus/*"},{ua:"Galaxy Nexus"}],dpi:[315.3,314.2],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N910H/*"},{ua:"SM-N910H"}],dpi:[515.1,518],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-N910C/*"},{ua:"SM-N910C"}],dpi:[515.2,520.2],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G130M/*"},{ua:"SM-G130M"}],dpi:[165.9,164.8],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G928I/*"},{ua:"SM-G928I"}],dpi:[515.1,518.4],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G920F/*"},{ua:"SM-G920F"}],dpi:580.6,bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G920P/*"},{ua:"SM-G920P"}],dpi:[522.5,577],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G925F/*"},{ua:"SM-G925F"}],dpi:580.6,bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G925V/*"},{ua:"SM-G925V"}],dpi:[522.5,576.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G930F/*"},{ua:"SM-G930F"}],dpi:576.6,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"samsung/*/SM-G935F/*"},{ua:"SM-G935F"}],dpi:533,bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G950F/*"},{ua:"SM-G950F"}],dpi:[562.707,565.293],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G955U/*"},{ua:"SM-G955U"}],dpi:[522.514,525.762],bw:3,ac:500},{type:"android",rules:[{mdmh:"samsung/*/SM-G955F/*"},{ua:"SM-G955F"}],dpi:[522.514,525.762],bw:3,ac:500},{type:"android",rules:[{mdmh:"Sony/*/C6903/*"},{ua:"C6903"}],dpi:[442.5,443.3],bw:3,ac:500},{type:"android",rules:[{mdmh:"Sony/*/D6653/*"},{ua:"D6653"}],dpi:[428.6,427.6],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Sony/*/E6653/*"},{ua:"E6653"}],dpi:[428.6,425.7],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Sony/*/E6853/*"},{ua:"E6853"}],dpi:[403.4,401.9],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Sony/*/SGP321/*"},{ua:"SGP321"}],dpi:[224.7,224.1],bw:3,ac:500},{type:"android",rules:[{mdmh:"TCT/*/ALCATEL ONE TOUCH Fierce/*"},{ua:"ALCATEL ONE TOUCH Fierce"}],dpi:[240,247.5],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"THL/*/thl 5000/*"},{ua:"thl 5000"}],dpi:[480,443.3],bw:3,ac:1e3},{type:"android",rules:[{mdmh:"Fly/*/IQ4412/*"},{ua:"IQ4412"}],dpi:307.9,bw:3,ac:1e3},{type:"android",rules:[{mdmh:"ZTE/*/ZTE Blade L2/*"},{ua:"ZTE Blade L2"}],dpi:240,bw:3,ac:500},{type:"android",rules:[{mdmh:"BENEVE/*/VR518/*"},{ua:"VR518"}],dpi:480,bw:3,ac:500},{type:"ios",rules:[{res:[640,960]}],dpi:[325.1,328.4],bw:4,ac:1e3},{type:"ios",rules:[{res:[640,1136]}],dpi:[317.1,320.2],bw:3,ac:1e3},{type:"ios",rules:[{res:[750,1334]}],dpi:326.4,bw:4,ac:1e3},{type:"ios",rules:[{res:[1242,2208]}],dpi:[453.6,458.4],bw:4,ac:1e3},{type:"ios",rules:[{res:[1125,2001]}],dpi:[410.9,415.4],bw:4,ac:1e3},{type:"ios",rules:[{res:[1125,2436]}],dpi:458,bw:4,ac:1e3}],he={format:1,last_updated:"2018-12-10T17:01:42Z",devices:ce};o.prototype.getDeviceParams=function(){return this.deviceParams},o.prototype.recalculateDeviceParams_=function(){var e=this.calcDeviceParams_();e?(this.deviceParams=e,this.onDeviceParamsUpdated&&this.onDeviceParamsUpdated(this.deviceParams)):console.error("Failed to recalculate device parameters.")},o.prototype.calcDeviceParams_=function(){var e=this.dpdb;if(!e)return console.error("DPDB not available."),null;if(1!=e.format)return console.error("DPDB has unexpected format version."),null;if(!e.devices||!e.devices.length)return console.error("DPDB does not have a devices section."),null;var t=navigator.userAgent||navigator.vendor||window.opera,i=x(),r=L();if(!e.devices)return console.error("DPDB has no devices section."),null;for(var n=0;n1?(Z("fusion-pose-sensor:invalid:outside-threshold","Invalid timestamps detected: Timestamp from devicemotion outside expected range."),void(this.previousTimestampS=r)):(this.accelerometer.set(-t.x,-t.y,-t.z),C()?this.gyroscope.set(-i.beta,i.alpha,i.gamma):this.gyroscope.set(i.alpha,i.beta,i.gamma),this.isDeviceMotionInRadians||this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addAccelMeasurement(this.accelerometer,r),this.filter.addGyroMeasurement(this.gyroscope,r),void(this.previousTimestampS=r))},u.prototype.onOrientationChange_=function(e){this.setScreenTransform_()},u.prototype.onMessage_=function(e){var t=e.data;if(t&&t.type){"devicemotion"===t.type.toLowerCase()&&this.updateDeviceMotion_(t.deviceMotionEvent)}},u.prototype.setScreenTransform_=function(){switch(this.worldToScreenQ.set(0,0,0,1),window.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new Ae(0,0,1),-Math.PI/2);break;case-90:this.worldToScreenQ.setFromAxisAngle(new Ae(0,0,1),Math.PI/2)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},u.prototype.start=function(){this.onDeviceMotionCallback_=this.onDeviceMotion_.bind(this),this.onOrientationChangeCallback_=this.onOrientationChange_.bind(this),this.onMessageCallback_=this.onMessage_.bind(this),this.onDeviceOrientationCallback_=this.onDeviceOrientation_.bind(this),M()&&W()&&window.addEventListener("message",this.onMessageCallback_),window.addEventListener("orientationchange",this.onOrientationChangeCallback_),this.isWithoutDeviceMotion?window.addEventListener("deviceorientation",this.onDeviceOrientationCallback_):window.addEventListener("devicemotion",this.onDeviceMotionCallback_)},u.prototype.stop=function(){window.removeEventListener("devicemotion",this.onDeviceMotionCallback_),window.removeEventListener("deviceorientation",this.onDeviceOrientationCallback_),window.removeEventListener("orientationchange",this.onOrientationChangeCallback_),window.removeEventListener("message",this.onMessageCallback_)};var de=new Ae(1,0,0),ue=new Ae(0,0,1),pe=new se;pe.setFromAxisAngle(de,-Math.PI/2),pe.multiply((new se).setFromAxisAngle(ue,Math.PI/2));var fe=function(){function e(t){y(this,e),this.config=t,this.sensor=null,this.fusionSensor=null,this._out=new Float32Array(4),this.api=null,this.errors=[],this._sensorQ=new se,this._outQ=new se,this._onSensorRead=this._onSensorRead.bind(this),this._onSensorError=this._onSensorError.bind(this),this.init()}return E(e,[{key:"init",value:function(){var e=null;try{e=new RelativeOrientationSensor({frequency:60,referenceFrame:"screen"}),e.addEventListener("error",this._onSensorError)}catch(e){this.errors.push(e),"SecurityError"===e.name?(console.error("Cannot construct sensors due to the Feature Policy"),console.warn('Attempting to fall back using "devicemotion"; however this will fail in the future without correct permissions.'),this.useDeviceMotion()):"ReferenceError"===e.name?this.useDeviceMotion():console.error(e)}e&&(this.api="sensor",this.sensor=e,this.sensor.addEventListener("reading",this._onSensorRead),this.sensor.start())}},{key:"useDeviceMotion",value:function(){this.api="devicemotion",this.fusionSensor=new u(this.config.K_FILTER,this.config.PREDICTION_TIME_S,this.config.YAW_ONLY,this.config.DEBUG),this.sensor&&(this.sensor.removeEventListener("reading",this._onSensorRead),this.sensor.removeEventListener("error",this._onSensorError),this.sensor=null)}},{key:"getOrientation",value:function(){if(this.fusionSensor)return this.fusionSensor.getOrientation();if(!this.sensor||!this.sensor.quaternion)return this._out[0]=this._out[1]=this._out[2]=0,this._out[3]=1,this._out;var e=this.sensor.quaternion;this._sensorQ.set(e[0],e[1],e[2],e[3]);var t=this._outQ;return t.copy(pe),t.multiply(this._sensorQ),this.config.YAW_ONLY&&(t.x=t.z=0,t.normalize()),this._out[0]=t.x,this._out[1]=t.y,this._out[2]=t.z,this._out[3]=t.w,this._out}},{key:"_onSensorError",value:function(e){this.errors.push(e.error),"NotAllowedError"===e.error.name?console.error("Permission to access sensor was denied"):"NotReadableError"===e.error.name?console.error("Sensor could not be read"):console.error(e.error),this.useDeviceMotion()}},{key:"_onSensorRead",value:function(){}}]),e}();p.prototype.show=function(e){e||this.overlay.parentElement?e&&(this.overlay.parentElement&&this.overlay.parentElement!=e&&this.overlay.parentElement.removeChild(this.overlay),e.appendChild(this.overlay)):document.body.appendChild(this.overlay),this.overlay.style.display="block";var t=this.overlay.querySelector("img"),i=t.style;S()?(i.width="20%",i.marginLeft="40%",i.marginTop="3%"):(i.width="50%",i.marginLeft="25%",i.marginTop="25%")},p.prototype.hide=function(){this.overlay.style.display="none"},p.prototype.showTemporarily=function(e,t){this.show(t),this.timer=setTimeout(this.hide.bind(this),e)},p.prototype.disableShowTemporarily=function(){clearTimeout(this.timer)},p.prototype.update=function(){this.disableShowTemporarily(),!S()&&k()?this.show():this.hide()},p.prototype.loadIcon_=function(){ this.icon=_("image/svg+xml","")};var me="CardboardV1",ve="WEBVR_CARDBOARD_VIEWER";f.prototype.show=function(e){this.root=e,e.appendChild(this.dialog),this.dialog.querySelector("#"+this.selectedKey).checked=!0,this.dialog.style.display="block"},f.prototype.hide=function(){this.root&&this.root.contains(this.dialog)&&this.root.removeChild(this.dialog),this.dialog.style.display="none"},f.prototype.getCurrentViewer=function(){return s.Viewers[this.selectedKey]},f.prototype.getSelectedKey_=function(){var e=this.dialog.querySelector("input[name=field]:checked");return e?e.id:null},f.prototype.onChange=function(e){this.onChangeCallbacks_.push(e)},f.prototype.fireOnChange_=function(e){for(var t=0;t.5&&(this.noSleepVideo.currentTime=Math.random())}.bind(this)))}return n(e,[{key:"enable",value:function(){s?(this.disable(),this.noSleepTimer=window.setInterval(function(){window.location.href="/",window.setTimeout(window.stop,0)},15e3)):this.noSleepVideo.play()}},{key:"disable",value:function(){s?this.noSleepTimer&&(window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause()}}]),e}();e.exports=a},function(e,t,i){ e.exports="data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTEgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9MiBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MCA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0wIHRocmVhZHM9NiBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MSBrZXlpbnQ9MzAwIGtleWludF9taW49MzAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD0xMCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIwLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IHZidl9tYXhyYXRlPTIwMDAwIHZidl9idWZzaXplPTI1MDAwIGNyZl9tYXg9MC4wIG5hbF9ocmQ9bm9uZSBmaWxsZXI9MCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAA3//p+C7v8tDDSTjf97w55i3SbRPO4ZY+hkjD5hbkAkL3zpJ6h/LR1CAABzgB1kqqzUorlhQAAAAxBmiQYhn/+qZYADLgAAAAJQZ5CQhX/AAj5IQADQGgcIQADQGgcAAAACQGeYUQn/wALKCEAA0BoHAAAAAkBnmNEJ/8ACykhAANAaBwhAANAaBwAAAANQZpoNExDP/6plgAMuSEAA0BoHAAAAAtBnoZFESwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBnqVEJ/8ACykhAANAaBwAAAAJAZ6nRCf/AAsoIQADQGgcIQADQGgcAAAADUGarDRMQz/+qZYADLghAANAaBwAAAALQZ7KRRUsK/8ACPkhAANAaBwAAAAJAZ7pRCf/AAsoIQADQGgcIQADQGgcAAAACQGe60Qn/wALKCEAA0BoHAAAAA1BmvA0TEM//qmWAAy5IQADQGgcIQADQGgcAAAAC0GfDkUVLCv/AAj5IQADQGgcAAAACQGfLUQn/wALKSEAA0BoHCEAA0BoHAAAAAkBny9EJ/8ACyghAANAaBwAAAANQZs0NExDP/6plgAMuCEAA0BoHAAAAAtBn1JFFSwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBn3FEJ/8ACyghAANAaBwAAAAJAZ9zRCf/AAsoIQADQGgcIQADQGgcAAAADUGbeDRMQz/+qZYADLkhAANAaBwAAAALQZ+WRRUsK/8ACPghAANAaBwhAANAaBwAAAAJAZ+1RCf/AAspIQADQGgcAAAACQGft0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bm7w0TEM//qmWAAy4IQADQGgcAAAAC0Gf2kUVLCv/AAj5IQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHAAAAAkBn/tEJ/8ACykhAANAaBwAAAANQZvgNExDP/6plgAMuSEAA0BoHCEAA0BoHAAAAAtBnh5FFSwr/wAI+CEAA0BoHAAAAAkBnj1EJ/8ACyghAANAaBwhAANAaBwAAAAJAZ4/RCf/AAspIQADQGgcAAAADUGaJDRMQz/+qZYADLghAANAaBwAAAALQZ5CRRUsK/8ACPkhAANAaBwhAANAaBwAAAAJAZ5hRCf/AAsoIQADQGgcAAAACQGeY0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bmmg0TEM//qmWAAy5IQADQGgcAAAAC0GehkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGepUQn/wALKSEAA0BoHAAAAAkBnqdEJ/8ACyghAANAaBwAAAANQZqsNExDP/6plgAMuCEAA0BoHCEAA0BoHAAAAAtBnspFFSwr/wAI+SEAA0BoHAAAAAkBnulEJ/8ACyghAANAaBwhAANAaBwAAAAJAZ7rRCf/AAsoIQADQGgcAAAADUGa8DRMQz/+qZYADLkhAANAaBwhAANAaBwAAAALQZ8ORRUsK/8ACPkhAANAaBwAAAAJAZ8tRCf/AAspIQADQGgcIQADQGgcAAAACQGfL0Qn/wALKCEAA0BoHAAAAA1BmzQ0TEM//qmWAAy4IQADQGgcAAAAC0GfUkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGfcUQn/wALKCEAA0BoHAAAAAkBn3NEJ/8ACyghAANAaBwhAANAaBwAAAANQZt4NExC//6plgAMuSEAA0BoHAAAAAtBn5ZFFSwr/wAI+CEAA0BoHCEAA0BoHAAAAAkBn7VEJ/8ACykhAANAaBwAAAAJAZ+3RCf/AAspIQADQGgcAAAADUGbuzRMQn/+nhAAYsAhAANAaBwhAANAaBwAAAAJQZ/aQhP/AAspIQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHAAACiFtb292AAAAbG12aGQAAAAA1YCCX9WAgl8AAAPoAAAH/AABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAGGlvZHMAAAAAEICAgAcAT////v7/AAAF+XRyYWsAAABcdGtoZAAAAAPVgIJf1YCCXwAAAAEAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAygAAAMoAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAB9AAABdwAAEAAAAABXFtZGlhAAAAIG1kaGQAAAAA1YCCX9WAgl8AAV+QAAK/IFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAUcbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAE3HN0YmwAAACYc3RzZAAAAAAAAAABAAAAiGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAygDKAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAyYXZjQwFNQCj/4QAbZ01AKOyho3ySTUBAQFAAAAMAEAAr8gDxgxlgAQAEaO+G8gAAABhzdHRzAAAAAAAAAAEAAAA8AAALuAAAABRzdHNzAAAAAAAAAAEAAAABAAAB8GN0dHMAAAAAAAAAPAAAAAEAABdwAAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAAC7gAAAAAQAAF3AAAAABAAAAAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAEEc3RzegAAAAAAAAAAAAAAPAAAAzQAAAAQAAAADQAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAANAAAADQAAAQBzdGNvAAAAAAAAADwAAAAwAAADZAAAA3QAAAONAAADoAAAA7kAAAPQAAAD6wAAA/4AAAQXAAAELgAABEMAAARcAAAEbwAABIwAAAShAAAEugAABM0AAATkAAAE/wAABRIAAAUrAAAFQgAABV0AAAVwAAAFiQAABaAAAAW1AAAFzgAABeEAAAX+AAAGEwAABiwAAAY/AAAGVgAABnEAAAaEAAAGnQAABrQAAAbPAAAG4gAABvUAAAcSAAAHJwAAB0AAAAdTAAAHcAAAB4UAAAeeAAAHsQAAB8gAAAfjAAAH9gAACA8AAAgmAAAIQQAACFQAAAhnAAAIhAAACJcAAAMsdHJhawAAAFx0a2hkAAAAA9WAgl/VgIJfAAAAAgAAAAAAAAf8AAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACsm1kaWEAAAAgbWRoZAAAAADVgIJf1YCCXwAArEQAAWAAVcQAAAAAACdoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU3RlcmVvAAAAAmNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAidzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA="}])})})),we=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(ge),ye=1e3,Ee=[0,0,.5,1],be=[.5,0,.5,1],_e=window.requestAnimationFrame,De=window.cancelAnimationFrame;g.prototype.getFrameData=function(e){return H(e,this._getPose(),this)},g.prototype.getPose=function(){return j("VRDisplay.prototype.getPose","VRDisplay.prototype.getFrameData"),this._getPose()},g.prototype.resetPose=function(){return j("VRDisplay.prototype.resetPose"),this._resetPose()},g.prototype.getImmediatePose=function(){return j("VRDisplay.prototype.getImmediatePose","VRDisplay.prototype.getFrameData"),this._getPose()},g.prototype.requestAnimationFrame=function(e){return _e(e)},g.prototype.cancelAnimationFrame=function(e){return De(e)},g.prototype.wrapForFullscreen=function(e){if(M())return e;if(!this.fullscreenWrapper_){this.fullscreenWrapper_=document.createElement("div");var t=["height: "+Math.min(screen.height,screen.width)+"px !important","top: 0 !important","left: 0 !important","right: 0 !important","border: 0","margin: 0","padding: 0","z-index: 999999 !important","position: fixed"];this.fullscreenWrapper_.setAttribute("style",t.join("; ")+";"),this.fullscreenWrapper_.classList.add("webvr-polyfill-fullscreen-wrapper")}if(this.fullscreenElement_==e)return this.fullscreenWrapper_;if(this.fullscreenElement_&&(this.originalParent_?this.originalParent_.appendChild(this.fullscreenElement_):this.fullscreenElement_.parentElement.removeChild(this.fullscreenElement_)),this.fullscreenElement_=e,this.originalParent_=e.parentElement,this.originalParent_||document.body.appendChild(e),!this.fullscreenWrapper_.parentElement){var i=this.fullscreenElement_.parentElement;i.insertBefore(this.fullscreenWrapper_,this.fullscreenElement_),i.removeChild(this.fullscreenElement_)}this.fullscreenWrapper_.insertBefore(this.fullscreenElement_,this.fullscreenWrapper_.firstChild),this.fullscreenElementCachedStyle_=this.fullscreenElement_.getAttribute("style");var r=this;return function(){if(r.fullscreenElement_){var e=["position: absolute","top: 0","left: 0","width: "+Math.max(screen.width,screen.height)+"px","height: "+Math.min(screen.height,screen.width)+"px","border: 0","margin: 0","padding: 0"];r.fullscreenElement_.setAttribute("style",e.join("; ")+";")}}(),this.fullscreenWrapper_},g.prototype.removeFullscreenWrapper=function(){if(this.fullscreenElement_){var e=this.fullscreenElement_;this.fullscreenElementCachedStyle_?e.setAttribute("style",this.fullscreenElementCachedStyle_):e.removeAttribute("style"),this.fullscreenElement_=null,this.fullscreenElementCachedStyle_=null;var t=this.fullscreenWrapper_.parentElement;return this.fullscreenWrapper_.removeChild(e),this.originalParent_===t?t.insertBefore(e,this.fullscreenWrapper_):this.originalParent_&&this.originalParent_.appendChild(e),t.removeChild(this.fullscreenWrapper_),e}},g.prototype.requestPresent=function(e){var t=this.isPresenting,i=this;return e instanceof Array||(j("VRDisplay.prototype.requestPresent with non-array argument","an array of VRLayers as the first argument"),e=[e]),new Promise(function(r,n){if(!i.capabilities.canPresent)return void n(new Error("VRDisplay is not capable of presenting."));if(0==e.length||e.length>i.capabilities.maxLayers)return void n(new Error("Invalid number of layers."));var A=e[0];if(!A.source)return void r();var s=A.leftBounds||Ee,a=A.rightBounds||be;if(t){var o=i.layer_;o.source!==A.source&&(o.source=A.source);for(var l=0;l<4;l++)o.leftBounds[l]=s[l],o.rightBounds[l]=a[l];return i.wrapForFullscreen(i.layer_.source),i.updatePresent_(),void r()}if(i.layer_={predistorted:A.predistorted,source:A.source,leftBounds:s.slice(0),rightBounds:a.slice(0)},i.waitingForPresent_=!1,i.layer_&&i.layer_.source){var c=i.wrapForFullscreen(i.layer_.source),h=function(){var e=Q();i.isPresenting=c===e,i.isPresenting?(screen.orientation&&screen.orientation.lock&&screen.orientation.lock("landscape-primary").catch(function(e){console.error("screen.orientation.lock() failed due to",e.message)}),i.waitingForPresent_=!1,i.beginPresent_(),r()):(screen.orientation&&screen.orientation.unlock&&screen.orientation.unlock(),i.removeFullscreenWrapper(),i.disableWakeLock(),i.endPresent_(),i.removeFullscreenListeners_()),i.fireVRDisplayPresentChange_()},d=function(){i.waitingForPresent_&&(i.removeFullscreenWrapper(),i.removeFullscreenListeners_(),i.disableWakeLock(),i.waitingForPresent_=!1,i.isPresenting=!1,n(new Error("Unable to present.")))};i.addFullscreenListeners_(c,h,d),P(c)?(i.enableWakeLock(),i.waitingForPresent_=!0):(M()||B())&&(i.enableWakeLock(),i.isPresenting=!0,i.beginPresent_(),i.fireVRDisplayPresentChange_(),r())}i.waitingForPresent_||M()||(N(),n(new Error("Unable to present.")))})},g.prototype.exitPresent=function(){var e=this.isPresenting,t=this;return this.isPresenting=!1,this.layer_=null,this.disableWakeLock(),new Promise(function(i,r){e?(!N()&&M()&&(t.endPresent_(),t.fireVRDisplayPresentChange_()),B()&&(t.removeFullscreenWrapper(),t.removeFullscreenListeners_(),t.endPresent_(),t.fireVRDisplayPresentChange_()),i()):r(new Error("Was not presenting to VRDisplay."))})},g.prototype.getLayers=function(){return this.layer_?[this.layer_]:[]},g.prototype.fireVRDisplayPresentChange_=function(){var e=new CustomEvent("vrdisplaypresentchange",{detail:{display:this}});window.dispatchEvent(e)},g.prototype.fireVRDisplayConnect_=function(){var e=new CustomEvent("vrdisplayconnect",{detail:{display:this}});window.dispatchEvent(e)},g.prototype.addFullscreenListeners_=function(e,t,i){this.removeFullscreenListeners_(),this.fullscreenEventTarget_=e,this.fullscreenChangeHandler_=t,this.fullscreenErrorHandler_=i,t&&(document.fullscreenEnabled?e.addEventListener("fullscreenchange",t,!1):document.webkitFullscreenEnabled?e.addEventListener("webkitfullscreenchange",t,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenchange",t,!1):document.msFullscreenEnabled&&e.addEventListener("msfullscreenchange",t,!1)),i&&(document.fullscreenEnabled?e.addEventListener("fullscreenerror",i,!1):document.webkitFullscreenEnabled?e.addEventListener("webkitfullscreenerror",i,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenerror",i,!1):document.msFullscreenEnabled&&e.addEventListener("msfullscreenerror",i,!1))},g.prototype.removeFullscreenListeners_=function(){if(this.fullscreenEventTarget_){var e=this.fullscreenEventTarget_;if(this.fullscreenChangeHandler_){var t=this.fullscreenChangeHandler_;e.removeEventListener("fullscreenchange",t,!1),e.removeEventListener("webkitfullscreenchange",t,!1),document.removeEventListener("mozfullscreenchange",t,!1),e.removeEventListener("msfullscreenchange",t,!1)}if(this.fullscreenErrorHandler_){var i=this.fullscreenErrorHandler_;e.removeEventListener("fullscreenerror",i,!1),e.removeEventListener("webkitfullscreenerror",i,!1),document.removeEventListener("mozfullscreenerror",i,!1),e.removeEventListener("msfullscreenerror",i,!1)}this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null}},g.prototype.enableWakeLock=function(){this.wakelock_&&this.wakelock_.enable()},g.prototype.disableWakeLock=function(){this.wakelock_&&this.wakelock_.disable()},g.prototype.beginPresent_=function(){},g.prototype.endPresent_=function(){},g.prototype.submitFrame=function(e){},g.prototype.getEyeParameters=function(e){return null};var Me={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:"",MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:"https://dpdb.webvr.rocks/dpdb.json",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1},Be={LEFT:"left",RIGHT:"right"};return w.prototype=Object.create(g.prototype),w.prototype._getPose=function(){return{position:null,orientation:this.poseSensor_.getOrientation(),linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},w.prototype._resetPose=function(){this.poseSensor_.resetPose&&this.poseSensor_.resetPose()},w.prototype._getFieldOfView=function(e){var t;if(e==Be.LEFT)t=this.deviceInfo_.getFieldOfViewLeftEye();else{if(e!=Be.RIGHT)return console.error("Invalid eye provided: %s",e),null;t=this.deviceInfo_.getFieldOfViewRightEye()}return t},w.prototype._getEyeOffset=function(e){var t;if(e==Be.LEFT)t=[.5*-this.deviceInfo_.viewer.interLensDistance,0,0];else{if(e!=Be.RIGHT)return console.error("Invalid eye provided: %s",e),null;t=[.5*this.deviceInfo_.viewer.interLensDistance,0,0]}return t},w.prototype.getEyeParameters=function(e){var t=this._getEyeOffset(e),i=this._getFieldOfView(e),r={offset:t,renderWidth:.5*this.deviceInfo_.device.width*this.bufferScale_,renderHeight:this.deviceInfo_.device.height*this.bufferScale_};return Object.defineProperty(r,"fieldOfView",{enumerable:!0,get:function(){return j("VRFieldOfView","VRFrameData's projection matrices"),i}}),r},w.prototype.onDeviceParamsUpdated_=function(e){this.config.DEBUG&&console.log("DPDB reported that device params were updated."),this.deviceInfo_.updateDeviceParams(e),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_)},w.prototype.updateBounds_=function(){this.layer_&&this.distorter_&&(this.layer_.leftBounds||this.layer_.rightBounds)&&this.distorter_.setTextureBounds(this.layer_.leftBounds,this.layer_.rightBounds)},w.prototype.beginPresent_=function(){var e=this.layer_.source.getContext("webgl");e||(e=this.layer_.source.getContext("experimental-webgl")),e||(e=this.layer_.source.getContext("webgl2")),e&&(this.layer_.predistorted?this.config.CARDBOARD_UI_DISABLED||(e.canvas.width=x()*this.bufferScale_,e.canvas.height=L()*this.bufferScale_,this.cardboardUI_=new r(e)):(this.config.CARDBOARD_UI_DISABLED||(this.cardboardUI_=new r(e)),this.distorter_=new i(e,this.cardboardUI_,this.config.BUFFER_SCALE,this.config.DIRTY_SUBMIT_FRAME_BINDINGS),this.distorter_.updateDeviceInfo(this.deviceInfo_)),this.cardboardUI_&&this.cardboardUI_.listen(function(e){this.viewerSelector_.show(this.layer_.source.parentElement),e.stopPropagation(),e.preventDefault()}.bind(this),function(e){this.exitPresent(),e.stopPropagation(),e.preventDefault()}.bind(this)),this.rotateInstructions_&&(S()&&k()?this.rotateInstructions_.showTemporarily(3e3,this.layer_.source.parentElement):this.rotateInstructions_.update()),this.orientationHandler=this.onOrientationChange_.bind(this),window.addEventListener("orientationchange",this.orientationHandler),this.vrdisplaypresentchangeHandler=this.updateBounds_.bind(this),window.addEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler),this.fireVRDisplayDeviceParamsChange_())},w.prototype.endPresent_=function(){this.distorter_&&(this.distorter_.destroy(),this.distorter_=null),this.cardboardUI_&&(this.cardboardUI_.destroy(),this.cardboardUI_=null),this.rotateInstructions_&&this.rotateInstructions_.hide(),this.viewerSelector_.hide(),window.removeEventListener("orientationchange",this.orientationHandler),window.removeEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler)},w.prototype.updatePresent_=function(){this.endPresent_(),this.beginPresent_()},w.prototype.submitFrame=function(e){if(this.distorter_)this.updateBounds_(),this.distorter_.submitFrame();else if(this.cardboardUI_&&this.layer_){var t=this.layer_.source.getContext("webgl").canvas;t.width==this.lastWidth&&t.height==this.lastHeight||this.cardboardUI_.onResize(),this.lastWidth=t.width,this.lastHeight=t.height,this.cardboardUI_.render()}},w.prototype.onOrientationChange_=function(e){this.viewerSelector_.hide(),this.rotateInstructions_&&this.rotateInstructions_.update(),this.onResize_()},w.prototype.onResize_=function(e){if(this.layer_){var t=this.layer_.source.getContext("webgl"),i=["position: absolute","top: 0","left: 0","width: 100vw","height: 100vh","border: 0","margin: 0","padding: 0px","box-sizing: content-box"];t.canvas.setAttribute("style",i.join("; ")+";"),z(t.canvas)}},w.prototype.onViewerChanged_=function(e){this.deviceInfo_.setViewer(e),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_),this.fireVRDisplayDeviceParamsChange_()},w.prototype.fireVRDisplayDeviceParamsChange_=function(){var e=new CustomEvent("vrdisplaydeviceparamschange",{detail:{vrdisplay:this,deviceInfo:this.deviceInfo_}});window.dispatchEvent(e)},w.VRFrameData=m,w.VRDisplay=g,w}()}()}),s=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(A),a={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:"",PROVIDE_MOBILE_VRDISPLAY:!0,MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:"https://dpdb.webvr.rocks/dpdb.json",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1};e.prototype.getPolyfillDisplays=function(){if(this._polyfillDisplaysPopulated)return this.polyfillDisplays;if(i()){var e=new s({ADDITIONAL_VIEWERS:this.config.ADDITIONAL_VIEWERS,DEFAULT_VIEWER:this.config.DEFAULT_VIEWER,MOBILE_WAKE_LOCK:this.config.MOBILE_WAKE_LOCK,DEBUG:this.config.DEBUG,DPDB_URL:this.config.DPDB_URL,CARDBOARD_UI_DISABLED:this.config.CARDBOARD_UI_DISABLED,K_FILTER:this.config.K_FILTER,PREDICTION_TIME_S:this.config.PREDICTION_TIME_S,ROTATE_INSTRUCTIONS_DISABLED:this.config.ROTATE_INSTRUCTIONS_DISABLED,YAW_ONLY:this.config.YAW_ONLY,BUFFER_SCALE:this.config.BUFFER_SCALE,DIRTY_SUBMIT_FRAME_BINDINGS:this.config.DIRTY_SUBMIT_FRAME_BINDINGS});this.polyfillDisplays.push(e)}return this._polyfillDisplaysPopulated=!0,this.polyfillDisplays},e.prototype.enable=function(){if(this.enabled=!0,this.hasNative&&this.native.VRFrameData){var e=this.native.VRFrameData,t=new this.native.VRFrameData,i=this.native.VRDisplay.prototype.getFrameData;window.VRDisplay.prototype.getFrameData=function(n){if(n instanceof e)return void i.call(this,n);i.call(this,t),n.pose=t.pose,r(t.leftProjectionMatrix,n.leftProjectionMatrix),r(t.rightProjectionMatrix,n.rightProjectionMatrix),r(t.leftViewMatrix,n.leftViewMatrix),r(t.rightViewMatrix,n.rightViewMatrix)}}navigator.getVRDisplays=this.getVRDisplays.bind(this),window.VRDisplay=s.VRDisplay,window.VRFrameData=s.VRFrameData},e.prototype.getVRDisplays=function(){var e=this;this.config;return this.hasNative?this.native.getVRDisplays.call(navigator).then(function(t){return t.length>0?t:e.getPolyfillDisplays()}):Promise.resolve(this.getPolyfillDisplays())},e.version="0.10.10",e.VRFrameData=s.VRFrameData,e.VRDisplay=s.VRDisplay;var o=Object.freeze({default:e}),l=o&&e||o;return void 0!==t&&t.window&&(t.document||(t.document=t.window.document),t.navigator||(t.navigator=t.window.navigator)),l}); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],68:[function(_dereq_,module,exports){ function idxOf(e,n,r,t){var i=e.indexOf(n,r);return-1===i||i>t?t:i}function isWhitespace(e){return whitespace.test(e)}function pre(e,n,r,t,i){for(var a=[],o=r,s=r;sr&&!isWhitespace(n.charAt(f));)f--;if(f===r)p>r+newlineChar.length&&p--,f=p;else for(p=f;f>r&&isWhitespace(n.charAt(f-newlineChar.length));)f--}if(f>=r){var c=e(n,r,f,s);o.push(c)}r=p}return o}function monospace(e,n,r,t){return{start:n,end:n+Math.min(t,r-n)}}var newline=/\n/,newlineChar="\n",whitespace=/\s/;module.exports=function(e,n){return module.exports.lines(e,n).map(function(n){return e.substring(n.start,n.end)}).join("\n")},module.exports.lines=function(e,n){if(n=n||{},0===n.width&&"nowrap"!==n.mode)return[];e=e||"";var r="number"==typeof n.width?n.width:Number.MAX_VALUE,t=Math.max(0,n.start||0),i="number"==typeof n.end?n.end:e.length,a=n.mode,o=n.measure||monospace;return"pre"===a?pre(o,e,t,i,r):greedy(o,e,t,i,r,a)}; },{}],69:[function(_dereq_,module,exports){ "use strict";function forEachArray(e,t){for(var r=0;r0&&(d=setTimeout(function(){if(!c){c=!0,i.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",n(e)}},e.timeout)),i.setRequestHeader)for(u in m)m.hasOwnProperty(u)&&i.setRequestHeader(u,m[u]);else if(e.headers&&!isEmpty(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(i.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(i),i.send(f||null),i}function getXml(e){try{if("document"===e.responseType)return e.responseXML;var t=e.responseXML&&"parsererror"===e.responseXML.documentElement.nodeName;if(""===e.responseType&&!t)return e.responseXML}catch(e){}return null}function noop(){}var window=_dereq_("global/window"),isFunction=_dereq_("is-function"),parseHeaders=_dereq_("parse-headers"),xtend=_dereq_("xtend");module.exports=createXHR,module.exports.default=createXHR,createXHR.XMLHttpRequest=window.XMLHttpRequest||noop,createXHR.XDomainRequest="withCredentials"in new createXHR.XMLHttpRequest?createXHR.XMLHttpRequest:window.XDomainRequest,forEachArray(["get","put","post","patch","head","delete"],function(e){createXHR["delete"===e?"del":e]=function(t,r,n){return r=initParams(t,r,n),r.method=e.toUpperCase(),_createXHR(r)}}); },{"global/window":27,"is-function":33,"parse-headers":47,"xtend":71}],70:[function(_dereq_,module,exports){ module.exports=function(){return void 0!==self.DOMParser?function(e){return(new self.DOMParser).parseFromString(e,"application/xml")}:void 0!==self.ActiveXObject&&new self.ActiveXObject("Microsoft.XMLDOM")?function(e){var n=new self.ActiveXObject("Microsoft.XMLDOM");return n.async="false",n.loadXML(e),n}:function(e){var n=document.createElement("div");return n.innerHTML=e,n}}(); },{}],71:[function(_dereq_,module,exports){ function extend(){for(var r={},e=0;e dist/aframe-master.js","dist:min":"npm run browserify -s -- --debug -p [minifyify --map aframe-master.min.js.map --output dist/aframe-master.min.js.map] -o dist/aframe-master.min.js","docs":"markserv --dir docs --port 9001","preghpages":"node ./scripts/preghpages.js","ghpages":"ghpages -p gh-pages/","lint":"semistandard -v | snazzy","lint:fix":"semistandard --fix","precommit":"npm run lint","prepush":"node scripts/testOnlyCheck.js","prerelease":"node scripts/release.js 0.9.1 0.9.2","start":"npm run dev","start:https":"cross-env SSL=true npm run dev","test":"karma start ./tests/karma.conf.js","test:docs":"node scripts/docsLint.js","test:firefox":"npm test -- --browsers Firefox","test:chrome":"npm test -- --browsers Chrome","test:nobrowser":"NO_BROWSER=true npm test","test:node":"mocha --ui tdd tests/node"},"repository":"aframevr/aframe","license":"MIT","files":["dist/*","docs/**/*","src/**/*","vendor/**/*"],"dependencies":{"custom-event-polyfill":"^1.0.6","debug":"ngokevin/debug#noTimestamp","deep-assign":"^2.0.0","document-register-element":"dmarcos/document-register-element#8ccc532b7f3744be954574caf3072a5fd260ca90","load-bmfont":"^1.2.3","object-assign":"^4.0.1","present":"0.0.6","promise-polyfill":"^3.1.0","super-animejs":"^3.1.0","super-three":"^0.108.0","three-bmfont-text":"^2.1.0","webvr-polyfill":"^0.10.10"},"devDependencies":{"browserify":"^13.1.0","browserify-css":"^0.8.4","browserify-derequire":"^0.9.4","browserify-istanbul":"^2.0.0","budo":"^9.2.0","chai":"^3.5.0","chai-shallow-deep-equal":"^1.4.0","chalk":"^1.1.3","codecov":"^1.0.1","cross-env":"^5.0.1","envify":"^3.4.1","exorcist":"^0.4.0","ghpages":"0.0.8","git-rev":"^0.2.1","glob":"^7.1.1","husky":"^0.11.7","istanbul":"^0.4.5","jsdom":"^9.11.0","karma":"1.4.1","karma-browserify":"^5.1.0","karma-chai-shallow-deep-equal":"0.0.4","karma-chrome-launcher":"^2.0.0","karma-coverage":"^1.1.1","karma-env-preprocessor":"^0.1.1","karma-firefox-launcher":"^1.0.0","karma-mocha":"^1.1.1","karma-mocha-reporter":"^2.1.0","karma-sinon-chai":"1.2.4","lolex":"^1.5.1","markserv":"github:sukima/markserv#feature/fix-broken-websoketio-link","minifyify":"^7.3.3","mocha":"^3.0.2","mozilla-download":"^1.1.1","replace-in-file":"^2.5.3","semistandard":"^9.0.0","shelljs":"^0.7.7","shx":"^0.2.2","sinon":"^1.17.5","sinon-chai":"2.8.0","snazzy":"^5.0.0","too-wordy":"ngokevin/too-wordy","uglifyjs":"^2.4.10","write-good":"^0.9.1"},"link":true,"browserify":{"transform":["browserify-css","envify"]},"semistandard":{"ignore":["build/**","dist/**","examples/**/shaders/*.js","**/vendor/**"]},"keywords":["3d","aframe","cardboard","components","oculus","three","three.js","rift","vive","vr","web-components","webvr"],"browserify-css":{"minify":true},"engines":{"node":">= 4.6.0","npm":"^2.15.9"}} },{}],73:[function(_dereq_,module,exports){ function getPropertyType(t,e){var i,n,o,a;return o=e.split("."),n=o[0],a=o[1],i=t.components[n]||components[n],i?a&&!i.schema[a]?null:a?i.schema[a].type:i.schema.type:null}function toRadians(t){t.x=THREE.Math.degToRad(t.x),t.y=THREE.Math.degToRad(t.y),t.z=THREE.Math.degToRad(t.z)}function addEventListeners(t,e,i){var n;for(n=0;n=1),isRawProperty(a)?setRawProperty(r,a.property,n,a.type):setComponentProperty(r,a.property,n))}}())},updateConfigForVector:function(){var t,e,i,n=this.config,o=this.data,a=this.el;e=""!==o.from?utils.coordinates.parse(o.from):getComponentProperty(a,o.property),i=utils.coordinates.parse(o.to),o.property===PROP_ROTATION&&(toRadians(e),toRadians(i)),this.targetsArray.length=0,this.targetsArray.push(e),n.targets=this.targetsArray;for(t in i)n[t]=i[t];if(o.property===PROP_POSITION||o.property===PROP_ROTATION||o.property===PROP_SCALE)return void(n.update=function(){var t={};return function(e){var i=e.animatables[0].target;o.property===PROP_SCALE&&(i.x=Math.max(1e-4,i.x),i.y=Math.max(1e-4,i.y),i.z=Math.max(1e-4,i.z)),i.x===t.x&&i.y===t.y&&i.z===t.z||(t.x=i.x,t.y=i.y,t.z=i.z,a.object3D[o.property].set(i.x,i.y,i.z))}}());n.update=function(){var t={};return function(e){var i=e.animatables[0].target;i.x===t.x&&i.y===t.y&&i.z===t.z||(t.x=i.x,t.y=i.y,t.z=i.z,setComponentProperty(a,o.property,i))}}()},updateConfig:function(){var t;t=getPropertyType(this.el,this.data.property),isRawProperty(this.data)&&this.data.type===TYPE_COLOR?this.updateConfigForRawColor():"vec2"===t||"vec3"===t||"vec4"===t?this.updateConfigForVector():this.updateConfigForDefault()},waitComponentInitRawProperty:function(t){var e,i=this.data,n=this.el,o=this;return""===i.from&&(!!i.property.startsWith(STRING_COMPONENTS)&&(e=splitDot(i.property)[1],!n.components[e]&&(n.addEventListener("componentinitialized",function i(a){a.detail.name===e&&(t(),o.animation=anime(o.config),n.removeEventListener("componentinitialized",i))}),!0)))},stopRelatedAnimations:function(){var t,e;for(e in this.el.components)t=this.el.components[e],e!==this.attrName&&"animation"===t.name&&t.animationIsPlaying&&t.data.property===this.data.property&&(t.animationIsPlaying=!1)},addEventListeners:function(){var t=this.data,e=this.el;addEventListeners(e,t.startEvents,this.onStartEvent),addEventListeners(e,t.pauseEvents,this.pauseAnimation),addEventListeners(e,t.resumeEvents,this.resumeAnimation)},removeEventListeners:function(){var t=this.data,e=this.el;removeEventListeners(e,t.startEvents,this.onStartEvent),removeEventListeners(e,t.pauseEvents,this.pauseAnimation),removeEventListeners(e,t.resumeEvents,this.resumeAnimation)},setColorConfig:function(t,e){colorHelperFrom.set(t),colorHelperTo.set(e),t=this.fromColor,e=this.toColor,t.r=colorHelperFrom.r,t.g=colorHelperFrom.g,t.b=colorHelperFrom.b,e.r=colorHelperTo.r,e.g=colorHelperTo.g,e.b=colorHelperTo.b}}); },{"../core/component":124,"../lib/three":172,"../utils":197,"super-animejs":56}],74:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,THREE=_dereq_("../lib/three");module.exports.Component=registerComponent("camera",{schema:{active:{default:!0},far:{default:1e4},fov:{default:80,min:0},near:{default:.005,min:0},spectator:{default:!1},zoom:{default:1,min:0}},init:function(){var e,t=this.el;e=this.camera=new THREE.PerspectiveCamera,t.setObject3D("camera",e)},update:function(e){var t=this.data,a=this.camera;a.aspect=t.aspect||window.innerWidth/window.innerHeight,a.far=t.far,a.fov=t.fov,a.near=t.near,a.zoom=t.zoom,a.updateProjectionMatrix(),this.updateActiveCamera(e),this.updateSpectatorCamera(e)},updateActiveCamera:function(e){var t=this.data,a=this.el,r=this.system;e&&e.active===t.active||t.spectator||(t.active&&r.activeCameraEl!==a?r.setActiveCamera(a):t.active||r.activeCameraEl!==a||r.disableActiveCamera())},updateSpectatorCamera:function(e){var t=this.data,a=this.el,r=this.system;e&&e.spectator===t.spectator||(t.spectator&&r.spectatorCameraEl!==a?r.setSpectatorCamera(a):t.spectator||r.spectatorCameraEl!==a||r.disableSpectatorCamera())},remove:function(){this.el.removeObject3D("camera")}}); },{"../core/component":124,"../lib/three":172}],75:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,utils=_dereq_("../utils/"),bind=utils.bind,EVENTS={CLICK:"click",FUSING:"fusing",MOUSEENTER:"mouseenter",MOUSEDOWN:"mousedown",MOUSELEAVE:"mouseleave",MOUSEUP:"mouseup"},STATES={FUSING:"cursor-fusing",HOVERING:"cursor-hovering",HOVERED:"cursor-hovered"},CANVAS_EVENTS={DOWN:["mousedown","touchstart"],UP:["mouseup","touchend"]},CANVAS_HOVER_CLASS="a-mouse-cursor-hover";module.exports.Component=registerComponent("cursor",{dependencies:["raycaster"],schema:{downEvents:{default:[]},fuse:{default:utils.device.isMobile()},fuseTimeout:{default:1500,min:0},mouseCursorStylesEnabled:{default:!0},upEvents:{default:[]},rayOrigin:{default:"entity",oneOf:["mouse","entity"]}},init:function(){var e=this;this.fuseTimeout=void 0,this.cursorDownEl=null,this.intersectedEl=null,this.canvasBounds=document.body.getBoundingClientRect(),this.isCursorDown=!1,this.updateCanvasBounds=utils.debounce(function(){e.canvasBounds=e.el.sceneEl.canvas.getBoundingClientRect()},500),this.eventDetail={},this.intersectedEventDetail={cursorEl:this.el},this.onCursorDown=bind(this.onCursorDown,this),this.onCursorUp=bind(this.onCursorUp,this),this.onIntersection=bind(this.onIntersection,this),this.onIntersectionCleared=bind(this.onIntersectionCleared,this),this.onMouseMove=bind(this.onMouseMove,this)},update:function(e){this.data.rayOrigin!==e.rayOrigin&&this.updateMouseEventListeners()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners()},remove:function(){var e=this.el;e.removeState(STATES.HOVERING),e.removeState(STATES.FUSING),clearTimeout(this.fuseTimeout),this.intersectedEl&&this.intersectedEl.removeState(STATES.HOVERED),this.removeEventListeners()},addEventListeners:function(){function e(){t=n.sceneEl.canvas,s.downEvents.length||s.upEvents.length||(CANVAS_EVENTS.DOWN.forEach(function(e){t.addEventListener(e,i.onCursorDown)}),CANVAS_EVENTS.UP.forEach(function(e){t.addEventListener(e,i.onCursorUp)}))}var t,s=this.data,n=this.el,i=this;t=n.sceneEl.canvas,t?e():n.sceneEl.addEventListener("render-target-loaded",e),s.downEvents.forEach(function(e){n.addEventListener(e,i.onCursorDown)}),s.upEvents.forEach(function(e){n.addEventListener(e,i.onCursorUp)}),n.addEventListener("raycaster-intersection",this.onIntersection),n.addEventListener("raycaster-intersection-cleared",this.onIntersectionCleared),n.sceneEl.addEventListener("rendererresize",this.updateCanvasBounds),window.addEventListener("resize",this.updateCanvasBounds),window.addEventListener("scroll",this.updateCanvasBounds),this.updateMouseEventListeners()},removeEventListeners:function(){var e,t=this.data,s=this.el,n=this;e=s.sceneEl.canvas,!e||t.downEvents.length||t.upEvents.length||(CANVAS_EVENTS.DOWN.forEach(function(t){e.removeEventListener(t,n.onCursorDown)}),CANVAS_EVENTS.UP.forEach(function(t){e.removeEventListener(t,n.onCursorUp)})),t.downEvents.forEach(function(e){s.removeEventListener(e,n.onCursorDown)}),t.upEvents.forEach(function(e){s.removeEventListener(e,n.onCursorUp)}),s.removeEventListener("raycaster-intersection",this.onIntersection),s.removeEventListener("raycaster-intersection-cleared",this.onIntersectionCleared),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("touchstart",this.onMouseMove),e.removeEventListener("touchmove",this.onMouseMove),s.sceneEl.removeEventListener("rendererresize",this.updateCanvasBounds),window.removeEventListener("resize",this.updateCanvasBounds),window.removeEventListener("scroll",this.updateCanvasBounds)},updateMouseEventListeners:function(){var e,t=this.el;e=t.sceneEl.canvas,e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("touchmove",this.onMouseMove),t.setAttribute("raycaster","useWorldCoordinates",!1),"mouse"===this.data.rayOrigin&&(e.addEventListener("mousemove",this.onMouseMove,!1),e.addEventListener("touchmove",this.onMouseMove,!1),t.setAttribute("raycaster","useWorldCoordinates",!0),this.updateCanvasBounds())},onMouseMove:function(){var e=new THREE.Vector3,t=new THREE.Vector2,s=new THREE.Vector3,n={origin:s,direction:e};return function(i){var o,r,a,u=this.canvasBounds,c=this.el.sceneEl.camera;c.parent.updateMatrixWorld(),r="touchmove"===i.type||"touchstart"===i.type?i.touches.item(0):i,o=r.clientX-u.left,a=r.clientY-u.top,t.x=o/u.width*2-1,t.y=-a/u.height*2+1,s.setFromMatrixPosition(c.matrixWorld),e.set(t.x,t.y,.5).unproject(c).sub(s).normalize(),this.el.setAttribute("raycaster",n),"touchmove"===i.type&&i.preventDefault()}}(),onCursorDown:function(e){this.isCursorDown=!0,"mouse"===this.data.rayOrigin&&"touchstart"===e.type&&(this.onMouseMove(e),this.el.components.raycaster.checkIntersections(),e.preventDefault()),this.twoWayEmit(EVENTS.MOUSEDOWN),this.cursorDownEl=this.intersectedEl},onCursorUp:function(e){if(this.isCursorDown){this.isCursorDown=!1;var t=this.data;this.twoWayEmit(EVENTS.MOUSEUP),this.cursorDownEl&&this.cursorDownEl!==this.intersectedEl&&(this.intersectedEventDetail.intersection=null,this.cursorDownEl.emit(EVENTS.MOUSEUP,this.intersectedEventDetail)),t.fuse&&"mouse"!==t.rayOrigin||!this.intersectedEl||this.cursorDownEl!==this.intersectedEl||this.twoWayEmit(EVENTS.CLICK),this.cursorDownEl=null,"touchend"===e.type&&e.preventDefault()}},onIntersection:function(e){var t,s,n,i,o=this.el;s=e.detail.els[0]===o?1:0,i=e.detail.intersections[s],(n=e.detail.els[s])&&this.intersectedEl!==n&&(this.intersectedEl&&(t=this.el.components.raycaster.getIntersection(this.intersectedEl))&&t.distance<=i.distance||(this.clearCurrentIntersection(!0),this.setIntersection(n,i)))},onIntersectionCleared:function(e){-1!==e.detail.clearedEls.indexOf(this.intersectedEl)&&this.clearCurrentIntersection()},setIntersection:function(e,t){var s=this.el,n=this.data,i=this;this.intersectedEl!==e&&(this.intersectedEl=e,s.addState(STATES.HOVERING),e.addState(STATES.HOVERED),this.twoWayEmit(EVENTS.MOUSEENTER),this.data.mouseCursorStylesEnabled&&"mouse"===this.data.rayOrigin&&this.el.sceneEl.canvas.classList.add(CANVAS_HOVER_CLASS),0!==n.fuseTimeout&&n.fuse&&(s.addState(STATES.FUSING),this.twoWayEmit(EVENTS.FUSING),this.fuseTimeout=setTimeout(function(){s.removeState(STATES.FUSING),i.twoWayEmit(EVENTS.CLICK)},n.fuseTimeout)))},clearCurrentIntersection:function(e){var t,s,n,i=this.el;this.intersectedEl&&(this.intersectedEl.removeState(STATES.HOVERED),i.removeState(STATES.HOVERING),i.removeState(STATES.FUSING),this.twoWayEmit(EVENTS.MOUSELEAVE),this.data.mouseCursorStylesEnabled&&"mouse"===this.data.rayOrigin&&this.el.sceneEl.canvas.classList.remove(CANVAS_HOVER_CLASS),this.intersectedEl=null,clearTimeout(this.fuseTimeout),!0!==e&&(n=this.el.components.raycaster.intersections,0!==n.length&&(t=n[0].object.el===i?1:0,(s=n[t])&&this.setIntersection(s.object.el,s))))},twoWayEmit:function(e){var t,s=this.el,n=this.intersectedEl;t=this.el.components.raycaster.getIntersection(n),this.eventDetail.intersectedEl=n,this.eventDetail.intersection=t,s.emit(e,this.eventDetail),n&&(this.intersectedEventDetail.intersection=t,n.emit(e,this.intersectedEventDetail))}}); },{"../core/component":124,"../utils/":197}],76:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,bind=_dereq_("../utils/bind"),trackedControlsUtils=_dereq_("../utils/tracked-controls"),checkControllerPresentAndSetup=trackedControlsUtils.checkControllerPresentAndSetup,emitIfAxesChanged=trackedControlsUtils.emitIfAxesChanged,onButtonEvent=trackedControlsUtils.onButtonEvent,DAYDREAM_CONTROLLER_MODEL_BASE_URL="https://cdn.aframe.io/controllers/google/",DAYDREAM_CONTROLLER_MODEL_OBJ_URL=DAYDREAM_CONTROLLER_MODEL_BASE_URL+"vr_controller_daydream.obj",DAYDREAM_CONTROLLER_MODEL_OBJ_MTL=DAYDREAM_CONTROLLER_MODEL_BASE_URL+"vr_controller_daydream.mtl",GAMEPAD_ID_PREFIX="Daydream Controller";module.exports.Component=registerComponent("daydream-controls",{schema:{hand:{default:""},buttonColor:{type:"color",default:"#000000"},buttonTouchedColor:{type:"color",default:"#777777"},buttonHighlightColor:{type:"color",default:"#FFFFFF"},model:{default:!0},orientationOffset:{type:"vec3"},armModel:{default:!0}},mapping:{axes:{trackpad:[0,1]},buttons:["trackpad","menu","system"]},bindMethods:function(){this.onModelLoaded=bind(this.onModelLoaded,this),this.onControllersUpdate=bind(this.onControllersUpdate,this),this.checkIfControllerPresent=bind(this.checkIfControllerPresent,this),this.removeControllersUpdateListener=bind(this.removeControllersUpdateListener,this),this.onAxisMoved=bind(this.onAxisMoved,this)},init:function(){var t=this;this.onButtonChanged=bind(this.onButtonChanged,this),this.onButtonDown=function(e){onButtonEvent(e.detail.id,"down",t)},this.onButtonUp=function(e){onButtonEvent(e.detail.id,"up",t)},this.onButtonTouchStart=function(e){onButtonEvent(e.detail.id,"touchstart",t)},this.onButtonTouchEnd=function(e){onButtonEvent(e.detail.id,"touchend",t)},this.controllerPresent=!1,this.lastControllerCheck=0,this.bindMethods()},addEventListeners:function(){var t=this.el;t.addEventListener("buttonchanged",this.onButtonChanged),t.addEventListener("buttondown",this.onButtonDown),t.addEventListener("buttonup",this.onButtonUp),t.addEventListener("touchstart",this.onButtonTouchStart),t.addEventListener("touchend",this.onButtonTouchEnd),t.addEventListener("model-loaded",this.onModelLoaded),t.addEventListener("axismove",this.onAxisMoved),this.controllerEventsActive=!0},removeEventListeners:function(){var t=this.el;t.removeEventListener("buttonchanged",this.onButtonChanged),t.removeEventListener("buttondown",this.onButtonDown),t.removeEventListener("buttonup",this.onButtonUp),t.removeEventListener("touchstart",this.onButtonTouchStart),t.removeEventListener("touchend",this.onButtonTouchEnd),t.removeEventListener("model-loaded",this.onModelLoaded),t.removeEventListener("axismove",this.onAxisMoved),this.controllerEventsActive=!1},checkIfControllerPresent:function(){checkControllerPresentAndSetup(this,GAMEPAD_ID_PREFIX,{hand:this.data.hand})},play:function(){this.checkIfControllerPresent(),this.addControllersUpdateListener()},pause:function(){this.removeEventListeners(),this.removeControllersUpdateListener()},injectTrackedControls:function(){var t=this.el,e=this.data;t.setAttribute("tracked-controls",{armModel:e.armModel,hand:e.hand,idPrefix:GAMEPAD_ID_PREFIX,orientationOffset:e.orientationOffset}),this.data.model&&this.el.setAttribute("obj-model",{obj:DAYDREAM_CONTROLLER_MODEL_OBJ_URL,mtl:DAYDREAM_CONTROLLER_MODEL_OBJ_MTL})},addControllersUpdateListener:function(){this.el.sceneEl.addEventListener("controllersupdated",this.onControllersUpdate,!1)},removeControllersUpdateListener:function(){this.el.sceneEl.removeEventListener("controllersupdated",this.onControllersUpdate,!1)},onControllersUpdate:function(){this.checkIfControllerPresent()},onModelLoaded:function(t){var e,o=t.detail.model;this.data.model&&(e=this.buttonMeshes={},e.menu=o.getObjectByName("AppButton_AppButton_Cylinder.004"),e.system=o.getObjectByName("HomeButton_HomeButton_Cylinder.005"),e.trackpad=o.getObjectByName("TouchPad_TouchPad_Cylinder.003"),o.position.set(0,0,-.04))},onAxisMoved:function(t){emitIfAxesChanged(this,this.mapping.axes,t)},onButtonChanged:function(t){var e=this.mapping.buttons[t.detail.id];e&&this.el.emit(e+"changed",t.detail.state)},updateModel:function(t,e){this.data.model&&this.updateButtonModel(t,e)},updateButtonModel:function(t,e){var o=this.buttonMeshes;if(o&&o[t]){var n;switch(e){case"down":n=this.data.buttonHighlightColor;break;case"touchstart":n=this.data.buttonTouchedColor;break;default:n=this.data.buttonColor}o[t].material.color.set(n)}}}); },{"../core/component":124,"../utils/bind":191,"../utils/tracked-controls":205}],77:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,bind=_dereq_("../utils/bind"),trackedControlsUtils=_dereq_("../utils/tracked-controls"),checkControllerPresentAndSetup=trackedControlsUtils.checkControllerPresentAndSetup,emitIfAxesChanged=trackedControlsUtils.emitIfAxesChanged,onButtonEvent=trackedControlsUtils.onButtonEvent,GEARVR_CONTROLLER_MODEL_BASE_URL="https://cdn.aframe.io/controllers/samsung/",GEARVR_CONTROLLER_MODEL_OBJ_URL=GEARVR_CONTROLLER_MODEL_BASE_URL+"gear_vr_controller.obj",GEARVR_CONTROLLER_MODEL_OBJ_MTL=GEARVR_CONTROLLER_MODEL_BASE_URL+"gear_vr_controller.mtl",GAMEPAD_ID_PREFIX="Gear VR";module.exports.Component=registerComponent("gearvr-controls",{schema:{hand:{default:""},buttonColor:{type:"color",default:"#000000"},buttonTouchedColor:{type:"color",default:"#777777"},buttonHighlightColor:{type:"color",default:"#FFFFFF"},model:{default:!0},orientationOffset:{type:"vec3"},armModel:{default:!0}},mapping:{axes:{trackpad:[0,1]},buttons:["trackpad","trigger"]},bindMethods:function(){this.onModelLoaded=bind(this.onModelLoaded,this),this.onControllersUpdate=bind(this.onControllersUpdate,this),this.checkIfControllerPresent=bind(this.checkIfControllerPresent,this),this.removeControllersUpdateListener=bind(this.removeControllersUpdateListener,this),this.onAxisMoved=bind(this.onAxisMoved,this)},init:function(){var t=this;this.onButtonChanged=bind(this.onButtonChanged,this),this.onButtonDown=function(e){onButtonEvent(e.detail.id,"down",t)},this.onButtonUp=function(e){onButtonEvent(e.detail.id,"up",t)},this.onButtonTouchStart=function(e){onButtonEvent(e.detail.id,"touchstart",t)},this.onButtonTouchEnd=function(e){onButtonEvent(e.detail.id,"touchend",t)},this.controllerPresent=!1,this.lastControllerCheck=0,this.bindMethods()},addEventListeners:function(){var t=this.el;t.addEventListener("buttonchanged",this.onButtonChanged),t.addEventListener("buttondown",this.onButtonDown),t.addEventListener("buttonup",this.onButtonUp),t.addEventListener("touchstart",this.onButtonTouchStart),t.addEventListener("touchend",this.onButtonTouchEnd),t.addEventListener("model-loaded",this.onModelLoaded),t.addEventListener("axismove",this.onAxisMoved),this.controllerEventsActive=!0},removeEventListeners:function(){var t=this.el;t.removeEventListener("buttonchanged",this.onButtonChanged),t.removeEventListener("buttondown",this.onButtonDown),t.removeEventListener("buttonup",this.onButtonUp),t.removeEventListener("touchstart",this.onButtonTouchStart),t.removeEventListener("touchend",this.onButtonTouchEnd),t.removeEventListener("model-loaded",this.onModelLoaded),t.removeEventListener("axismove",this.onAxisMoved),this.controllerEventsActive=!1},checkIfControllerPresent:function(){checkControllerPresentAndSetup(this,GAMEPAD_ID_PREFIX,this.data.hand?{hand:this.data.hand}:{})},play:function(){this.checkIfControllerPresent(),this.addControllersUpdateListener()},pause:function(){this.removeEventListeners(),this.removeControllersUpdateListener()},injectTrackedControls:function(){var t=this.el,e=this.data;t.setAttribute("tracked-controls",{armModel:e.armModel,idPrefix:GAMEPAD_ID_PREFIX,orientationOffset:e.orientationOffset}),this.data.model&&this.el.setAttribute("obj-model",{obj:GEARVR_CONTROLLER_MODEL_OBJ_URL,mtl:GEARVR_CONTROLLER_MODEL_OBJ_MTL})},addControllersUpdateListener:function(){this.el.sceneEl.addEventListener("controllersupdated",this.onControllersUpdate,!1)},removeControllersUpdateListener:function(){this.el.sceneEl.removeEventListener("controllersupdated",this.onControllersUpdate,!1)},onControllersUpdate:function(){this.checkIfControllerPresent()},onModelLoaded:function(t){var e,o=t.detail.model;this.data.model&&(e=this.buttonMeshes={},e.trigger=o.children[2],e.trackpad=o.children[1])},onButtonChanged:function(t){var e=this.mapping.buttons[t.detail.id];e&&this.el.emit(e+"changed",t.detail.state)},onAxisMoved:function(t){emitIfAxesChanged(this,this.mapping.axes,t)},updateModel:function(t,e){this.data.model&&this.updateButtonModel(t,e)},updateButtonModel:function(t,e){var o=this.buttonMeshes;if(o&&o[t]){var n;switch(e){case"down":n=this.data.buttonHighlightColor;break;case"touchstart":n=this.data.buttonTouchedColor;break;default:n=this.data.buttonColor}o[t].material.color.set(n)}}}); },{"../core/component":124,"../utils/bind":191,"../utils/tracked-controls":205}],78:[function(_dereq_,module,exports){ var geometries=_dereq_("../core/geometry").geometries,geometryNames=_dereq_("../core/geometry").geometryNames,registerComponent=_dereq_("../core/component").registerComponent,THREE=_dereq_("../lib/three"),dummyGeometry=new THREE.Geometry;module.exports.Component=registerComponent("geometry",{schema:{buffer:{default:!0},primitive:{default:"box",oneOf:geometryNames,schemaChange:!0},skipCache:{default:!1}},init:function(){this.geometry=null},update:function(e){var t,r=this.data,m=this.el,o=this.system;this.geometry&&(o.unuseGeometry(e),this.geometry=null),this.geometry=o.getOrCreateGeometry(r),t=m.getObject3D("mesh"),t?t.geometry=this.geometry:(t=new THREE.Mesh,t.geometry=this.geometry,m.setObject3D("mesh",t))},remove:function(){this.system.unuseGeometry(this.data),this.el.getObject3D("mesh").geometry=dummyGeometry,this.geometry=null},updateSchema:function(e){var t=this.oldData&&this.oldData.primitive,r=e.primitive,m=geometries[r]&&geometries[r].schema;if(!m)throw new Error("Unknown geometry schema `"+r+"`");t&&t===r||this.extendSchema(m)}}); },{"../core/component":124,"../core/geometry":125,"../lib/three":172}],79:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,THREE=_dereq_("../lib/three"),utils=_dereq_("../utils/"),warn=utils.debug("components:gltf-model:warn");module.exports.Component=registerComponent("gltf-model",{schema:{type:"model"},init:function(){var e=this.system.getDRACOLoader();this.model=null,this.loader=new THREE.GLTFLoader,e&&this.loader.setDRACOLoader(e)},update:function(){var e=this,o=this.el,t=this.data;t&&(this.remove(),this.loader.load(t,function(t){e.model=t.scene||t.scenes[0],e.model.animations=t.animations,o.setObject3D("mesh",e.model),o.emit("model-loaded",{format:"gltf",model:e.model})},void 0,function(e){var r=e&&e.message?e.message:"Failed to load glTF model";warn(r),o.emit("model-error",{format:"gltf",src:t})}))},remove:function(){this.model&&this.el.removeObject3D("mesh")}}); },{"../core/component":124,"../lib/three":172,"../utils/":197}],80:[function(_dereq_,module,exports){ function getGestureEventName(t,e){var n;if(t)return n=EVENTS[t],"grip"===n?n+(e?"close":"open"):"point"===n?n+(e?"up":"down"):"pointing"===n||"pistol"===n?n+(e?"start":"end"):void 0}function isViveController(t){var e=t&&t.controller&&t.controller.id;return e&&0===e.indexOf("OpenVR ")}var registerComponent=_dereq_("../core/component").registerComponent,MODEL_URLS={left:"https://cdn.aframe.io/controllers/hands/leftHand.glb",right:"https://cdn.aframe.io/controllers/hands/rightHand.glb"},ANIMATIONS={open:"Open",point:"Point",pointThumb:"Point + Thumb",fist:"Fist",hold:"Hold",thumbUp:"Thumb Up"},EVENTS={};EVENTS[ANIMATIONS.fist]="grip",EVENTS[ANIMATIONS.thumbUp]="pistol",EVENTS[ANIMATIONS.point]="pointing",module.exports.Component=registerComponent("hand-controls",{schema:{default:"left"},init:function(){var t=this,e=this.el;this.gesture=ANIMATIONS.open,this.pressedButtons={},this.touchedButtons={},this.loader=new THREE.GLTFLoader,this.loader.setCrossOrigin("anonymous"),this.onGripDown=function(){t.handleButton("grip","down")},this.onGripUp=function(){t.handleButton("grip","up")},this.onTrackpadDown=function(){t.handleButton("trackpad","down")},this.onTrackpadUp=function(){t.handleButton("trackpad","up")},this.onTrackpadTouchStart=function(){t.handleButton("trackpad","touchstart")},this.onTrackpadTouchEnd=function(){t.handleButton("trackpad","touchend")},this.onTriggerDown=function(){t.handleButton("trigger","down")},this.onTriggerUp=function(){t.handleButton("trigger","up")},this.onTriggerTouchStart=function(){t.handleButton("trigger","touchstart")},this.onTriggerTouchEnd=function(){t.handleButton("trigger","touchend")},this.onGripTouchStart=function(){t.handleButton("grip","touchstart")},this.onGripTouchEnd=function(){t.handleButton("grip","touchend")},this.onThumbstickDown=function(){t.handleButton("thumbstick","down")},this.onThumbstickUp=function(){t.handleButton("thumbstick","up")},this.onAorXTouchStart=function(){t.handleButton("AorX","touchstart")},this.onAorXTouchEnd=function(){t.handleButton("AorX","touchend")},this.onBorYTouchStart=function(){t.handleButton("BorY","touchstart")},this.onBorYTouchEnd=function(){t.handleButton("BorY","touchend")},this.onSurfaceTouchStart=function(){t.handleButton("surface","touchstart")},this.onSurfaceTouchEnd=function(){t.handleButton("surface","touchend")},e.addEventListener("controllerconnected",this.onControllerConnected),e.addEventListener("controllerdisconnected",this.onControllerDisconnected),e.object3D.visible=!1},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners()},tick:function(t,e){var n=this.el.getObject3D("mesh");n&&n.mixer&&n.mixer.update(e/1e3)},addEventListeners:function(){var t=this.el;t.addEventListener("gripdown",this.onGripDown),t.addEventListener("gripup",this.onGripUp),t.addEventListener("trackpaddown",this.onTrackpadDown),t.addEventListener("trackpadup",this.onTrackpadUp),t.addEventListener("trackpadtouchstart",this.onTrackpadTouchStart),t.addEventListener("trackpadtouchend",this.onTrackpadTouchEnd),t.addEventListener("triggerdown",this.onTriggerDown),t.addEventListener("triggerup",this.onTriggerUp),t.addEventListener("triggertouchstart",this.onTriggerTouchStart),t.addEventListener("triggertouchend",this.onTriggerTouchEnd),t.addEventListener("griptouchstart",this.onGripTouchStart),t.addEventListener("griptouchend",this.onGripTouchEnd),t.addEventListener("thumbstickdown",this.onThumbstickDown),t.addEventListener("thumbstickup",this.onThumbstickUp),t.addEventListener("abuttontouchstart",this.onAorXTouchStart),t.addEventListener("abuttontouchend",this.onAorXTouchEnd),t.addEventListener("bbuttontouchstart",this.onBorYTouchStart),t.addEventListener("bbuttontouchend",this.onBorYTouchEnd),t.addEventListener("xbuttontouchstart",this.onAorXTouchStart),t.addEventListener("xbuttontouchend",this.onAorXTouchEnd),t.addEventListener("ybuttontouchstart",this.onBorYTouchStart),t.addEventListener("ybuttontouchend",this.onBorYTouchEnd),t.addEventListener("surfacetouchstart",this.onSurfaceTouchStart),t.addEventListener("surfacetouchend",this.onSurfaceTouchEnd)},removeEventListeners:function(){var t=this.el;t.removeEventListener("gripdown",this.onGripDown),t.removeEventListener("gripup",this.onGripUp),t.removeEventListener("trackpaddown",this.onTrackpadDown),t.removeEventListener("trackpadup",this.onTrackpadUp),t.removeEventListener("trackpadtouchstart",this.onTrackpadTouchStart),t.removeEventListener("trackpadtouchend",this.onTrackpadTouchEnd),t.removeEventListener("triggerdown",this.onTriggerDown),t.removeEventListener("triggerup",this.onTriggerUp),t.removeEventListener("triggertouchstart",this.onTriggerTouchStart),t.removeEventListener("triggertouchend",this.onTriggerTouchEnd),t.removeEventListener("griptouchstart",this.onGripTouchStart),t.removeEventListener("griptouchend",this.onGripTouchEnd),t.removeEventListener("thumbstickdown",this.onThumbstickDown),t.removeEventListener("thumbstickup",this.onThumbstickUp),t.removeEventListener("abuttontouchstart",this.onAorXTouchStart),t.removeEventListener("abuttontouchend",this.onAorXTouchEnd),t.removeEventListener("bbuttontouchstart",this.onBorYTouchStart),t.removeEventListener("bbuttontouchend",this.onBorYTouchEnd),t.removeEventListener("xbuttontouchstart",this.onAorXTouchStart),t.removeEventListener("xbuttontouchend",this.onAorXTouchEnd),t.removeEventListener("ybuttontouchstart",this.onBorYTouchStart),t.removeEventListener("ybuttontouchend",this.onBorYTouchEnd),t.removeEventListener("surfacetouchstart",this.onSurfaceTouchStart),t.removeEventListener("surfacetouchend",this.onSurfaceTouchEnd)},update:function(t){var e,n=this.el,o=this.data,r=this;e={hand:o,model:!1,orientationOffset:{x:0,y:0,z:"left"===o?90:-90}},o!==t&&this.loader.load(MODEL_URLS[o],function(t){var o=t.scene.children[0];o.mixer=new THREE.AnimationMixer(o),r.clips=t.animations,n.setObject3D("mesh",o),o.position.set(0,0,0),o.rotation.set(0,0,0),n.setAttribute("vive-controls",e),n.setAttribute("oculus-touch-controls",e),n.setAttribute("windows-motion-controls",e)})},remove:function(){this.el.removeObject3D("mesh")},handleButton:function(t,e){var n,o="down"===e,r="touchstart"===e;if(0===e.indexOf("touch")){if(r===this.touchedButtons[t])return;this.touchedButtons[t]=r}else{if(o===this.pressedButtons[t])return;this.pressedButtons[t]=o}n=this.gesture,this.gesture=this.determineGesture(),this.gesture!==n&&(this.animateGesture(this.gesture,n),this.emitGestureEvents(this.gesture,n))},determineGesture:function(){var t,e=this.pressedButtons.grip,n=this.pressedButtons.surface||this.touchedButtons.surface,o=this.pressedButtons.trackpad||this.touchedButtons.trackpad,r=this.pressedButtons.trigger||this.touchedButtons.trigger,i=this.touchedButtons.AorX||this.touchedButtons.BorY;return isViveController(this.el.components["tracked-controls"])?e||r?t=ANIMATIONS.fist:o&&(t=ANIMATIONS.point):e?t=n||i||o?r?ANIMATIONS.fist:ANIMATIONS.point:r?ANIMATIONS.thumbUp:ANIMATIONS.pointThumb:r&&(t=ANIMATIONS.hold),t},getClip:function(t){var e,n;for(n=0;n20)this.previousQuaternion||(this.quaternionClone.copy(i),this.previousQuaternion=this.quaternionClone),s.lookAt(e);else{if(o=this.calculateCameraPortalOrientation(),a<.5){if(!0===this.semiSphereEl.getAttribute("visible"))return;d.setAttribute("text","width",1.5),o<=0?(d.setAttribute("position","0 0 0.75"),d.setAttribute("rotation","0 180 0"),this.semiSphereEl.setAttribute("rotation","0 0 0")):(d.setAttribute("position","0 0 -0.75"),d.setAttribute("rotation","0 0 0"),this.semiSphereEl.setAttribute("rotation","0 180 0")),n.getObject3D("mesh").visible=!1,this.semiSphereEl.setAttribute("visible",!0),this.peekCameraPortalOrientation=o}else o<=0?d.setAttribute("rotation","0 180 0"):d.setAttribute("rotation","0 0 0"),d.setAttribute("text","width",5),d.setAttribute("position","0 1.5 0"),n.getObject3D("mesh").visible=!0,this.semiSphereEl.setAttribute("visible",!1),this.peekCameraPortalOrientation=void 0;this.previousQuaternion&&(s.quaternion.copy(this.previousQuaternion),this.previousQuaternion=void 0)}}}(),hideAll:function(){var e=this.el,t=this.hiddenEls,i=this;t.length>0||e.sceneEl.object3D.traverse(function(r){r&&r.el&&r.el.hasAttribute("link-controls")||r.el&&r!==e.sceneEl.object3D&&r.el!==e&&r.el!==i.sphereEl&&r.el!==e.sceneEl.cameraEl&&!1!==r.el.getAttribute("visible")&&r.el!==i.textEl&&r.el!==i.semiSphereEl&&(r.el.setAttribute("visible",!1),t.push(r.el))})},showAll:function(){this.hiddenEls.forEach(function(e){e.setAttribute("visible",!0)}),this.hiddenEls=[]},calculateCameraPortalOrientation:function(){var e=new THREE.Matrix4,t=new THREE.Vector3,i=new THREE.Vector3(0,0,1),r=new THREE.Vector3(0,0,0);return function(){var o=this.el,a=o.sceneEl.camera;return t.set(0,0,0),i.set(0,0,1),r.set(0,0,0),o.object3D.matrixWorld.extractRotation(e),i.applyMatrix4(e),o.object3D.updateMatrixWorld(),o.object3D.localToWorld(r),a.parent.parent.updateMatrixWorld(),a.parent.updateMatrixWorld(),a.updateMatrixWorld(),a.localToWorld(t),t.sub(r).normalize(),i.normalize(),Math.sign(i.dot(t))}}(),remove:function(){this.removeEventListener()}}),registerShader("portal",{schema:{borderEnabled:{default:1,type:"int",is:"uniform"},backgroundColor:{default:"red",type:"color",is:"uniform"},pano:{type:"map",is:"uniform"},strokeColor:{default:"white",type:"color",is:"uniform"}},vertexShader:["vec3 portalPosition;","varying vec3 vWorldPosition;","varying float vDistanceToCenter;","varying float vDistance;","void main() {","vDistanceToCenter = clamp(length(position - vec3(0.0, 0.0, 0.0)), 0.0, 1.0);","portalPosition = (modelMatrix * vec4(0.0, 0.0, 0.0, 1.0)).xyz;","vDistance = length(portalPosition - cameraPosition);","vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI2 0.15915494","uniform sampler2D pano;","uniform vec3 strokeColor;","uniform vec3 backgroundColor;","uniform float borderEnabled;","varying float vDistanceToCenter;","varying float vDistance;","varying vec3 vWorldPosition;","void main() {","vec3 direction = normalize(vWorldPosition - cameraPosition);","vec2 sampleUV;","float borderThickness = clamp(exp(-vDistance / 50.0), 0.6, 0.95);","sampleUV.y = saturate(direction.y * 0.5 + 0.5);","sampleUV.x = atan(direction.z, -direction.x) * -RECIPROCAL_PI2 + 0.5;","if (vDistanceToCenter > borderThickness && borderEnabled == 1.0) {","gl_FragColor = vec4(strokeColor, 1.0);","} else {","gl_FragColor = mix(texture2D(pano, sampleUV), vec4(backgroundColor, 1.0), clamp(pow((vDistance / 15.0), 2.0), 0.0, 1.0));","}","}"].join("\n")}); },{"../core/component":124,"../core/shader":134,"../lib/three":172}],86:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,THREE=_dereq_("../lib/three"),utils=_dereq_("../utils/"),bind=utils.bind,PolyfillControls=_dereq_("../utils").device.PolyfillControls,PI_2=Math.PI/2;module.exports.Component=registerComponent("look-controls",{dependencies:["position","rotation"],schema:{enabled:{default:!0},hmdEnabled:{default:!0},pointerLockEnabled:{default:!1},reverseMouseDrag:{default:!1},reverseTouchDrag:{default:!1},touchEnabled:{default:!0}},init:function(){this.previousHMDPosition=new THREE.Vector3,this.hmdQuaternion=new THREE.Quaternion,this.hmdEuler=new THREE.Euler,this.position=new THREE.Vector3,this.savedRotation=new THREE.Vector3,this.savedPosition=new THREE.Vector3,this.polyfillObject=new THREE.Object3D,this.polyfillControls=new PolyfillControls(this.polyfillObject),this.rotation={},this.deltaRotation={},this.savedPose=null,this.pointerLocked=!1,this.setupMouseControls(),this.bindMethods(),this.el.object3D.matrixAutoUpdate=!1,this.el.object3D.updateMatrix(),this.savedPose={position:new THREE.Vector3,rotation:new THREE.Euler},this.el.sceneEl.is("vr-mode")&&this.onEnterVR()},update:function(e){var t=this.data;t.enabled!==e.enabled&&this.updateGrabCursor(t.enabled),!e||t.hmdEnabled||e.hmdEnabled||(this.pitchObject.rotation.set(0,0,0),this.yawObject.rotation.set(0,0,0)),e&&!t.pointerLockEnabled!==e.pointerLockEnabled&&(this.removeEventListeners(),this.addEventListeners(),this.pointerLocked&&this.exitPointerLock())},tick:function(e){this.data.enabled&&this.updateOrientation()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.pointerLocked&&this.exitPointerLock()},remove:function(){this.removeEventListeners(),this.pointerLocked&&this.exitPointerLock()},bindMethods:function(){this.onMouseDown=bind(this.onMouseDown,this),this.onMouseMove=bind(this.onMouseMove,this),this.onMouseUp=bind(this.onMouseUp,this),this.onTouchStart=bind(this.onTouchStart,this),this.onTouchMove=bind(this.onTouchMove,this),this.onTouchEnd=bind(this.onTouchEnd,this),this.onEnterVR=bind(this.onEnterVR,this),this.onExitVR=bind(this.onExitVR,this),this.onPointerLockChange=bind(this.onPointerLockChange,this),this.onPointerLockError=bind(this.onPointerLockError,this)},setupMouseControls:function(){this.mouseDown=!1,this.pitchObject=new THREE.Object3D,this.yawObject=new THREE.Object3D,this.yawObject.position.y=10,this.yawObject.add(this.pitchObject)},addEventListeners:function(){var e=this.el.sceneEl,t=e.canvas;if(!t)return void e.addEventListener("render-target-loaded",bind(this.addEventListeners,this));t.addEventListener("mousedown",this.onMouseDown,!1),window.addEventListener("mousemove",this.onMouseMove,!1),window.addEventListener("mouseup",this.onMouseUp,!1),t.addEventListener("touchstart",this.onTouchStart),window.addEventListener("touchmove",this.onTouchMove),window.addEventListener("touchend",this.onTouchEnd),e.addEventListener("enter-vr",this.onEnterVR),e.addEventListener("exit-vr",this.onExitVR),this.data.pointerLockEnabled&&(document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this.onPointerLockChange,!1),document.addEventListener("pointerlockerror",this.onPointerLockError,!1))},removeEventListeners:function(){var e=this.el.sceneEl,t=e&&e.canvas;t&&(t.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),t.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd),e.removeEventListener("enter-vr",this.onEnterVR),e.removeEventListener("exit-vr",this.onExitVR),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1),document.removeEventListener("mozpointerlockchange",this.onPointerLockChange,!1),document.removeEventListener("pointerlockerror",this.onPointerLockError,!1))},updateOrientation:function(){var e=new THREE.Matrix4;return function(){var t,o=this.hmdEuler,n=this.el.object3D,i=this.pitchObject,s=this.yawObject,r=this.el.sceneEl;r.is("vr-mode")&&r.hasWebXR?(t=r.renderer.vr.getCameraPose())&&(e.elements=t.transform.matrix,e.decompose(n.position,n.rotation,n.scale)):n.updateMatrix(),r.is("vr-mode")&&r.checkHeadsetConnected()||(this.polyfillControls.update(),o.setFromQuaternion(this.polyfillObject.quaternion,"YXZ"),n.rotation.x=o.x+i.rotation.x,n.rotation.y=o.y+s.rotation.y)}}(),onMouseMove:function(e){var t,o,n,i=this.pitchObject,s=this.previousMouseEvent,r=this.yawObject;this.data.enabled&&(this.mouseDown||this.pointerLocked)&&(this.pointerLocked?(o=e.movementX||e.mozMovementX||0,n=e.movementY||e.mozMovementY||0):(o=e.screenX-s.screenX,n=e.screenY-s.screenY),this.previousMouseEvent=e,t=this.data.reverseMouseDrag?1:-1,r.rotation.y+=.002*o*t,i.rotation.x+=.002*n*t,i.rotation.x=Math.max(-PI_2,Math.min(PI_2,i.rotation.x)))},onMouseDown:function(e){if(this.data.enabled&&0===e.button){var t=this.el.sceneEl,o=t&&t.canvas;this.mouseDown=!0,this.previousMouseEvent=e,this.showGrabbingCursor(),this.data.pointerLockEnabled&&!this.pointerLocked&&(o.requestPointerLock?o.requestPointerLock():o.mozRequestPointerLock&&o.mozRequestPointerLock())}},showGrabbingCursor:function(){this.el.sceneEl.canvas.style.cursor="grabbing"},hideGrabbingCursor:function(){this.el.sceneEl.canvas.style.cursor=""},onMouseUp:function(){this.mouseDown=!1,this.hideGrabbingCursor()},onTouchStart:function(e){1===e.touches.length&&this.data.touchEnabled&&(this.touchStart={x:e.touches[0].pageX,y:e.touches[0].pageY},this.touchStarted=!0)},onTouchMove:function(e){var t,o,n=this.el.sceneEl.canvas,i=this.yawObject;this.touchStarted&&this.data.touchEnabled&&(o=2*Math.PI*(e.touches[0].pageX-this.touchStart.x)/n.clientWidth,t=this.data.reverseTouchDrag?1:-1,i.rotation.y-=.5*o*t,this.touchStart={x:e.touches[0].pageX,y:e.touches[0].pageY})},onTouchEnd:function(){this.touchStarted=!1},onEnterVR:function(){this.el.sceneEl.checkHeadsetConnected()&&(this.saveCameraPose(),this.el.object3D.position.set(0,0,0),this.el.object3D.updateMatrix())},onExitVR:function(){this.el.sceneEl.checkHeadsetConnected()&&(this.restoreCameraPose(),this.previousHMDPosition.set(0,0,0))},onPointerLockChange:function(){this.pointerLocked=!(!document.pointerLockElement&&!document.mozPointerLockElement)},onPointerLockError:function(){this.pointerLocked=!1},exitPointerLock:function(){document.exitPointerLock(),this.pointerLocked=!1},updateGrabCursor:function(e){function t(){n.canvas.classList.add("a-grab-cursor")}function o(){n.canvas.classList.remove("a-grab-cursor")}var n=this.el.sceneEl;return n.canvas?e?void t():void o():void(e?n.addEventListener("render-target-loaded",t):n.addEventListener("render-target-loaded",o))},saveCameraPose:function(){var e=this.el;this.savedPose.position.copy(e.object3D.position),this.savedPose.rotation.copy(e.object3D.rotation),this.hasSavedPose=!0},restoreCameraPose:function(){var e=this.el,t=this.savedPose;this.hasSavedPose&&(e.object3D.position.copy(t.position),e.object3D.rotation.copy(t.rotation),this.hasSavedPose=!1)}}); },{"../core/component":124,"../lib/three":172,"../utils":197,"../utils/":197}],87:[function(_dereq_,module,exports){ function parseSide(e){switch(e){case"back":return THREE.BackSide;case"double":return THREE.DoubleSide;default:return THREE.FrontSide}}function parseVertexColors(e){switch(e){case"face":return THREE.FaceColors;case"vertex":return THREE.VertexColors;default:return THREE.NoColors}}function parseBlending(e){switch(e){case"none":return THREE.NoBlending;case"additive":return THREE.AdditiveBlending;case"subtractive":return THREE.SubtractiveBlending;case"multiply":return THREE.MultiplyBlending;default:return THREE.NormalBlending}}function disposeMaterial(e,t){e.dispose(),t.unregisterMaterial(e)}var utils=_dereq_("../utils/"),component=_dereq_("../core/component"),THREE=_dereq_("../lib/three"),shader=_dereq_("../core/shader"),error=utils.debug("components:material:error"),registerComponent=component.registerComponent,shaders=shader.shaders,shaderNames=shader.shaderNames;module.exports.Component=registerComponent("material",{schema:{alphaTest:{default:0,min:0,max:1},depthTest:{default:!0},depthWrite:{default:!0},flatShading:{default:!1},npot:{default:!1},offset:{type:"vec2",default:{x:0,y:0}},opacity:{default:1,min:0,max:1},repeat:{type:"vec2",default:{x:1,y:1}},shader:{default:"standard",oneOf:shaderNames,schemaChange:!0},side:{default:"front",oneOf:["front","back","double"]},transparent:{default:!1},vertexColors:{type:"string",default:"none",oneOf:["face","vertex"]},visible:{default:!0},blending:{default:"normal",oneOf:["none","normal","additive","subtractive","multiply"]}},init:function(){this.material=null},update:function(e){var t=this.data;this.shader&&t.shader===e.shader||this.updateShader(t.shader),this.shader.update(this.data),this.updateMaterial(e)},updateSchema:function(e){var t,a,r,i;a=e&&e.shader,t=this.oldData&&this.oldData.shader,i=a||t,r=shaders[i]&&shaders[i].schema,r||error("Unknown shader schema "+i),t&&a===t||(this.extendSchema(r),this.updateBehavior())},updateBehavior:function(){function e(e,t){var r;for(r in a)a[r]=e;s.shader.update(a)}var t,a,r=this.el.sceneEl,i=this.schema,s=this;this.tick=void 0,a={};for(t in i)"time"===i[t].type&&(this.tick=e,a[t]=!0);r&&(this.tick?r.addBehavior(this):r.removeBehavior(this))},updateShader:function(e){var t,a=this.data,r=shaders[e]&&shaders[e].Shader;if(!r)throw new Error("Unknown shader "+e);t=this.shader=new r,t.el=this.el,t.init(a),this.setMaterial(t.material),this.updateSchema(a)},updateMaterial:function(e){var t,a=this.data,r=this.material;r.alphaTest=a.alphaTest,r.depthTest=!1!==a.depthTest,r.depthWrite=!1!==a.depthWrite,r.opacity=a.opacity,r.flatShading=a.flatShading,r.side=parseSide(a.side),r.transparent=!1!==a.transparent||a.opacity<1,r.vertexColors=parseVertexColors(a.vertexColors),r.visible=a.visible,r.blending=parseBlending(a.blending);for(t in e)break;!t||e.alphaTest===a.alphaTest&&e.side===a.side&&e.vertexColors===a.vertexColors||(r.needsUpdate=!0)},remove:function(){var e=new THREE.MeshBasicMaterial,t=this.material,a=this.el.getObject3D("mesh");a&&(a.material=e),disposeMaterial(t,this.system)},setMaterial:function(e){var t,a=this.el,r=this.system;this.material&&disposeMaterial(this.material,r),this.material=e,r.registerMaterial(e),t=a.getObject3D("mesh"),t?t.material=e:a.addEventListener("object3dset",function t(r){"mesh"===r.detail.type&&r.target===a&&(a.getObject3D("mesh").material=e,a.removeEventListener("object3dset",t))})}}); },{"../core/component":124,"../core/shader":134,"../lib/three":172,"../utils/":197}],88:[function(_dereq_,module,exports){ var debug=_dereq_("../utils/debug"),registerComponent=_dereq_("../core/component").registerComponent,THREE=_dereq_("../lib/three"),warn=debug("components:obj-model:warn");module.exports.Component=registerComponent("obj-model",{schema:{mtl:{type:"model"},obj:{type:"model"}},init:function(){var e=this;this.model=null,this.objLoader=new THREE.OBJLoader,this.mtlLoader=new THREE.MTLLoader(this.objLoader.manager),this.mtlLoader.crossOrigin="",this.el.addEventListener("componentinitialized",function(o){e.model&&"material"===o.detail.name&&e.applyMaterial()})},update:function(){var e=this.data;e.obj&&(this.resetMesh(),this.loadObj(e.obj,e.mtl))},remove:function(){this.model&&this.resetMesh()},resetMesh:function(){this.el.removeObject3D("mesh")},loadObj:function(e,o){var t=this,r=this.el,i=this.mtlLoader,a=this.objLoader,s=this.el.sceneEl.systems.renderer,n=o.substr(0,o.lastIndexOf("/")+1);if(o)return r.hasAttribute("material")&&warn("Material component properties are ignored when a .MTL is provided"),i.setResourcePath(n),void i.load(o,function(o){o.preload(),a.setMaterials(o),a.load(e,function(e){t.model=e,t.model.traverse(function(e){if(e.isMesh){var o=e.material;o.color&&s.applyColorCorrection(o.color),o.map&&s.applyColorCorrection(o.map),o.emissive&&s.applyColorCorrection(o.emissive),o.emissiveMap&&s.applyColorCorrection(o.emissiveMap)}}),r.setObject3D("mesh",e),r.emit("model-loaded",{format:"obj",model:e})})});a.load(e,function(e){t.model=e,t.applyMaterial(),r.setObject3D("mesh",e),r.emit("model-loaded",{format:"obj",model:e})})},applyMaterial:function(){var e=this.el.components.material;e&&this.model.traverse(function(o){o instanceof THREE.Mesh&&(o.material=e.material)})}}); },{"../core/component":124,"../lib/three":172,"../utils/debug":193}],89:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,bind=_dereq_("../utils/bind"),trackedControlsUtils=_dereq_("../utils/tracked-controls"),checkControllerPresentAndSetup=trackedControlsUtils.checkControllerPresentAndSetup,emitIfAxesChanged=trackedControlsUtils.emitIfAxesChanged,onButtonEvent=trackedControlsUtils.onButtonEvent,GAMEPAD_ID_PREFIX="Oculus Go",OCULUS_GO_CONTROLLER_MODEL_URL="https://cdn.aframe.io/controllers/oculus/go/oculus-go-controller.gltf";module.exports.Component=registerComponent("oculus-go-controls",{schema:{hand:{default:""},buttonColor:{type:"color",default:"#FFFFFF"},buttonTouchedColor:{type:"color",default:"#BBBBBB"},buttonHighlightColor:{type:"color",default:"#7A7A7A"},model:{default:!0},orientationOffset:{type:"vec3"},armModel:{default:!0}},mapping:{axes:{trackpad:[0,1]},buttons:["trackpad","trigger"]},bindMethods:function(){this.onModelLoaded=bind(this.onModelLoaded,this),this.onControllersUpdate=bind(this.onControllersUpdate,this),this.checkIfControllerPresent=bind(this.checkIfControllerPresent,this),this.removeControllersUpdateListener=bind(this.removeControllersUpdateListener,this),this.onAxisMoved=bind(this.onAxisMoved,this)},init:function(){var t=this;this.onButtonChanged=bind(this.onButtonChanged,this),this.onButtonDown=function(e){onButtonEvent(e.detail.id,"down",t)},this.onButtonUp=function(e){onButtonEvent(e.detail.id,"up",t)},this.onButtonTouchStart=function(e){onButtonEvent(e.detail.id,"touchstart",t)},this.onButtonTouchEnd=function(e){onButtonEvent(e.detail.id,"touchend",t)},this.controllerPresent=!1,this.lastControllerCheck=0,this.rendererSystem=this.el.sceneEl.systems.renderer,this.bindMethods()},addEventListeners:function(){var t=this.el;t.addEventListener("buttonchanged",this.onButtonChanged),t.addEventListener("buttondown",this.onButtonDown),t.addEventListener("buttonup",this.onButtonUp),t.addEventListener("touchstart",this.onButtonTouchStart),t.addEventListener("touchend",this.onButtonTouchEnd),t.addEventListener("model-loaded",this.onModelLoaded),t.addEventListener("axismove",this.onAxisMoved),this.controllerEventsActive=!0},removeEventListeners:function(){var t=this.el;t.removeEventListener("buttonchanged",this.onButtonChanged),t.removeEventListener("buttondown",this.onButtonDown),t.removeEventListener("buttonup",this.onButtonUp),t.removeEventListener("touchstart",this.onButtonTouchStart),t.removeEventListener("touchend",this.onButtonTouchEnd),t.removeEventListener("model-loaded",this.onModelLoaded),t.removeEventListener("axismove",this.onAxisMoved),this.controllerEventsActive=!1},checkIfControllerPresent:function(){checkControllerPresentAndSetup(this,GAMEPAD_ID_PREFIX,this.data.hand?{hand:this.data.hand}:{})},play:function(){this.checkIfControllerPresent(),this.addControllersUpdateListener()},pause:function(){this.removeEventListeners(),this.removeControllersUpdateListener()},injectTrackedControls:function(){var t=this.el,e=this.data;t.setAttribute("tracked-controls",{armModel:e.armModel,hand:e.hand,idPrefix:GAMEPAD_ID_PREFIX,orientationOffset:e.orientationOffset}),this.data.model&&this.el.setAttribute("gltf-model",OCULUS_GO_CONTROLLER_MODEL_URL)},addControllersUpdateListener:function(){this.el.sceneEl.addEventListener("controllersupdated",this.onControllersUpdate,!1)},removeControllersUpdateListener:function(){this.el.sceneEl.removeEventListener("controllersupdated",this.onControllersUpdate,!1)},onControllersUpdate:function(){this.checkIfControllerPresent()},onModelLoaded:function(t){var e,o=t.detail.model;this.data.model&&(e=this.buttonMeshes={},e.trigger=o.getObjectByName("oculus_go_button_trigger"),e.trackpad=o.getObjectByName("oculus_go_touchpad"))},onButtonChanged:function(t){var e=this.mapping.buttons[t.detail.id];e&&this.el.emit(e+"changed",t.detail.state)},onAxisMoved:function(t){emitIfAxesChanged(this,this.mapping.axes,t)},updateModel:function(t,e){this.data.model&&this.updateButtonModel(t,e)},updateButtonModel:function(t,e){var o=this.buttonMeshes;if(o&&o[t]){var n,s;switch(e){case"down":n=this.data.buttonHighlightColor;break;case"touchstart":n=this.data.buttonTouchedColor;break;default:n=this.data.buttonColor}s=o[t],s.material.color.set(n),this.rendererSystem.applyColorCorrection(s.material.color)}}}); },{"../core/component":124,"../utils/bind":191,"../utils/tracked-controls":205}],90:[function(_dereq_,module,exports){ var bind=_dereq_("../utils/bind"),registerComponent=_dereq_("../core/component").registerComponent,THREE=_dereq_("../lib/three"),trackedControlsUtils=_dereq_("../utils/tracked-controls"),checkControllerPresentAndSetup=trackedControlsUtils.checkControllerPresentAndSetup,emitIfAxesChanged=trackedControlsUtils.emitIfAxesChanged,onButtonEvent=trackedControlsUtils.onButtonEvent,TOUCH_CONTROLLER_MODEL_BASE_URL="https://cdn.aframe.io/controllers/oculus/oculus-touch-controller-",TOUCH_CONTROLLER_MODEL_URL={left:TOUCH_CONTROLLER_MODEL_BASE_URL+"left.gltf",right:TOUCH_CONTROLLER_MODEL_BASE_URL+"right.gltf"},GAMEPAD_ID_PREFIX="Oculus Touch",DEFAULT_MODEL_PIVOT_OFFSET=new THREE.Vector3(0,0,-.053),RAY_ORIGIN={left:{origin:{x:.008,y:-.004,z:0},direction:{x:0,y:-.8,z:-1}},right:{origin:{x:-.008,y:-.004,z:0},direction:{x:0,y:-.8,z:-1}}};module.exports.Component=registerComponent("oculus-touch-controls",{schema:{hand:{default:"left"},buttonColor:{type:"color",default:"#999"},buttonTouchColor:{type:"color",default:"#8AB"},buttonHighlightColor:{type:"color",default:"#2DF"},model:{default:!0},orientationOffset:{type:"vec3",default:{x:43,y:0,z:0}}},mapping:{left:{axes:{thumbstick:[0,1]},buttons:["thumbstick","trigger","grip","xbutton","ybutton","surface"]},right:{axes:{thumbstick:[0,1]},buttons:["thumbstick","trigger","grip","abutton","bbutton","surface"]}},bindMethods:function(){this.onModelLoaded=bind(this.onModelLoaded,this),this.onControllersUpdate=bind(this.onControllersUpdate,this),this.checkIfControllerPresent=bind(this.checkIfControllerPresent,this),this.onAxisMoved=bind(this.onAxisMoved,this)},init:function(){var t=this;this.onButtonChanged=bind(this.onButtonChanged,this),this.onButtonDown=function(e){onButtonEvent(e.detail.id,"down",t,t.data.hand)},this.onButtonUp=function(e){onButtonEvent(e.detail.id,"up",t,t.data.hand)},this.onButtonTouchStart=function(e){onButtonEvent(e.detail.id,"touchstart",t,t.data.hand)},this.onButtonTouchEnd=function(e){onButtonEvent(e.detail.id,"touchend",t,t.data.hand)},this.controllerPresent=!1,this.lastControllerCheck=0,this.previousButtonValues={},this.rendererSystem=this.el.sceneEl.systems.renderer,this.bindMethods()},addEventListeners:function(){var t=this.el;t.addEventListener("buttonchanged",this.onButtonChanged),t.addEventListener("buttondown",this.onButtonDown),t.addEventListener("buttonup",this.onButtonUp),t.addEventListener("touchstart",this.onButtonTouchStart),t.addEventListener("touchend",this.onButtonTouchEnd),t.addEventListener("axismove",this.onAxisMoved),t.addEventListener("model-loaded",this.onModelLoaded),this.controllerEventsActive=!0},removeEventListeners:function(){var t=this.el;t.removeEventListener("buttonchanged",this.onButtonChanged),t.removeEventListener("buttondown",this.onButtonDown),t.removeEventListener("buttonup",this.onButtonUp),t.removeEventListener("touchstart",this.onButtonTouchStart),t.removeEventListener("touchend",this.onButtonTouchEnd),t.removeEventListener("axismove",this.onAxisMoved),t.removeEventListener("model-loaded",this.onModelLoaded),this.controllerEventsActive=!1},checkIfControllerPresent:function(){checkControllerPresentAndSetup(this,GAMEPAD_ID_PREFIX,{hand:this.data.hand})},play:function(){this.checkIfControllerPresent(),this.addControllersUpdateListener()},pause:function(){this.removeEventListeners(),this.removeControllersUpdateListener()},loadModel:function(){var t=this.data;t.model&&this.el.setAttribute("gltf-model","url("+TOUCH_CONTROLLER_MODEL_URL[t.hand]+")")},injectTrackedControls:function(){var t=this.data;this.el.setAttribute("tracked-controls",{id:"right"===t.hand?"Oculus Touch (Right)":"Oculus Touch (Left)",controller:0,hand:t.hand,orientationOffset:t.orientationOffset}),this.loadModel()},addControllersUpdateListener:function(){this.el.sceneEl.addEventListener("controllersupdated",this.onControllersUpdate,!1)},removeControllersUpdateListener:function(){this.el.sceneEl.removeEventListener("controllersupdated",this.onControllersUpdate,!1)},onControllersUpdate:function(){this.checkIfControllerPresent()},onButtonChanged:function(t){var e,o=this.mapping[this.data.hand].buttons[t.detail.id],n=this.buttonMeshes;o&&("trigger"!==o&&"grip"!==o||(e=t.detail.state.value),n&&("trigger"===o&&n.trigger&&(n.trigger.rotation.x=this.originalXRotationTrigger-e*(Math.PI/26)),"grip"===o&&n.grip&&(n.grip.position.x=this.originalXPositionGrip+("left"===this.data.hand?-1:1)*e*.004)),this.el.emit(o+"changed",t.detail.state))},onModelLoaded:function(t){var e,o=t.detail.model;this.data.model&&(e=this.buttonMeshes={},e.grip=o.getObjectByName("buttonHand"),this.originalXPositionGrip=e.grip.position.x,e.thumbstick=o.getObjectByName("stick"),e.trigger=o.getObjectByName("buttonTrigger"),this.originalXRotationTrigger=e.trigger.rotation.x,e.xbutton=o.getObjectByName("buttonX"),e.abutton=o.getObjectByName("buttonA"),e.ybutton=o.getObjectByName("buttonY"),e.bbutton=o.getObjectByName("buttonB"),o.position.copy(DEFAULT_MODEL_PIVOT_OFFSET),this.el.emit("controllermodelready",{name:"oculus-touch-controls",model:this.data.model,rayOrigin:RAY_ORIGIN[this.data.hand]}))},onAxisMoved:function(t){emitIfAxesChanged(this,this.mapping[this.data.hand].axes,t)},updateModel:function(t,e){this.data.model&&this.updateButtonModel(t,e)},updateButtonModel:function(t,e){var o,n="up"===e||"touchend"===e?this.data.buttonColor:"touchstart"===e?this.data.buttonTouchColor:this.data.buttonHighlightColor,i=this.buttonMeshes;this.data.model&&i&&i[t]&&(o=i[t],o.material.color.set(n),this.rendererSystem.applyColorCorrection(o.material.color))}}); },{"../core/component":124,"../lib/three":172,"../utils/bind":191,"../utils/tracked-controls":205}],91:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent;module.exports.Component=registerComponent("position",{schema:{type:"vec3"},update:function(){var e=this.el.object3D,o=this.data;e.position.set(o.x,o.y,o.z)},remove:function(){this.el.object3D.position.set(0,0,0)}}); },{"../core/component":124}],92:[function(_dereq_,module,exports){ function copyArray(e,t){var i;for(e.length=t.length,i=0;i")},remove:function(){var e=this.el.object3D.fog;e&&(e.far=0,e.near=.1)}}); },{"../../core/component":124,"../../lib/three":172,"../../utils/debug":193}],99:[function(_dereq_,module,exports){ (function (process){ function getFuzzyPatchVersion(e){var n=e.split(".");return n[2]="x",n.join(".")}var AFRAME_INJECTED=_dereq_("../../constants").AFRAME_INJECTED,pkg=_dereq_("../../../package"),registerComponent=_dereq_("../../core/component").registerComponent,utils=_dereq_("../../utils/"),INSPECTOR_DEV_URL="https://aframe.io/aframe-inspector/dist/aframe-inspector.js",INSPECTOR_RELEASE_URL="https://unpkg.com/aframe-inspector@"+getFuzzyPatchVersion(pkg.version)+"/dist/aframe-inspector.min.js",INSPECTOR_URL="dev"===process.env.INSPECTOR_VERSION?INSPECTOR_DEV_URL:INSPECTOR_RELEASE_URL,LOADING_MESSAGE="Loading Inspector",LOADING_ERROR_MESSAGE="Error loading Inspector";module.exports.Component=registerComponent("inspector",{schema:{url:{default:INSPECTOR_URL}},init:function(){this.firstPlay=!0,this.onKeydown=this.onKeydown.bind(this),this.onMessage=this.onMessage.bind(this),this.initOverlay(),window.addEventListener("keydown",this.onKeydown),window.addEventListener("message",this.onMessage)},play:function(){var e;this.firstPlay&&"false"!==(e=utils.getUrlParameter("inspector"))&&e&&(this.openInspector(),this.firstPlay=!1)},initOverlay:function(){this.loadingMessageEl=document.createElement("div"),this.loadingMessageEl.classList.add("a-inspector-loader"),this.loadingMessageEl.innerHTML=LOADING_MESSAGE+'...'},remove:function(){this.removeEventListeners()},onKeydown:function(e){73===e.keyCode&&e.ctrlKey&&e.altKey&&this.openInspector()},showLoader:function(){document.body.appendChild(this.loadingMessageEl)},hideLoader:function(){document.body.removeChild(this.loadingMessageEl)},onMessage:function(e){"INJECT_AFRAME_INSPECTOR"===e.data&&this.openInspector()},openInspector:function(e){var n,t=this;if(AFRAME.INSPECTOR||AFRAME.inspectorInjected)return void AFRAME.INSPECTOR.open(e);this.showLoader(),n=document.createElement("script"),n.src=this.data.url,n.setAttribute("data-name","aframe-inspector"),n.setAttribute(AFRAME_INJECTED,""),n.onload=function(){AFRAME.INSPECTOR.open(e),t.hideLoader(),t.removeEventListeners()},n.onerror=function(){t.loadingMessageEl.innerHTML=LOADING_ERROR_MESSAGE},document.head.appendChild(n),AFRAME.inspectorInjected=!0},removeEventListeners:function(){window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("message",this.onMessage)}}); }).call(this,_dereq_('_process')) },{"../../../package":72,"../../constants":116,"../../core/component":124,"../../utils/":197,"_process":49}],100:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../../core/component").registerComponent,shouldCaptureKeyEvent=_dereq_("../../utils/").shouldCaptureKeyEvent;module.exports.Component=registerComponent("keyboard-shortcuts",{schema:{enterVR:{default:!0},exitVR:{default:!0}},init:function(){this.onKeyup=this.onKeyup.bind(this)},update:function(e){var t=this.data;this.enterVREnabled=t.enterVR},play:function(){window.addEventListener("keyup",this.onKeyup,!1)},pause:function(){window.removeEventListener("keyup",this.onKeyup)},onKeyup:function(e){var t=this.el;shouldCaptureKeyEvent(e)&&(this.enterVREnabled&&70===e.keyCode&&t.enterVR(),this.enterVREnabled&&27===e.keyCode&&t.exitVR())}}); },{"../../core/component":124,"../../utils/":197}],101:[function(_dereq_,module,exports){ var debug=_dereq_("../../utils/debug"),registerComponent=_dereq_("../../core/component").registerComponent,warn=debug("components:pool:warn");module.exports.Component=registerComponent("pool",{schema:{container:{default:""},mixin:{default:""},size:{default:0},dynamic:{default:!1}},multiple:!0,initPool:function(){var t;for(this.availableEls=[],this.usedEls=[],this.data.mixin||warn("No mixin provided for pool component."),this.data.container&&(this.container=document.querySelector(this.data.container),this.container||warn("Container "+this.data.container+" not found.")),this.container=this.container||this.el,t=0;t0&&(this.stopSound(),o.removeObject3D("sound"));var s=this.listener=i.audioListener||new THREE.AudioListener;for(i.audioListener=s,i.camera&&i.camera.add(s),i.addEventListener("camera-set-active",function(e){e.detail.cameraEl.getObject3D("camera").add(s)}),this.pool=new THREE.Group,e=0;e=0&&(e=30),e&&a.chars.map(function(t){t.yoffset+=e}),r(a)})})}function loadTexture(t){return new Promise(function(e,r){(new THREE.ImageLoader).load(t,function(t){e(t)},void 0,function(){error("Error loading font image",t),r(null)})})}function createShader(t,e,r){var n,o;return o=new shaders[e].Shader,o.el=t,o.init(r),o.update(r),n=o.material,n.transparent=r.transparent,{material:n,shader:o}}function computeWidth(t,e,r){return t||(.5+e)*r}function computeFontWidthFactor(t){var e=0,r=0,n=0;return t.chars.map(function(t){e+=t.xadvance,t.id>=48&&t.id<=57&&(n++,r+=t.xadvance)}),n?r/n:e/t.chars.length}function PromiseCache(){var t=this.cache={};this.get=function(e,r){return e in t?t[e]:(t[e]=r(),t[e])}}var createTextGeometry=_dereq_("three-bmfont-text"),loadBMFont=_dereq_("load-bmfont"),registerComponent=_dereq_("../core/component").registerComponent,coreShader=_dereq_("../core/shader"),THREE=_dereq_("../lib/three"),utils=_dereq_("../utils/"),error=utils.debug("components:text:error"),shaders=coreShader.shaders,warn=utils.debug("components:text:warn"),DEFAULT_WIDTH=1,MAX_ANISOTROPY=16,FONT_BASE_URL="https://cdn.aframe.io/fonts/",FONTS={aileronsemibold:FONT_BASE_URL+"Aileron-Semibold.fnt",dejavu:FONT_BASE_URL+"DejaVu-sdf.fnt",exo2bold:FONT_BASE_URL+"Exo2Bold.fnt",exo2semibold:FONT_BASE_URL+"Exo2SemiBold.fnt",kelsonsans:FONT_BASE_URL+"KelsonSans.fnt",monoid:FONT_BASE_URL+"Monoid.fnt",mozillavr:FONT_BASE_URL+"mozillavr.fnt",roboto:FONT_BASE_URL+"Roboto-msdf.json",sourcecodepro:FONT_BASE_URL+"SourceCodePro.fnt"},MSDF_FONTS=["roboto"],DEFAULT_FONT="roboto";module.exports.FONTS=FONTS;var cache=new PromiseCache,fontWidthFactors={},textures={},protocolRe=/^\w+:/;module.exports.Component=registerComponent("text",{multiple:!0,schema:{align:{type:"string",default:"left",oneOf:["left","right","center"]},alphaTest:{default:.5},anchor:{default:"center",oneOf:["left","right","center","align"]},baseline:{default:"center",oneOf:["top","center","bottom"]},color:{type:"color",default:"#FFF"},font:{type:"string",default:DEFAULT_FONT},fontImage:{type:"string"},height:{type:"number"},letterSpacing:{type:"number",default:0},lineHeight:{type:"number"},negate:{type:"boolean",default:!0},opacity:{type:"number",default:1},shader:{default:"sdf",oneOf:shaders},side:{default:"front",oneOf:["front","back","double"]},tabSize:{default:4},transparent:{default:!0},value:{type:"string"},whiteSpace:{default:"normal",oneOf:["normal","pre","nowrap"]},width:{type:"number"},wrapCount:{type:"number",default:40},wrapPixels:{type:"number"},xOffset:{type:"number",default:0},yOffset:{type:"number",default:0},zOffset:{type:"number",default:.001}},init:function(){this.shaderData={},this.geometry=createTextGeometry(),this.createOrUpdateMaterial(),this.mesh=new THREE.Mesh(this.geometry,this.material),this.el.setObject3D(this.attrName,this.mesh)},update:function(t){var e=this.data,r=this.currentFont;if(textures[e.font]?this.texture=textures[e.font]:(this.texture=textures[e.font]=new THREE.Texture,this.texture.anisotropy=MAX_ANISOTROPY),this.createOrUpdateMaterial(),t.font!==e.font)return void this.updateFont();r&&(this.updateGeometry(this.geometry,r),this.updateLayout())},remove:function(){this.geometry.dispose(),this.geometry=null,this.el.removeObject3D(this.attrName),this.material.dispose(),this.material=null,this.texture.dispose(),this.texture=null,this.shaderObject&&delete this.shaderObject},createOrUpdateMaterial:function(){var t,e,r,n=this.data,o=this.material,a=this.shaderData;if(r=n.shader,-1!==MSDF_FONTS.indexOf(n.font)||n.font.indexOf("-msdf.")>=0?r="msdf":n.font in FONTS&&-1===MSDF_FONTS.indexOf(n.font)&&(r="sdf"),t=(this.shaderObject&&this.shaderObject.name)!==r,a.alphaTest=n.alphaTest,a.color=n.color,a.map=this.texture,a.opacity=n.opacity,a.side=parseSide(n.side),a.transparent=n.transparent,a.negate=n.negate,!t)return this.shaderObject.update(a),o.transparent=a.transparent,void(o.side=a.side);e=createShader(this.el,r,a),this.material=e.material,this.shaderObject=e.shader,this.material.side=a.side,this.mesh&&(this.mesh.material=this.material)},updateFont:function(){var t,e=this.data,r=this.el,n=this.geometry,o=this;e.font||warn("No font specified. Using the default font."),this.mesh.visible=!1,t=this.lookupFont(e.font||DEFAULT_FONT)||e.font,cache.get(t,function(){return loadFont(t,e.yOffset)}).then(function(a){var i;if(1!==a.pages.length)throw new Error("Currently only single-page bitmap fonts are supported.");fontWidthFactors[t]||(a.widthFactor=fontWidthFactors[a]=computeFontWidthFactor(a)),o.updateGeometry(n,a),o.currentFont=a,o.updateLayout(),i=o.getFontImageSrc(),cache.get(i,function(){return loadTexture(i)}).then(function(t){var n=o.texture;n.image=t,n.needsUpdate=!0,textures[e.font]=n,o.texture=n,o.mesh.visible=!0,r.emit("textfontset",{font:e.font,fontObj:a})}).catch(function(t){error(t.message),error(t.stack)})}).catch(function(t){error(t.message),error(t.stack)})},getFontImageSrc:function(){if(this.data.fontImage)return this.data.fontImage;var t=this.lookupFont(this.data.font||DEFAULT_FONT)||this.data.font,e=this.currentFont.pages[0];return e.match(protocolRe)&&0!==e.indexOf("http")?t.replace(/(\.fnt)|(\.json)/,".png"):THREE.LoaderUtils.extractUrlBase(t)+e},updateLayout:function(){var t,e,r,n,o,a,i,s,h,u,d=this.el,l=this.data,f=this.geometry,c=this.mesh;if(f.layout){if(r=d.getAttribute("geometry"),s=l.width||r&&r.width||DEFAULT_WIDTH,a=computeWidth(l.wrapPixels,l.wrapCount,this.currentFont.widthFactor),i=s/a,o=f.layout,n=i*(o.height+o.descender),r&&"plane"===r.primitive&&(r.width||d.setAttribute("geometry","width",s),r.height||d.setAttribute("geometry","height",n)),"left"===(t="align"===l.anchor?l.align:l.anchor))h=0;else if("right"===t)h=-1*o.width;else{if("center"!==t)throw new TypeError("Invalid text.anchor property value",t);h=-1*o.width/2}if("bottom"===(e=l.baseline))u=0;else if("top"===e)u=-1*o.height+o.ascender;else{if("center"!==e)throw new TypeError("Invalid text.baseline property value",e);u=-1*o.height/2}c.position.x=h*i+l.xOffset,c.position.y=u*i,c.position.z=l.zOffset,c.scale.set(i,-1*i,i)}},lookupFont:function(t){return FONTS[t]},updateGeometry:function(){var t={},e={},r=/\\n/g,n=/\\t/g;return function(o,a){var i=this.data;e.font=a,e.lineHeight=i.lineHeight&&isFinite(i.lineHeight)?i.lineHeight:a.common.lineHeight,e.text=i.value.toString().replace(r,"\n").replace(n,"\t"),e.width=computeWidth(i.wrapPixels,i.wrapCount,a.widthFactor),o.update(utils.extend(t,i,e))}}()}); },{"../core/component":124,"../core/shader":134,"../lib/three":172,"../utils/":197,"load-bmfont":37,"three-bmfont-text":62}],108:[function(_dereq_,module,exports){ var registerComponent=_dereq_("../core/component").registerComponent,controllerUtils=_dereq_("../utils/tracked-controls"),DEFAULT_CAMERA_HEIGHT=_dereq_("../constants").DEFAULT_CAMERA_HEIGHT,THREE=_dereq_("../lib/three"),DEFAULT_HANDEDNESS=_dereq_("../constants").DEFAULT_HANDEDNESS,EYES_TO_ELBOW={x:.175,y:-.3,z:-.03},FOREARM={x:0,y:0,z:-.175},EMPTY_DAYDREAM_TOUCHES={touches:[]},EVENTS={AXISMOVE:"axismove",BUTTONCHANGED:"buttonchanged",BUTTONDOWN:"buttondown",BUTTONUP:"buttonup",TOUCHSTART:"touchstart",TOUCHEND:"touchend"};module.exports.Component=registerComponent("tracked-controls-webvr",{schema:{autoHide:{default:!0},controller:{default:0},id:{type:"string",default:""},hand:{type:"string",default:""},idPrefix:{type:"string",default:""},orientationOffset:{type:"vec3"},armModel:{default:!0},headElement:{type:"selector"}},init:function(){this.axis=this.el.components["tracked-controls"].axis=[0,0,0],this.buttonStates=this.el.components["tracked-controls"].buttonStates={},this.changedAxes=[],this.targetControllerNumber=this.data.controller,this.axisMoveEventDetail={axis:this.axis,changed:this.changedAxes},this.deltaControllerPosition=new THREE.Vector3,this.controllerQuaternion=new THREE.Quaternion,this.controllerEuler=new THREE.Euler,this.updateGamepad(),this.buttonEventDetails={}},tick:function(t,e){var o=this.el.getObject3D("mesh");o&&o.update&&o.update(e/1e3),this.updateGamepad(),this.updatePose(),this.updateButtons()},defaultUserHeight:function(){return DEFAULT_CAMERA_HEIGHT},getHeadElement:function(){return this.data.headElement||this.el.sceneEl.camera.el},updateGamepad:function(){var t=this.data,e=controllerUtils.findMatchingControllerWebVR(this.system.controllers,t.id,t.idPrefix,t.hand,t.controller);this.controller=e,this.el.components["tracked-controls"].controller=e,this.data.autoHide&&(this.el.object3D.visible=!!this.controller)},applyArmModel:function(t){var e,o,i,n,s,r=this.controller,a=this.controllerEuler,l=this.controllerQuaternion,h=this.deltaControllerPosition;o=this.getHeadElement(),i=o.object3D,s=this.defaultUserHeight(),n=r.pose,e=(r?r.hand:void 0)||DEFAULT_HANDEDNESS,t.copy(i.position),h.set(EYES_TO_ELBOW.x*("left"===e?-1:"right"===e?1:0),EYES_TO_ELBOW.y,EYES_TO_ELBOW.z),h.multiplyScalar(s),h.applyAxisAngle(i.up,i.rotation.y),t.add(h),h.set(FOREARM.x,FOREARM.y,FOREARM.z),h.multiplyScalar(s),n.orientation?l.fromArray(n.orientation):l.copy(i.quaternion),a.setFromQuaternion(l),a.set(a.x,a.y,0),h.applyEuler(a),t.add(h)},updatePose:function(){var t,e,o=this.controller,i=this.data,n=this.el.object3D,s=this.system.vrDisplay;o&&(t=o.pose,t.position?n.position.fromArray(t.position):i.armModel&&this.applyArmModel(n.position),t.orientation&&n.quaternion.fromArray(t.orientation),s&&t.position&&(e=this.el.sceneEl.renderer.vr.getStandingMatrix(),n.matrix.compose(n.position,n.quaternion,n.scale),n.matrix.multiplyMatrices(e,n.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale)),n.rotateX(this.data.orientationOffset.x*THREE.Math.DEG2RAD),n.rotateY(this.data.orientationOffset.y*THREE.Math.DEG2RAD),n.rotateZ(this.data.orientationOffset.z*THREE.Math.DEG2RAD))},updateButtons:function(){var t,e,o=this.controller;if(o){for(e=0;eMAX_DELTA)return d[i]=0,void(d[s]=0);var h=Math.pow(1/this.easing,60*e);0!==d[i]&&(d[i]-=d[i]*h),0!==d[s]&&(d[s]-=d[s]*h),Math.abs(d[i])=e.duration&&("VIDEO"===e.tagName&&(THREE.Cache.files[e.getAttribute("src")]=e),t())}return 4===e.readyState?t():e.error?r():(e.addEventListener("loadeddata",i,!1),e.addEventListener("progress",i,!1),void e.addEventListener("error",r,!1))})}function fixUpMediaElement(e){var t=setCrossOrigin(e);return t.tagName&&"video"===t.tagName.toLowerCase()&&(t.setAttribute("playsinline",""),t.setAttribute("webkit-playsinline","")),t!==e&&(e.parentNode.appendChild(t),e.parentNode.removeChild(e)),t}function setCrossOrigin(e){var t;if(e.hasAttribute("crossorigin"))return e;if(null!==(t=e.getAttribute("src"))){if(-1===t.indexOf("://"))return e;if(extractDomain(t)===window.location.host)return e}return warn('Cross-origin element (e.g., ) was requested without `crossorigin` set. A-Frame will re-request the asset with `crossorigin` attribute set. Please set `crossorigin` on the element (e.g., )',t),e.crossOrigin="anonymous",e.cloneNode(!0)}function extractDomain(e){var t=e.indexOf("://")>-1?e.split("/")[2]:e.split("/")[0];return t.substring(0,t.indexOf(":"))}function getArrayBuffer(e){for(var t=new ArrayBuffer(2*e.length),r=new Uint16Array(t),i=0,a=e.length;i must be a child of a .");for(a=this.querySelectorAll("img"),e=0;e did not contain exactly six elements each with a `src` attribute.")},writable:window.debug}})}); },{"../utils/debug":193,"./a-register-element":123}],120:[function(_dereq_,module,exports){ function checkComponentDefined(t,e){return!(!t.components[e]||!t.components[e].attrValue)||isComponentMixedIn(e,t.mixinEls)}function isComponentMixedIn(t,e){var i,n=!1;for(i=0;i2?s.slice(1).join("__"):s[1],COMPONENTS[a]&&(checkComponentDefined(this,t)||void 0!==e||i)&&!(t in this.components)){if(this.initComponentDependencies(a),o&&!COMPONENTS[a].multiple)throw new Error("Trying to initialize multiple components of type `"+a+"`. There can only be one component of this type per entity.");n=new COMPONENTS[a].Component(this,e,o),this.isPlaying&&n.play(),this.hasAttribute(t)||(n.justInitialized=!0,window.HTMLElement.prototype.setAttribute.call(this,t,"")),debug("Component initialized: %s",t)}},writable:window.debug},initComponentDependencies:{value:function(t){var e,i,n=this,o=COMPONENTS[t];if(o&&(e=COMPONENTS[t].dependencies))for(i=0;i0?e.substring(0,r):e,!COMPONENTS[a])return"mixin"===e&&this.mixinUpdate(i),void ANode.prototype.setAttribute.call(this,e,i);if(!this.components[e]&&this.hasAttribute(e)&&this.updateComponent(e,window.HTMLElement.prototype.getAttribute.call(this,e)),void 0!==n&&"string"==typeof i&&i.length>0&&"string"==typeof utils.styleParser.parse(i)){for(l in t)delete t[l];o=t,o[i]=n,s=!1}else o=i,s=!0===n;this.updateComponent(e,o,s),(h=this.sceneEl&&this.sceneEl.getAttribute("debug"))&&this.components[e].flushToDOM()}}(),writable:window.debug},flushToDOM:{value:function(t){var e,i,n,o=this.components,s=this.children;for(n in o)o[n].flushToDOM();if(t)for(i=0;i outside of an A-Frame scene. Append this element to `` instead."),this.hasLoaded=!1,this.emit("nodeready",void 0,!1),this.isMixin||(t=this.getAttribute("mixin"))&&this.updateMixins(t)},writable:window.debug},attributeChangedCallback:{value:function(t,e,i){i!==this.computedMixinStr&&("mixin"!==t||this.isMixin||this.updateMixins(i,e))}},closestScene:{value:function(){for(var t=this;t&&!t.isScene;)t=t.parentElement;return t}},closest:{value:function(t){for(var e=this.matches||this.mozMatchesSelector||this.msMatchesSelector||this.oMatchesSelector||this.webkitMatchesSelector,i=this;i&&!e.call(i,t);)i=i.parentElement;return i}},detachedCallback:{value:function(){this.hasLoaded=!1}},load:{value:function(t,e){var i,n,s=this;this.hasLoaded||(e=e||isNode,i=this.getChildren(),n=i.filter(e).map(function(t){return new Promise(function(e){if(t.hasLoaded)return e();t.addEventListener("loaded",e)})}),Promise.all(n).then(function(){s.hasLoaded=!0,t&&t(),s.emit("loaded",void 0,!1)}).catch(function(t){error("Failure loading node: ",t)}))},writable:!0},getChildren:{value:function(){return Array.prototype.slice.call(this.children,0)}},updateMixins:{value:function(){var t=[],e=[],i={};return function(n,s){var r,a,o;for(t.length=0,e.length=0,a=n?utils.split(n.trim(),/\s+/):t,o=s?utils.split(s.trim(),/\s+/):e,i.newMixinIds=a,i.oldMixinIds=o,r=0;r tag after the scene. Component