MediaWiki:Snow 3D Vendor.js

function PxLoaderImage(e,t,i){var r=this,o=null;this.img=new Image,this.tags=t,this.priority=i;var n=function{"complete"===r.img.readyState&&(l,o.onLoad(r))},a=function{l,o.onLoad(r)},s=function{l,o.onError(r)},l=function{r.unbind("load",a),r.unbind("readystatechange",n),r.unbind("error",s)};this.start=function(t){o=t,r.bind("load",a),r.bind("readystatechange",n),r.bind("error",s),r.img.src=e},this.checkStatus=function{r.img.complete&&(l,o.onLoad(r))},this.onTimeout=function{l,r.img.complete?o.onLoad(r):o.onTimeout(r)},this.getName=function{return e},this.bind=function(e,t){r.img.addEventListener?r.img.addEventListener(e,t,!1):r.img.attachEvent&&r.img.attachEvent("on"+e,t)},this.unbind=function(e,t){r.img.removeEventListener?r.img.removeEventListener(e,t,!1):r.img.detachEvent&&r.img.detachEvent("on"+e,t)}}!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){function t(e){return s.raw?e:encodeURIComponent(e)}function i(e){return s.raw?e:decodeURIComponent(e)}function r(e){return t(s.json?JSON.stringify(e):String(e))}function o(e){0===e.indexOf('"')&&(e=e.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return e=decodeURIComponent(e.replace(a," ")),s.json?JSON.parse(e):e}catch(t){}}function n(t,i){var r=s.raw?t:o(t);return e.isFunction(i)?i(r):r}var a=/\+/g,s=e.cookie=function(o,a,l){if(arguments.length>1&&!e.isFunction(a)){if(l=e.extend({},s.defaults,l),"number"==typeof l.expires){var h=l.expires,u=l.expires=new Date;u.setTime(+u+864e5*h)}return document.cookie=[t(o),"=",r(a),l.expires?"; expires="+l.expires.toUTCString:"",l.path?"; path="+l.path:"",l.domain?"; domain="+l.domain:"",l.secure?"; secure":""].join("")}for(var c=o?void 0:{},f=document.cookie?document.cookie.split("; "):[],d=0,p=f.length;p>d;d++){var m=f[d].split("="),E=i(m.shift),g=m.join("=");if(o&&o===E){c=n(g,a);break}o||void 0===(g=n(g))||(c[E]=g)}return c};s.defaults={},e.removeCookie=function(t,i){return void 0===e.cookie(t)?!1:(e.cookie(t,"",e.extend({},i,{expires:-1})),!e.cookie(t))}}),function(e){function t(e){e=e||{},this.settings=e,null==e.statusInterval&&(e.statusInterval=5e3),null==e.loggingDelay&&(e.loggingDelay=2e4),null==e.noProgressTimeout&&(e.noProgressTimeout=1/0);var t,r=[],o=[],n=Date.now,a={QUEUED:0,WAITING:1,LOADED:2,ERROR:3,TIMEOUT:4},s=function(e){return null==e?[]:Array.isArray(e)?e:[e]};this.add=function(e){e.tags=new i(e.tags),null==e.priority&&(e.priority=1/0),r.push({resource:e,status:a.QUEUED})},this.addProgressListener=function(e,t){o.push({callback:e,tags:new i(t)})},this.addCompletionListener=function(e,t){o.push({tags:new i(t),callback:function(t){t.completedCount===t.totalCount&&e(t)}})};var l=function(e){e=s(e);var t=function(t){for(var i=t.resource,r=1/0,o=0;on&&(r=n,0===r))&&0!==r;n++);return r};return function(e,i){var r=t(e),o=t(i);return o>r?-1:r>o?1:e.priorityi.priority?1:0}};this.start=function(e){t=Date.now;var i=l(e);r.sort(i);for(var o=0,n=r.length;n>o;o++){var s=r[o];s.status=a.WAITING,s.resource.start(this)}setTimeout(h,100)};var h=function{for(var t=!1,i=Date.now-n,o=i>=e.noProgressTimeout,s=i>=e.loggingDelay,l=0,u=r.length;u>l;l++){var c=r[l];c.status===a.WAITING&&(c.resource.checkStatus&&c.resource.checkStatus,c.status===a.WAITING&&(o?c.resource.onTimeout:t=!0))}s&&t&&f,t&&setTimeout(h,e.statusInterval)};this.isBusy=function{for(var e=0,t=r.length;t>e;e++)if(r[e].status===a.QUEUED||r[e].status===a.WAITING)return!0;return!1};var u=function(e,t){var i,s,l,h,u,f=null;for(i=0,s=r.length;s>i;i++)if(r[i].resource===e){f=r[i];break}if(null!=f&&f.status===a.WAITING)for(f.status=t,n=Date.now,l=e.tags.length,i=0,s=o.length;s>i;i++)h=o[i],u=0===h.tags.length?!0:e.tags.intersects(h.tags),u&&c(f,h)};this.onLoad=function(e){u(e,a.LOADED)},this.onError=function(e){u(e,a.ERROR)},this.onTimeout=function(e){u(e,a.TIMEOUT)};var c=function(e,t){var i,o,n,s,l=0,h=0;for(i=0,o=r.length;o>i;i++)n=r[i],s=!1,s=0===t.tags.length?!0:n.resource.tags.intersects(t.tags),s&&(h++,(n.status===a.LOADED||n.status===a.ERROR||n.status===a.TIMEOUT)&&l++);t.callback({resource:e.resource,loaded:e.status===a.LOADED,error:e.status===a.ERROR,timeout:e.status===a.TIMEOUT,completedCount:l,totalCount:h})},f=this.log=function(e){if(window.console){var i=Math.round((Date.now-t)/1e3);window.console.log("PxLoader elapsed: "+i+" sec");for(var o=0,n=r.length;n>o;o++){var s=r[o];if(e||s.status===a.WAITING){var l="PxLoader: #"+o+" "+s.resource.getName;switch(s.status){case a.QUEUED:l+=" (Not Started)";break;case a.WAITING:l+=" (Waiting)";break;case a.LOADED:l+=" (Loaded)";break;case a.ERROR:l+=" (Error)";break;case a.TIMEOUT:l+=" (Timeout)"}s.resource.tags.length>0&&(l+=" Tags: ["+s.resource.tags.all.join(",")+"]"),window.console.log(l)}}}}}function i(e){if(this.all=[],this.first=null,this.length=0,this.lookup={},e){if(Array.isArray(e))this.all=e.slice(0);else if("object"==typeof e)for(var t in e)e.hasOwnProperty(t)&&this.all.push(t);else this.all.push(e);this.length=this.all.length,this.length>0&&(this.first=this.all[0]);for(var i=0;i<this.length;i++)this.lookup[this.all[i]]=!0}}i.prototype.intersects=function(e){if(0===this.length||0===e.length)return!1;if(1===this.length&&1===e.length)return this.first===e.first;if(e.length<this.length)return e.intersects(this);for(var t in this.lookup)if(e.lookup[t])return!0;return!1},"function"==typeof define&&define.amd&&define("PxLoader",[],function{return t}),e.PxLoader=t}(this),Date.now||(Date.now=function{return(new Date).getTime}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),PxLoader.prototype.addImage=function(e,t,i){var r=new PxLoaderImage(e,t,i);return this.add(r),r.img},"function"==typeof define&&define.amd&&define("PxLoaderImage",[],function{return PxLoaderImage});var WebGLDetector={canvas:!!window.CanvasRenderingContext2D,webgl:function{try{var e=document.createElement("canvas");return!!window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl"))}catch(t){return!1}},workers:!!window.Worker,fileapi:window.File&&window.FileReader&&window.FileList&&window.Blob,getWebGLErrorMessage:function{var e=document.createElement("div");return e.id="webgl-error-message",e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.fontWeight="normal",e.style.textAlign="center",e.style.background="#fff",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",this.webgl||(e.innerHTML=window.WebGLRenderingContext?['Your graphics card does not seem to support WebGL. ','Find out how to get it here.'].join("\n"):['Your browser does not seem to support WebGL. ','Find out how to get it here.'].join("\n")),e},addGetWebGLMessage:function(e){var t,i,r;e=e||{},t=void 0!==e.parent?e.parent:document.body,i=void 0!==e.id?e.id:"oldie",r=Detector.getWebGLErrorMessage,r.id=i,t.appendChild(r)}},THREE={REVISION:"64"};self.console=self.console||{info:function{},log:function{},debug:function{},warn:function{},error:function{}},String.prototype.trim=String.prototype.trim||function{return this.replace(/^\s+|\s+$/g,"")},THREE.extend=function(e,t){if(Object.keys)for(var i=Object.keys(t),r=0,o=i.length;o>r;r++){var n=i[r];Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}else{var a={}.hasOwnProperty;for(var n in t)a.call(t,n)&&(e[n]=t[n])}return e},function{for(var e=0,t=["ms","moz","webkit","o"],i=0;i<t.length&&!self.requestAnimationFrame;++i)self.requestAnimationFrame=self[t[i]+"RequestAnimationFrame"],self.cancelAnimationFrame=self[t[i]+"CancelAnimationFrame"]||self[t[i]+"CancelRequestAnimationFrame"];void 0===self.requestAnimationFrame&&void 0!==self.setTimeout&&(self.requestAnimationFrame=function(t){var i=Date.now,r=Math.max(0,16-(i-e)),o=self.setTimeout(function{t(i+r)},r);return e=i+r,o}),void 0===self.cancelAnimationFrame&&void 0!==self.clearTimeout&&(self.cancelAnimationFrame=function(e){self.clearTimeout(e)})},THREE.CullFaceNone=0,THREE.CullFaceBack=1,THREE.CullFaceFront=2,THREE.CullFaceFrontBack=3,THREE.FrontFaceDirectionCW=0,THREE.FrontFaceDirectionCCW=1,THREE.BasicShadowMap=0,THREE.PCFShadowMap=1,THREE.PCFSoftShadowMap=2,THREE.FrontSide=0,THREE.BackSide=1,THREE.DoubleSide=2,THREE.NoShading=0,THREE.FlatShading=1,THREE.SmoothShading=2,THREE.NoColors=0,THREE.FaceColors=1,THREE.VertexColors=2,THREE.NoBlending=0,THREE.NormalBlending=1,THREE.AdditiveBlending=2,THREE.SubtractiveBlending=3,THREE.MultiplyBlending=4,THREE.CustomBlending=5,THREE.AddEquation=100,THREE.SubtractEquation=101,THREE.ReverseSubtractEquation=102,THREE.ZeroFactor=200,THREE.OneFactor=201,THREE.SrcColorFactor=202,THREE.OneMinusSrcColorFactor=203,THREE.SrcAlphaFactor=204,THREE.OneMinusSrcAlphaFactor=205,THREE.DstAlphaFactor=206,THREE.OneMinusDstAlphaFactor=207,THREE.DstColorFactor=208,THREE.OneMinusDstColorFactor=209,THREE.SrcAlphaSaturateFactor=210,THREE.MultiplyOperation=0,THREE.MixOperation=1,THREE.AddOperation=2,THREE.UVMapping=function{},THREE.CubeReflectionMapping=function{},THREE.CubeRefractionMapping=function{},THREE.SphericalReflectionMapping=function{},THREE.SphericalRefractionMapping=function{},THREE.RepeatWrapping=1e3,THREE.ClampToEdgeWrapping=1001,THREE.MirroredRepeatWrapping=1002,THREE.NearestFilter=1003,THREE.NearestMipMapNearestFilter=1004,THREE.NearestMipMapLinearFilter=1005,THREE.LinearFilter=1006,THREE.LinearMipMapNearestFilter=1007,THREE.LinearMipMapLinearFilter=1008,THREE.UnsignedByteType=1009,THREE.ByteType=1010,THREE.ShortType=1011,THREE.UnsignedShortType=1012,THREE.IntType=1013,THREE.UnsignedIntType=1014,THREE.FloatType=1015,THREE.UnsignedShort4444Type=1016,THREE.UnsignedShort5551Type=1017,THREE.UnsignedShort565Type=1018,THREE.AlphaFormat=1019,THREE.RGBFormat=1020,THREE.RGBAFormat=1021,THREE.LuminanceFormat=1022,THREE.LuminanceAlphaFormat=1023,THREE.RGB_S3TC_DXT1_Format=2001,THREE.RGBA_S3TC_DXT1_Format=2002,THREE.RGBA_S3TC_DXT3_Format=2003,THREE.RGBA_S3TC_DXT5_Format=2004,THREE.EventDispatcher=function{},THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(e){e.addEventListener=THREE.EventDispatcher.prototype.addEventListener,e.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener,e.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener,e.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)?!0:!1},removeEventListener:function(e,t){if(void 0!==this._listeners){var i=this._listeners,r=i[e];if(void 0!==r){var o=r.indexOf(t);-1!==o&&r.splice(o,1)}}},dispatchEvent:function{var e=[];return function(t){if(void 0!==this._listeners){var i=this._listeners,r=i[t.type];if(void 0!==r){t.target=this;for(var o=r.length,n=0;o>n;n++)e[n]=r[n];for(var n=0;o>n;n++)e[n].call(this,t)}}}}},THREE.Texture=function(e,t,i,r,o,n,a,s,l){this.id=THREE.TextureIdCount++,this.uuid=THREE.Math.generateUUID,this.name="",this.image=e,this.mipmaps=[],this.mapping=void 0!==t?t:new THREE.UVMapping,this.wrapS=void 0!==i?i:THREE.ClampToEdgeWrapping,this.wrapT=void 0!==r?r:THREE.ClampToEdgeWrapping,this.magFilter=void 0!==o?o:THREE.LinearFilter,this.minFilter=void 0!==n?n:THREE.LinearMipMapLinearFilter,this.anisotropy=void 0!==l?l:1,this.format=void 0!==a?a:THREE.RGBAFormat,this.type=void 0!==s?s:THREE.UnsignedByteType,this.offset=new THREE.Vector2(0,0),this.repeat=new THREE.Vector2(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.needsUpdate=!1,this.onUpdate=null},THREE.Texture.prototype={constructor:THREE.Texture,clone:function(e){return void 0===e&&(e=new THREE.Texture),e.image=this.image,e.mipmaps=this.mipmaps.slice(0),e.mapping=this.mapping,e.wrapS=this.wrapS,e.wrapT=this.wrapT,e.magFilter=this.magFilter,e.minFilter=this.minFilter,e.anisotropy=this.anisotropy,e.format=this.format,e.type=this.type,e.offset.copy(this.offset),e.repeat.copy(this.repeat),e.generateMipmaps=this.generateMipmaps,e.premultiplyAlpha=this.premultiplyAlpha,e.flipY=this.flipY,e.unpackAlignment=this.unpackAlignment,e},dispose:function{this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype),THREE.TextureIdCount=0,THREE.CompressedTexture=function(e,t,i,r,o,n,a,s,l,h,u){THREE.Texture.call(this,null,n,a,s,l,h,r,o,u),this.image={width:t,height:i},this.mipmaps=e,this.generateMipmaps=!1},THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype),THREE.CompressedTexture.prototype.clone=function{var e=new THREE.CompressedTexture;return THREE.Texture.prototype.clone.call(this,e),e},THREE.LoadingManager=function(e,t,i){var r=this,o=0,n=0;this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function{n++},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,n),o===n&&void 0!==r.onLoad&&r.onLoad}},THREE.DefaultLoadingManager=new THREE.LoadingManager,THREE.ImageLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(e,t,i,r){var o=this,n=document.createElement("img");return void 0!==t&&n.addEventListener("load",function{o.manager.itemEnd(e),t(this)},!1),void 0!==i&&n.addEventListener("progress",function(e){i(e)},!1),void 0!==r&&n.addEventListener("error",function(e){r(e)},!1),void 0!==this.crossOrigin&&(n.crossOrigin=this.crossOrigin),n.src=e,o.manager.itemStart(e),n},setCrossOrigin:function(e){this.crossOrigin=e}},THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(e,t,i){var r=new THREE.ImageLoader;r.crossOrigin=this.crossOrigin;var o=new THREE.Texture(void 0,t),n=r.load(e,function{o.needsUpdate=!0,i&&i(o)});return o.image=n,o.sourceFile=e,o},loadCompressedTexture:function(e,t,i,r){var o=new THREE.CompressedTexture;o.mapping=t;var n=new XMLHttpRequest;return n.onload=function{var e=n.response,t=THREE.ImageUtils.parseDDS(e,!0);o.format=t.format,o.mipmaps=t.mipmaps,o.image.width=t.width,o.image.height=t.height,o.generateMipmaps=!1,o.needsUpdate=!0,i&&i(o)},n.onerror=r,n.open("GET",e,!0),n.responseType="arraybuffer",n.send(null),o},loadTextureCube:function(e,t,i,r){var o=[];o.loadCount=0;var n=new THREE.Texture;n.image=o,void 0!==t&&(n.mapping=t),n.flipY=!1;for(var a=0,s=e.length;s>a;++a){var l=new Image;o[a]=l,l.onload=function{o.loadCount+=1,6===o.loadCount&&(n.needsUpdate=!0,i&&i(n))},l.onerror=r,l.crossOrigin=this.crossOrigin,l.src=e[a]}return n},loadCompressedTextureCube:function(e,t,i,r){var o=[];o.loadCount=0;var n=new THREE.CompressedTexture;n.image=o,void 0!==t&&(n.mapping=t),n.flipY=!1,n.generateMipmaps=!1;var a=function(e,t){return function{var r=e.response,a=THREE.ImageUtils.parseDDS(r,!0);t.format=a.format,t.mipmaps=a.mipmaps,t.width=a.width,t.height=a.height,o.loadCount+=1,6===o.loadCount&&(n.format=a.format,n.needsUpdate=!0,i&&i(n))}};if(e instanceof Array)for(var s=0,l=e.length;l>s;++s){var h={};o[s]=h;var u=new XMLHttpRequest;u.onload=a(u,h),u.onerror=r;var c=e[s];u.open("GET",c,!0),u.responseType="arraybuffer",u.send(null)}else{var c=e,u=new XMLHttpRequest;u.onload=function{var e=u.response,t=THREE.ImageUtils.parseDDS(e,!0);if(t.isCubemap){for(var r=t.mipmaps.length/t.mipmapCount,a=0;r>a;a++){o[a]={mipmaps:[]};for(var s=0;s<t.mipmapCount;s++)o[a].mipmaps.push(t.mipmaps[a*t.mipmapCount+s]),o[a].format=t.format,o[a].width=t.width,o[a].height=t.height}n.format=t.format,n.needsUpdate=!0,i&&i(n)}},u.onerror=r,u.open("GET",c,!0),u.responseType="arraybuffer",u.send(null)}return n},loadDDSTexture:function(e,t,i,r){var o=[];o.loadCount=0;var n=new THREE.CompressedTexture;n.image=o,void 0!==t&&(n.mapping=t),n.flipY=!1,n.generateMipmaps=!1;var a=new XMLHttpRequest;return a.onload=function{var e=a.response,t=THREE.ImageUtils.parseDDS(e,!0);if(t.isCubemap)for(var r=t.mipmaps.length/t.mipmapCount,s=0;r>s;s++){o[s]={mipmaps:[]};for(var l=0;l>8&255,e>>16&255,e>>24&255)}function o(e,t,i,r){for(var o=i*r*4,n=new Uint8Array(e,t,o),a=new Uint8Array(o),s=0,l=0,h=0;r>h;h++)for(var u=0;i>u;u++){var c=n[l];l++;var f=n[l];l++;var d=n[l];l++;var p=n[l];l++,a[s]=d,s++,a[s]=f,s++,a[s]=c,s++,a[s]=p,s++}return a}var n={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},a=542327876,s=131072,l=512,h=4,u=i("DXT1"),c=i("DXT3"),f=i("DXT5"),d=31,p=0,m=1,E=2,g=3,v=4,T=7,_=20,x=21,y=22,R=23,b=24,S=25,w=26,M=28,H=new Int32Array(e,0,d);if(H[p]!==a)return console.error("ImageUtils.parseDDS: Invalid magic number in DDS header"),n;if(!H[_]&h)return console.error("ImageUtils.parseDDS: Unsupported format, must contain a FourCC code"),n;var A,C=H[x],D=!1;switch(C){case u:A=8,n.format=THREE.RGB_S3TC_DXT1_Format;break;case c:A=16,n.format=THREE.RGBA_S3TC_DXT3_Format;break;case f:A=16,n.format=THREE.RGBA_S3TC_DXT5_Format;break;default:if(!(32==H[y]&&16711680&H[R]&&65280&H[b]&&255&H[S]&&4278190080&H[w]))return console.error("ImageUtils.parseDDS: Unsupported FourCC code: ",r(C)),n;D=!0,A=64,n.format=THREE.RGBAFormat}n.mipmapCount=1,H[E]&s&&t!==!1&&(n.mipmapCount=Math.max(1,H[T])),n.isCubemap=H[M]&l?!0:!1,n.width=H[v],n.height=H[g];for(var P=H[m]+4,L=n.width,F=n.height,U=n.isCubemap?6:1,z=0;U>z;z++){for(var B=0;B<n.mipmapCount;B++){if(D)var I=o(e,P,L,F),N=I.length;else var N=Math.max(4,L)/4*Math.max(4,F)/4*A,I=new Uint8Array(e,P,N);var O={data:I,width:L,height:F};n.mipmaps.push(O),P+=N,L=Math.max(.5*L,1),F=Math.max(.5*F,1)}L=n.width,F=n.height}return n},getNormalMap:function(e,t){var i=function(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]},r=function(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]},o=function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]};t=1|t;var n=e.width,a=e.height,s=document.createElement("canvas");s.width=n,s.height=a;var l=s.getContext("2d");l.drawImage(e,0,0);for(var h=l.getImageData(0,0,n,a).data,u=l.createImageData(n,a),c=u.data,f=0;n>f;f++)for(var d=0;a>d;d++){var p=0>d-1?0:d-1,m=d+1>a-1?a-1:d+1,E=0>f-1?0:f-1,g=f+1>n-1?n-1:f+1,v=[],T=[0,0,h[4*(d*n+f)]/255*t];v.push([-1,0,h[4*(d*n+E)]/255*t]),v.push([-1,-1,h[4*(p*n+E)]/255*t]),v.push([0,-1,h[4*(p*n+f)]/255*t]),v.push([1,-1,h[4*(p*n+g)]/255*t]),v.push([1,0,h[4*(d*n+g)]/255*t]),v.push([1,1,h[4*(m*n+g)]/255*t]),v.push([0,1,h[4*(m*n+f)]/255*t]),v.push([-1,1,h[4*(m*n+E)]/255*t]);for(var _=[],x=v.length,y=0;x>y;y++){var R=v[y],b=v[(y+1)%x];R=r(R,T),b=r(b,T),_.push(o(i(R,b)))}for(var S=[0,0,0],y=0;y<_.length;y++)S[0]+=_[y][0],S[1]+=_[y][1],S[2]+=_[y][2];S[0]/=_.length,S[1]/=_.length,S[2]/=_.length;var w=4*(d*n+f);c[w]=(S[0]+1)/2*255|0,c[w+1]=(S[1]+1)/2*255|0,c[w+2]=255*S[2]|0,c[w+3]=255}return l.putImageData(u,0,0),s},generateDataTexture:function(e,t,i){for(var r=e*t,o=new Uint8Array(3*r),n=Math.floor(255*i.r),a=Math.floor(255*i.g),s=Math.floor(255*i.b),l=0;r>l;l++)o[3*l]=n,o[3*l+1]=a,o[3*l+2]=s;var h=new THREE.DataTexture(o,e,t,THREE.RGBFormat);return h.needsUpdate=!0,h}},THREE.Math={PI2:2*Math.PI,generateUUID:function{var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function{for(var o=0;36>o;o++)8==o||13==o||18==o||23==o?i[o]="-":14==o?i[o]="4":(2>=r&&(r=33554432+16777216*Math.random|0),e=15&r,r>>=4,i[o]=t[19==o?3&e|8:e]);return i.join("")}},clamp:function(e,t,i){return t>e?t:e>i?i:e},clampBottom:function(e,t){return t>e?t:e},mapLinear:function(e,t,i,r,o){return r+(e-t)*(o-r)/(i-t)},smoothstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(6*e-15)+10))},random16:function{return(65280*Math.random+255*Math.random)/65535},randInt:function(e,t){return e+Math.floor(Math.random*(t-e+1))},randFloat:function(e,t){return e+Math.random*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random)},sign:function(e){return 0>e?-1:e>0?1:0},degToRad:function{var e=Math.PI/180;return function(t){return t*e}},radToDeg:function{var e=180/Math.PI;return function(t){return t*e}}},THREE.Vector2=function(e,t){this.x=e||0,this.y=t||0},THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(e,t){return this.x=e,this.y=t,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector2's .add now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScalar:function(e){return this.x+=e,this.y+=e,this},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector2's .sub now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divideScalar:function(e){if(0!==e){var t=1/e;this.x*=t,this.y*=t}else this.x=0,this.y=0;return this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this},negate:function{return this.multiplyScalar(-1)},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function{return this.x*this.x+this.y*this.y},length:function{return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function{return this.divideScalar(this.length)},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},setLength:function(e){var t=this.length;return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e){return this.x=e[0],this.y=e[1],this},toArray:function{return[this.x,this.y]},clone:function{return new THREE.Vector2(this.x,this.y)}},THREE.Quaternion=function(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1},THREE.Quaternion.prototype={constructor:THREE.Quaternion,_x:0,_y:0,_z:0,_w:0,_euler:void 0,_updateEuler:function{void 0!==this._euler&&this._euler.setFromQuaternion(this,void 0,!1)},get x{return this._x},set x(e){this._x=e,this._updateEuler},get y{return this._y},set y(e){this._y=e,this._updateEuler},get z{return this._z},set z(e){this._z=e,this._updateEuler},get w{return this._w},set w(e){this._w=e,this._updateEuler},set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._updateEuler,this},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._updateEuler,this},setFromEuler:function(e,t){if(e instanceof THREE.Euler==!1)throw new Error("ERROR: Quaternion's .setFromEuler now expects a Euler rotation rather than a Vector3 and order. Please update your code.");var i=Math.cos(e._x/2),r=Math.cos(e._y/2),o=Math.cos(e._z/2),n=Math.sin(e._x/2),a=Math.sin(e._y/2),s=Math.sin(e._z/2);return"XYZ"===e.order?(this._x=n*r*o+i*a*s,this._y=i*a*o-n*r*s,this._z=i*r*s+n*a*o,this._w=i*r*o-n*a*s):"YXZ"===e.order?(this._x=n*r*o+i*a*s,this._y=i*a*o-n*r*s,this._z=i*r*s-n*a*o,this._w=i*r*o+n*a*s):"ZXY"===e.order?(this._x=n*r*o-i*a*s,this._y=i*a*o+n*r*s,this._z=i*r*s+n*a*o,this._w=i*r*o-n*a*s):"ZYX"===e.order?(this._x=n*r*o-i*a*s,this._y=i*a*o+n*r*s,this._z=i*r*s-n*a*o,this._w=i*r*o+n*a*s):"YZX"===e.order?(this._x=n*r*o+i*a*s,this._y=i*a*o+n*r*s,this._z=i*r*s-n*a*o,this._w=i*r*o-n*a*s):"XZY"===e.order&&(this._x=n*r*o-i*a*s,this._y=i*a*o-n*r*s,this._z=i*r*s+n*a*o,this._w=i*r*o+n*a*s),t!==!1&&this._updateEuler,this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._updateEuler,this},setFromRotationMatrix:function(e){var t,i=e.elements,r=i[0],o=i[4],n=i[8],a=i[1],s=i[5],l=i[9],h=i[2],u=i[6],c=i[10],f=r+s+c;return f>0?(t=.5/Math.sqrt(f+1),this._w=.25/t,this._x=(u-l)*t,this._y=(n-h)*t,this._z=(a-o)*t):r>s&&r>c?(t=2*Math.sqrt(1+r-s-c),this._w=(u-l)/t,this._x=.25*t,this._y=(o+a)/t,this._z=(n+h)/t):s>c?(t=2*Math.sqrt(1+s-r-c),this._w=(n-h)/t,this._x=(o+a)/t,this._y=.25*t,this._z=(l+u)/t):(t=2*Math.sqrt(1+c-r-s),this._w=(a-o)/t,this._x=(n+h)/t,this._y=(l+u)/t,this._z=.25*t),this._updateEuler,this},inverse:function{return this.conjugate.normalize,this},conjugate:function{return this._x*=-1,this._y*=-1,this._z*=-1,this._updateEuler,this},lengthSq:function{return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function{return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function{var e=this.length;return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this},multiply:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Quaternion's .multiply now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,o=e._z,n=e._w,a=t._x,s=t._y,l=t._z,h=t._w;return this._x=i*h+n*a+r*l-o*s,this._y=r*h+n*s+o*a-i*l,this._z=o*h+n*l+i*s-r*a,this._w=n*h-i*a-r*s-o*l,this._updateEuler,this},multiplyVector3:function(e){return console.warn("DEPRECATED: Quaternion's .multiplyVector3 has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},slerp:function(e,t){var i=this._x,r=this._y,o=this._z,n=this._w,a=n*e._w+i*e._x+r*e._y+o*e._z;if(0>a?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=n,this._x=i,this._y=r,this._z=o,this;var s=Math.acos(a),l=Math.sqrt(1-a*a);if(Math.abs(l)<.001)return this._w=.5*(n+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(o+this._z),this;var h=Math.sin((1-t)*s)/l,u=Math.sin(t*s)/l;return this._w=n*h+this._w*u,this._x=i*h+this._x*u,this._y=r*h+this._y*u,this._z=o*h+this._z*u,this._updateEuler,this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],this._w=e[3],this._updateEuler,this},toArray:function{return[this._x,this._y,this._z,this._w]},clone:function{return new THREE.Quaternion(this._x,this._y,this._z,this._w)}},THREE.Quaternion.slerp=function(e,t,i,r){return i.copy(e).slerp(t,r)},THREE.Vector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector3's .add now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},sub:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector3's .sub now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("DEPRECATED: Vector3's .multiply now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*i+o[6]*r,this.y=o[1]*t+o[4]*i+o[7]*r,this.z=o[2]*t+o[5]*i+o[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12],this.y=o[1]*t+o[5]*i+o[9]*r+o[13],this.z=o[2]*t+o[6]*i+o[10]*r+o[14],this},applyProjection:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements,n=1/(o[3]*t+o[7]*i+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*i+o[8]*r+o[12])*n,this.y=(o[1]*t+o[5]*i+o[9]*r+o[13])*n,this.z=(o[2]*t+o[6]*i+o[10]*r+o[14])*n,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,o=e.x,n=e.y,a=e.z,s=e.w,l=s*t+n*r-a*i,h=s*i+a*t-o*r,u=s*r+o*i-n*t,c=-o*t-n*i-a*r;return this.x=l*s+c*-o+h*-a-u*-n,this.y=h*s+c*-n+u*-o-l*-a,this.z=u*s+c*-a+l*-n-h*-o,this},transformDirection:function(e){var t=this.x,i=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r,this.y=o[1]*t+o[5]*i+o[9]*r,this.z=o[2]*t+o[6]*i+o[10]*r,this.normalize,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){if(0!==e){var t=1/e;this.x*=t,this.y*=t,this.z*=t}else this.x=0,this.y=0,this.z=0;return this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this.zt.z&&(this.z=t.z),this},negate:function{return this.multiplyScalar(-1)},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function{return this.x*this.x+this.y*this.y+this.z*this.z},length:function{return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function{return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function{return this.divideScalar(this.length)},setLength:function(e){var t=this.length;return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},cross:function(e,t){if(void 0!==t)return console.warn("DEPRECATED: Vector3's .cross now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);