JAVASCRIPT
/*! gorescript / http://gorescript.com */
/*! three.js / threejs.org/license */
/*! tween.js - http://github.com/sole/tween.js */
/*!
* jQuery JavaScript Library v2.2.1
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2016-02-22T19:11Z
*/
!function(global,factory){factory(global)}("undefined"!=typeof window?window:this,function(window,noGlobal){function isArrayLike(obj){var length=!!obj&&"length"in obj&&obj.length,type=jQuery.type(obj);return"function"!==type&&!jQuery.isWindow(obj)&&("array"===type||0===length||"number"==typeof length&&length>0&&length-1 in obj)}function winnow(elements,qualifier,not){if(jQuery.isFunction(qualifier))return jQuery.grep(elements,function(elem,i){return!!qualifier.call(elem,i,elem)!==not});if(qualifier.nodeType)return jQuery.grep(elements,function(elem){return elem===qualifier!==not});if("string"==typeof qualifier){if(risSimple.test(qualifier))return jQuery.filter(qualifier,elements,not);qualifier=jQuery.filter(qualifier,elements)}return jQuery.grep(elements,function(elem){return indexOf.call(qualifier,elem)>-1!==not})}function sibling(cur,dir){for(;(cur=cur[dir])&&1!==cur.nodeType;);return cur}function createOptions(options){var object={};return jQuery.each(options.match(rnotwhite)||[],function(_,flag){object[flag]=!0}),object}function completed(){document.removeEventListener("DOMContentLoaded",completed),window.removeEventListener("load",completed),jQuery.ready()}function Data(){this.expando=jQuery.expando+Data.uid++}function dataAttr(elem,key,data){var name;if(void 0===data&&1===elem.nodeType)if(name="data-"+key.replace(rmultiDash,"-$&").toLowerCase(),data=elem.getAttribute(name),"string"==typeof data){try{data="true"===data||"false"!==data&&("null"===data?null:+data+""===data?+data:rbrace.test(data)?jQuery.parseJSON(data):data)}catch(e){}dataUser.set(elem,key,data)}else data=void 0;return data}function adjustCSS(elem,prop,valueParts,tween){var adjusted,scale=1,maxIterations=20,currentValue=tween?function(){return tween.cur()}:function(){return jQuery.css(elem,prop,"")},initial=currentValue(),unit=valueParts&&valueParts[3]||(jQuery.cssNumber[prop]?"":"px"),initialInUnit=(jQuery.cssNumber[prop]||"px"!==unit&&+initial)&&rcssNum.exec(jQuery.css(elem,prop));if(initialInUnit&&initialInUnit[3]!==unit){unit=unit||initialInUnit[3],valueParts=valueParts||[],initialInUnit=+initial||1;do scale=scale||".5",initialInUnit/=scale,jQuery.style(elem,prop,initialInUnit+unit);while(scale!==(scale=currentValue()/initial)&&1!==scale&&--maxIterations)}return valueParts&&(initialInUnit=+initialInUnit||+initial||0,adjusted=valueParts[1]?initialInUnit+(valueParts[1]+1)*valueParts[2]:+valueParts[2],tween&&(tween.unit=unit,tween.start=initialInUnit,tween.end=adjusted)),adjusted}function getAll(context,tag){var ret="undefined"!=typeof context.getElementsByTagName?context.getElementsByTagName(tag||"*"):"undefined"!=typeof context.querySelectorAll?context.querySelectorAll(tag||"*"):[];return void 0===tag||tag&&jQuery.nodeName(context,tag)?jQuery.merge([context],ret):ret}function setGlobalEval(elems,refElements){for(var i=0,l=elems.length;i<l;i++)dataPriv.set(elems[i],"globalEval",!refElements||dataPriv.get(refElements[i],"globalEval"))}function buildFragment(elems,context,scripts,selection,ignored){for(var elem,tmp,tag,wrap,contains,j,fragment=context.createDocumentFragment(),nodes=[],i=0,l=elems.length;i<l;i++)if(elem=elems[i],elem||0===elem)if("object"===jQuery.type(elem))jQuery.merge(nodes,elem.nodeType?[elem]:elem);else if(rhtml.test(elem)){for(tmp=tmp||fragment.appendChild(context.createElement("div")),tag=(rtagName.exec(elem)||["",""])[1].toLowerCase(),wrap=wrapMap[tag]||wrapMap._default,tmp.innerHTML=wrap[1]+jQuery.htmlPrefilter(elem)+wrap[2],j=wrap[0];j--;)tmp=tmp.lastChild;jQuery.merge(nodes,tmp.childNodes),tmp=fragment.firstChild,tmp.textContent=""}else nodes.push(context.createTextNode(elem));for(fragment.textContent="",i=0;elem=nodes[i++];)if(selection&&jQuery.inArray(elem,selection)>-1)ignored&&ignored.push(elem);else if(contains=jQuery.contains(elem.ownerDocument,elem),tmp=getAll(fragment.appendChild(elem),"script"),contains&&setGlobalEval(tmp),scripts)for(j=0;elem=tmp[j++];)rscriptType.test(elem.type||"")&&scripts.push(elem);return fragment}function returnTrue(){return!0}function returnFalse(){return!1}function safeActiveElement(){try{return document.activeElement}catch(err){}}function on(elem,types,selector,data,fn,one){var origFn,type;if("object"==typeof types){"string"!=typeof selector&&(data=data||selector,selector=void 0);for(type in types)on(elem,type,selector,data,types[type],one);return elem}if(null==data&&null==fn?(fn=selector,data=selector=void 0):null==fn&&("string"==typeof selector?(fn=data,data=void 0):(fn=data,data=selector,selector=void 0)),fn===!1)fn=returnFalse;else if(!fn)return elem;return 1===one&&(origFn=fn,fn=function(event){return jQuery().off(event),origFn.apply(this,arguments)},fn.guid=origFn.guid||(origFn.guid=jQuery.guid++)),elem.each(function(){jQuery.event.add(this,types,fn,data,selector)})}function manipulationTarget(elem,content){return jQuery.nodeName(elem,"table")&&jQuery.nodeName(11!==content.nodeType?content:content.firstChild,"tr")?elem.getElementsByTagName("tbody")[0]||elem.appendChild(elem.ownerDocument.createElement("tbody")):elem}function disableScript(elem){return elem.type=(null!==elem.getAttribute("type"))+"/"+elem.type,elem}function restoreScript(elem){var match=rscriptTypeMasked.exec(elem.type);return match?elem.type=match[1]:elem.removeAttribute("type"),elem}function cloneCopyEvent(src,dest){var i,l,type,pdataOld,pdataCur,udataOld,udataCur,events;if(1===dest.nodeType){if(dataPriv.hasData(src)&&(pdataOld=dataPriv.access(src),pdataCur=dataPriv.set(dest,pdataOld),events=pdataOld.events)){delete pdataCur.handle,pdataCur.events={};for(type in events)for(i=0,l=events[type].length;i<l;i++)jQuery.event.add(dest,type,events[type][i])}dataUser.hasData(src)&&(udataOld=dataUser.access(src),udataCur=jQuery.extend({},udataOld),dataUser.set(dest,udataCur))}}function fixInput(src,dest){var nodeName=dest.nodeName.toLowerCase();"input"===nodeName&&rcheckableType.test(src.type)?dest.checked=src.checked:"input"!==nodeName&&"textarea"!==nodeName||(dest.defaultValue=src.defaultValue)}function domManip(collection,args,callback,ignored){args=concat.apply([],args);var fragment,first,scripts,hasScripts,node,doc,i=0,l=collection.length,iNoClone=l-1,value=args[0],isFunction=jQuery.isFunction(value);if(isFunction||l>1&&"string"==typeof value&&!support.checkClone&&rchecked.test(value))return collection.each(function(index){var self=collection.eq(index);isFunction&&(args[0]=value.call(this,index,self.html())),domManip(self,args,callback,ignored)});if(l&&(fragment=buildFragment(args,collection[0].ownerDocument,!1,collection,ignored),first=fragment.firstChild,1===fragment.childNodes.length&&(fragment=first),first||ignored)){for(scripts=jQuery.map(getAll(fragment,"script"),disableScript),hasScripts=scripts.length;i<l;i++)node=fragment,i!==iNoClone&&(node=jQuery.clone(node,!0,!0),hasScripts&&jQuery.merge(scripts,getAll(node,"script"))),callback.call(collection[i],node,i);if(hasScripts)for(doc=scripts[scripts.length-1].ownerDocument,jQuery.map(scripts,restoreScript),i=0;i<hasScripts;i++)node=scripts[i],rscriptType.test(node.type||"")&&!dataPriv.access(node,"globalEval")&&jQuery.contains(doc,node)&&(node.src?jQuery._evalUrl&&jQuery._evalUrl(node.src):jQuery.globalEval(node.textContent.replace(rcleanScript,"")))}return collection}function remove(elem,selector,keepData){for(var node,nodes=selector?jQuery.filter(selector,elem):elem,i=0;null!=(node=nodes[i]);i++)keepData||1!==node.nodeType||jQuery.cleanData(getAll(node)),node.parentNode&&(keepData&&jQuery.contains(node.ownerDocument,node)&&setGlobalEval(getAll(node,"script")),node.parentNode.removeChild(node));return elem}function actualDisplay(name,doc){var elem=jQuery(doc.createElement(name)).appendTo(doc.body),display=jQuery.css(elem[0],"display");return elem.detach(),display}function defaultDisplay(nodeName){var doc=document,display=elemdisplay[nodeName];return display||(display=actualDisplay(nodeName,doc),"none"!==display&&display||(iframe=(iframe||jQuery("<iframe frameborder='0' width='0' height='0'/>")).appendTo(doc.documentElement),doc=iframe[0].contentDocument,doc.write(),doc.close(),display=actualDisplay(nodeName,doc),iframe.detach()),elemdisplay[nodeName]=display),display}function curCSS(elem,name,computed){var width,minWidth,maxWidth,ret,style=elem.style;return computed=computed||getStyles(elem),ret=computed?computed.getPropertyValue(name)||computed[name]:void 0,""!==ret&&void 0!==ret||jQuery.contains(elem.ownerDocument,elem)||(ret=jQuery.style(elem,name)),computed&&!support.pixelMarginRight()&&rnumnonpx.test(ret)&&rmargin.test(name)&&(width=style.width,minWidth=style.minWidth,maxWidth=style.maxWidth,style.minWidth=style.maxWidth=style.width=ret,ret=computed.width,style.width=width,style.minWidth=minWidth,style.maxWidth=maxWidth),void 0!==ret?ret+"":ret}function addGetHookIf(conditionFn,hookFn){return{get:function(){return conditionFn()?void delete this.get:(this.get=hookFn).apply(this,arguments)}}}function vendorPropName(name){if(name in emptyStyle)return name;for(var capName=name[0].toUpperCase()+name.slice(1),i=cssPrefixes.length;i--;)if(name=cssPrefixes[i]+capName,name in emptyStyle)return name}function setPositiveNumber(elem,value,subtract){var matches=rcssNum.exec(value);return matches?Math.max(0,matches[2]-(subtract||0))+(matches[3]||"px"):value}function augmentWidthOrHeight(elem,name,extra,isBorderBox,styles){for(var i=extra===(isBorderBox?"border":"content")?4:"width"===name?1:0,val=0;i<4;i+=2)"margin"===extra&&(val+=jQuery.css(elem,extra+cssExpand[i],!0,styles)),isBorderBox?("content"===extra&&(val-=jQuery.css(elem,"padding"+cssExpand[i],!0,styles)),"margin"!==extra&&(val-=jQuery.css(elem,"border"+cssExpand[i]+"Width",!0,styles))):(val+=jQuery.css(elem,"padding"+cssExpand[i],!0,styles),"padding"!==extra&&(val+=jQuery.css(elem,"border"+cssExpand[i]+"Width",!0,styles)));return val}function getWidthOrHeight(elem,name,extra){var valueIsBorderBox=!0,val="width"===name?elem.offsetWidth:elem.offsetHeight,styles=getStyles(elem),isBorderBox="border-box"===jQuery.css(elem,"boxSizing",!1,styles);if(document.msFullscreenElement&&window.top!==window&&elem.getClientRects().length&&(val=Math.round(100*elem.getBoundingClientRect()[name])),val<=0||null==val){if(val=curCSS(elem,name,styles),(val<0||null==val)&&(val=elem.style[name]),rnumnonpx.test(val))return val;valueIsBorderBox=isBorderBox&&(support.boxSizingReliable()||val===elem.style[name]),val=parseFloat(val)||0}return val+augmentWidthOrHeight(elem,name,extra||(isBorderBox?"border":"content"),valueIsBorderBox,styles)+"px"}function showHide(elements,show){for(var display,elem,hidden,values=[],index=0,length=elements.length;index<length;index++)elem=elements[index],elem.style&&(values[index]=dataPriv.get(elem,"olddisplay"),display=elem.style.display,show?(values[index]||"none"!==display||(elem.style.display=""),""===elem.style.display&&isHidden(elem)&&(values[index]=dataPriv.access(elem,"olddisplay",defaultDisplay(elem.nodeName)))):(hidden=isHidden(elem),"none"===display&&hidden||dataPriv.set(elem,"olddisplay",hidden?display:jQuery.css(elem,"display"))));for(index=0;index<length;index++)elem=elements[index],elem.style&&(show&&"none"!==elem.style.display&&""!==elem.style.display||(elem.style.display=show?values[index]||"":"none"));return elements}function Tween(elem,options,prop,end,easing){return new Tween.prototype.init(elem,options,prop,end,easing)}function createFxNow(){return window.setTimeout(function(){fxNow=void 0}),fxNow=jQuery.now()}function genFx(type,includeWidth){var which,i=0,attrs={height:type};for(includeWidth=includeWidth?1:0;i<4;i+=2-includeWidth)which=cssExpand[i],attrs["margin"+which]=attrs["padding"+which]=type;return includeWidth&&(attrs.opacity=attrs.width=type),attrs}function createTween(value,prop,animation){for(var tween,collection=(Animation.tweeners[prop]||[]).concat(Animation.tweeners["*"]),index=0,length=collection.length;index<length;index++)if(tween=collection[index].call(animation,prop,value))return tween}function defaultPrefilter(elem,props,opts){var prop,value,toggle,tween,hooks,oldfire,display,checkDisplay,anim=this,orig={},style=elem.style,hidden=elem.nodeType&&isHidden(elem),dataShow=dataPriv.get(elem,"fxshow");opts.queue||(hooks=jQuery._queueHooks(elem,"fx"),null==hooks.unqueued&&(hooks.unqueued=0,oldfire=hooks.empty.fire,hooks.empty.fire=function(){hooks.unqueued||oldfire()}),hooks.unqueued++,anim.always(function(){anim.always(function(){hooks.unqueued--,jQuery.queue(elem,"fx").length||hooks.empty.fire()})})),1===elem.nodeType&&("height"in props||"width"in props)&&(opts.overflow=[style.overflow,style.overflowX,style.overflowY],display=jQuery.css(elem,"display"),checkDisplay="none"===display?dataPriv.get(elem,"olddisplay")||defaultDisplay(elem.nodeName):display,"inline"===checkDisplay&&"none"===jQuery.css(elem,"float")&&(style.display="inline-block")),opts.overflow&&(style.overflow="hidden",anim.always(function(){style.overflow=opts.overflow[0],style.overflowX=opts.overflow[1],style.overflowY=opts.overflow[2]}));for(prop in props)if(value=props[prop],rfxtypes.exec(value)){if(delete props[prop],toggle=toggle||"toggle"===value,value===(hidden?"hide":"show")){if("show"!==value||!dataShow||void 0===dataShow[prop])continue;hidden=!0}orig[prop]=dataShow&&dataShow[prop]||jQuery.style(elem,prop)}else display=void 0;if(jQuery.isEmptyObject(orig))"inline"===("none"===display?defaultDisplay(elem.nodeName):display)&&(style.display=display);else{dataShow?"hidden"in dataShow&&(hidden=dataShow.hidden):dataShow=dataPriv.access(elem,"fxshow",{}),toggle&&(dataShow.hidden=!hidden),hidden?jQuery(elem).show():anim.done(function(){jQuery(elem).hide()}),anim.done(function(){var prop;dataPriv.remove(elem,"fxshow");for(prop in orig)jQuery.style(elem,prop,orig[prop])});for(prop in orig)tween=createTween(hidden?dataShow[prop]:0,prop,anim),prop in dataShow||(dataShow[prop]=tween.start,hidden&&(tween.end=tween.start,tween.start="width"===prop||"height"===prop?1:0))}}function propFilter(props,specialEasing){var index,name,easing,value,hooks;for(index in props)if(name=jQuery.camelCase(index),easing=specialEasing[name],value=props[index],jQuery.isArray(value)&&(easing=value[1],value=props[index]=value[0]),index!==name&&(props[name]=value,delete props[index]),hooks=jQuery.cssHooks[name],hooks&&"expand"in hooks){value=hooks.expand(value),delete props[name];for(index in value)index in props||(props[index]=value[index],specialEasing[index]=easing)}else specialEasing[name]=easing}function Animation(elem,properties,options){var result,stopped,index=0,length=Animation.prefilters.length,deferred=jQuery.Deferred().always(function(){delete tick.elem}),tick=function(){if(stopped)return!1;for(var currentTime=fxNow||createFxNow(),remaining=Math.max(0,animation.startTime+animation.duration-currentTime),temp=remaining/animation.duration||0,percent=1-temp,index=0,length=animation.tweens.length;index<length;index++)animation.tweens[index].run(percent);return deferred.notifyWith(elem,[animation,percent,remaining]),percent<1&&length?remaining:(deferred.resolveWith(elem,[animation]),!1)},animation=deferred.promise({elem:elem,props:jQuery.extend({},properties),opts:jQuery.extend(!0,{specialEasing:{},easing:jQuery.easing._default},options),originalProperties:properties,originalOptions:options,startTime:fxNow||createFxNow(),duration:options.duration,tweens:[],createTween:function(prop,end){var tween=jQuery.Tween(elem,animation.opts,prop,end,animation.opts.specialEasing[prop]||animation.opts.easing);return animation.tweens.push(tween),tween},stop:function(gotoEnd){var index=0,length=gotoEnd?animation.tweens.length:0;if(stopped)return this;for(stopped=!0;index<length;index++)animation.tweens[index].run(1);return gotoEnd?(deferred.notifyWith(elem,[animation,1,0]),deferred.resolveWith(elem,[animation,gotoEnd])):deferred.rejectWith(elem,[animation,gotoEnd]),this}}),props=animation.props;for(propFilter(props,animation.opts.specialEasing);index<length;index++)if(result=Animation.prefilters[index].call(animation,elem,props,animation.opts))return jQuery.isFunction(result.stop)&&(jQuery._queueHooks(animation.elem,animation.opts.queue).stop=jQuery.proxy(result.stop,result)),result;return jQuery.map(props,createTween,animation),jQuery.isFunction(animation.opts.start)&&animation.opts.start.call(elem,animation),jQuery.fx.timer(jQuery.extend(tick,{elem:elem,anim:animation,queue:animation.opts.queue})),animation.progress(animation.opts.progress).done(animation.opts.done,animation.opts.complete).fail(animation.opts.fail).always(animation.opts.always)}function getClass(elem){return elem.getAttribute&&elem.getAttribute("class")||""}function addToPrefiltersOrTransports(structure){return function(dataTypeExpression,func){"string"!=typeof dataTypeExpression&&(func=dataTypeExpression,dataTypeExpression="*");var dataType,i=0,dataTypes=dataTypeExpression.toLowerCase().match(rnotwhite)||[];if(jQuery.isFunction(func))for(;dataType=dataTypes[i++];)"+"===dataType[0]?(dataType=dataType.slice(1)||"*",(structure[dataType]=structure[dataType]||[]).unshift(func)):(structure[dataType]=structure[dataType]||[]).push(func)}}function inspectPrefiltersOrTransports(structure,options,originalOptions,jqXHR){function inspect(dataType){var selected;return inspected[dataType]=!0,jQuery.each(structure[dataType]||[],function(_,prefilterOrFactory){var dataTypeOrTransport=prefilterOrFactory(options,originalOptions,jqXHR);return"string"!=typeof dataTypeOrTransport||seekingTransport||inspected[dataTypeOrTransport]?seekingTransport?!(selected=dataTypeOrTransport):void 0:(options.dataTypes.unshift(dataTypeOrTransport),inspect(dataTypeOrTransport),!1)}),selected}var inspected={},seekingTransport=structure===transports;return inspect(options.dataTypes[0])||!inspected["*"]&&inspect("*")}function ajaxExtend(target,src){var key,deep,flatOptions=jQuery.ajaxSettings.flatOptions||{};for(key in src)void 0!==src[key]&&((flatOptions[key]?target:deep||(deep={}))[key]=src[key]);return deep&&jQuery.extend(!0,target,deep),target}function ajaxHandleResponses(s,jqXHR,responses){for(var ct,type,finalDataType,firstDataType,contents=s.contents,dataTypes=s.dataTypes;"*"===dataTypes[0];)dataTypes.shift(),void 0===ct&&(ct=s.mimeType||jqXHR.getResponseHeader("Content-Type"));if(ct)for(type in contents)if(contents[type]&&contents[type].test(ct)){dataTypes.unshift(type);break}if(dataTypes[0]in responses)finalDataType=dataTypes[0];else{for(type in responses){if(!dataTypes[0]||s.converters[type+" "+dataTypes[0]]){finalDataType=type;break}firstDataType||(firstDataType=type)}finalDataType=finalDataType||firstDataType}if(finalDataType)return finalDataType!==dataTypes[0]&&dataTypes.unshift(finalDataType),responses[finalDataType]}function ajaxConvert(s,response,jqXHR,isSuccess){var conv2,current,conv,tmp,prev,converters={},dataTypes=s.dataTypes.slice();if(dataTypes[1])for(conv in s.converters)converters[conv.toLowerCase()]=s.converters[conv];for(current=dataTypes.shift();current;)if(s.responseFields[current]&&(jqXHR[s.responseFields[current]]=response),!prev&&isSuccess&&s.dataFilter&&(response=s.dataFilter(response,s.dataType)),prev=current,current=dataTypes.shift())if("*"===current)current=prev;else if("*"!==prev&&prev!==current){if(conv=converters[prev+" "+current]||converters["* "+current],!conv)for(conv2 in converters)if(tmp=conv2.split(" "),tmp[1]===current&&(conv=converters[prev+" "+tmp[0]]||converters["* "+tmp[0]])){conv===!0?conv=converters[conv2]:converters[conv2]!==!0&&(current=tmp[0],dataTypes.unshift(tmp[1]));break}if(conv!==!0)if(conv&&s["throws"])response=conv(response);else try{response=conv(response)}catch(e){return{state:"parsererror",error:conv?e:"No conversion from "+prev+" to "+current}}}return{state:"success",data:response}}function buildParams(prefix,obj,traditional,add){var name;if(jQuery.isArray(obj))jQuery.each(obj,function(i,v){traditional||rbracket.test(prefix)?add(prefix,v):buildParams(prefix+"["+("object"==typeof v&&null!=v?i:"")+"]",v,traditional,add)});else if(traditional||"object"!==jQuery.type(obj))add(prefix,obj);else for(name in obj)buildParams(prefix+"["+name+"]",obj[name],traditional,add)}function getWindow(elem){return jQuery.isWindow(elem)?elem:9===elem.nodeType&&elem.defaultView}var arr=[],document=window.document,slice=arr.slice,concat=arr.concat,push=arr.push,indexOf=arr.indexOf,class2type={},toString=class2type.toString,hasOwn=class2type.hasOwnProperty,support={},version="2.2.1",jQuery=function(selector,context){return new jQuery.fn.init(selector,context)},rtrim=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,rmsPrefix=/^-ms-/,rdashAlpha=/-([\da-z])/gi,fcamelCase=function(all,letter){return letter.toUpperCase()};jQuery.fn=jQuery.prototype={jquery:version,constructor:jQuery,selector:"",length:0,toArray:function(){return slice.call(this)},get:function(num){return null!=num?num<0?this[num+this.length]:this[num]:slice.call(this)},pushStack:function(elems){var ret=jQuery.merge(this.constructor(),elems);return ret.prevObject=this,ret.context=this.context,ret},each:function(callback){return jQuery.each(this,callback)},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem)}))},slice:function(){return this.pushStack(slice.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(i){var len=this.length,j=+i+(i<0?len:0);return this.pushStack(j>=0&&j<len?[this[j]]:[])},end:function(){return this.prevObject||this.constructor()},push:push,sort:arr.sort,splice:arr.splice},jQuery.extend=jQuery.fn.extend=function(){var options,name,src,copy,copyIsArray,clone,target=arguments[0]||{},i=1,length=arguments.length,deep=!1;for("boolean"==typeof target&&(deep=target,target=arguments[i]||{},i++),"object"==typeof target||jQuery.isFunction(target)||(target={}),i===length&&(target=this,i--);i<length;i++)if(null!=(options=arguments[i]))for(name in options)src=target[name],copy=options[name],target!==copy&&(deep&©&&(jQuery.isPlainObject(copy)||(copyIsArray=jQuery.isArray(copy)))?(copyIsArray?(copyIsArray=!1,clone=src&&jQuery.isArray(src)?src:[]):clone=src&&jQuery.isPlainObject(src)?src:{},target[name]=jQuery.extend(deep,clone,copy)):void 0!==copy&&(target[name]=copy));return target},jQuery.extend({expando:"jQuery"+(version+Math.random()).replace(/\D/g,""),isReady:!0,error:function(msg){throw new Error(msg)},noop:function(){},isFunction:function(obj){return"function"===jQuery.type(obj)},isArray:Array.isArray,isWindow:function(obj){return null!=obj&&obj===obj.window},isNumeric:function(obj){var realStringObj=obj&&obj.toString();return!jQuery.isArray(obj)&&realStringObj-parseFloat(realStringObj)+1>=0},isPlainObject:function(obj){return"object"===jQuery.type(obj)&&!obj.nodeType&&!jQuery.isWindow(obj)&&!(obj.constructor&&!hasOwn.call(obj.constructor.prototype,"isPrototypeOf"))},isEmptyObject:function(obj){var name;for(name in obj)return!1;return!0},type:function(obj){return null==obj?obj+"":"object"==typeof obj||"function"==typeof obj?class2type[toString.call(obj)]||"object":typeof obj},globalEval:function(code){var script,indirect=eval;code=jQuery.trim(code),code&&(1===code.indexOf("use strict")?(script=document.createElement("script"),script.text=code,document.head.appendChild(script).parentNode.removeChild(script)):indirect(code))},camelCase:function(string){return string.replace(rmsPrefix,"ms-").replace(rdashAlpha,fcamelCase)},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toLowerCase()===name.toLowerCase()},each:function(obj,callback){var length,i=0;if(isArrayLike(obj))for(length=obj.length;i<length&&callback.call(obj[i],i,obj[i])!==!1;i++);else for(i in obj)if(callback.call(obj[i],i,obj[i])===!1)break;return obj},trim:function(text){return null==text?"":(text+"").replace(rtrim,"")},makeArray:function(arr,results){var ret=results||[];return null!=arr&&(isArrayLike(Object(arr))?jQuery.merge(ret,"string"==typeof arr?[arr]:arr):push.call(ret,arr)),ret},inArray:function(elem,arr,i){return null==arr?-1:indexOf.call(arr,elem,i)},merge:function(first,second){for(var len=+second.length,j=0,i=first.length;j<len;j++)first[i++]=second[j];return first.length=i,first},grep:function(elems,callback,invert){for(var callbackInverse,matches=[],i=0,length=elems.length,callbackExpect=!invert;i<length;i++)callbackInverse=!callback(elems[i],i),callbackInverse!==callbackExpect&&matches.push(elems[i]);return matches},map:function(elems,callback,arg){var length,value,i=0,ret=[];if(isArrayLike(elems))for(length=elems.length;i<length;i++)value=callback(elems[i],i,arg),null!=value&&ret.push(value);else for(i in elems)value=callback(elems[i],i,arg),null!=value&&ret.push(value);return concat.apply([],ret)},guid:1,proxy:function(fn,context){var tmp,args,proxy;if("string"==typeof context&&(tmp=fn[context],context=fn,fn=tmp),jQuery.isFunction(fn))return args=slice.call(arguments,2),proxy=function(){return fn.apply(context||this,args.concat(slice.call(arguments)))},proxy.guid=fn.guid=fn.guid||jQuery.guid++,proxy},now:Date.now,support:support}),"function"==typeof Symbol&&(jQuery.fn[Symbol.iterator]=arr[Symbol.iterator]),jQuery.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(i,name){class2type["[object "+name+"]"]=name.toLowerCase()});var Sizzle=/*!
* Sizzle CSS Selector Engine v2.2.1
* http://sizzlejs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-10-17
*/
function(window){function Sizzle(selector,context,results,seed){var m,i,elem,nid,nidselect,match,groups,newSelector,newContext=context&&context.ownerDocument,nodeType=context?context.nodeType:9;if(results=results||[],"string"!=typeof selector||!selector||1!==nodeType&&9!==nodeType&&11!==nodeType)return results;if(!seed&&((context?context.ownerDocument||context:preferredDoc)!==document&&setDocument(context),context=context||document,documentIsHTML)){if(11!==nodeType&&(match=rquickExpr.exec(selector)))if(m=match[1]){if(9===nodeType){if(!(elem=context.getElementById(m)))return results;if(elem.id===m)return results.push(elem),results}else if(newContext&&(elem=newContext.getElementById(m))&&contains(context,elem)&&elem.id===m)return results.push(elem),results}else{if(match[2])return push.apply(results,context.getElementsByTagName(selector)),results;if((m=match[3])&&support.getElementsByClassName&&context.getElementsByClassName)return push.apply(results,context.getElementsByClassName(m)),results}if(support.qsa&&!compilerCache[selector+" "]&&(!rbuggyQSA||!rbuggyQSA.test(selector))){if(1!==nodeType)newContext=context,newSelector=selector;else if("object"!==context.nodeName.toLowerCase()){for((nid=context.getAttribute("id"))?nid=nid.replace(rescape,"\\$&"):context.setAttribute("id",nid=expando),groups=tokenize(selector),i=groups.length,nidselect=ridentifier.test(nid)?"#"+nid:"[id='"+nid+"']";i--;)groups[i]=nidselect+" "+toSelector(groups[i]);newSelector=groups.join(","),newContext=rsibling.test(selector)&&testContext(context.parentNode)||context}if(newSelector)try{return push.apply(results,newContext.querySelectorAll(newSelector)),results}catch(qsaError){}finally{nid===expando&&context.removeAttribute("id")}}}return select(selector.replace(rtrim,"$1"),context,results,seed)}function createCache(){function cache(key,value){return keys.push(key+" ")>Expr.cacheLength&&delete cache[keys.shift()],cache[key+" "]=value}var keys=[];return cache}function markFunction(fn){return fn[expando]=!0,fn}function assert(fn){var div=document.createElement("div");try{return!!fn(div)}catch(e){return!1}finally{div.parentNode&&div.parentNode.removeChild(div),div=null}}function addHandle(attrs,handler){for(var arr=attrs.split("|"),i=arr.length;i--;)Expr.attrHandle[arr[i]]=handler}function siblingCheck(a,b){var cur=b&&a,diff=cur&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||MAX_NEGATIVE)-(~a.sourceIndex||MAX_NEGATIVE);if(diff)return diff;if(cur)for(;cur=cur.nextSibling;)if(cur===b)return-1;return a?1:-1}function createInputPseudo(type){return function(elem){var name=elem.nodeName.toLowerCase();return"input"===name&&elem.type===type}}function createButtonPseudo(type){return function(elem){var name=elem.nodeName.toLowerCase();return("input"===name||"button"===name)&&elem.type===type}}function createPositionalPseudo(fn){return markFunction(function(argument){return argument=+argument,markFunction(function(seed,matches){for(var j,matchIndexes=fn([],seed.length,argument),i=matchIndexes.length;i--;)seed[j=matchIndexes[i]]&&(seed[j]=!(matches[j]=seed[j]))})})}function testContext(context){return context&&"undefined"!=typeof context.getElementsByTagName&&context}function setFilters(){}function toSelector(tokens){for(var i=0,len=tokens.length,selector="";i<len;i++)selector+=tokens[i].value;return selector}function addCombinator(matcher,combinator,base){var dir=combinator.dir,checkNonElements=base&&"parentNode"===dir,doneName=done++;return combinator.first?function(elem,context,xml){for(;elem=elem[dir];)if(1===elem.nodeType||checkNonElements)return matcher(elem,context,xml)}:function(elem,context,xml){var oldCache,uniqueCache,outerCache,newCache=[dirruns,doneName];if(xml){for(;elem=elem[dir];)if((1===elem.nodeType||checkNonElements)&&matcher(elem,context,xml))return!0}else for(;elem=elem[dir];)if(1===elem.nodeType||checkNonElements){if(outerCache=elem[expando]||(elem[expando]={}),uniqueCache=outerCache[elem.uniqueID]||(outerCache[elem.uniqueID]={}),(oldCache=uniqueCache[dir])&&oldCache[0]===dirruns&&oldCache[1]===doneName)return newCache[2]=oldCache[2];if(uniqueCache[dir]=newCache,newCache[2]=matcher(elem,context,xml))return!0}}}function elementMatcher(matchers){return matchers.length>1?function(elem,context,xml){for(var i=matchers.length;i--;)if(!matchers[i](elem,context,xml))return!1;return!0}:matchers[0]}function multipleContexts(selector,contexts,results){for(var i=0,len=contexts.length;i<len;i++)Sizzle(selector,contexts[i],results);return results}function condense(unmatched,map,filter,context,xml){for(var elem,newUnmatched=[],i=0,len=unmatched.length,mapped=null!=map;i<len;i++)(elem=unmatched[i])&&(filter&&!filter(elem,context,xml)||(newUnmatched.push(elem),mapped&&map.push(i)));return newUnmatched}function setMatcher(preFilter,selector,matcher,postFilter,postFinder,postSelector){return postFilter&&!postFilter[expando]&&(postFilter=setMatcher(postFilter)),postFinder&&!postFinder[expando]&&(postFinder=setMatcher(postFinder,postSelector)),markFunction(function(seed,results,context,xml){var temp,i,elem,preMap=[],postMap=[],preexisting=results.length,elems=seed||multipleContexts(selector||"*",context.nodeType?[context]:context,[]),matcherIn=!preFilter||!seed&&selector?elems:condense(elems,preMap,preFilter,context,xml),matcherOut=matcher?postFinder||(seed?preFilter:preexisting||postFilter)?[]:results:matcherIn;if(matcher&&matcher(matcherIn,matcherOut,context,xml),postFilter)for(temp=condense(matcherOut,postMap),postFilter(temp,[],context,xml),i=temp.length;i--;)(elem=temp[i])&&(matcherOut[postMap[i]]=!(matcherIn[postMap[i]]=elem));if(seed){if(postFinder||preFilter){if(postFinder){for(temp=[],i=matcherOut.length;i--;)(elem=matcherOut[i])&&temp.push(matcherIn[i]=elem);postFinder(null,matcherOut=[],temp,xml)}for(i=matcherOut.length;i--;)(elem=matcherOut[i])&&(temp=postFinder?indexOf(seed,elem):preMap[i])>-1&&(seed[temp]=!(results[temp]=elem))}}else matcherOut=condense(matcherOut===results?matcherOut.splice(preexisting,matcherOut.length):matcherOut),postFinder?postFinder(null,results,matcherOut,xml):push.apply(results,matcherOut)})}function matcherFromTokens(tokens){for(var checkContext,matcher,j,len=tokens.length,leadingRelative=Expr.relative[tokens[0].type],implicitRelative=leadingRelative||Expr.relative[" "],i=leadingRelative?1:0,matchContext=addCombinator(function(elem){return elem===checkContext},implicitRelative,!0),matchAnyContext=addCombinator(function(elem){return indexOf(checkContext,elem)>-1},implicitRelative,!0),matchers=[function(elem,context,xml){var ret=!leadingRelative&&(xml||context!==outermostContext)||((checkContext=context).nodeType?matchContext(elem,context,xml):matchAnyContext(elem,context,xml));return checkContext=null,ret}];i<len;i++)if(matcher=Expr.relative[tokens[i].type])matchers=[addCombinator(elementMatcher(matchers),matcher)];else{if(matcher=Expr.filter[tokens[i].type].apply(null,tokens[i].matches),matcher[expando]){for(j=++i;j<len&&!Expr.relative[tokens[j].type];j++);return setMatcher(i>1&&elementMatcher(matchers),i>1&&toSelector(tokens.slice(0,i-1).concat({value:" "===tokens[i-2].type?"*":""})).replace(rtrim,"$1"),matcher,i<j&&matcherFromTokens(tokens.slice(i,j)),j<len&&matcherFromTokens(tokens=tokens.slice(j)),j<len&&toSelector(tokens))}matchers.push(matcher)}return elementMatcher(matchers)}function matcherFromGroupMatchers(elementMatchers,setMatchers){var bySet=setMatchers.length>0,byElement=elementMatchers.length>0,superMatcher=function(seed,context,xml,results,outermost){var elem,j,matcher,matchedCount=0,i="0",unmatched=seed&&[],setMatched=[],contextBackup=outermostContext,elems=seed||byElement&&Expr.find.TAG("*",outermost),dirrunsUnique=dirruns+=null==contextBackup?1:Math.random()||.1,len=elems.length;for(outermost&&(outermostContext=context===document||context||outermost);i!==len&&null!=(elem=elems[i]);i++){if(byElement&&elem){for(j=0,context||elem.ownerDocument===document||(setDocument(elem),xml=!documentIsHTML);matcher=elementMatchers[j++];)if(matcher(elem,context||document,xml)){results.push(elem);break}outermost&&(dirruns=dirrunsUnique)}bySet&&((elem=!matcher&&elem)&&matchedCount--,seed&&unmatched.push(elem))}if(matchedCount+=i,bySet&&i!==matchedCount){for(j=0;matcher=setMatchers[j++];)matcher(unmatched,setMatched,context,xml);if(seed){if(matchedCount>0)for(;i--;)unmatched[i]||setMatched[i]||(setMatched[i]=pop.call(results));setMatched=condense(setMatched)}push.apply(results,setMatched),outermost&&!seed&&setMatched.length>0&&matchedCount+setMatchers.length>1&&Sizzle.uniqueSort(results)}return outermost&&(dirruns=dirrunsUnique,outermostContext=contextBackup),unmatched};return bySet?markFunction(superMatcher):superMatcher}var i,support,Expr,getText,isXML,tokenize,compile,select,outermostContext,sortInput,hasDuplicate,setDocument,document,docElem,documentIsHTML,rbuggyQSA,rbuggyMatches,matches,contains,expando="sizzle"+1*new Date,preferredDoc=window.document,dirruns=0,done=0,classCache=createCache(),tokenCache=createCache(),compilerCache=createCache(),sortOrder=function(a,b){return a===b&&(hasDuplicate=!0),0},MAX_NEGATIVE=1<<31,hasOwn={}.hasOwnProperty,arr=[],pop=arr.pop,push_native=arr.push,push=arr.push,slice=arr.slice,indexOf=function(list,elem){for(var i=0,len=list.length;i<len;i++)if(list[i]===elem)return i;return-1},booleans="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",whitespace="[\\x20\\t\\r\\n\\f]",identifier="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",attributes="\\["+whitespace+"*("+identifier+")(?:"+whitespace+"*([*^$|!~]?=)"+whitespace+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+identifier+"))|)"+whitespace+"*\\]",pseudos=":("+identifier+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+attributes+")*)|.*)\\)|)",rwhitespace=new RegExp(whitespace+"+","g"),rtrim=new RegExp("^"+whitespace+"+|((?:^|[^\\\\])(?:\\\\.)*)"+whitespace+"+$","g"),rcomma=new RegExp("^"+whitespace+"*,"+whitespace+"*"),rcombinators=new RegExp("^"+whitespace+"*([>+~]|"+whitespace+")"+whitespace+"*"),rattributeQuotes=new RegExp("="+whitespace+"*([^\\]'\"]*?)"+whitespace+"*\\]","g"),rpseudo=new RegExp(pseudos),ridentifier=new RegExp("^"+identifier+"$"),matchExpr={ID:new RegExp("^#("+identifier+")"),CLASS:new RegExp("^\\.("+identifier+")"),TAG:new RegExp("^("+identifier+"|[*])"),ATTR:new RegExp("^"+attributes),PSEUDO:new RegExp("^"+pseudos),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+whitespace+"*(even|odd|(([+-]|)(\\d*)n|)"+whitespace+"*(?:([+-]|)"+whitespace+"*(\\d+)|))"+whitespace+"*\\)|)","i"),bool:new RegExp("^(?:"+booleans+")$","i"),needsContext:new RegExp("^"+whitespace+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+whitespace+"*((?:-\\d)?\\d*)"+whitespace+"*\\)|)(?=[^-]|$)","i")},rinputs=/^(?:input|select|textarea|button)$/i,rheader=/^h\d$/i,rnative=/^[^{]+\{\s*\[native \w/,rquickExpr=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,rsibling=/[+~]/,rescape=/'|\\/g,runescape=new RegExp("\\\\([\\da-f]{1,6}"+whitespace+"?|("+whitespace+")|.)","ig"),funescape=function(_,escaped,escapedWhitespace){var high="0x"+escaped-65536;return high!==high||escapedWhitespace?escaped:high<0?String.fromCharCode(high+65536):String.fromCharCode(high>>10|55296,1023&high|56320)},unloadHandler=function(){setDocument()};try{push.apply(arr=slice.call(preferredDoc.childNodes),preferredDoc.childNodes),arr[preferredDoc.childNodes.length].nodeType}catch(e){push={apply:arr.length?function(target,els){push_native.apply(target,slice.call(els))}:function(target,els){for(var j=target.length,i=0;target[j++]=els[i++];);target.length=j-1}}}support=Sizzle.support={},isXML=Sizzle.isXML=function(elem){var documentElement=elem&&(elem.ownerDocument||elem).documentElement;return!!documentElement&&"HTML"!==documentElement.nodeName},setDocument=Sizzle.setDocument=function(node){var hasCompare,parent,doc=node?node.ownerDocument||node:preferredDoc;return doc!==document&&9===doc.nodeType&&doc.documentElement?(document=doc,docElem=document.documentElement,documentIsHTML=!isXML(document),(parent=document.defaultView)&&parent.top!==parent&&(parent.addEventListener?parent.addEventListener("unload",unloadHandler,!1):parent.attachEvent&&parent.attachEvent("onunload",unloadHandler)),support.attributes=assert(function(div){return div.className="i",!div.getAttribute("className")}),support.getElementsByTagName=assert(function(div){return div.appendChild(document.createComment("")),!div.getElementsByTagName("*").length}),support.getElementsByClassName=rnative.test(document.getElementsByClassName),support.getById=assert(function(div){return docElem.appendChild(div).id=expando,!document.getElementsByName||!document.getElementsByName(expando).length}),support.getById?(Expr.find.ID=function(id,context){if("undefined"!=typeof context.getElementById&&documentIsHTML){var m=context.getElementById(id);return m?[m]:[]}},Expr.filter.ID=function(id){var attrId=id.replace(runescape,funescape);return function(elem){return elem.getAttribute("id")===attrId}}):(delete Expr.find.ID,Expr.filter.ID=function(id){var attrId=id.replace(runescape,funescape);return function(elem){var node="undefined"!=typeof elem.getAttributeNode&&elem.getAttributeNode("id");return node&&node.value===attrId}}),Expr.find.TAG=support.getElementsByTagName?function(tag,context){return"undefined"!=typeof context.getElementsByTagName?context.getElementsByTagName(tag):support.qsa?context.querySelectorAll(tag):void 0}:function(tag,context){var elem,tmp=[],i=0,results=context.getElementsByTagName(tag);if("*"===tag){for(;elem=results[i++];)1===elem.nodeType&&tmp.push(elem);return tmp}return results},Expr.find.CLASS=support.getElementsByClassName&&function(className,context){if("undefined"!=typeof context.getElementsByClassName&&documentIsHTML)return context.getElementsByClassName(className)},rbuggyMatches=[],rbuggyQSA=[],(support.qsa=rnative.test(document.querySelectorAll))&&(assert(function(div){docElem.appendChild(div).innerHTML="<a id='"+expando+"'></a><select id='"+expando+"-\r\\' msallowcapture=''><option selected=''></option></select>",div.querySelectorAll("[msallowcapture^='']").length&&rbuggyQSA.push("[*^$]="+whitespace+"*(?:''|\"\")"),div.querySelectorAll("[selected]").length||rbuggyQSA.push("\\["+whitespace+"*(?:value|"+booleans+")"),div.querySelectorAll("[id~="+expando+"-]").length||rbuggyQSA.push("~="),div.querySelectorAll(":checked").length||rbuggyQSA.push(":checked"),div.querySelectorAll("a#"+expando+"+*").length||rbuggyQSA.push(".#.+[+~]")}),assert(function(div){var input=document.createElement("input");input.setAttribute("type","hidden"),div.appendChild(input).setAttribute("name","D"),div.querySelectorAll("[name=d]").length&&rbuggyQSA.push("name"+whitespace+"*[*^$|!~]?="),div.querySelectorAll(":enabled").length||rbuggyQSA.push(":enabled",":disabled"),div.querySelectorAll("*,:x"),rbuggyQSA.push(",.*:")})),(support.matchesSelector=rnative.test(matches=docElem.matches||docElem.webkitMatchesSelector||docElem.mozMatchesSelector||docElem.oMatchesSelector||docElem.msMatchesSelector))&&assert(function(div){support.disconnectedMatch=matches.call(div,"div"),matches.call(div,"[s!='']:x"),rbuggyMatches.push("!=",pseudos)}),rbuggyQSA=rbuggyQSA.length&&new RegExp(rbuggyQSA.join("|")),rbuggyMatches=rbuggyMatches.length&&new RegExp(rbuggyMatches.join("|")),hasCompare=rnative.test(docElem.compareDocumentPosition),contains=hasCompare||rnative.test(docElem.contains)?function(a,b){var adown=9===a.nodeType?a.documentElement:a,bup=b&&b.parentNode;return a===bup||!(!bup||1!==bup.nodeType||!(adown.contains?adown.contains(bup):a.compareDocumentPosition&&16&a.compareDocumentPosition(bup)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},sortOrder=hasCompare?function(a,b){if(a===b)return hasDuplicate=!0,0;var compare=!a.compareDocumentPosition-!b.compareDocumentPosition;return compare?compare:(compare=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&compare||!support.sortDetached&&b.compareDocumentPosition(a)===compare?a===document||a.ownerDocument===preferredDoc&&contains(preferredDoc,a)?-1:b===document||b.ownerDocument===preferredDoc&&contains(preferredDoc,b)?1:sortInput?indexOf(sortInput,a)-indexOf(sortInput,b):0:4&compare?-1:1)}:function(a,b){if(a===b)return hasDuplicate=!0,0;var cur,i=0,aup=a.parentNode,bup=b.parentNode,ap=[a],bp=[b];if(!aup||!bup)return a===document?-1:b===document?1:aup?-1:bup?1:sortInput?indexOf(sortInput,a)-indexOf(sortInput,b):0;if(aup===bup)return siblingCheck(a,b);for(cur=a;cur=cur.parentNode;)ap.unshift(cur);for(cur=b;cur=cur.parentNode;)bp.unshift(cur);for(;ap[i]===bp[i];)i++;return i?siblingCheck(ap[i],bp[i]):ap[i]===preferredDoc?-1:bp[i]===preferredDoc?1:0},document):document},Sizzle.matches=function(expr,elements){return Sizzle(expr,null,null,elements)},Sizzle.matchesSelector=function(elem,expr){if((elem.ownerDocument||elem)!==document&&setDocument(elem),expr=expr.replace(rattributeQuotes,"='$1']"),support.matchesSelector&&documentIsHTML&&!compilerCache[expr+" "]&&(!rbuggyMatches||!rbuggyMatches.test(expr))&&(!rbuggyQSA||!rbuggyQSA.test(expr)))try{var ret=matches.call(elem,expr);if(ret||support.disconnectedMatch||elem.document&&11!==elem.document.nodeType)return ret}catch(e){}return Sizzle(expr,document,null,[elem]).length>0},Sizzle.contains=function(context,elem){return(context.ownerDocument||context)!==document&&setDocument(context),contains(context,elem)},Sizzle.attr=function(elem,name){(elem.ownerDocument||elem)!==document&&setDocument(elem);var fn=Expr.attrHandle[name.toLowerCase()],val=fn&&hasOwn.call(Expr.attrHandle,name.toLowerCase())?fn(elem,name,!documentIsHTML):void 0;return void 0!==val?val:support.attributes||!documentIsHTML?elem.getAttribute(name):(val=elem.getAttributeNode(name))&&val.specified?val.value:null},Sizzle.error=function(msg){throw new Error("Syntax error, unrecognized expression: "+msg)},Sizzle.uniqueSort=function(results){var elem,duplicates=[],j=0,i=0;if(hasDuplicate=!support.detectDuplicates,sortInput=!support.sortStable&&results.slice(0),results.sort(sortOrder),hasDuplicate){for(;elem=results[i++];)elem===results[i]&&(j=duplicates.push(i));for(;j--;)results.splice(duplicates[j],1)}return sortInput=null,results},getText=Sizzle.getText=function(elem){var node,ret="",i=0,nodeType=elem.nodeType;if(nodeType){if(1===nodeType||9===nodeType||11===nodeType){if("string"==typeof elem.textContent)return elem.textContent;for(elem=elem.firstChild;elem;elem=elem.nextSibling)ret+=getText(elem)}else if(3===nodeType||4===nodeType)return elem.nodeValue}else for(;node=elem[i++];)ret+=getText(node);return ret},Expr=Sizzle.selectors={cacheLength:50,createPseudo:markFunction,match:matchExpr,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(match){return match[1]=match[1].replace(runescape,funescape),match[3]=(match[3]||match[4]||match[5]||"").replace(runescape,funescape),"~="===match[2]&&(match[3]=" "+match[3]+" "),match.slice(0,4)},CHILD:function(match){return match[1]=match[1].toLowerCase(),"nth"===match[1].slice(0,3)?(match[3]||Sizzle.error(match[0]),match[4]=+(match[4]?match[5]+(match[6]||1):2*("even"===match[3]||"odd"===match[3])),match[5]=+(match[7]+match[8]||"odd"===match[3])):match[3]&&Sizzle.error(match[0]),match},PSEUDO:function(match){var excess,unquoted=!match[6]&&match[2];return matchExpr.CHILD.test(match[0])?null:(match[3]?match[2]=match[4]||match[5]||"":unquoted&&rpseudo.test(unquoted)&&(excess=tokenize(unquoted,!0))&&(excess=unquoted.indexOf(")",unquoted.length-excess)-unquoted.length)&&(match[0]=match[0].slice(0,excess),match[2]=unquoted.slice(0,excess)),match.slice(0,3))}},filter:{TAG:function(nodeNameSelector){var nodeName=nodeNameSelector.replace(runescape,funescape).toLowerCase();return"*"===nodeNameSelector?function(){return!0}:function(elem){return elem.nodeName&&elem.nodeName.toLowerCase()===nodeName}},CLASS:function(className){var pattern=classCache[className+" "];return pattern||(pattern=new RegExp("(^|"+whitespace+")"+className+"("+whitespace+"|$)"))&&classCache(className,function(elem){return pattern.test("string"==typeof elem.className&&elem.className||"undefined"!=typeof elem.getAttribute&&elem.getAttribute("class")||"")})},ATTR:function(name,operator,check){return function(elem){var result=Sizzle.attr(elem,name);return null==result?"!="===operator:!operator||(result+="","="===operator?result===check:"!="===operator?result!==check:"^="===operator?check&&0===result.indexOf(check):"*="===operator?check&&result.indexOf(check)>-1:"$="===operator?check&&result.slice(-check.length)===check:"~="===operator?(" "+result.replace(rwhitespace," ")+" ").indexOf(check)>-1:"|="===operator&&(result===check||result.slice(0,check.length+1)===check+"-"))}},CHILD:function(type,what,argument,first,last){var simple="nth"!==type.slice(0,3),forward="last"!==type.slice(-4),ofType="of-type"===what;return 1===first&&0===last?function(elem){return!!elem.parentNode}:function(elem,context,xml){var cache,uniqueCache,outerCache,node,nodeIndex,start,dir=simple!==forward?"nextSibling":"previousSibling",parent=elem.parentNode,name=ofType&&elem.nodeName.toLowerCase(),useCache=!xml&&!ofType,diff=!1;if(parent){if(simple){for(;dir;){for(node=elem;node=node[dir];)if(ofType?node.nodeName.toLowerCase()===name:1===node.nodeType)return!1;start=dir="only"===type&&!start&&"nextSibling"}return!0}if(start=[forward?parent.firstChild:parent.lastChild],forward&&useCache){for(node=parent,outerCache=node[expando]||(node[expando]={}),uniqueCache=outerCache[node.uniqueID]||(outerCache[node.uniqueID]={}),cache=uniqueCache[type]||[],nodeIndex=cache[0]===dirruns&&cache[1],diff=nodeIndex&&cache[2],node=nodeIndex&&parent.childNodes[nodeIndex];node=++nodeIndex&&node&&node[dir]||(diff=nodeIndex=0)||start.pop();)if(1===node.nodeType&&++diff&&node===elem){uniqueCache[type]=[dirruns,nodeIndex,diff];break}}else if(useCache&&(node=elem,outerCache=node[expando]||(node[expando]={}),uniqueCache=outerCache[node.uniqueID]||(outerCache[node.uniqueID]={}),cache=uniqueCache[type]||[],nodeIndex=cache[0]===dirruns&&cache[1],diff=nodeIndex),diff===!1)for(;(node=++nodeIndex&&node&&node[dir]||(diff=nodeIndex=0)||start.pop())&&((ofType?node.nodeName.toLowerCase()!==name:1!==node.nodeType)||!++diff||(useCache&&(outerCache=node[expando]||(node[expando]={}),uniqueCache=outerCache[node.uniqueID]||(outerCache[node.uniqueID]={}),uniqueCache[type]=[dirruns,diff]),node!==elem)););return diff-=last,diff===first||diff%first===0&&diff/first>=0}}},PSEUDO:function(pseudo,argument){var args,fn=Expr.pseudos[pseudo]||Expr.setFilters[pseudo.toLowerCase()]||Sizzle.error("unsupported pseudo: "+pseudo);return fn[expando]?fn(argument):fn.length>1?(args=[pseudo,pseudo,"",argument],Expr.setFilters.hasOwnProperty(pseudo.toLowerCase())?markFunction(function(seed,matches){for(var idx,matched=fn(seed,argument),i=matched.length;i--;)idx=indexOf(seed,matched[i]),seed[idx]=!(matches[idx]=matched[i])}):function(elem){return fn(elem,0,args)}):fn}},pseudos:{not:markFunction(function(selector){var input=[],results=[],matcher=compile(selector.replace(rtrim,"$1"));return matcher[expando]?markFunction(function(seed,matches,context,xml){for(var elem,unmatched=matcher(seed,null,xml,[]),i=seed.length;i--;)(elem=unmatched[i])&&(seed[i]=!(matches[i]=elem))}):function(elem,context,xml){return input[0]=elem,matcher(input,null,xml,results),input[0]=null,!results.pop()}}),has:markFunction(function(selector){return function(elem){return Sizzle(selector,elem).length>0}}),contains:markFunction(function(text){return text=text.replace(runescape,funescape),function(elem){return(elem.textContent||elem.innerText||getText(elem)).indexOf(text)>-1}}),lang:markFunction(function(lang){return ridentifier.test(lang||"")||Sizzle.error("unsupported lang: "+lang),lang=lang.replace(runescape,funescape).toLowerCase(),function(elem){var elemLang;do if(elemLang=documentIsHTML?elem.lang:elem.getAttribute("xml:lang")||elem.getAttribute("lang"))return elemLang=elemLang.toLowerCase(),elemLang===lang||0===elemLang.indexOf(lang+"-");while((elem=elem.parentNode)&&1===elem.nodeType);return!1}}),target:function(elem){var hash=window.location&&window.location.hash;return hash&&hash.slice(1)===elem.id},root:function(elem){return elem===docElem},focus:function(elem){return elem===document.activeElement&&(!document.hasFocus||document.hasFocus())&&!!(elem.type||elem.href||~elem.tabIndex)},enabled:function(elem){return elem.disabled===!1},disabled:function(elem){return elem.disabled===!0},checked:function(elem){var nodeName=elem.nodeName.toLowerCase();return"input"===nodeName&&!!elem.checked||"option"===nodeName&&!!elem.selected},selected:function(elem){return elem.parentNode&&elem.parentNode.selectedIndex,elem.selected===!0},empty:function(elem){for(elem=elem.firstChild;elem;elem=elem.nextSibling)if(elem.nodeType<6)return!1;return!0},parent:function(elem){return!Expr.pseudos.empty(elem)},header:function(elem){return rheader.test(elem.nodeName)},input:function(elem){return rinputs.test(elem.nodeName)},button:function(elem){var name=elem.nodeName.toLowerCase();return"input"===name&&"button"===elem.type||"button"===name},text:function(elem){var attr;return"input"===elem.nodeName.toLowerCase()&&"text"===elem.type&&(null==(attr=elem.getAttribute("type"))||"text"===attr.toLowerCase())},first:createPositionalPseudo(function(){return[0]}),last:createPositionalPseudo(function(matchIndexes,length){return[length-1]}),eq:createPositionalPseudo(function(matchIndexes,length,argument){return[argument<0?argument+length:argument]}),even:createPositionalPseudo(function(matchIndexes,length){for(var i=0;i<length;i+=2)matchIndexes.push(i);return matchIndexes}),odd:createPositionalPseudo(function(matchIndexes,length){for(var i=1;i<length;i+=2)matchIndexes.push(i);return matchIndexes}),lt:createPositionalPseudo(function(matchIndexes,length,argument){for(var i=argument<0?argument+length:argument;--i>=0;)matchIndexes.push(i);return matchIndexes}),gt:createPositionalPseudo(function(matchIndexes,length,argument){for(var i=argument<0?argument+length:argument;++i<length;)matchIndexes.push(i);return matchIndexes})}},Expr.pseudos.nth=Expr.pseudos.eq;for(i in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})Expr.pseudos[i]=createInputPseudo(i);for(i in{submit:!0,reset:!0})Expr.pseudos[i]=createButtonPseudo(i);return setFilters.prototype=Expr.filters=Expr.pseudos,Expr.setFilters=new setFilters,tokenize=Sizzle.tokenize=function(selector,parseOnly){var matched,match,tokens,type,soFar,groups,preFilters,cached=tokenCache[selector+" "];if(cached)return parseOnly?0:cached.slice(0);for(soFar=selector,groups=[],preFilters=Expr.preFilter;soFar;){matched&&!(match=rcomma.exec(soFar))||(match&&(soFar=soFar.slice(match[0].length)||soFar),groups.push(tokens=[])),matched=!1,(match=rcombinators.exec(soFar))&&(matched=match.shift(),tokens.push({value:matched,type:match[0].replace(rtrim," ")}),soFar=soFar.slice(matched.length));for(type in Expr.filter)!(match=matchExpr[type].exec(soFar))||preFilters[type]&&!(match=preFilters[type](match))||(matched=match.shift(),tokens.push({value:matched,type:type,matches:match}),soFar=soFar.slice(matched.length));if(!matched)break}return parseOnly?soFar.length:soFar?Sizzle.error(selector):tokenCache(selector,groups).slice(0)},compile=Sizzle.compile=function(selector,match){var i,setMatchers=[],elementMatchers=[],cached=compilerCache[selector+" "];if(!cached){for(match||(match=tokenize(selector)),i=match.length;i--;)cached=matcherFromTokens(match[i]),cached[expando]?setMatchers.push(cached):elementMatchers.push(cached);cached=compilerCache(selector,matcherFromGroupMatchers(elementMatchers,setMatchers)),cached.selector=selector}return cached},select=Sizzle.select=function(selector,context,results,seed){var i,tokens,token,type,find,compiled="function"==typeof selector&&selector,match=!seed&&tokenize(selector=compiled.selector||selector);if(results=results||[],1===match.length){if(tokens=match[0]=match[0].slice(0),tokens.length>2&&"ID"===(token=tokens[0]).type&&support.getById&&9===context.nodeType&&documentIsHTML&&Expr.relative[tokens[1].type]){if(context=(Expr.find.ID(token.matches[0].replace(runescape,funescape),context)||[])[0],!context)return results;compiled&&(context=context.parentNode),selector=selector.slice(tokens.shift().value.length)}for(i=matchExpr.needsContext.test(selector)?0:tokens.length;i--&&(token=tokens[i],!Expr.relative[type=token.type]);)if((find=Expr.find[type])&&(seed=find(token.matches[0].replace(runescape,funescape),rsibling.test(tokens[0].type)&&testContext(context.parentNode)||context))){if(tokens.splice(i,1),selector=seed.length&&toSelector(tokens),!selector)return push.apply(results,seed),results;break}}return(compiled||compile(selector,match))(seed,context,!documentIsHTML,results,!context||rsibling.test(selector)&&testContext(context.parentNode)||context),results},support.sortStable=expando.split("").sort(sortOrder).join("")===expando,support.detectDuplicates=!!hasDuplicate,setDocument(),support.sortDetached=assert(function(div1){return 1&div1.compareDocumentPosition(document.createElement("div"))}),assert(function(div){return div.innerHTML="<a href='#'></a>","#"===div.firstChild.getAttribute("href")})||addHandle("type|href|height|width",function(elem,name,isXML){if(!isXML)return elem.getAttribute(name,"type"===name.toLowerCase()?1:2)}),support.attributes&&assert(function(div){return div.innerHTML="<input/>",div.firstChild.setAttribute("value",""),""===div.firstChild.getAttribute("value")})||addHandle("value",function(elem,name,isXML){if(!isXML&&"input"===elem.nodeName.toLowerCase())return elem.defaultValue}),assert(function(div){return null==div.getAttribute("disabled")})||addHandle(booleans,function(elem,name,isXML){var val;if(!isXML)return elem[name]===!0?name.toLowerCase():(val=elem.getAttributeNode(name))&&val.specified?val.value:null}),Sizzle}(window);jQuery.find=Sizzle,jQuery.expr=Sizzle.selectors,jQuery.expr[":"]=jQuery.expr.pseudos,jQuery.uniqueSort=jQuery.unique=Sizzle.uniqueSort,jQuery.text=Sizzle.getText,jQuery.isXMLDoc=Sizzle.isXML,jQuery.contains=Sizzle.contains;var dir=function(elem,dir,until){for(var matched=[],truncate=void 0!==until;(elem=elem[dir])&&9!==elem.nodeType;)if(1===elem.nodeType){if(truncate&&jQuery(elem).is(until))break;matched.push(elem)}return matched},siblings=function(n,elem){for(var matched=[];n;n=n.nextSibling)1===n.nodeType&&n!==elem&&matched.push(n);return matched},rneedsContext=jQuery.expr.match.needsContext,rsingleTag=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,risSimple=/^.[^:#\[\.,]*$/;jQuery.filter=function(expr,elems,not){var elem=elems[0];return not&&(expr=":not("+expr+")"),1===elems.length&&1===elem.nodeType?jQuery.find.matchesSelector(elem,expr)?[elem]:[]:jQuery.find.matches(expr,jQuery.grep(elems,function(elem){return 1===elem.nodeType}))},jQuery.fn.extend({find:function(selector){var i,len=this.length,ret=[],self=this;if("string"!=typeof selector)return this.pushStack(jQuery(selector).filter(function(){for(i=0;i<len;i++)if(jQuery.contains(self[i],this))return!0}));for(i=0;i<len;i++)jQuery.find(selector,self[i],ret);return ret=this.pushStack(len>1?jQuery.unique(ret):ret),ret.selector=this.selector?this.selector+" "+selector:selector,ret},filter:function(selector){return this.pushStack(winnow(this,selector||[],!1))},not:function(selector){return this.pushStack(winnow(this,selector||[],!0))},is:function(selector){return!!winnow(this,"string"==typeof selector&&rneedsContext.test(selector)?jQuery(selector):selector||[],!1).length}});var rootjQuery,rquickExpr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,init=jQuery.fn.init=function(selector,context,root){var match,elem;if(!selector)return this;if(root=root||rootjQuery,"string"==typeof selector){if(match="<"===selector[0]&&">"===selector[selector.length-1]&&selector.length>=3?[null,selector,null]:rquickExpr.exec(selector),
!match||!match[1]&&context)return!context||context.jquery?(context||root).find(selector):this.constructor(context).find(selector);if(match[1]){if(context=context instanceof jQuery?context[0]:context,jQuery.merge(this,jQuery.parseHTML(match[1],context&&context.nodeType?context.ownerDocument||context:document,!0)),rsingleTag.test(match[1])&&jQuery.isPlainObject(context))for(match in context)jQuery.isFunction(this[match])?this[match](context[match]):this.attr(match,context[match]);return this}return elem=document.getElementById(match[2]),elem&&elem.parentNode&&(this.length=1,this[0]=elem),this.context=document,this.selector=selector,this}return selector.nodeType?(this.context=this[0]=selector,this.length=1,this):jQuery.isFunction(selector)?void 0!==root.ready?root.ready(selector):selector(jQuery):(void 0!==selector.selector&&(this.selector=selector.selector,this.context=selector.context),jQuery.makeArray(selector,this))};init.prototype=jQuery.fn,rootjQuery=jQuery(document);var rparentsprev=/^(?:parents|prev(?:Until|All))/,guaranteedUnique={children:!0,contents:!0,next:!0,prev:!0};jQuery.fn.extend({has:function(target){var targets=jQuery(target,this),l=targets.length;return this.filter(function(){for(var i=0;i<l;i++)if(jQuery.contains(this,targets[i]))return!0})},closest:function(selectors,context){for(var cur,i=0,l=this.length,matched=[],pos=rneedsContext.test(selectors)||"string"!=typeof selectors?jQuery(selectors,context||this.context):0;i<l;i++)for(cur=this[i];cur&&cur!==context;cur=cur.parentNode)if(cur.nodeType<11&&(pos?pos.index(cur)>-1:1===cur.nodeType&&jQuery.find.matchesSelector(cur,selectors))){matched.push(cur);break}return this.pushStack(matched.length>1?jQuery.uniqueSort(matched):matched)},index:function(elem){return elem?"string"==typeof elem?indexOf.call(jQuery(elem),this[0]):indexOf.call(this,elem.jquery?elem[0]:elem):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(selector,context){return this.pushStack(jQuery.uniqueSort(jQuery.merge(this.get(),jQuery(selector,context))))},addBack:function(selector){return this.add(null==selector?this.prevObject:this.prevObject.filter(selector))}}),jQuery.each({parent:function(elem){var parent=elem.parentNode;return parent&&11!==parent.nodeType?parent:null},parents:function(elem){return dir(elem,"parentNode")},parentsUntil:function(elem,i,until){return dir(elem,"parentNode",until)},next:function(elem){return sibling(elem,"nextSibling")},prev:function(elem){return sibling(elem,"previousSibling")},nextAll:function(elem){return dir(elem,"nextSibling")},prevAll:function(elem){return dir(elem,"previousSibling")},nextUntil:function(elem,i,until){return dir(elem,"nextSibling",until)},prevUntil:function(elem,i,until){return dir(elem,"previousSibling",until)},siblings:function(elem){return siblings((elem.parentNode||{}).firstChild,elem)},children:function(elem){return siblings(elem.firstChild)},contents:function(elem){return elem.contentDocument||jQuery.merge([],elem.childNodes)}},function(name,fn){jQuery.fn[name]=function(until,selector){var matched=jQuery.map(this,fn,until);return"Until"!==name.slice(-5)&&(selector=until),selector&&"string"==typeof selector&&(matched=jQuery.filter(selector,matched)),this.length>1&&(guaranteedUnique[name]||jQuery.uniqueSort(matched),rparentsprev.test(name)&&matched.reverse()),this.pushStack(matched)}});var rnotwhite=/\S+/g;jQuery.Callbacks=function(options){options="string"==typeof options?createOptions(options):jQuery.extend({},options);var firing,memory,fired,locked,list=[],queue=[],firingIndex=-1,fire=function(){for(locked=options.once,fired=firing=!0;queue.length;firingIndex=-1)for(memory=queue.shift();++firingIndex<list.length;)list[firingIndex].apply(memory[0],memory[1])===!1&&options.stopOnFalse&&(firingIndex=list.length,memory=!1);options.memory||(memory=!1),firing=!1,locked&&(list=memory?[]:"")},self={add:function(){return list&&(memory&&!firing&&(firingIndex=list.length-1,queue.push(memory)),function add(args){jQuery.each(args,function(_,arg){jQuery.isFunction(arg)?options.unique&&self.has(arg)||list.push(arg):arg&&arg.length&&"string"!==jQuery.type(arg)&&add(arg)})}(arguments),memory&&!firing&&fire()),this},remove:function(){return jQuery.each(arguments,function(_,arg){for(var index;(index=jQuery.inArray(arg,list,index))>-1;)list.splice(index,1),index<=firingIndex&&firingIndex--}),this},has:function(fn){return fn?jQuery.inArray(fn,list)>-1:list.length>0},empty:function(){return list&&(list=[]),this},disable:function(){return locked=queue=[],list=memory="",this},disabled:function(){return!list},lock:function(){return locked=queue=[],memory||(list=memory=""),this},locked:function(){return!!locked},fireWith:function(context,args){return locked||(args=args||[],args=[context,args.slice?args.slice():args],queue.push(args),firing||fire()),this},fire:function(){return self.fireWith(this,arguments),this},fired:function(){return!!fired}};return self},jQuery.extend({Deferred:function(func){var tuples=[["resolve","done",jQuery.Callbacks("once memory"),"resolved"],["reject","fail",jQuery.Callbacks("once memory"),"rejected"],["notify","progress",jQuery.Callbacks("memory")]],state="pending",promise={state:function(){return state},always:function(){return deferred.done(arguments).fail(arguments),this},then:function(){var fns=arguments;return jQuery.Deferred(function(newDefer){jQuery.each(tuples,function(i,tuple){var fn=jQuery.isFunction(fns[i])&&fns[i];deferred[tuple[1]](function(){var returned=fn&&fn.apply(this,arguments);returned&&jQuery.isFunction(returned.promise)?returned.promise().progress(newDefer.notify).done(newDefer.resolve).fail(newDefer.reject):newDefer[tuple[0]+"With"](this===promise?newDefer.promise():this,fn?[returned]:arguments)})}),fns=null}).promise()},promise:function(obj){return null!=obj?jQuery.extend(obj,promise):promise}},deferred={};return promise.pipe=promise.then,jQuery.each(tuples,function(i,tuple){var list=tuple[2],stateString=tuple[3];promise[tuple[1]]=list.add,stateString&&list.add(function(){state=stateString},tuples[1^i][2].disable,tuples[2][2].lock),deferred[tuple[0]]=function(){return deferred[tuple[0]+"With"](this===deferred?promise:this,arguments),this},deferred[tuple[0]+"With"]=list.fireWith}),promise.promise(deferred),func&&func.call(deferred,deferred),deferred},when:function(subordinate){var progressValues,progressContexts,resolveContexts,i=0,resolveValues=slice.call(arguments),length=resolveValues.length,remaining=1!==length||subordinate&&jQuery.isFunction(subordinate.promise)?length:0,deferred=1===remaining?subordinate:jQuery.Deferred(),updateFunc=function(i,contexts,values){return function(value){contexts[i]=this,values[i]=arguments.length>1?slice.call(arguments):value,values===progressValues?deferred.notifyWith(contexts,values):--remaining||deferred.resolveWith(contexts,values)}};if(length>1)for(progressValues=new Array(length),progressContexts=new Array(length),resolveContexts=new Array(length);i<length;i++)resolveValues[i]&&jQuery.isFunction(resolveValues[i].promise)?resolveValues[i].promise().progress(updateFunc(i,progressContexts,progressValues)).done(updateFunc(i,resolveContexts,resolveValues)).fail(deferred.reject):--remaining;return remaining||deferred.resolveWith(resolveContexts,resolveValues),deferred.promise()}});var readyList;jQuery.fn.ready=function(fn){return jQuery.ready.promise().done(fn),this},jQuery.extend({isReady:!1,readyWait:1,holdReady:function(hold){hold?jQuery.readyWait++:jQuery.ready(!0)},ready:function(wait){(wait===!0?--jQuery.readyWait:jQuery.isReady)||(jQuery.isReady=!0,wait!==!0&&--jQuery.readyWait>0||(readyList.resolveWith(document,[jQuery]),jQuery.fn.triggerHandler&&(jQuery(document).triggerHandler("ready"),jQuery(document).off("ready"))))}}),jQuery.ready.promise=function(obj){return readyList||(readyList=jQuery.Deferred(),"complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?window.setTimeout(jQuery.ready):(document.addEventListener("DOMContentLoaded",completed),window.addEventListener("load",completed))),readyList.promise(obj)},jQuery.ready.promise();var access=function(elems,fn,key,value,chainable,emptyGet,raw){var i=0,len=elems.length,bulk=null==key;if("object"===jQuery.type(key)){chainable=!0;for(i in key)access(elems,fn,i,key[i],!0,emptyGet,raw)}else if(void 0!==value&&(chainable=!0,jQuery.isFunction(value)||(raw=!0),bulk&&(raw?(fn.call(elems,value),fn=null):(bulk=fn,fn=function(elem,key,value){return bulk.call(jQuery(elem),value)})),fn))for(;i<len;i++)fn(elems[i],key,raw?value:value.call(elems[i],i,fn(elems[i],key)));return chainable?elems:bulk?fn.call(elems):len?fn(elems[0],key):emptyGet},acceptData=function(owner){return 1===owner.nodeType||9===owner.nodeType||!+owner.nodeType};Data.uid=1,Data.prototype={register:function(owner,initial){var value=initial||{};return owner.nodeType?owner[this.expando]=value:Object.defineProperty(owner,this.expando,{value:value,writable:!0,configurable:!0}),owner[this.expando]},cache:function(owner){if(!acceptData(owner))return{};var value=owner[this.expando];return value||(value={},acceptData(owner)&&(owner.nodeType?owner[this.expando]=value:Object.defineProperty(owner,this.expando,{value:value,configurable:!0}))),value},set:function(owner,data,value){var prop,cache=this.cache(owner);if("string"==typeof data)cache[data]=value;else for(prop in data)cache[prop]=data[prop];return cache},get:function(owner,key){return void 0===key?this.cache(owner):owner[this.expando]&&owner[this.expando][key]},access:function(owner,key,value){var stored;return void 0===key||key&&"string"==typeof key&&void 0===value?(stored=this.get(owner,key),void 0!==stored?stored:this.get(owner,jQuery.camelCase(key))):(this.set(owner,key,value),void 0!==value?value:key)},remove:function(owner,key){var i,name,camel,cache=owner[this.expando];if(void 0!==cache){if(void 0===key)this.register(owner);else{jQuery.isArray(key)?name=key.concat(key.map(jQuery.camelCase)):(camel=jQuery.camelCase(key),key in cache?name=[key,camel]:(name=camel,name=name in cache?[name]:name.match(rnotwhite)||[])),i=name.length;for(;i--;)delete cache[name[i]]}(void 0===key||jQuery.isEmptyObject(cache))&&(owner.nodeType?owner[this.expando]=void 0:delete owner[this.expando])}},hasData:function(owner){var cache=owner[this.expando];return void 0!==cache&&!jQuery.isEmptyObject(cache)}};var dataPriv=new Data,dataUser=new Data,rbrace=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,rmultiDash=/[A-Z]/g;jQuery.extend({hasData:function(elem){return dataUser.hasData(elem)||dataPriv.hasData(elem)},data:function(elem,name,data){return dataUser.access(elem,name,data)},removeData:function(elem,name){dataUser.remove(elem,name)},_data:function(elem,name,data){return dataPriv.access(elem,name,data)},_removeData:function(elem,name){dataPriv.remove(elem,name)}}),jQuery.fn.extend({data:function(key,value){var i,name,data,elem=this[0],attrs=elem&&elem.attributes;if(void 0===key){if(this.length&&(data=dataUser.get(elem),1===elem.nodeType&&!dataPriv.get(elem,"hasDataAttrs"))){for(i=attrs.length;i--;)attrs[i]&&(name=attrs[i].name,0===name.indexOf("data-")&&(name=jQuery.camelCase(name.slice(5)),dataAttr(elem,name,data[name])));dataPriv.set(elem,"hasDataAttrs",!0)}return data}return"object"==typeof key?this.each(function(){dataUser.set(this,key)}):access(this,function(value){var data,camelKey;if(elem&&void 0===value){if(data=dataUser.get(elem,key)||dataUser.get(elem,key.replace(rmultiDash,"-$&").toLowerCase()),void 0!==data)return data;if(camelKey=jQuery.camelCase(key),data=dataUser.get(elem,camelKey),void 0!==data)return data;if(data=dataAttr(elem,camelKey,void 0),void 0!==data)return data}else camelKey=jQuery.camelCase(key),this.each(function(){var data=dataUser.get(this,camelKey);dataUser.set(this,camelKey,value),key.indexOf("-")>-1&&void 0!==data&&dataUser.set(this,key,value)})},null,value,arguments.length>1,null,!0)},removeData:function(key){return this.each(function(){dataUser.remove(this,key)})}}),jQuery.extend({queue:function(elem,type,data){var queue;if(elem)return type=(type||"fx")+"queue",queue=dataPriv.get(elem,type),data&&(!queue||jQuery.isArray(data)?queue=dataPriv.access(elem,type,jQuery.makeArray(data)):queue.push(data)),queue||[]},dequeue:function(elem,type){type=type||"fx";var queue=jQuery.queue(elem,type),startLength=queue.length,fn=queue.shift(),hooks=jQuery._queueHooks(elem,type),next=function(){jQuery.dequeue(elem,type)};"inprogress"===fn&&(fn=queue.shift(),startLength--),fn&&("fx"===type&&queue.unshift("inprogress"),delete hooks.stop,fn.call(elem,next,hooks)),!startLength&&hooks&&hooks.empty.fire()},_queueHooks:function(elem,type){var key=type+"queueHooks";return dataPriv.get(elem,key)||dataPriv.access(elem,key,{empty:jQuery.Callbacks("once memory").add(function(){dataPriv.remove(elem,[type+"queue",key])})})}}),jQuery.fn.extend({queue:function(type,data){var setter=2;return"string"!=typeof type&&(data=type,type="fx",setter--),arguments.length<setter?jQuery.queue(this[0],type):void 0===data?this:this.each(function(){var queue=jQuery.queue(this,type,data);jQuery._queueHooks(this,type),"fx"===type&&"inprogress"!==queue[0]&&jQuery.dequeue(this,type)})},dequeue:function(type){return this.each(function(){jQuery.dequeue(this,type)})},clearQueue:function(type){return this.queue(type||"fx",[])},promise:function(type,obj){var tmp,count=1,defer=jQuery.Deferred(),elements=this,i=this.length,resolve=function(){--count||defer.resolveWith(elements,[elements])};for("string"!=typeof type&&(obj=type,type=void 0),type=type||"fx";i--;)tmp=dataPriv.get(elements[i],type+"queueHooks"),tmp&&tmp.empty&&(count++,tmp.empty.add(resolve));return resolve(),defer.promise(obj)}});var pnum=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,rcssNum=new RegExp("^(?:([+-])=|)("+pnum+")([a-z%]*)$","i"),cssExpand=["Top","Right","Bottom","Left"],isHidden=function(elem,el){return elem=el||elem,"none"===jQuery.css(elem,"display")||!jQuery.contains(elem.ownerDocument,elem)},rcheckableType=/^(?:checkbox|radio)$/i,rtagName=/<([\w:-]+)/,rscriptType=/^$|\/(?:java|ecma)script/i,wrapMap={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};wrapMap.optgroup=wrapMap.option,wrapMap.tbody=wrapMap.tfoot=wrapMap.colgroup=wrapMap.caption=wrapMap.thead,wrapMap.th=wrapMap.td;var rhtml=/<|&#?\w+;/;!function(){var fragment=document.createDocumentFragment(),div=fragment.appendChild(document.createElement("div")),input=document.createElement("input");input.setAttribute("type","radio"),input.setAttribute("checked","checked"),input.setAttribute("name","t"),div.appendChild(input),support.checkClone=div.cloneNode(!0).cloneNode(!0).lastChild.checked,div.innerHTML="<textarea>x</textarea>",support.noCloneChecked=!!div.cloneNode(!0).lastChild.defaultValue}();var rkeyEvent=/^key/,rmouseEvent=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,rtypenamespace=/^([^.]*)(?:\.(.+)|)/;jQuery.event={global:{},add:function(elem,types,handler,data,selector){var handleObjIn,eventHandle,tmp,events,t,handleObj,special,handlers,type,namespaces,origType,elemData=dataPriv.get(elem);if(elemData)for(handler.handler&&(handleObjIn=handler,handler=handleObjIn.handler,selector=handleObjIn.selector),handler.guid||(handler.guid=jQuery.guid++),(events=elemData.events)||(events=elemData.events={}),(eventHandle=elemData.handle)||(eventHandle=elemData.handle=function(e){return"undefined"!=typeof jQuery&&jQuery.event.triggered!==e.type?jQuery.event.dispatch.apply(elem,arguments):void 0}),types=(types||"").match(rnotwhite)||[""],t=types.length;t--;)tmp=rtypenamespace.exec(types[t])||[],type=origType=tmp[1],namespaces=(tmp[2]||"").split(".").sort(),type&&(special=jQuery.event.special[type]||{},type=(selector?special.delegateType:special.bindType)||type,special=jQuery.event.special[type]||{},handleObj=jQuery.extend({type:type,origType:origType,data:data,handler:handler,guid:handler.guid,selector:selector,needsContext:selector&&jQuery.expr.match.needsContext.test(selector),namespace:namespaces.join(".")},handleObjIn),(handlers=events[type])||(handlers=events[type]=[],handlers.delegateCount=0,special.setup&&special.setup.call(elem,data,namespaces,eventHandle)!==!1||elem.addEventListener&&elem.addEventListener(type,eventHandle)),special.add&&(special.add.call(elem,handleObj),handleObj.handler.guid||(handleObj.handler.guid=handler.guid)),selector?handlers.splice(handlers.delegateCount++,0,handleObj):handlers.push(handleObj),jQuery.event.global[type]=!0)},remove:function(elem,types,handler,selector,mappedTypes){var j,origCount,tmp,events,t,handleObj,special,handlers,type,namespaces,origType,elemData=dataPriv.hasData(elem)&&dataPriv.get(elem);if(elemData&&(events=elemData.events)){for(types=(types||"").match(rnotwhite)||[""],t=types.length;t--;)if(tmp=rtypenamespace.exec(types[t])||[],type=origType=tmp[1],namespaces=(tmp[2]||"").split(".").sort(),type){for(special=jQuery.event.special[type]||{},type=(selector?special.delegateType:special.bindType)||type,handlers=events[type]||[],tmp=tmp[2]&&new RegExp("(^|\\.)"+namespaces.join("\\.(?:.*\\.|)")+"(\\.|$)"),origCount=j=handlers.length;j--;)handleObj=handlers[j],!mappedTypes&&origType!==handleObj.origType||handler&&handler.guid!==handleObj.guid||tmp&&!tmp.test(handleObj.namespace)||selector&&selector!==handleObj.selector&&("**"!==selector||!handleObj.selector)||(handlers.splice(j,1),handleObj.selector&&handlers.delegateCount--,special.remove&&special.remove.call(elem,handleObj));origCount&&!handlers.length&&(special.teardown&&special.teardown.call(elem,namespaces,elemData.handle)!==!1||jQuery.removeEvent(elem,type,elemData.handle),delete events[type])}else for(type in events)jQuery.event.remove(elem,type+types[t],handler,selector,!0);jQuery.isEmptyObject(events)&&dataPriv.remove(elem,"handle events")}},dispatch:function(event){event=jQuery.event.fix(event);var i,j,ret,matched,handleObj,handlerQueue=[],args=slice.call(arguments),handlers=(dataPriv.get(this,"events")||{})[event.type]||[],special=jQuery.event.special[event.type]||{};if(args[0]=event,event.delegateTarget=this,!special.preDispatch||special.preDispatch.call(this,event)!==!1){for(handlerQueue=jQuery.event.handlers.call(this,event,handlers),i=0;(matched=handlerQueue[i++])&&!event.isPropagationStopped();)for(event.currentTarget=matched.elem,j=0;(handleObj=matched.handlers[j++])&&!event.isImmediatePropagationStopped();)event.rnamespace&&!event.rnamespace.test(handleObj.namespace)||(event.handleObj=handleObj,event.data=handleObj.data,ret=((jQuery.event.special[handleObj.origType]||{}).handle||handleObj.handler).apply(matched.elem,args),void 0!==ret&&(event.result=ret)===!1&&(event.preventDefault(),event.stopPropagation()));return special.postDispatch&&special.postDispatch.call(this,event),event.result}},handlers:function(event,handlers){var i,matches,sel,handleObj,handlerQueue=[],delegateCount=handlers.delegateCount,cur=event.target;if(delegateCount&&cur.nodeType&&("click"!==event.type||isNaN(event.button)||event.button<1))for(;cur!==this;cur=cur.parentNode||this)if(1===cur.nodeType&&(cur.disabled!==!0||"click"!==event.type)){for(matches=[],i=0;i<delegateCount;i++)handleObj=handlers[i],sel=handleObj.selector+" ",void 0===matches[sel]&&(matches[sel]=handleObj.needsContext?jQuery(sel,this).index(cur)>-1:jQuery.find(sel,this,null,[cur]).length),matches[sel]&&matches.push(handleObj);matches.length&&handlerQueue.push({elem:cur,handlers:matches})}return delegateCount<handlers.length&&handlerQueue.push({elem:this,handlers:handlers.slice(delegateCount)}),handlerQueue},props:"altKey bubbles cancelable ctrlKey currentTarget detail eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(event,original){return null==event.which&&(event.which=null!=original.charCode?original.charCode:original.keyCode),event}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(event,original){var eventDoc,doc,body,button=original.button;return null==event.pageX&&null!=original.clientX&&(eventDoc=event.target.ownerDocument||document,doc=eventDoc.documentElement,body=eventDoc.body,event.pageX=original.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc&&doc.clientLeft||body&&body.clientLeft||0),event.pageY=original.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc&&doc.clientTop||body&&body.clientTop||0)),event.which||void 0===button||(event.which=1&button?1:2&button?3:4&button?2:0),event}},fix:function(event){if(event[jQuery.expando])return event;var i,prop,copy,type=event.type,originalEvent=event,fixHook=this.fixHooks[type];for(fixHook||(this.fixHooks[type]=fixHook=rmouseEvent.test(type)?this.mouseHooks:rkeyEvent.test(type)?this.keyHooks:{}),copy=fixHook.props?this.props.concat(fixHook.props):this.props,event=new jQuery.Event(originalEvent),i=copy.length;i--;)prop=copy[i],event[prop]=originalEvent[prop];return event.target||(event.target=document),3===event.target.nodeType&&(event.target=event.target.parentNode),fixHook.filter?fixHook.filter(event,originalEvent):event},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==safeActiveElement()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===safeActiveElement()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&jQuery.nodeName(this,"input"))return this.click(),!1},_default:function(event){return jQuery.nodeName(event.target,"a")}},beforeunload:{postDispatch:function(event){void 0!==event.result&&event.originalEvent&&(event.originalEvent.returnValue=event.result)}}}},jQuery.removeEvent=function(elem,type,handle){elem.removeEventListener&&elem.removeEventListener(type,handle)},jQuery.Event=function(src,props){return this instanceof jQuery.Event?(src&&src.type?(this.originalEvent=src,this.type=src.type,this.isDefaultPrevented=src.defaultPrevented||void 0===src.defaultPrevented&&src.returnValue===!1?returnTrue:returnFalse):this.type=src,props&&jQuery.extend(this,props),this.timeStamp=src&&src.timeStamp||jQuery.now(),void(this[jQuery.expando]=!0)):new jQuery.Event(src,props)},jQuery.Event.prototype={constructor:jQuery.Event,isDefaultPrevented:returnFalse,isPropagationStopped:returnFalse,isImmediatePropagationStopped:returnFalse,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=returnTrue,e&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=returnTrue,e&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=returnTrue,e&&e.stopImmediatePropagation(),this.stopPropagation()}},jQuery.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(orig,fix){jQuery.event.special[orig]={delegateType:fix,bindType:fix,handle:function(event){var ret,target=this,related=event.relatedTarget,handleObj=event.handleObj;return related&&(related===target||jQuery.contains(target,related))||(event.type=handleObj.origType,ret=handleObj.handler.apply(this,arguments),event.type=fix),ret}}}),jQuery.fn.extend({on:function(types,selector,data,fn){return on(this,types,selector,data,fn)},one:function(types,selector,data,fn){return on(this,types,selector,data,fn,1)},off:function(types,selector,fn){var handleObj,type;if(types&&types.preventDefault&&types.handleObj)return handleObj=types.handleObj,jQuery(types.delegateTarget).off(handleObj.namespace?handleObj.origType+"."+handleObj.namespace:handleObj.origType,handleObj.selector,handleObj.handler),this;if("object"==typeof types){for(type in types)this.off(type,selector,types[type]);return this}return selector!==!1&&"function"!=typeof selector||(fn=selector,selector=void 0),fn===!1&&(fn=returnFalse),this.each(function(){jQuery.event.remove(this,types,fn,selector)})}});var rxhtmlTag=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,rnoInnerhtml=/<script|<style|<link/i,rchecked=/checked\s*(?:[^=]|=\s*.checked.)/i,rscriptTypeMasked=/^true\/(.*)/,rcleanScript=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;jQuery.extend({htmlPrefilter:function(html){return html.replace(rxhtmlTag,"<$1></$2>")},clone:function(elem,dataAndEvents,deepDataAndEvents){var i,l,srcElements,destElements,clone=elem.cloneNode(!0),inPage=jQuery.contains(elem.ownerDocument,elem);if(!(support.noCloneChecked||1!==elem.nodeType&&11!==elem.nodeType||jQuery.isXMLDoc(elem)))for(destElements=getAll(clone),srcElements=getAll(elem),i=0,l=srcElements.length;i<l;i++)fixInput(srcElements[i],destElements[i]);if(dataAndEvents)if(deepDataAndEvents)for(srcElements=srcElements||getAll(elem),destElements=destElements||getAll(clone),i=0,l=srcElements.length;i<l;i++)cloneCopyEvent(srcElements[i],destElements[i]);else cloneCopyEvent(elem,clone);return destElements=getAll(clone,"script"),destElements.length>0&&setGlobalEval(destElements,!inPage&&getAll(elem,"script")),clone},cleanData:function(elems){for(var data,elem,type,special=jQuery.event.special,i=0;void 0!==(elem=elems[i]);i++)if(acceptData(elem)){if(data=elem[dataPriv.expando]){if(data.events)for(type in data.events)special[type]?jQuery.event.remove(elem,type):jQuery.removeEvent(elem,type,data.handle);elem[dataPriv.expando]=void 0}elem[dataUser.expando]&&(elem[dataUser.expando]=void 0)}}}),jQuery.fn.extend({domManip:domManip,detach:function(selector){return remove(this,selector,!0)},remove:function(selector){return remove(this,selector)},text:function(value){return access(this,function(value){return void 0===value?jQuery.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=value)})},null,value,arguments.length)},append:function(){return domManip(this,arguments,function(elem){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var target=manipulationTarget(this,elem);target.appendChild(elem)}})},prepend:function(){return domManip(this,arguments,function(elem){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var target=manipulationTarget(this,elem);target.insertBefore(elem,target.firstChild)}})},before:function(){return domManip(this,arguments,function(elem){this.parentNode&&this.parentNode.insertBefore(elem,this)})},after:function(){return domManip(this,arguments,function(elem){this.parentNode&&this.parentNode.insertBefore(elem,this.nextSibling)})},empty:function(){for(var elem,i=0;null!=(elem=this[i]);i++)1===elem.nodeType&&(jQuery.cleanData(getAll(elem,!1)),elem.textContent="");return this},clone:function(dataAndEvents,deepDataAndEvents){return dataAndEvents=null!=dataAndEvents&&dataAndEvents,deepDataAndEvents=null==deepDataAndEvents?dataAndEvents:deepDataAndEvents,this.map(function(){return jQuery.clone(this,dataAndEvents,deepDataAndEvents)})},html:function(value){return access(this,function(value){var elem=this[0]||{},i=0,l=this.length;if(void 0===value&&1===elem.nodeType)return elem.innerHTML;if("string"==typeof value&&!rnoInnerhtml.test(value)&&!wrapMap[(rtagName.exec(value)||["",""])[1].toLowerCase()]){value=jQuery.htmlPrefilter(value);try{for(;i<l;i++)elem=this[i]||{},1===elem.nodeType&&(jQuery.cleanData(getAll(elem,!1)),elem.innerHTML=value);elem=0}catch(e){}}elem&&this.empty().append(value)},null,value,arguments.length)},replaceWith:function(){var ignored=[];return domManip(this,arguments,function(elem){var parent=this.parentNode;jQuery.inArray(this,ignored)<0&&(jQuery.cleanData(getAll(this)),parent&&parent.replaceChild(elem,this))},ignored)}}),jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(selector){for(var elems,ret=[],insert=jQuery(selector),last=insert.length-1,i=0;i<=last;i++)elems=i===last?this:this.clone(!0),jQuery(insert[i])[original](elems),push.apply(ret,elems.get());return this.pushStack(ret)}});var iframe,elemdisplay={HTML:"block",BODY:"block"},rmargin=/^margin/,rnumnonpx=new RegExp("^("+pnum+")(?!px)[a-z%]+$","i"),getStyles=function(elem){var view=elem.ownerDocument.defaultView;return view&&view.opener||(view=window),view.getComputedStyle(elem)},swap=function(elem,options,callback,args){var ret,name,old={};for(name in options)old[name]=elem.style[name],elem.style[name]=options[name];ret=callback.apply(elem,args||[]);for(name in options)elem.style[name]=old[name];return ret},documentElement=document.documentElement;!function(){function computeStyleTests(){div.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",div.innerHTML="",documentElement.appendChild(container);var divStyle=window.getComputedStyle(div);pixelPositionVal="1%"!==divStyle.top,reliableMarginLeftVal="2px"===divStyle.marginLeft,boxSizingReliableVal="4px"===divStyle.width,div.style.marginRight="50%",pixelMarginRightVal="4px"===divStyle.marginRight,documentElement.removeChild(container)}var pixelPositionVal,boxSizingReliableVal,pixelMarginRightVal,reliableMarginLeftVal,container=document.createElement("div"),div=document.createElement("div");div.style&&(div.style.backgroundClip="content-box",div.cloneNode(!0).style.backgroundClip="",support.clearCloneStyle="content-box"===div.style.backgroundClip,container.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",container.appendChild(div),jQuery.extend(support,{pixelPosition:function(){return computeStyleTests(),pixelPositionVal},boxSizingReliable:function(){return null==boxSizingReliableVal&&computeStyleTests(),boxSizingReliableVal},pixelMarginRight:function(){return null==boxSizingReliableVal&&computeStyleTests(),pixelMarginRightVal},reliableMarginLeft:function(){return null==boxSizingReliableVal&&computeStyleTests(),reliableMarginLeftVal},reliableMarginRight:function(){var ret,marginDiv=div.appendChild(document.createElement("div"));return marginDiv.style.cssText=div.style.cssText="-webkit-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",marginDiv.style.marginRight=marginDiv.style.width="0",div.style.width="1px",documentElement.appendChild(container),ret=!parseFloat(window.getComputedStyle(marginDiv).marginRight),documentElement.removeChild(container),div.removeChild(marginDiv),ret}}))}();var rdisplayswap=/^(none|table(?!-c[ea]).+)/,cssShow={position:"absolute",visibility:"hidden",display:"block"},cssNormalTransform={letterSpacing:"0",fontWeight:"400"},cssPrefixes=["Webkit","O","Moz","ms"],emptyStyle=document.createElement("div").style;jQuery.extend({cssHooks:{opacity:{get:function(elem,computed){if(computed){var ret=curCSS(elem,"opacity");return""===ret?"1":ret}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(elem,name,value,extra){if(elem&&3!==elem.nodeType&&8!==elem.nodeType&&elem.style){var ret,type,hooks,origName=jQuery.camelCase(name),style=elem.style;return name=jQuery.cssProps[origName]||(jQuery.cssProps[origName]=vendorPropName(origName)||origName),hooks=jQuery.cssHooks[name]||jQuery.cssHooks[origName],void 0===value?hooks&&"get"in hooks&&void 0!==(ret=hooks.get(elem,!1,extra))?ret:style[name]:(type=typeof value,"string"===type&&(ret=rcssNum.exec(value))&&ret[1]&&(value=adjustCSS(elem,name,ret),type="number"),null!=value&&value===value&&("number"===type&&(value+=ret&&ret[3]||(jQuery.cssNumber[origName]?"":"px")),support.clearCloneStyle||""!==value||0!==name.indexOf("background")||(style[name]="inherit"),hooks&&"set"in hooks&&void 0===(value=hooks.set(elem,value,extra))||(style[name]=value)),
void 0)}},css:function(elem,name,extra,styles){var val,num,hooks,origName=jQuery.camelCase(name);return name=jQuery.cssProps[origName]||(jQuery.cssProps[origName]=vendorPropName(origName)||origName),hooks=jQuery.cssHooks[name]||jQuery.cssHooks[origName],hooks&&"get"in hooks&&(val=hooks.get(elem,!0,extra)),void 0===val&&(val=curCSS(elem,name,styles)),"normal"===val&&name in cssNormalTransform&&(val=cssNormalTransform[name]),""===extra||extra?(num=parseFloat(val),extra===!0||isFinite(num)?num||0:val):val}}),jQuery.each(["height","width"],function(i,name){jQuery.cssHooks[name]={get:function(elem,computed,extra){if(computed)return rdisplayswap.test(jQuery.css(elem,"display"))&&0===elem.offsetWidth?swap(elem,cssShow,function(){return getWidthOrHeight(elem,name,extra)}):getWidthOrHeight(elem,name,extra)},set:function(elem,value,extra){var matches,styles=extra&&getStyles(elem),subtract=extra&&augmentWidthOrHeight(elem,name,extra,"border-box"===jQuery.css(elem,"boxSizing",!1,styles),styles);return subtract&&(matches=rcssNum.exec(value))&&"px"!==(matches[3]||"px")&&(elem.style[name]=value,value=jQuery.css(elem,name)),setPositiveNumber(elem,value,subtract)}}}),jQuery.cssHooks.marginLeft=addGetHookIf(support.reliableMarginLeft,function(elem,computed){if(computed)return(parseFloat(curCSS(elem,"marginLeft"))||elem.getBoundingClientRect().left-swap(elem,{marginLeft:0},function(){return elem.getBoundingClientRect().left}))+"px"}),jQuery.cssHooks.marginRight=addGetHookIf(support.reliableMarginRight,function(elem,computed){if(computed)return swap(elem,{display:"inline-block"},curCSS,[elem,"marginRight"])}),jQuery.each({margin:"",padding:"",border:"Width"},function(prefix,suffix){jQuery.cssHooks[prefix+suffix]={expand:function(value){for(var i=0,expanded={},parts="string"==typeof value?value.split(" "):[value];i<4;i++)expanded[prefix+cssExpand[i]+suffix]=parts[i]||parts[i-2]||parts[0];return expanded}},rmargin.test(prefix)||(jQuery.cssHooks[prefix+suffix].set=setPositiveNumber)}),jQuery.fn.extend({css:function(name,value){return access(this,function(elem,name,value){var styles,len,map={},i=0;if(jQuery.isArray(name)){for(styles=getStyles(elem),len=name.length;i<len;i++)map[name[i]]=jQuery.css(elem,name[i],!1,styles);return map}return void 0!==value?jQuery.style(elem,name,value):jQuery.css(elem,name)},name,value,arguments.length>1)},show:function(){return showHide(this,!0)},hide:function(){return showHide(this)},toggle:function(state){return"boolean"==typeof state?state?this.show():this.hide():this.each(function(){isHidden(this)?jQuery(this).show():jQuery(this).hide()})}}),jQuery.Tween=Tween,Tween.prototype={constructor:Tween,init:function(elem,options,prop,end,easing,unit){this.elem=elem,this.prop=prop,this.easing=easing||jQuery.easing._default,this.options=options,this.start=this.now=this.cur(),this.end=end,this.unit=unit||(jQuery.cssNumber[prop]?"":"px")},cur:function(){var hooks=Tween.propHooks[this.prop];return hooks&&hooks.get?hooks.get(this):Tween.propHooks._default.get(this)},run:function(percent){var eased,hooks=Tween.propHooks[this.prop];return this.options.duration?this.pos=eased=jQuery.easing[this.easing](percent,this.options.duration*percent,0,1,this.options.duration):this.pos=eased=percent,this.now=(this.end-this.start)*eased+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),hooks&&hooks.set?hooks.set(this):Tween.propHooks._default.set(this),this}},Tween.prototype.init.prototype=Tween.prototype,Tween.propHooks={_default:{get:function(tween){var result;return 1!==tween.elem.nodeType||null!=tween.elem[tween.prop]&&null==tween.elem.style[tween.prop]?tween.elem[tween.prop]:(result=jQuery.css(tween.elem,tween.prop,""),result&&"auto"!==result?result:0)},set:function(tween){jQuery.fx.step[tween.prop]?jQuery.fx.step[tween.prop](tween):1!==tween.elem.nodeType||null==tween.elem.style[jQuery.cssProps[tween.prop]]&&!jQuery.cssHooks[tween.prop]?tween.elem[tween.prop]=tween.now:jQuery.style(tween.elem,tween.prop,tween.now+tween.unit)}}},Tween.propHooks.scrollTop=Tween.propHooks.scrollLeft={set:function(tween){tween.elem.nodeType&&tween.elem.parentNode&&(tween.elem[tween.prop]=tween.now)}},jQuery.easing={linear:function(p){return p},swing:function(p){return.5-Math.cos(p*Math.PI)/2},_default:"swing"},jQuery.fx=Tween.prototype.init,jQuery.fx.step={};var fxNow,timerId,rfxtypes=/^(?:toggle|show|hide)$/,rrun=/queueHooks$/;jQuery.Animation=jQuery.extend(Animation,{tweeners:{"*":[function(prop,value){var tween=this.createTween(prop,value);return adjustCSS(tween.elem,prop,rcssNum.exec(value),tween),tween}]},tweener:function(props,callback){jQuery.isFunction(props)?(callback=props,props=["*"]):props=props.match(rnotwhite);for(var prop,index=0,length=props.length;index<length;index++)prop=props[index],Animation.tweeners[prop]=Animation.tweeners[prop]||[],Animation.tweeners[prop].unshift(callback)},prefilters:[defaultPrefilter],prefilter:function(callback,prepend){prepend?Animation.prefilters.unshift(callback):Animation.prefilters.push(callback)}}),jQuery.speed=function(speed,easing,fn){var opt=speed&&"object"==typeof speed?jQuery.extend({},speed):{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&!jQuery.isFunction(easing)&&easing};return opt.duration=jQuery.fx.off?0:"number"==typeof opt.duration?opt.duration:opt.duration in jQuery.fx.speeds?jQuery.fx.speeds[opt.duration]:jQuery.fx.speeds._default,null!=opt.queue&&opt.queue!==!0||(opt.queue="fx"),opt.old=opt.complete,opt.complete=function(){jQuery.isFunction(opt.old)&&opt.old.call(this),opt.queue&&jQuery.dequeue(this,opt.queue)},opt},jQuery.fn.extend({fadeTo:function(speed,to,easing,callback){return this.filter(isHidden).css("opacity",0).show().end().animate({opacity:to},speed,easing,callback)},animate:function(prop,speed,easing,callback){var empty=jQuery.isEmptyObject(prop),optall=jQuery.speed(speed,easing,callback),doAnimation=function(){var anim=Animation(this,jQuery.extend({},prop),optall);(empty||dataPriv.get(this,"finish"))&&anim.stop(!0)};return doAnimation.finish=doAnimation,empty||optall.queue===!1?this.each(doAnimation):this.queue(optall.queue,doAnimation)},stop:function(type,clearQueue,gotoEnd){var stopQueue=function(hooks){var stop=hooks.stop;delete hooks.stop,stop(gotoEnd)};return"string"!=typeof type&&(gotoEnd=clearQueue,clearQueue=type,type=void 0),clearQueue&&type!==!1&&this.queue(type||"fx",[]),this.each(function(){var dequeue=!0,index=null!=type&&type+"queueHooks",timers=jQuery.timers,data=dataPriv.get(this);if(index)data[index]&&data[index].stop&&stopQueue(data[index]);else for(index in data)data[index]&&data[index].stop&&rrun.test(index)&&stopQueue(data[index]);for(index=timers.length;index--;)timers[index].elem!==this||null!=type&&timers[index].queue!==type||(timers[index].anim.stop(gotoEnd),dequeue=!1,timers.splice(index,1));!dequeue&&gotoEnd||jQuery.dequeue(this,type)})},finish:function(type){return type!==!1&&(type=type||"fx"),this.each(function(){var index,data=dataPriv.get(this),queue=data[type+"queue"],hooks=data[type+"queueHooks"],timers=jQuery.timers,length=queue?queue.length:0;for(data.finish=!0,jQuery.queue(this,type,[]),hooks&&hooks.stop&&hooks.stop.call(this,!0),index=timers.length;index--;)timers[index].elem===this&&timers[index].queue===type&&(timers[index].anim.stop(!0),timers.splice(index,1));for(index=0;index<length;index++)queue[index]&&queue[index].finish&&queue[index].finish.call(this);delete data.finish})}}),jQuery.each(["toggle","show","hide"],function(i,name){var cssFn=jQuery.fn[name];jQuery.fn[name]=function(speed,easing,callback){return null==speed||"boolean"==typeof speed?cssFn.apply(this,arguments):this.animate(genFx(name,!0),speed,easing,callback)}}),jQuery.each({slideDown:genFx("show"),slideUp:genFx("hide"),slideToggle:genFx("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(name,props){jQuery.fn[name]=function(speed,easing,callback){return this.animate(props,speed,easing,callback)}}),jQuery.timers=[],jQuery.fx.tick=function(){var timer,i=0,timers=jQuery.timers;for(fxNow=jQuery.now();i<timers.length;i++)timer=timers[i],timer()||timers[i]!==timer||timers.splice(i--,1);timers.length||jQuery.fx.stop(),fxNow=void 0},jQuery.fx.timer=function(timer){jQuery.timers.push(timer),timer()?jQuery.fx.start():jQuery.timers.pop()},jQuery.fx.interval=13,jQuery.fx.start=function(){timerId||(timerId=window.setInterval(jQuery.fx.tick,jQuery.fx.interval))},jQuery.fx.stop=function(){window.clearInterval(timerId),timerId=null},jQuery.fx.speeds={slow:600,fast:200,_default:400},jQuery.fn.delay=function(time,type){return time=jQuery.fx?jQuery.fx.speeds[time]||time:time,type=type||"fx",this.queue(type,function(next,hooks){var timeout=window.setTimeout(next,time);hooks.stop=function(){window.clearTimeout(timeout)}})},function(){var input=document.createElement("input"),select=document.createElement("select"),opt=select.appendChild(document.createElement("option"));input.type="checkbox",support.checkOn=""!==input.value,support.optSelected=opt.selected,select.disabled=!0,support.optDisabled=!opt.disabled,input=document.createElement("input"),input.value="t",input.type="radio",support.radioValue="t"===input.value}();var boolHook,attrHandle=jQuery.expr.attrHandle;jQuery.fn.extend({attr:function(name,value){return access(this,jQuery.attr,name,value,arguments.length>1)},removeAttr:function(name){return this.each(function(){jQuery.removeAttr(this,name)})}}),jQuery.extend({attr:function(elem,name,value){var ret,hooks,nType=elem.nodeType;if(3!==nType&&8!==nType&&2!==nType)return"undefined"==typeof elem.getAttribute?jQuery.prop(elem,name,value):(1===nType&&jQuery.isXMLDoc(elem)||(name=name.toLowerCase(),hooks=jQuery.attrHooks[name]||(jQuery.expr.match.bool.test(name)?boolHook:void 0)),void 0!==value?null===value?void jQuery.removeAttr(elem,name):hooks&&"set"in hooks&&void 0!==(ret=hooks.set(elem,value,name))?ret:(elem.setAttribute(name,value+""),value):hooks&&"get"in hooks&&null!==(ret=hooks.get(elem,name))?ret:(ret=jQuery.find.attr(elem,name),null==ret?void 0:ret))},attrHooks:{type:{set:function(elem,value){if(!support.radioValue&&"radio"===value&&jQuery.nodeName(elem,"input")){var val=elem.value;return elem.setAttribute("type",value),val&&(elem.value=val),value}}}},removeAttr:function(elem,value){var name,propName,i=0,attrNames=value&&value.match(rnotwhite);if(attrNames&&1===elem.nodeType)for(;name=attrNames[i++];)propName=jQuery.propFix[name]||name,jQuery.expr.match.bool.test(name)&&(elem[propName]=!1),elem.removeAttribute(name)}}),boolHook={set:function(elem,value,name){return value===!1?jQuery.removeAttr(elem,name):elem.setAttribute(name,name),name}},jQuery.each(jQuery.expr.match.bool.source.match(/\w+/g),function(i,name){var getter=attrHandle[name]||jQuery.find.attr;attrHandle[name]=function(elem,name,isXML){var ret,handle;return isXML||(handle=attrHandle[name],attrHandle[name]=ret,ret=null!=getter(elem,name,isXML)?name.toLowerCase():null,attrHandle[name]=handle),ret}});var rfocusable=/^(?:input|select|textarea|button)$/i,rclickable=/^(?:a|area)$/i;jQuery.fn.extend({prop:function(name,value){return access(this,jQuery.prop,name,value,arguments.length>1)},removeProp:function(name){return this.each(function(){delete this[jQuery.propFix[name]||name]})}}),jQuery.extend({prop:function(elem,name,value){var ret,hooks,nType=elem.nodeType;if(3!==nType&&8!==nType&&2!==nType)return 1===nType&&jQuery.isXMLDoc(elem)||(name=jQuery.propFix[name]||name,hooks=jQuery.propHooks[name]),void 0!==value?hooks&&"set"in hooks&&void 0!==(ret=hooks.set(elem,value,name))?ret:elem[name]=value:hooks&&"get"in hooks&&null!==(ret=hooks.get(elem,name))?ret:elem[name]},propHooks:{tabIndex:{get:function(elem){var tabindex=jQuery.find.attr(elem,"tabindex");return tabindex?parseInt(tabindex,10):rfocusable.test(elem.nodeName)||rclickable.test(elem.nodeName)&&elem.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),support.optSelected||(jQuery.propHooks.selected={get:function(elem){var parent=elem.parentNode;return parent&&parent.parentNode&&parent.parentNode.selectedIndex,null}}),jQuery.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){jQuery.propFix[this.toLowerCase()]=this});var rclass=/[\t\r\n\f]/g;jQuery.fn.extend({addClass:function(value){var classes,elem,cur,curValue,clazz,j,finalValue,i=0;if(jQuery.isFunction(value))return this.each(function(j){jQuery(this).addClass(value.call(this,j,getClass(this)))});if("string"==typeof value&&value)for(classes=value.match(rnotwhite)||[];elem=this[i++];)if(curValue=getClass(elem),cur=1===elem.nodeType&&(" "+curValue+" ").replace(rclass," ")){for(j=0;clazz=classes[j++];)cur.indexOf(" "+clazz+" ")<0&&(cur+=clazz+" ");finalValue=jQuery.trim(cur),curValue!==finalValue&&elem.setAttribute("class",finalValue)}return this},removeClass:function(value){var classes,elem,cur,curValue,clazz,j,finalValue,i=0;if(jQuery.isFunction(value))return this.each(function(j){jQuery(this).removeClass(value.call(this,j,getClass(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof value&&value)for(classes=value.match(rnotwhite)||[];elem=this[i++];)if(curValue=getClass(elem),cur=1===elem.nodeType&&(" "+curValue+" ").replace(rclass," ")){for(j=0;clazz=classes[j++];)for(;cur.indexOf(" "+clazz+" ")>-1;)cur=cur.replace(" "+clazz+" "," ");finalValue=jQuery.trim(cur),curValue!==finalValue&&elem.setAttribute("class",finalValue)}return this},toggleClass:function(value,stateVal){var type=typeof value;return"boolean"==typeof stateVal&&"string"===type?stateVal?this.addClass(value):this.removeClass(value):jQuery.isFunction(value)?this.each(function(i){jQuery(this).toggleClass(value.call(this,i,getClass(this),stateVal),stateVal)}):this.each(function(){var className,i,self,classNames;if("string"===type)for(i=0,self=jQuery(this),classNames=value.match(rnotwhite)||[];className=classNames[i++];)self.hasClass(className)?self.removeClass(className):self.addClass(className);else void 0!==value&&"boolean"!==type||(className=getClass(this),className&&dataPriv.set(this,"__className__",className),this.setAttribute&&this.setAttribute("class",className||value===!1?"":dataPriv.get(this,"__className__")||""))})},hasClass:function(selector){var className,elem,i=0;for(className=" "+selector+" ";elem=this[i++];)if(1===elem.nodeType&&(" "+getClass(elem)+" ").replace(rclass," ").indexOf(className)>-1)return!0;return!1}});var rreturn=/\r/g;jQuery.fn.extend({val:function(value){var hooks,ret,isFunction,elem=this[0];{if(arguments.length)return isFunction=jQuery.isFunction(value),this.each(function(i){var val;1===this.nodeType&&(val=isFunction?value.call(this,i,jQuery(this).val()):value,null==val?val="":"number"==typeof val?val+="":jQuery.isArray(val)&&(val=jQuery.map(val,function(value){return null==value?"":value+""})),hooks=jQuery.valHooks[this.type]||jQuery.valHooks[this.nodeName.toLowerCase()],hooks&&"set"in hooks&&void 0!==hooks.set(this,val,"value")||(this.value=val))});if(elem)return hooks=jQuery.valHooks[elem.type]||jQuery.valHooks[elem.nodeName.toLowerCase()],hooks&&"get"in hooks&&void 0!==(ret=hooks.get(elem,"value"))?ret:(ret=elem.value,"string"==typeof ret?ret.replace(rreturn,""):null==ret?"":ret)}}}),jQuery.extend({valHooks:{option:{get:function(elem){return jQuery.trim(elem.value)}},select:{get:function(elem){for(var value,option,options=elem.options,index=elem.selectedIndex,one="select-one"===elem.type||index<0,values=one?null:[],max=one?index+1:options.length,i=index<0?max:one?index:0;i<max;i++)if(option=options[i],(option.selected||i===index)&&(support.optDisabled?!option.disabled:null===option.getAttribute("disabled"))&&(!option.parentNode.disabled||!jQuery.nodeName(option.parentNode,"optgroup"))){if(value=jQuery(option).val(),one)return value;values.push(value)}return values},set:function(elem,value){for(var optionSet,option,options=elem.options,values=jQuery.makeArray(value),i=options.length;i--;)option=options[i],(option.selected=jQuery.inArray(jQuery.valHooks.option.get(option),values)>-1)&&(optionSet=!0);return optionSet||(elem.selectedIndex=-1),values}}}}),jQuery.each(["radio","checkbox"],function(){jQuery.valHooks[this]={set:function(elem,value){if(jQuery.isArray(value))return elem.checked=jQuery.inArray(jQuery(elem).val(),value)>-1}},support.checkOn||(jQuery.valHooks[this].get=function(elem){return null===elem.getAttribute("value")?"on":elem.value})});var rfocusMorph=/^(?:focusinfocus|focusoutblur)$/;jQuery.extend(jQuery.event,{trigger:function(event,data,elem,onlyHandlers){var i,cur,tmp,bubbleType,ontype,handle,special,eventPath=[elem||document],type=hasOwn.call(event,"type")?event.type:event,namespaces=hasOwn.call(event,"namespace")?event.namespace.split("."):[];if(cur=tmp=elem=elem||document,3!==elem.nodeType&&8!==elem.nodeType&&!rfocusMorph.test(type+jQuery.event.triggered)&&(type.indexOf(".")>-1&&(namespaces=type.split("."),type=namespaces.shift(),namespaces.sort()),ontype=type.indexOf(":")<0&&"on"+type,event=event[jQuery.expando]?event:new jQuery.Event(type,"object"==typeof event&&event),event.isTrigger=onlyHandlers?2:3,event.namespace=namespaces.join("."),event.rnamespace=event.namespace?new RegExp("(^|\\.)"+namespaces.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,event.result=void 0,event.target||(event.target=elem),data=null==data?[event]:jQuery.makeArray(data,[event]),special=jQuery.event.special[type]||{},onlyHandlers||!special.trigger||special.trigger.apply(elem,data)!==!1)){if(!onlyHandlers&&!special.noBubble&&!jQuery.isWindow(elem)){for(bubbleType=special.delegateType||type,rfocusMorph.test(bubbleType+type)||(cur=cur.parentNode);cur;cur=cur.parentNode)eventPath.push(cur),tmp=cur;tmp===(elem.ownerDocument||document)&&eventPath.push(tmp.defaultView||tmp.parentWindow||window)}for(i=0;(cur=eventPath[i++])&&!event.isPropagationStopped();)event.type=i>1?bubbleType:special.bindType||type,handle=(dataPriv.get(cur,"events")||{})[event.type]&&dataPriv.get(cur,"handle"),handle&&handle.apply(cur,data),handle=ontype&&cur[ontype],handle&&handle.apply&&acceptData(cur)&&(event.result=handle.apply(cur,data),event.result===!1&&event.preventDefault());return event.type=type,onlyHandlers||event.isDefaultPrevented()||special._default&&special._default.apply(eventPath.pop(),data)!==!1||!acceptData(elem)||ontype&&jQuery.isFunction(elem[type])&&!jQuery.isWindow(elem)&&(tmp=elem[ontype],tmp&&(elem[ontype]=null),jQuery.event.triggered=type,elem[type](),jQuery.event.triggered=void 0,tmp&&(elem[ontype]=tmp)),event.result}},simulate:function(type,elem,event){var e=jQuery.extend(new jQuery.Event,event,{type:type,isSimulated:!0});jQuery.event.trigger(e,null,elem),e.isDefaultPrevented()&&event.preventDefault()}}),jQuery.fn.extend({trigger:function(type,data){return this.each(function(){jQuery.event.trigger(type,data,this)})},triggerHandler:function(type,data){var elem=this[0];if(elem)return jQuery.event.trigger(type,data,elem,!0)}}),jQuery.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(i,name){jQuery.fn[name]=function(data,fn){return arguments.length>0?this.on(name,null,data,fn):this.trigger(name)}}),jQuery.fn.extend({hover:function(fnOver,fnOut){return this.mouseenter(fnOver).mouseleave(fnOut||fnOver)}}),support.focusin="onfocusin"in window,support.focusin||jQuery.each({focus:"focusin",blur:"focusout"},function(orig,fix){var handler=function(event){jQuery.event.simulate(fix,event.target,jQuery.event.fix(event))};jQuery.event.special[fix]={setup:function(){var doc=this.ownerDocument||this,attaches=dataPriv.access(doc,fix);attaches||doc.addEventListener(orig,handler,!0),dataPriv.access(doc,fix,(attaches||0)+1)},teardown:function(){var doc=this.ownerDocument||this,attaches=dataPriv.access(doc,fix)-1;attaches?dataPriv.access(doc,fix,attaches):(doc.removeEventListener(orig,handler,!0),dataPriv.remove(doc,fix))}}});var location=window.location,nonce=jQuery.now(),rquery=/\?/;jQuery.parseJSON=function(data){return JSON.parse(data+"")},jQuery.parseXML=function(data){var xml;if(!data||"string"!=typeof data)return null;try{xml=(new window.DOMParser).parseFromString(data,"text/xml")}catch(e){xml=void 0}return xml&&!xml.getElementsByTagName("parsererror").length||jQuery.error("Invalid XML: "+data),xml};var rhash=/#.*$/,rts=/([?&])_=[^&]*/,rheaders=/^(.*?):[ \t]*([^\r\n]*)$/gm,rlocalProtocol=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,rnoContent=/^(?:GET|HEAD)$/,rprotocol=/^\/\//,prefilters={},transports={},allTypes="*/".concat("*"),originAnchor=document.createElement("a");originAnchor.href=location.href,jQuery.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:location.href,type:"GET",isLocal:rlocalProtocol.test(location.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":allTypes,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":jQuery.parseJSON,"text xml":jQuery.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(target,settings){return settings?ajaxExtend(ajaxExtend(target,jQuery.ajaxSettings),settings):ajaxExtend(jQuery.ajaxSettings,target)},ajaxPrefilter:addToPrefiltersOrTransports(prefilters),ajaxTransport:addToPrefiltersOrTransports(transports),ajax:function(url,options){function done(status,nativeStatusText,responses,headers){var isSuccess,success,error,response,modified,statusText=nativeStatusText;2!==state&&(state=2,timeoutTimer&&window.clearTimeout(timeoutTimer),transport=void 0,responseHeadersString=headers||"",jqXHR.readyState=status>0?4:0,isSuccess=status>=200&&status<300||304===status,responses&&(response=ajaxHandleResponses(s,jqXHR,responses)),response=ajaxConvert(s,response,jqXHR,isSuccess),isSuccess?(s.ifModified&&(modified=jqXHR.getResponseHeader("Last-Modified"),modified&&(jQuery.lastModified[cacheURL]=modified),modified=jqXHR.getResponseHeader("etag"),modified&&(jQuery.etag[cacheURL]=modified)),204===status||"HEAD"===s.type?statusText="nocontent":304===status?statusText="notmodified":(statusText=response.state,success=response.data,error=response.error,isSuccess=!error)):(error=statusText,!status&&statusText||(statusText="error",status<0&&(status=0))),jqXHR.status=status,jqXHR.statusText=(nativeStatusText||statusText)+"",isSuccess?deferred.resolveWith(callbackContext,[success,statusText,jqXHR]):deferred.rejectWith(callbackContext,[jqXHR,statusText,error]),jqXHR.statusCode(statusCode),statusCode=void 0,fireGlobals&&globalEventContext.trigger(isSuccess?"ajaxSuccess":"ajaxError",[jqXHR,s,isSuccess?success:error]),completeDeferred.fireWith(callbackContext,[jqXHR,statusText]),fireGlobals&&(globalEventContext.trigger("ajaxComplete",[jqXHR,s]),--jQuery.active||jQuery.event.trigger("ajaxStop")))}"object"==typeof url&&(options=url,url=void 0),options=options||{};var transport,cacheURL,responseHeadersString,responseHeaders,timeoutTimer,urlAnchor,fireGlobals,i,s=jQuery.ajaxSetup({},options),callbackContext=s.context||s,globalEventContext=s.context&&(callbackContext.nodeType||callbackContext.jquery)?jQuery(callbackContext):jQuery.event,deferred=jQuery.Deferred(),completeDeferred=jQuery.Callbacks("once memory"),statusCode=s.statusCode||{},requestHeaders={},requestHeadersNames={},state=0,strAbort="canceled",jqXHR={readyState:0,getResponseHeader:function(key){var match;if(2===state){if(!responseHeaders)for(responseHeaders={};match=rheaders.exec(responseHeadersString);)responseHeaders[match[1].toLowerCase()]=match[2];match=responseHeaders[key.toLowerCase()]}return null==match?null:match},getAllResponseHeaders:function(){return 2===state?responseHeadersString:null},setRequestHeader:function(name,value){var lname=name.toLowerCase();return state||(name=requestHeadersNames[lname]=requestHeadersNames[lname]||name,requestHeaders[name]=value),this},overrideMimeType:function(type){return state||(s.mimeType=type),this},statusCode:function(map){var code;if(map)if(state<2)for(code in map)statusCode[code]=[statusCode[code],map[code]];else jqXHR.always(map[jqXHR.status]);return this},abort:function(statusText){var finalText=statusText||strAbort;return transport&&transport.abort(finalText),done(0,finalText),this}};if(deferred.promise(jqXHR).complete=completeDeferred.add,jqXHR.success=jqXHR.done,jqXHR.error=jqXHR.fail,s.url=((url||s.url||location.href)+"").replace(rhash,"").replace(rprotocol,location.protocol+"//"),s.type=options.method||options.type||s.method||s.type,s.dataTypes=jQuery.trim(s.dataType||"*").toLowerCase().match(rnotwhite)||[""],null==s.crossDomain){urlAnchor=document.createElement("a");try{urlAnchor.href=s.url,urlAnchor.href=urlAnchor.href,s.crossDomain=originAnchor.protocol+"//"+originAnchor.host!=urlAnchor.protocol+"//"+urlAnchor.host}catch(e){s.crossDomain=!0}}if(s.data&&s.processData&&"string"!=typeof s.data&&(s.data=jQuery.param(s.data,s.traditional)),inspectPrefiltersOrTransports(prefilters,s,options,jqXHR),2===state)return jqXHR;fireGlobals=jQuery.event&&s.global,fireGlobals&&0===jQuery.active++&&jQuery.event.trigger("ajaxStart"),s.type=s.type.toUpperCase(),s.hasContent=!rnoContent.test(s.type),cacheURL=s.url,s.hasContent||(s.data&&(cacheURL=s.url+=(rquery.test(cacheURL)?"&":"?")+s.data,delete s.data),s.cache===!1&&(s.url=rts.test(cacheURL)?cacheURL.replace(rts,"$1_="+nonce++):cacheURL+(rquery.test(cacheURL)?"&":"?")+"_="+nonce++)),s.ifModified&&(jQuery.lastModified[cacheURL]&&jqXHR.setRequestHeader("If-Modified-Since",jQuery.lastModified[cacheURL]),jQuery.etag[cacheURL]&&jqXHR.setRequestHeader("If-None-Match",jQuery.etag[cacheURL])),(s.data&&s.hasContent&&s.contentType!==!1||options.contentType)&&jqXHR.setRequestHeader("Content-Type",s.contentType),jqXHR.setRequestHeader("Accept",s.dataTypes[0]&&s.accepts[s.dataTypes[0]]?s.accepts[s.dataTypes[0]]+("*"!==s.dataTypes[0]?", "+allTypes+"; q=0.01":""):s.accepts["*"]);for(i in s.headers)jqXHR.setRequestHeader(i,s.headers[i]);if(s.beforeSend&&(s.beforeSend.call(callbackContext,jqXHR,s)===!1||2===state))return jqXHR.abort();strAbort="abort";for(i in{success:1,error:1,complete:1})jqXHR[i](s[i]);if(transport=inspectPrefiltersOrTransports(transports,s,options,jqXHR)){if(jqXHR.readyState=1,fireGlobals&&globalEventContext.trigger("ajaxSend",[jqXHR,s]),2===state)return jqXHR;s.async&&s.timeout>0&&(timeoutTimer=window.setTimeout(function(){jqXHR.abort("timeout")},s.timeout));try{state=1,transport.send(requestHeaders,done)}catch(e){if(!(state<2))throw e;done(-1,e)}}else done(-1,"No Transport");return jqXHR},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json")},getScript:function(url,callback){return jQuery.get(url,void 0,callback,"script")}}),jQuery.each(["get","post"],function(i,method){jQuery[method]=function(url,data,callback,type){return jQuery.isFunction(data)&&(type=type||callback,callback=data,data=void 0),jQuery.ajax(jQuery.extend({url:url,type:method,dataType:type,data:data,success:callback},jQuery.isPlainObject(url)&&url))}}),jQuery._evalUrl=function(url){return jQuery.ajax({url:url,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},jQuery.fn.extend({wrapAll:function(html){var wrap;return jQuery.isFunction(html)?this.each(function(i){jQuery(this).wrapAll(html.call(this,i))}):(this[0]&&(wrap=jQuery(html,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&wrap.insertBefore(this[0]),wrap.map(function(){for(var elem=this;elem.firstElementChild;)elem=elem.firstElementChild;return elem}).append(this)),this)},wrapInner:function(html){return jQuery.isFunction(html)?this.each(function(i){jQuery(this).wrapInner(html.call(this,i))}):this.each(function(){var self=jQuery(this),contents=self.contents();contents.length?contents.wrapAll(html):self.append(html)})},wrap:function(html){var isFunction=jQuery.isFunction(html);return this.each(function(i){jQuery(this).wrapAll(isFunction?html.call(this,i):html)})},unwrap:function(){return this.parent().each(function(){jQuery.nodeName(this,"body")||jQuery(this).replaceWith(this.childNodes)}).end()}}),jQuery.expr.filters.hidden=function(elem){return!jQuery.expr.filters.visible(elem)},jQuery.expr.filters.visible=function(elem){return elem.offsetWidth>0||elem.offsetHeight>0||elem.getClientRects().length>0};var r20=/%20/g,rbracket=/\[\]$/,rCRLF=/\r?\n/g,rsubmitterTypes=/^(?:submit|button|image|reset|file)$/i,rsubmittable=/^(?:input|select|textarea|keygen)/i;jQuery.param=function(a,traditional){var prefix,s=[],add=function(key,value){value=jQuery.isFunction(value)?value():null==value?"":value,s[s.length]=encodeURIComponent(key)+"="+encodeURIComponent(value)};if(void 0===traditional&&(traditional=jQuery.ajaxSettings&&jQuery.ajaxSettings.traditional),jQuery.isArray(a)||a.jquery&&!jQuery.isPlainObject(a))jQuery.each(a,function(){add(this.name,this.value)});else for(prefix in a)buildParams(prefix,a[prefix],traditional,add);return s.join("&").replace(r20,"+")},jQuery.fn.extend({serialize:function(){return jQuery.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var elements=jQuery.prop(this,"elements");return elements?jQuery.makeArray(elements):this}).filter(function(){var type=this.type;return this.name&&!jQuery(this).is(":disabled")&&rsubmittable.test(this.nodeName)&&!rsubmitterTypes.test(type)&&(this.checked||!rcheckableType.test(type))}).map(function(i,elem){var val=jQuery(this).val();return null==val?null:jQuery.isArray(val)?jQuery.map(val,function(val){return{name:elem.name,value:val.replace(rCRLF,"\r\n")}}):{name:elem.name,value:val.replace(rCRLF,"\r\n")}}).get()}}),jQuery.ajaxSettings.xhr=function(){try{return new window.XMLHttpRequest}catch(e){}};var xhrSuccessStatus={0:200,1223:204},xhrSupported=jQuery.ajaxSettings.xhr();support.cors=!!xhrSupported&&"withCredentials"in xhrSupported,support.ajax=xhrSupported=!!xhrSupported,jQuery.ajaxTransport(function(options){var callback,errorCallback;if(support.cors||xhrSupported&&!options.crossDomain)return{send:function(headers,complete){var i,xhr=options.xhr();if(xhr.open(options.type,options.url,options.async,options.username,options.password),options.xhrFields)for(i in options.xhrFields)xhr[i]=options.xhrFields[i];options.mimeType&&xhr.overrideMimeType&&xhr.overrideMimeType(options.mimeType),options.crossDomain||headers["X-Requested-With"]||(headers["X-Requested-With"]="XMLHttpRequest");for(i in headers)xhr.setRequestHeader(i,headers[i]);callback=function(type){return function(){callback&&(callback=errorCallback=xhr.onload=xhr.onerror=xhr.onabort=xhr.onreadystatechange=null,"abort"===type?xhr.abort():"error"===type?"number"!=typeof xhr.status?complete(0,"error"):complete(xhr.status,xhr.statusText):complete(xhrSuccessStatus[xhr.status]||xhr.status,xhr.statusText,"text"!==(xhr.responseType||"text")||"string"!=typeof xhr.responseText?{binary:xhr.response}:{text:xhr.responseText},xhr.getAllResponseHeaders()))}},xhr.onload=callback(),errorCallback=xhr.onerror=callback("error"),void 0!==xhr.onabort?xhr.onabort=errorCallback:xhr.onreadystatechange=function(){4===xhr.readyState&&window.setTimeout(function(){callback&&errorCallback()})},callback=callback("abort");try{xhr.send(options.hasContent&&options.data||null)}catch(e){if(callback)throw e}},abort:function(){callback&&callback()}}}),jQuery.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(text){return jQuery.globalEval(text),text}}}),jQuery.ajaxPrefilter("script",function(s){void 0===s.cache&&(s.cache=!1),s.crossDomain&&(s.type="GET")}),jQuery.ajaxTransport("script",function(s){
if(s.crossDomain){var script,callback;return{send:function(_,complete){script=jQuery("<script>").prop({charset:s.scriptCharset,src:s.url}).on("load error",callback=function(evt){script.remove(),callback=null,evt&&complete("error"===evt.type?404:200,evt.type)}),document.head.appendChild(script[0])},abort:function(){callback&&callback()}}}});var oldCallbacks=[],rjsonp=/(=)\?(?=&|$)|\?\?/;jQuery.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var callback=oldCallbacks.pop()||jQuery.expando+"_"+nonce++;return this[callback]=!0,callback}}),jQuery.ajaxPrefilter("json jsonp",function(s,originalSettings,jqXHR){var callbackName,overwritten,responseContainer,jsonProp=s.jsonp!==!1&&(rjsonp.test(s.url)?"url":"string"==typeof s.data&&0===(s.contentType||"").indexOf("application/x-www-form-urlencoded")&&rjsonp.test(s.data)&&"data");if(jsonProp||"jsonp"===s.dataTypes[0])return callbackName=s.jsonpCallback=jQuery.isFunction(s.jsonpCallback)?s.jsonpCallback():s.jsonpCallback,jsonProp?s[jsonProp]=s[jsonProp].replace(rjsonp,"$1"+callbackName):s.jsonp!==!1&&(s.url+=(rquery.test(s.url)?"&":"?")+s.jsonp+"="+callbackName),s.converters["script json"]=function(){return responseContainer||jQuery.error(callbackName+" was not called"),responseContainer[0]},s.dataTypes[0]="json",overwritten=window[callbackName],window[callbackName]=function(){responseContainer=arguments},jqXHR.always(function(){void 0===overwritten?jQuery(window).removeProp(callbackName):window[callbackName]=overwritten,s[callbackName]&&(s.jsonpCallback=originalSettings.jsonpCallback,oldCallbacks.push(callbackName)),responseContainer&&jQuery.isFunction(overwritten)&&overwritten(responseContainer[0]),responseContainer=overwritten=void 0}),"script"}),support.createHTMLDocument=function(){var body=document.implementation.createHTMLDocument("").body;return body.innerHTML="<form></form><form></form>",2===body.childNodes.length}(),jQuery.parseHTML=function(data,context,keepScripts){if(!data||"string"!=typeof data)return null;"boolean"==typeof context&&(keepScripts=context,context=!1),context=context||(support.createHTMLDocument?document.implementation.createHTMLDocument(""):document);var parsed=rsingleTag.exec(data),scripts=!keepScripts&&[];return parsed?[context.createElement(parsed[1])]:(parsed=buildFragment([data],context,scripts),scripts&&scripts.length&&jQuery(scripts).remove(),jQuery.merge([],parsed.childNodes))};var _load=jQuery.fn.load;jQuery.fn.load=function(url,params,callback){if("string"!=typeof url&&_load)return _load.apply(this,arguments);var selector,type,response,self=this,off=url.indexOf(" ");return off>-1&&(selector=jQuery.trim(url.slice(off)),url=url.slice(0,off)),jQuery.isFunction(params)?(callback=params,params=void 0):params&&"object"==typeof params&&(type="POST"),self.length>0&&jQuery.ajax({url:url,type:type||"GET",dataType:"html",data:params}).done(function(responseText){response=arguments,self.html(selector?jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector):responseText)}).always(callback&&function(jqXHR,status){self.each(function(){callback.apply(self,response||[jqXHR.responseText,status,jqXHR])})}),this},jQuery.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(i,type){jQuery.fn[type]=function(fn){return this.on(type,fn)}}),jQuery.expr.filters.animated=function(elem){return jQuery.grep(jQuery.timers,function(fn){return elem===fn.elem}).length},jQuery.offset={setOffset:function(elem,options,i){var curPosition,curLeft,curCSSTop,curTop,curOffset,curCSSLeft,calculatePosition,position=jQuery.css(elem,"position"),curElem=jQuery(elem),props={};"static"===position&&(elem.style.position="relative"),curOffset=curElem.offset(),curCSSTop=jQuery.css(elem,"top"),curCSSLeft=jQuery.css(elem,"left"),calculatePosition=("absolute"===position||"fixed"===position)&&(curCSSTop+curCSSLeft).indexOf("auto")>-1,calculatePosition?(curPosition=curElem.position(),curTop=curPosition.top,curLeft=curPosition.left):(curTop=parseFloat(curCSSTop)||0,curLeft=parseFloat(curCSSLeft)||0),jQuery.isFunction(options)&&(options=options.call(elem,i,jQuery.extend({},curOffset))),null!=options.top&&(props.top=options.top-curOffset.top+curTop),null!=options.left&&(props.left=options.left-curOffset.left+curLeft),"using"in options?options.using.call(elem,props):curElem.css(props)}},jQuery.fn.extend({offset:function(options){if(arguments.length)return void 0===options?this:this.each(function(i){jQuery.offset.setOffset(this,options,i)});var docElem,win,elem=this[0],box={top:0,left:0},doc=elem&&elem.ownerDocument;if(doc)return docElem=doc.documentElement,jQuery.contains(docElem,elem)?(box=elem.getBoundingClientRect(),win=getWindow(doc),{top:box.top+win.pageYOffset-docElem.clientTop,left:box.left+win.pageXOffset-docElem.clientLeft}):box},position:function(){if(this[0]){var offsetParent,offset,elem=this[0],parentOffset={top:0,left:0};return"fixed"===jQuery.css(elem,"position")?offset=elem.getBoundingClientRect():(offsetParent=this.offsetParent(),offset=this.offset(),jQuery.nodeName(offsetParent[0],"html")||(parentOffset=offsetParent.offset()),parentOffset.top+=jQuery.css(offsetParent[0],"borderTopWidth",!0),parentOffset.left+=jQuery.css(offsetParent[0],"borderLeftWidth",!0)),{top:offset.top-parentOffset.top-jQuery.css(elem,"marginTop",!0),left:offset.left-parentOffset.left-jQuery.css(elem,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var offsetParent=this.offsetParent;offsetParent&&"static"===jQuery.css(offsetParent,"position");)offsetParent=offsetParent.offsetParent;return offsetParent||documentElement})}}),jQuery.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(method,prop){var top="pageYOffset"===prop;jQuery.fn[method]=function(val){return access(this,function(elem,method,val){var win=getWindow(elem);return void 0===val?win?win[prop]:elem[method]:void(win?win.scrollTo(top?win.pageXOffset:val,top?val:win.pageYOffset):elem[method]=val)},method,val,arguments.length)}}),jQuery.each(["top","left"],function(i,prop){jQuery.cssHooks[prop]=addGetHookIf(support.pixelPosition,function(elem,computed){if(computed)return computed=curCSS(elem,prop),rnumnonpx.test(computed)?jQuery(elem).position()[prop]+"px":computed})}),jQuery.each({Height:"height",Width:"width"},function(name,type){jQuery.each({padding:"inner"+name,content:type,"":"outer"+name},function(defaultExtra,funcName){jQuery.fn[funcName]=function(margin,value){var chainable=arguments.length&&(defaultExtra||"boolean"!=typeof margin),extra=defaultExtra||(margin===!0||value===!0?"margin":"border");return access(this,function(elem,type,value){var doc;return jQuery.isWindow(elem)?elem.document.documentElement["client"+name]:9===elem.nodeType?(doc=elem.documentElement,Math.max(elem.body["scroll"+name],doc["scroll"+name],elem.body["offset"+name],doc["offset"+name],doc["client"+name])):void 0===value?jQuery.css(elem,type,extra):jQuery.style(elem,type,value,extra)},type,chainable?margin:void 0,chainable,null)}})}),jQuery.fn.extend({bind:function(types,data,fn){return this.on(types,null,data,fn)},unbind:function(types,fn){return this.off(types,null,fn)},delegate:function(selector,types,data,fn){return this.on(types,selector,data,fn)},undelegate:function(selector,types,fn){return 1===arguments.length?this.off(selector,"**"):this.off(types,selector||"**",fn)},size:function(){return this.length}}),jQuery.fn.andSelf=jQuery.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return jQuery});var _jQuery=window.jQuery,_$=window.$;return jQuery.noConflict=function(deep){return window.$===jQuery&&(window.$=_$),deep&&window.jQuery===jQuery&&(window.jQuery=_jQuery),jQuery},noGlobal||(window.jQuery=window.$=jQuery),jQuery}),function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++e<r;)if(n[e]===t)return e;return-1}function t(t,e){var r=typeof e;if(t=t.l,"boolean"==r||null==e)return t[e]?0:-1;"number"!=r&&"string"!=r&&(r="object");var u="number"==r?e:m+e;return t=(t=t[r])&&t[u],"object"==r?t&&-1<n(t,e)?0:-1:t?0:-1}function e(n){var t=this.l,e=typeof n;if("boolean"==e||null==n)t[n]=!0;else{"number"!=e&&"string"!=e&&(e="object");var r="number"==e?n:m+n,t=t[e]||(t[e]={});"object"==e?(t[r]||(t[r]=[])).push(n):t[r]=!0}}function r(n){return n.charCodeAt(0)}function u(n,t){for(var e=n.m,r=t.m,u=-1,o=e.length;++u<o;){var i=e[u],a=r[u];if(i!==a){if(i>a||"undefined"==typeof i)return 1;if(i<a||"undefined"==typeof a)return-1}}return n.n-t.n}function o(n){var t=-1,r=n.length,u=n[0],o=n[r/2|0],i=n[r-1];if(u&&"object"==typeof u&&o&&"object"==typeof o&&i&&"object"==typeof i)return!1;for(u=f(),u["false"]=u["null"]=u["true"]=u.undefined=!1,o=f(),o.k=n,o.l=u,o.push=e;++t<r;)o.push(n[t]);return o}function i(n){return"\\"+U[n]}function a(){return h.pop()||[]}function f(){return g.pop()||{k:null,l:null,m:null,"false":!1,n:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,o:null}}function l(n){n.length=0,h.length<_&&h.push(n)}function c(n){var t=n.l;t&&c(t),n.k=n.l=n.m=n.object=n.number=n.string=n.o=null,g.length<_&&g.push(n)}function p(n,t,e){t||(t=0),"undefined"==typeof e&&(e=n?n.length:0);var r=-1;e=e-t||0;for(var u=Array(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function s(e){function h(n,t,e){if(!n||!V[typeof n])return n;t=t&&"undefined"==typeof e?t:tt(t,e,3);for(var r=-1,u=V[typeof n]&&Fe(n),o=u?u.length:0;++r<o&&(e=u[r],!1!==t(n[e],e,n)););return n}function g(n,t,e){var r;if(!n||!V[typeof n])return n;t=t&&"undefined"==typeof e?t:tt(t,e,3);for(r in n)if(!1===t(n[r],r,n))break;return n}function _(n,t,e){var r,u=n,o=u;if(!u)return o;for(var i=arguments,a=0,f="number"==typeof e?2:i.length;++a<f;)if((u=i[a])&&V[typeof u])for(var l=-1,c=V[typeof u]&&Fe(u),p=c?c.length:0;++l<p;)r=c[l],"undefined"==typeof o[r]&&(o[r]=u[r]);return o}function U(n,t,e){var r,u=n,o=u;if(!u)return o;var i=arguments,a=0,f="number"==typeof e?2:i.length;if(3<f&&"function"==typeof i[f-2])var l=tt(i[--f-1],i[f--],2);else 2<f&&"function"==typeof i[f-1]&&(l=i[--f]);for(;++a<f;)if((u=i[a])&&V[typeof u])for(var c=-1,p=V[typeof u]&&Fe(u),s=p?p.length:0;++c<s;)r=p[c],o[r]=l?l(o[r],u[r]):u[r];return o}function H(n){var t,e=[];if(!n||!V[typeof n])return e;for(t in n)me.call(n,t)&&e.push(t);return e}function J(n){return n&&"object"==typeof n&&!Te(n)&&me.call(n,"__wrapped__")?n:new Q(n)}function Q(n,t){this.__chain__=!!t,this.__wrapped__=n}function X(n){function t(){if(r){var n=p(r);be.apply(n,arguments)}if(this instanceof t){var o=nt(e.prototype),n=e.apply(o,n||arguments);return wt(n)?n:o}return e.apply(u,n||arguments)}var e=n[0],r=n[2],u=n[4];return $e(t,n),t}function Z(n,t,e,r,u){if(e){var o=e(n);if("undefined"!=typeof o)return o}if(!wt(n))return n;var i=ce.call(n);if(!K[i])return n;var f=Ae[i];switch(i){case T:case F:return new f((+n));case W:case P:return new f(n);case z:return o=f(n.source,C.exec(n)),o.lastIndex=n.lastIndex,o}if(i=Te(n),t){var c=!r;r||(r=a()),u||(u=a());for(var s=r.length;s--;)if(r[s]==n)return u[s];o=i?f(n.length):{}}else o=i?p(n):U({},n);return i&&(me.call(n,"index")&&(o.index=n.index),me.call(n,"input")&&(o.input=n.input)),t?(r.push(n),u.push(o),(i?St:h)(n,function(n,i){o[i]=Z(n,t,e,r,u)}),c&&(l(r),l(u)),o):o}function nt(n){return wt(n)?ke(n):{}}function tt(n,t,e){if("function"!=typeof n)return Ut;if("undefined"==typeof t||!("prototype"in n))return n;var r=n.__bindData__;if("undefined"==typeof r&&(De.funcNames&&(r=!n.name),r=r||!De.funcDecomp,!r)){var u=ge.call(n);De.funcNames||(r=!O.test(u)),r||(r=E.test(u),$e(n,r))}if(!1===r||!0!==r&&1&r[1])return n;switch(e){case 1:return function(e){return n.call(t,e)};case 2:return function(e,r){return n.call(t,e,r)};case 3:return function(e,r,u){return n.call(t,e,r,u)};case 4:return function(e,r,u,o){return n.call(t,e,r,u,o)}}return Mt(n,t)}function et(n){function t(){var n=f?i:this;if(u){var h=p(u);be.apply(h,arguments)}return(o||c)&&(h||(h=p(arguments)),o&&be.apply(h,o),c&&h.length<a)?(r|=16,et([e,s?r:-4&r,h,null,i,a])):(h||(h=arguments),l&&(e=n[v]),this instanceof t?(n=nt(e.prototype),h=e.apply(n,h),wt(h)?h:n):e.apply(n,h))}var e=n[0],r=n[1],u=n[2],o=n[3],i=n[4],a=n[5],f=1&r,l=2&r,c=4&r,s=8&r,v=e;return $e(t,n),t}function rt(e,r){var u=-1,i=st(),a=e?e.length:0,f=a>=b&&i===n,l=[];if(f){var p=o(r);p?(i=t,r=p):f=!1}for(;++u<a;)p=e[u],0>i(r,p)&&l.push(p);return f&&c(r),l}function ut(n,t,e,r){r=(r||0)-1;for(var u=n?n.length:0,o=[];++r<u;){var i=n[r];if(i&&"object"==typeof i&&"number"==typeof i.length&&(Te(i)||yt(i))){t||(i=ut(i,t,e));var a=-1,f=i.length,l=o.length;for(o.length+=f;++a<f;)o[l++]=i[a]}else e||o.push(i)}return o}function ot(n,t,e,r,u,o){if(e){var i=e(n,t);if("undefined"!=typeof i)return!!i}if(n===t)return 0!==n||1/n==1/t;if(n===n&&!(n&&V[typeof n]||t&&V[typeof t]))return!1;if(null==n||null==t)return n===t;var f=ce.call(n),c=ce.call(t);if(f==D&&(f=q),c==D&&(c=q),f!=c)return!1;switch(f){case T:case F:return+n==+t;case W:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case z:case P:return n==oe(t)}if(c=f==$,!c){var p=me.call(n,"__wrapped__"),s=me.call(t,"__wrapped__");if(p||s)return ot(p?n.__wrapped__:n,s?t.__wrapped__:t,e,r,u,o);if(f!=q)return!1;if(f=n.constructor,p=t.constructor,f!=p&&!(dt(f)&&f instanceof f&&dt(p)&&p instanceof p)&&"constructor"in n&&"constructor"in t)return!1}for(f=!u,u||(u=a()),o||(o=a()),p=u.length;p--;)if(u[p]==n)return o[p]==t;var v=0,i=!0;if(u.push(n),o.push(t),c){if(p=n.length,v=t.length,(i=v==p)||r)for(;v--;)if(c=p,s=t[v],r)for(;c--&&!(i=ot(n[c],s,e,r,u,o)););else if(!(i=ot(n[v],s,e,r,u,o)))break}else g(t,function(t,a,f){return me.call(f,a)?(v++,i=me.call(n,a)&&ot(n[a],t,e,r,u,o)):void 0}),i&&!r&&g(n,function(n,t,e){return me.call(e,t)?i=-1<--v:void 0});return u.pop(),o.pop(),f&&(l(u),l(o)),i}function it(n,t,e,r,u){(Te(t)?St:h)(t,function(t,o){var i,a,f=t,l=n[o];if(t&&((a=Te(t))||Pe(t))){for(f=r.length;f--;)if(i=r[f]==t){l=u[f];break}if(!i){var c;e&&(f=e(l,t),c="undefined"!=typeof f)&&(l=f),c||(l=a?Te(l)?l:[]:Pe(l)?l:{}),r.push(t),u.push(l),c||it(l,t,e,r,u)}}else e&&(f=e(l,t),"undefined"==typeof f&&(f=t)),"undefined"!=typeof f&&(l=f);n[o]=l})}function at(n,t){return n+he(Re()*(t-n+1))}function ft(e,r,u){var i=-1,f=st(),p=e?e.length:0,s=[],v=!r&&p>=b&&f===n,h=u||v?a():s;for(v&&(h=o(h),f=t);++i<p;){var g=e[i],y=u?u(g,i,e):g;(r?!i||h[h.length-1]!==y:0>f(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(l(h.k),c(h)):u&&l(h),s}function lt(n){return function(t,e,r){var u={};e=J.createCallback(e,r,3),r=-1;var o=t?t.length:0;if("number"==typeof o)for(;++r<o;){var i=t[r];n(u,i,e(i,r,t),t)}else h(t,function(t,r,o){n(u,t,e(t,r,o),o)});return u}}function ct(n,t,e,r,u,o){var i=1&t,a=4&t,f=16&t,l=32&t;if(!(2&t||dt(n)))throw new ie;f&&!e.length&&(t&=-17,f=e=!1),l&&!r.length&&(t&=-33,l=r=!1);var c=n&&n.__bindData__;return c&&!0!==c?(c=p(c),c[2]&&(c[2]=p(c[2])),c[3]&&(c[3]=p(c[3])),!i||1&c[1]||(c[4]=u),!i&&1&c[1]&&(t|=8),!a||4&c[1]||(c[5]=o),f&&be.apply(c[2]||(c[2]=[]),e),l&&we.apply(c[3]||(c[3]=[]),r),c[1]|=t,ct.apply(null,c)):(1==t||17===t?X:et)([n,t,e,r,u,o])}function pt(n){return Be[n]}function st(){var t=(t=J.indexOf)===Wt?n:t;return t}function vt(n){return"function"==typeof n&&pe.test(n)}function ht(n){var t,e;return!!(n&&ce.call(n)==q&&(t=n.constructor,!dt(t)||t instanceof t))&&(g(n,function(n,t){e=t}),"undefined"==typeof e||me.call(n,e))}function gt(n){return We[n]}function yt(n){return n&&"object"==typeof n&&"number"==typeof n.length&&ce.call(n)==D||!1}function mt(n,t,e){var r=Fe(n),u=r.length;for(t=tt(t,e,3);u--&&(e=r[u],!1!==t(n[e],e,n)););return n}function bt(n){var t=[];return g(n,function(n,e){dt(n)&&t.push(e)}),t.sort()}function _t(n){for(var t=-1,e=Fe(n),r=e.length,u={};++t<r;){var o=e[t];u[n[o]]=o}return u}function dt(n){return"function"==typeof n}function wt(n){return!(!n||!V[typeof n])}function jt(n){return"number"==typeof n||n&&"object"==typeof n&&ce.call(n)==W||!1}function kt(n){return"string"==typeof n||n&&"object"==typeof n&&ce.call(n)==P||!1}function xt(n){for(var t=-1,e=Fe(n),r=e.length,u=Xt(r);++t<r;)u[t]=n[e[t]];return u}function Ct(n,t,e){var r=-1,u=st(),o=n?n.length:0,i=!1;return e=(0>e?Ie(0,o+e):e)||0,Te(n)?i=-1<u(n,t,e):"number"==typeof o?i=-1<(kt(n)?n.indexOf(t,e):u(n,t,e)):h(n,function(n){return++r<e?void 0:!(i=n===t)}),i}function Ot(n,t,e){var r=!0;t=J.createCallback(t,e,3),e=-1;var u=n?n.length:0;if("number"==typeof u)for(;++e<u&&(r=!!t(n[e],e,n)););else h(n,function(n,e,u){return r=!!t(n,e,u)});return r}function Nt(n,t,e){var r=[];t=J.createCallback(t,e,3),e=-1;var u=n?n.length:0;if("number"==typeof u)for(;++e<u;){var o=n[e];t(o,e,n)&&r.push(o)}else h(n,function(n,e,u){t(n,e,u)&&r.push(n)});return r}function It(n,t,e){t=J.createCallback(t,e,3),e=-1;var r=n?n.length:0;if("number"!=typeof r){var u;return h(n,function(n,e,r){return t(n,e,r)?(u=n,!1):void 0}),u}for(;++e<r;){var o=n[e];if(t(o,e,n))return o}}function St(n,t,e){var r=-1,u=n?n.length:0;if(t=t&&"undefined"==typeof e?t:tt(t,e,3),"number"==typeof u)for(;++r<u&&!1!==t(n[r],r,n););else h(n,t);return n}function Et(n,t,e){var r=n?n.length:0;if(t=t&&"undefined"==typeof e?t:tt(t,e,3),"number"==typeof r)for(;r--&&!1!==t(n[r],r,n););else{var u=Fe(n),r=u.length;h(n,function(n,e,o){return e=u?u[--r]:--r,t(o[e],e,o)})}return n}function Rt(n,t,e){var r=-1,u=n?n.length:0;if(t=J.createCallback(t,e,3),"number"==typeof u)for(var o=Xt(u);++r<u;)o[r]=t(n[r],r,n);else o=[],h(n,function(n,e,u){o[++r]=t(n,e,u)});return o}function At(n,t,e){var u=-1/0,o=u;if("function"!=typeof t&&e&&e[t]===n&&(t=null),null==t&&Te(n)){e=-1;for(var i=n.length;++e<i;){var a=n[e];a>o&&(o=a)}}else t=null==t&&kt(n)?r:J.createCallback(t,e,3),St(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Dt(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=J.createCallback(t,r,4);var o=-1,i=n.length;if("number"==typeof i)for(u&&(e=n[++o]);++o<i;)e=t(e,n[o],o,n);else h(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)});return e}function $t(n,t,e,r){var u=3>arguments.length;return t=J.createCallback(t,r,4),Et(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Tt(n){var t=-1,e=n?n.length:0,r=Xt("number"==typeof e?e:0);return St(n,function(n){var e=at(0,++t);r[t]=r[e],r[e]=n}),r}function Ft(n,t,e){var r;t=J.createCallback(t,e,3),e=-1;var u=n?n.length:0;if("number"==typeof u)for(;++e<u&&!(r=t(n[e],e,n)););else h(n,function(n,e,u){return!(r=t(n,e,u))});return!!r}function Bt(n,t,e){var r=0,u=n?n.length:0;if("number"!=typeof t&&null!=t){var o=-1;for(t=J.createCallback(t,e,3);++o<u&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[0]:v;return p(n,0,Se(Ie(0,r),u))}function Wt(t,e,r){if("number"==typeof r){var u=t?t.length:0;r=0>r?Ie(0,u+r):r||0}else if(r)return r=zt(t,e),t[r]===e?r:-1;return n(t,e,r)}function qt(n,t,e){if("number"!=typeof t&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=J.createCallback(t,e,3);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:Ie(0,t);return p(n,r)}function zt(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?J.createCallback(e,r,1):Ut,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;return u}function Pt(n,t,e,r){return"boolean"!=typeof t&&null!=t&&(r=e,e="function"!=typeof t&&r&&r[t]===n?null:t,t=!1),null!=e&&(e=J.createCallback(e,r,3)),ft(n,t,e)}function Kt(){for(var n=1<arguments.length?arguments:arguments[0],t=-1,e=n?At(Ve(n,"length")):0,r=Xt(0>e?0:e);++t<e;)r[t]=Ve(n,t);return r}function Lt(n,t){var e=-1,r=n?n.length:0,u={};for(t||!r||Te(n[0])||(t=[]);++e<r;){var o=n[e];t?u[o]=t[e]:o&&(u[o[0]]=o[1])}return u}function Mt(n,t){return 2<arguments.length?ct(n,17,p(arguments,2),null,t):ct(n,1,null,null,t)}function Vt(n,t,e){function r(){c&&ve(c),i=c=p=v,(g||h!==t)&&(s=Ue(),a=n.apply(l,o),c||i||(o=l=null))}function u(){var e=t-(Ue()-f);0<e?c=_e(u,e):(i&&ve(i),e=p,i=c=p=v,e&&(s=Ue(),a=n.apply(l,o),c||i||(o=l=null)))}var o,i,a,f,l,c,p,s=0,h=!1,g=!0;if(!dt(n))throw new ie;if(t=Ie(0,t)||0,!0===e)var y=!0,g=!1;else wt(e)&&(y=e.leading,h="maxWait"in e&&(Ie(t,e.maxWait)||0),g="trailing"in e?e.trailing:g);return function(){if(o=arguments,f=Ue(),l=this,p=g&&(c||!y),!1===h)var e=y&&!c;else{i||y||(s=f);var v=h-(f-s),m=0>=v;m?(i&&(i=ve(i)),s=f,a=n.apply(l,o)):i||(i=_e(r,v))}return m&&c?c=ve(c):c||t===h||(c=_e(u,t)),e&&(m=!0,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function Ut(n){return n}function Gt(n,t,e){var r=!0,u=t&&bt(t);t&&(e||u.length)||(null==e&&(e=t),o=Q,t=n,n=J,u=bt(t)),!1===e?r=!1:wt(e)&&"chain"in e&&(r=e.chain);var o=n,i=dt(o);St(u,function(e){var u=n[e]=t[e];i&&(o.prototype[e]=function(){var t=this.__chain__,e=this.__wrapped__,i=[e];if(be.apply(i,arguments),i=u.apply(n,i),r||t){if(e===i&&wt(i))return this;i=new o(i),i.__chain__=t}return i})})}function Ht(){}function Jt(n){return function(t){return t[n]}}function Qt(){return this.__wrapped__}e=e?Y.defaults(G.Object(),e,Y.pick(G,A)):G;var Xt=e.Array,Yt=e.Boolean,Zt=e.Date,ne=e.Function,te=e.Math,ee=e.Number,re=e.Object,ue=e.RegExp,oe=e.String,ie=e.TypeError,ae=[],fe=re.prototype,le=e._,ce=fe.toString,pe=ue("^"+oe(ce).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),se=te.ceil,ve=e.clearTimeout,he=te.floor,ge=ne.prototype.toString,ye=vt(ye=re.getPrototypeOf)&&ye,me=fe.hasOwnProperty,be=ae.push,_e=e.setTimeout,de=ae.splice,we=ae.unshift,je=function(){try{var n={},t=vt(t=re.defineProperty)&&t,e=t(n,n,n)&&t}catch(r){}return e}(),ke=vt(ke=re.create)&&ke,xe=vt(xe=Xt.isArray)&&xe,Ce=e.isFinite,Oe=e.isNaN,Ne=vt(Ne=re.keys)&&Ne,Ie=te.max,Se=te.min,Ee=e.parseInt,Re=te.random,Ae={};Ae[$]=Xt,Ae[T]=Yt,Ae[F]=Zt,Ae[B]=ne,Ae[q]=re,Ae[W]=ee,Ae[z]=ue,Ae[P]=oe,Q.prototype=J.prototype;var De=J.support={};De.funcDecomp=!vt(e.a)&&E.test(s),De.funcNames="string"==typeof ne.name,J.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:J}},ke||(nt=function(){function n(){}return function(t){if(wt(t)){n.prototype=t;var r=new n;n.prototype=null}return r||e.Object()}}());var $e=je?function(n,t){M.value=t,je(n,"__bindData__",M)}:Ht,Te=xe||function(n){return n&&"object"==typeof n&&"number"==typeof n.length&&ce.call(n)==$||!1},Fe=Ne?function(n){return wt(n)?Ne(n):[]}:H,Be={"&":"&","<":"<",">":">",'"':""","'":"'"},We=_t(Be),qe=ue("("+Fe(We).join("|")+")","g"),ze=ue("["+Fe(Be).join("")+"]","g"),Pe=ye?function(n){if(!n||ce.call(n)!=q)return!1;var t=n.valueOf,e=vt(t)&&(e=ye(t))&&ye(e);return e?n==e||ye(n)==e:ht(n)}:ht,Ke=lt(function(n,t,e){me.call(n,e)?n[e]++:n[e]=1}),Le=lt(function(n,t,e){(me.call(n,e)?n[e]:n[e]=[]).push(t)}),Me=lt(function(n,t,e){n[e]=t}),Ve=Rt,Ue=vt(Ue=Zt.now)&&Ue||function(){return(new Zt).getTime()},Ge=8==Ee(d+"08")?Ee:function(n,t){return Ee(kt(n)?n.replace(I,""):n,t||0)};return J.after=function(n,t){if(!dt(t))throw new ie;return function(){return 1>--n?t.apply(this,arguments):void 0}},J.assign=U,J.at=function(n){for(var t=arguments,e=-1,r=ut(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Xt(t);++e<t;)u[e]=n[r[e]];return u},J.bind=Mt,J.bindAll=function(n){for(var t=1<arguments.length?ut(arguments,!0,!1,1):bt(n),e=-1,r=t.length;++e<r;){var u=t[e];n[u]=ct(n[u],1,null,null,n)}return n},J.bindKey=function(n,t){return 2<arguments.length?ct(t,19,p(arguments,2),null,n):ct(t,3,null,null,n)},J.chain=function(n){return n=new Q(n),n.__chain__=!0,n},J.compact=function(n){for(var t=-1,e=n?n.length:0,r=[];++t<e;){var u=n[t];u&&r.push(u)}return r},J.compose=function(){for(var n=arguments,t=n.length;t--;)if(!dt(n[t]))throw new ie;return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];return t[0]}},J.constant=function(n){return function(){return n}},J.countBy=Ke,J.create=function(n,t){var e=nt(n);return t?U(e,t):e},J.createCallback=function(n,t,e){var r=typeof n;if(null==n||"function"==r)return tt(n,t,e);if("object"!=r)return Jt(n);var u=Fe(n),o=u[0],i=n[o];return 1!=u.length||i!==i||wt(i)?function(t){for(var e=u.length,r=!1;e--&&(r=ot(t[u[e]],n[u[e]],null,!0)););return r}:function(n){return n=n[o],i===n&&(0!==i||1/i==1/n)}},J.curry=function(n,t){return t="number"==typeof t?t:+t||n.length,ct(n,4,null,null,null,t)},J.debounce=Vt,J.defaults=_,J.defer=function(n){if(!dt(n))throw new ie;var t=p(arguments,1);return _e(function(){n.apply(v,t)},1)},J.delay=function(n,t){if(!dt(n))throw new ie;var e=p(arguments,2);return _e(function(){n.apply(v,e)},t)},J.difference=function(n){return rt(n,ut(arguments,!0,!0,1))},J.filter=Nt,J.flatten=function(n,t,e,r){return"boolean"!=typeof t&&null!=t&&(r=e,e="function"!=typeof t&&r&&r[t]===n?null:t,t=!1),null!=e&&(n=Rt(n,e,r)),ut(n,t)},J.forEach=St,J.forEachRight=Et,J.forIn=g,J.forInRight=function(n,t,e){var r=[];g(n,function(n,t){r.push(t,n)});var u=r.length;for(t=tt(t,e,3);u--&&!1!==t(r[u--],r[u],n););return n},J.forOwn=h,J.forOwnRight=mt,J.functions=bt,J.groupBy=Le,J.indexBy=Me,J.initial=function(n,t,e){var r=0,u=n?n.length:0;if("number"!=typeof t&&null!=t){var o=u;for(t=J.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else r=null==t||e?1:t||r;return p(n,0,Se(Ie(0,u-r),u))},J.intersection=function(){for(var e=[],r=-1,u=arguments.length,i=a(),f=st(),p=f===n,s=a();++r<u;){var v=arguments[r];(Te(v)||yt(v))&&(e.push(v),i.push(p&&v.length>=b&&o(r?e[r]:s)))}var p=e[0],h=-1,g=p?p.length:0,y=[];n:for(;++h<g;){var m=i[0],v=p[h];if(0>(m?t(m,v):f(s,v))){for(r=u,(m||s).push(v);--r;)if(m=i[r],0>(m?t(m,v):f(e[r],v)))continue n;y.push(v)}}for(;u--;)(m=i[u])&&c(m);return l(i),l(s),y},J.invert=_t,J.invoke=function(n,t){var e=p(arguments,2),r=-1,u="function"==typeof t,o=n?n.length:0,i=Xt("number"==typeof o?o:0);return St(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},J.keys=Fe,J.map=Rt,J.mapValues=function(n,t,e){var r={};return t=J.createCallback(t,e,3),h(n,function(n,e,u){r[e]=t(n,e,u)}),r},J.max=At,J.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):m+arguments[0];return me.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!dt(n))throw new ie;return e.cache={},e},J.merge=function(n){var t=arguments,e=2;if(!wt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3<e&&"function"==typeof t[e-2])var r=tt(t[--e-1],t[e--],2);else 2<e&&"function"==typeof t[e-1]&&(r=t[--e]);for(var t=p(arguments,1,e),u=-1,o=a(),i=a();++u<e;)it(n,t[u],r,o,i);return l(o),l(i),n},J.min=function(n,t,e){var u=1/0,o=u;if("function"!=typeof t&&e&&e[t]===n&&(t=null),null==t&&Te(n)){e=-1;for(var i=n.length;++e<i;){var a=n[e];a<o&&(o=a)}}else t=null==t&&kt(n)?r:J.createCallback(t,e,3),St(n,function(n,e,r){e=t(n,e,r),e<u&&(u=e,o=n)});return o},J.omit=function(n,t,e){var r={};if("function"!=typeof t){var u=[];g(n,function(n,t){u.push(t)});for(var u=rt(u,ut(arguments,!0,!1,1)),o=-1,i=u.length;++o<i;){var a=u[o];r[a]=n[a]}}else t=J.createCallback(t,e,3),g(n,function(n,e,u){t(n,e,u)||(r[e]=n)});return r},J.once=function(n){var t,e;if(!dt(n))throw new ie;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},J.pairs=function(n){for(var t=-1,e=Fe(n),r=e.length,u=Xt(r);++t<r;){var o=e[t];u[t]=[o,n[o]]}return u},J.partial=function(n){return ct(n,16,p(arguments,1))},J.partialRight=function(n){return ct(n,32,null,p(arguments,1))},J.pick=function(n,t,e){var r={};if("function"!=typeof t)for(var u=-1,o=ut(arguments,!0,!1,1),i=wt(n)?o.length:0;++u<i;){var a=o[u];a in n&&(r[a]=n[a])}else t=J.createCallback(t,e,3),g(n,function(n,e,u){t(n,e,u)&&(r[e]=n)});return r},J.pluck=Ve,J.property=Jt,J.pull=function(n){for(var t=arguments,e=0,r=t.length,u=n?n.length:0;++e<r;)for(var o=-1,i=t[e];++o<u;)n[o]===i&&(de.call(n,o--,1),u--);return n},J.range=function(n,t,e){n=+n||0,e="number"==typeof e?e:+e||1,null==t&&(t=n,n=0);var r=-1;t=Ie(0,se((t-n)/(e||1)));for(var u=Xt(t);++r<t;)u[r]=n,n+=e;return u},J.reject=function(n,t,e){return t=J.createCallback(t,e,3),Nt(n,function(n,e,r){return!t(n,e,r)})},J.remove=function(n,t,e){var r=-1,u=n?n.length:0,o=[];for(t=J.createCallback(t,e,3);++r<u;)e=n[r],t(e,r,n)&&(o.push(e),de.call(n,r--,1),u--);return o},J.rest=qt,J.shuffle=Tt,J.sortBy=function(n,t,e){var r=-1,o=Te(t),i=n?n.length:0,p=Xt("number"==typeof i?i:0);for(o||(t=J.createCallback(t,e,3)),St(n,function(n,e,u){var i=p[++r]=f();o?i.m=Rt(t,function(t){return n[t]}):(i.m=a())[0]=t(n,e,u),i.n=r,i.o=n}),i=p.length,p.sort(u);i--;)n=p[i],p[i]=n.o,o||l(n.m),c(n);return p},J.tap=function(n,t){return t(n),n},J.throttle=function(n,t,e){var r=!0,u=!0;if(!dt(n))throw new ie;return!1===e?r=!1:wt(e)&&(r="leading"in e?e.leading:r,u="trailing"in e?e.trailing:u),L.leading=r,L.maxWait=t,L.trailing=u,Vt(n,t,L)},J.times=function(n,t,e){n=-1<(n=+n)?n:0;var r=-1,u=Xt(n);for(t=tt(t,e,1);++r<n;)u[r]=t(r);return u},J.toArray=function(n){return n&&"number"==typeof n.length?p(n):xt(n)},J.transform=function(n,t,e,r){var u=Te(n);if(null==e)if(u)e=[];else{var o=n&&n.constructor;e=nt(o&&o.prototype)}return t&&(t=J.createCallback(t,r,4),(u?St:h)(n,function(n,r,u){return t(e,n,r,u)})),e},J.union=function(){return ft(ut(arguments,!0,!0))},J.uniq=Pt,J.values=xt,J.where=Nt,J.without=function(n){return rt(n,p(arguments,1))},J.wrap=function(n,t){return ct(t,16,[n])},J.xor=function(){for(var n=-1,t=arguments.length;++n<t;){var e=arguments[n];if(Te(e)||yt(e))var r=r?ft(rt(r,e).concat(rt(e,r))):e}return r||[]},J.zip=Kt,J.zipObject=Lt,J.collect=Rt,J.drop=qt,J.each=St,J.eachRight=Et,J.extend=U,J.methods=bt,J.object=Lt,J.select=Nt,J.tail=qt,J.unique=Pt,J.unzip=Kt,Gt(J),J.clone=function(n,t,e,r){return"boolean"!=typeof t&&null!=t&&(r=e,e=t,t=!1),Z(n,t,"function"==typeof e&&tt(e,r,1))},J.cloneDeep=function(n,t,e){return Z(n,!0,"function"==typeof t&&tt(t,e,1))},J.contains=Ct,J.escape=function(n){return null==n?"":oe(n).replace(ze,pt)},J.every=Ot,J.find=It,J.findIndex=function(n,t,e){var r=-1,u=n?n.length:0;for(t=J.createCallback(t,e,3);++r<u;)if(t(n[r],r,n))return r;return-1},J.findKey=function(n,t,e){var r;return t=J.createCallback(t,e,3),h(n,function(n,e,u){return t(n,e,u)?(r=e,!1):void 0}),r},J.findLast=function(n,t,e){var r;return t=J.createCallback(t,e,3),Et(n,function(n,e,u){return t(n,e,u)?(r=n,!1):void 0}),r},J.findLastIndex=function(n,t,e){var r=n?n.length:0;for(t=J.createCallback(t,e,3);r--;)if(t(n[r],r,n))return r;return-1},J.findLastKey=function(n,t,e){var r;return t=J.createCallback(t,e,3),mt(n,function(n,e,u){return t(n,e,u)?(r=e,!1):void 0}),r},J.has=function(n,t){return!!n&&me.call(n,t)},J.identity=Ut,J.indexOf=Wt,J.isArguments=yt,J.isArray=Te,J.isBoolean=function(n){return!0===n||!1===n||n&&"object"==typeof n&&ce.call(n)==T||!1},J.isDate=function(n){return n&&"object"==typeof n&&ce.call(n)==F||!1},J.isElement=function(n){return n&&1===n.nodeType||!1},J.isEmpty=function(n){var t=!0;if(!n)return t;var e=ce.call(n),r=n.length;return e==$||e==P||e==D||e==q&&"number"==typeof r&&dt(n.splice)?!r:(h(n,function(){return t=!1}),t)},J.isEqual=function(n,t,e,r){return ot(n,t,"function"==typeof e&&tt(e,r,2))},J.isFinite=function(n){return Ce(n)&&!Oe(parseFloat(n))},J.isFunction=dt,J.isNaN=function(n){return jt(n)&&n!=+n},J.isNull=function(n){return null===n},J.isNumber=jt,J.isObject=wt,J.isPlainObject=Pe,J.isRegExp=function(n){return n&&"object"==typeof n&&ce.call(n)==z||!1},J.isString=kt,J.isUndefined=function(n){return"undefined"==typeof n},J.lastIndexOf=function(n,t,e){var r=n?n.length:0;for("number"==typeof e&&(r=(0>e?Ie(0,r+e):Se(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},J.mixin=Gt,J.noConflict=function(){return e._=le,this},J.noop=Ht,J.now=Ue,J.parseInt=Ge,J.random=function(n,t,e){var r=null==n,u=null==t;return null==e&&("boolean"==typeof n&&u?(e=n,n=1):u||"boolean"!=typeof t||(e=t,u=!0)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=Re(),Se(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):at(n,t)},J.reduce=Dt,J.reduceRight=$t,J.result=function(n,t){if(n){var e=n[t];return dt(e)?n[t]():e}},J.runInContext=s,J.size=function(n){var t=n?n.length:0;return"number"==typeof t?t:Fe(n).length},J.some=Ft,J.sortedIndex=zt,J.template=function(n,t,e){var r=J.templateSettings;n=oe(n||""),e=_({},e,r);var u,o=_({},e.imports,r.imports),r=Fe(o),o=xt(o),a=0,f=e.interpolate||S,l="__p+='",f=ue((e.escape||S).source+"|"+f.source+"|"+(f===N?x:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(a,c).replace(R,i),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),
a=c+t.length,t}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(w,""):l).replace(j,"$1").replace(k,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=ne(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},J.unescape=function(n){return null==n?"":oe(n).replace(qe,gt)},J.uniqueId=function(n){var t=++y;return oe(null==n?"":n)+t},J.all=Ot,J.any=Ft,J.detect=It,J.findWhere=It,J.foldl=Dt,J.foldr=$t,J.include=Ct,J.inject=Dt,Gt(function(){var n={};return h(J,function(t,e){J.prototype[e]||(n[e]=t)}),n}(),!1),J.first=Bt,J.last=function(n,t,e){var r=0,u=n?n.length:0;if("number"!=typeof t&&null!=t){var o=u;for(t=J.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:v;return p(n,Ie(0,u-r))},J.sample=function(n,t,e){return n&&"number"!=typeof n.length&&(n=xt(n)),null==t||e?n?n[at(0,n.length-1)]:v:(n=Tt(n),n.length=Se(Ie(0,t),n.length),n)},J.take=Bt,J.head=Bt,h(J,function(n,t){var e="sample"!==t;J.prototype[t]||(J.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&"function"==typeof t)?new Q(o,u):o})}),J.VERSION="2.4.1",J.prototype.chain=function(){return this.__chain__=!0,this},J.prototype.toString=function(){return oe(this.__wrapped__)},J.prototype.value=Qt,J.prototype.valueOf=Qt,St(["join","pop","shift"],function(n){var t=ae[n];J.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new Q(e,n):e}}),St(["push","reverse","sort","unshift"],function(n){var t=ae[n];J.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),St(["concat","slice","splice"],function(n){var t=ae[n];J.prototype[n]=function(){return new Q(t.apply(this.__wrapped__,arguments),this.__chain__)}}),J}var v,h=[],g=[],y=0,m=+new Date+"",b=75,_=40,d=" \t\x0B\f \ufeff\n\r\u2028\u2029 ",w=/\b__p\+='';/g,j=/\b(__p\+=)''\+/g,k=/(__e\(.*?\)|\b__t\))\+'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,I=RegExp("^["+d+"]*0+(?=.$)"),S=/($^)/,E=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,A="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setTimeout".split(" "),D="[object Arguments]",$="[object Array]",T="[object Boolean]",F="[object Date]",B="[object Function]",W="[object Number]",q="[object Object]",z="[object RegExp]",P="[object String]",K={};K[B]=!1,K[D]=K[$]=K[T]=K[F]=K[W]=K[q]=K[z]=K[P]=!0;var L={leading:!1,maxWait:0,trailing:!1},M={configurable:!1,enumerable:!1,value:null,writable:!1},V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},U={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},G=V[typeof window]&&window||this,H=V[typeof exports]&&exports&&!exports.nodeType&&exports,J=V[typeof module]&&module&&!module.nodeType&&module,Q=J&&J.exports===H&&H,X=V[typeof global]&&global;!X||X.global!==X&&X.window!==X||(G=X);var Y=s();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(G._=Y,define(function(){return Y})):H&&J?Q?(J.exports=Y)._=Y:H._=Y:G._=Y}.call(this),/*!
JSZip - A Javascript class for generating and reading zip files
<http://stuartk.com/jszip>
(c) 2009-2014 Stuart Knightley <stuart [at] stuartk.com>
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
JSZip uses the library zlib.js released under the following license :
zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License
*/
!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZip=a():"undefined"!=typeof global?global.JSZip=a():"undefined"!=typeof self&&(self.JSZip=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";c.encode=function(a){for(var b,c,e,f,g,h,i,j="",k=0;k<a.length;)b=a.charCodeAt(k++),c=a.charCodeAt(k++),e=a.charCodeAt(k++),f=b>>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)f=d.indexOf(a.charAt(k++)),g=d.indexOf(a.charAt(k++)),h=d.indexOf(a.charAt(k++)),i=d.indexOf(a.charAt(k++)),b=f<<2|g>>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\0\0",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":6}],4:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<a||0>a)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":14}],5:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.date=null,c.compression=null},{}],6:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("zlibjs/bin/rawdeflate.min").Zlib,f=a("zlibjs/bin/rawinflate.min").Zlib;c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\0",c.compress=function(a){var b=new e.RawDeflate(a);return b.compress()},c.uncompress=function(a){var b=new f.RawInflate(a);return b.decompress()}},{"zlibjs/bin/rawdeflate.min":19,"zlibjs/bin/rawinflate.min":20}],7:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./utils"),c.base64=a("./base64"),c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":5,"./load":8,"./object":9,"./support":12,"./utils":14}],8:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;g<e.length;g++)h=e[g],this.file(h.fileName,h.decompressed,{binary:!0,optimizedBinaryString:!0,date:h.date,dir:h.dir});return this}},{"./base64":1,"./zipEntries":15}],9:[function(a,b){"use strict";var c,d,e=a("./support"),f=a("./utils"),g=a("./signature"),h=a("./defaults"),i=a("./base64"),j=a("./compressions"),k=a("./compressedObject"),l=a("./nodeBuffer");e.uint8array&&"function"==typeof TextEncoder&&"function"==typeof TextDecoder&&(c=new TextEncoder("utf-8"),d=new TextDecoder("utf-8"));var m=function(a){if(a._data instanceof k&&(a._data=a._data.getContent(),a.options.binary=!0,a.options.base64=!1,"uint8array"===f.getTypeOf(a._data))){var b=a._data;a._data=new Uint8Array(b.length),0!==b.length&&a._data.set(b,0)}return a._data},n=function(a){var b=m(a),d=f.getTypeOf(b);if("string"===d){if(!a.options.binary){if(c)return c.encode(b);if(e.nodebuffer)return l(b,"utf-8")}return a.asBinary()}return b},o=function(a){var b=m(this);return null===b||"undefined"==typeof b?"":(this.options.base64&&(b=i.decode(b)),b=a&&this.options.binary?A.utf8decode(b):f.transformTo("string",b),a||this.options.binary||(b=A.utf8encode(b)),b)},p=function(a,b,c){this.name=a,this._data=b,this.options=c};p.prototype={asText:function(){return o.call(this,!0)},asBinary:function(){return o.call(this,!1)},asNodeBuffer:function(){var a=n(this);return f.transformTo("nodebuffer",a)},asUint8Array:function(){var a=n(this);return f.transformTo("uint8array",a)},asArrayBuffer:function(){return this.asUint8Array().buffer}};var q=function(a,b){var c,d="";for(c=0;b>c;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},r=function(){var a,b,c={};for(a=0;a<arguments.length;a++)for(b in arguments[a])arguments[a].hasOwnProperty(b)&&"undefined"==typeof c[b]&&(c[b]=arguments[a][b]);return c},s=function(a){return a=a||{},a.base64!==!0||null!==a.binary&&void 0!==a.binary||(a.binary=!0),a=r(a,h),a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),a},t=function(a,b,c){var d=u(a),e=f.getTypeOf(b);if(d&&v.call(this,d),c=s(c),c.dir||null===b||"undefined"==typeof b)c.base64=!1,c.binary=!1,b=null;else if("string"===e)c.binary&&!c.base64&&c.optimizedBinaryString!==!0&&(b=f.string2binary(b));else{if(c.base64=!1,c.binary=!0,!(e||b instanceof k))throw new Error("The data of '"+a+"' is in an unsupported format !");"arraybuffer"===e&&(b=f.transformTo("uint8array",b))}var g=new p(a,b,c);return this.files[a]=g,g},u=function(a){"/"==a.slice(-1)&&(a=a.substring(0,a.length-1));var b=a.lastIndexOf("/");return b>0?a.substring(0,b):""},v=function(a){return"/"!=a.slice(-1)&&(a+="/"),this.files[a]||t.call(this,a,null,{dir:!0}),this.files[a]},w=function(a,b){var c,d=new k;return a._data instanceof k?(d.uncompressedSize=a._data.uncompressedSize,d.crc32=a._data.crc32,0===d.uncompressedSize||a.options.dir?(b=j.STORE,d.compressedContent="",d.crc32=0):a._data.compressionMethod===b.magic?d.compressedContent=a._data.getCompressedContent():(c=a._data.getContent(),d.compressedContent=b.compress(f.transformTo(b.compressInputType,c)))):(c=n(a),(!c||0===c.length||a.options.dir)&&(b=j.STORE,c=""),d.uncompressedSize=c.length,d.crc32=this.crc32(c),d.compressedContent=b.compress(f.transformTo(b.compressInputType,c))),d.compressedSize=d.compressedContent.length,d.compressionMethod=b.magic,d},x=function(a,b,c,d){var e,f,h=(c.compressedContent,this.utf8encode(b.name)),i=h!==b.name,j=b.options,k="",l="";e=j.date.getHours(),e<<=6,e|=j.date.getMinutes(),e<<=5,e|=j.date.getSeconds()/2,f=j.date.getFullYear()-1980,f<<=4,f|=j.date.getMonth()+1,f<<=5,f|=j.date.getDate(),i&&(l=q(1,1)+q(this.crc32(h),4)+h,k+="up"+q(l.length,2)+l);var m="";m+="\n\0",m+=i?"\0\b":"\0\0",m+=c.compressionMethod,m+=q(e,2),m+=q(f,2),m+=q(c.crc32,4),m+=q(c.compressedSize,4),m+=q(c.uncompressedSize,4),m+=q(h.length,2),m+=q(k.length,2);var n=g.LOCAL_FILE_HEADER+m+h+k,o=g.CENTRAL_FILE_HEADER+"\0"+m+"\0\0\0\0\0\0"+(b.options.dir===!0?"\0\0\0":"\0\0\0\0")+q(d,4)+h+k;return{fileRecord:n,dirRecord:o,compressedObject:c}},y=function(){this.data=[]};y.prototype={append:function(a){a=f.transformTo("string",a),this.data.push(a)},finalize:function(){return this.data.join("")}};var z=function(a){this.data=new Uint8Array(a),this.index=0};z.prototype={append:function(a){0!==a.length&&(a=f.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}};var A={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new p(d.name,d._data,r(d.options)),c=b.slice(this.root.length,b.length),b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(f.isRegExp(a)){var d=a;return this.filter(function(a,b){return!b.options.dir&&d.test(a)})}return this.filter(function(b,c){return!c.options.dir&&b===a})[0]||null}return a=this.root+a,t.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(f.isRegExp(a))return this.filter(function(b,c){return c.options.dir&&a.test(b)});var b=this.root+a,c=v.call(this,b),d=this.clone();return d.root=c.name,d},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b)if(b.options.dir)for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d<c.length;d++)delete this.files[c[d].name];else delete this.files[a];return this},generate:function(a){a=r(a||{},{base64:!0,compression:"STORE",type:"base64"}),f.checkSupport(a.type);var b,c,d=[],e=0,h=0;for(var k in this.files)if(this.files.hasOwnProperty(k)){var l=this.files[k],m=l.options.compression||a.compression.toUpperCase(),n=j[m];if(!n)throw new Error(m+" is not a valid compression method !");var o=w.call(this,l,n),p=x.call(this,k,l,o,e);e+=p.fileRecord.length+o.compressedSize,h+=p.dirRecord.length,d.push(p)}var s="";s=g.CENTRAL_DIRECTORY_END+"\0\0\0\0"+q(d.length,2)+q(d.length,2)+q(h,4)+q(e,4)+"\0\0";var t=a.type.toLowerCase();for(b="uint8array"===t||"arraybuffer"===t||"blob"===t||"nodebuffer"===t?new z(e+h+s.length):new y(e+h+s.length),c=0;c<d.length;c++)b.append(d[c].fileRecord),b.append(d[c].compressedObject.compressedContent);for(c=0;c<d.length;c++)b.append(d[c].dirRecord);b.append(s);var u=b.finalize();switch(a.type.toLowerCase()){case"uint8array":case"arraybuffer":case"nodebuffer":return f.transformTo(a.type.toLowerCase(),u);case"blob":return f.arrayBuffer2Blob(f.transformTo("arraybuffer",u));case"base64":return a.base64?i.encode(u):u;default:return u}},crc32:function(a,b){if("undefined"==typeof a||!a.length)return 0;var c="string"!==f.getTypeOf(a),d=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];"undefined"==typeof b&&(b=0);var e=0,g=0,h=0;b=-1^b;for(var i=0,j=a.length;j>i;i++)h=c?a[i]:a.charCodeAt(i),g=255&(b^h),e=d[g],b=b>>>8^e;return-1^b},utf8encode:function(a){if(c){var b=c.encode(a);return f.transformTo("string",b)}if(e.nodebuffer)return f.transformTo("string",l(a,"utf-8"));for(var d=[],g=0,h=0;h<a.length;h++){var i=a.charCodeAt(h);128>i?d[g++]=String.fromCharCode(i):i>127&&2048>i?(d[g++]=String.fromCharCode(i>>6|192),d[g++]=String.fromCharCode(63&i|128)):(d[g++]=String.fromCharCode(i>>12|224),d[g++]=String.fromCharCode(i>>6&63|128),d[g++]=String.fromCharCode(63&i|128))}return d.join("")},utf8decode:function(a){var b=[],c=0,g=f.getTypeOf(a),h="string"!==g,i=0,j=0,k=0,l=0;if(d)return d.decode(f.transformTo("uint8array",a));if(e.nodebuffer)return f.transformTo("nodebuffer",a).toString("utf-8");for(;i<a.length;)j=h?a[i]:a.charCodeAt(i),128>j?(b[c++]=String.fromCharCode(j),i++):j>191&&224>j?(k=h?a[i+1]:a.charCodeAt(i+1),b[c++]=String.fromCharCode((31&j)<<6|63&k),i+=2):(k=h?a[i+1]:a.charCodeAt(i+1),l=h?a[i+2]:a.charCodeAt(i+2),b[c++]=String.fromCharCode((15&j)<<12|(63&k)<<6|63&l),i+=3);return b.join("")}};b.exports=A},{"./base64":1,"./compressedObject":2,"./compressions":3,"./defaults":5,"./nodeBuffer":17,"./signature":10,"./support":12,"./utils":14}],10:[function(a,b,c){"use strict";c.LOCAL_FILE_HEADER="PK",c.CENTRAL_FILE_HEADER="PK",c.CENTRAL_DIRECTORY_END="PK",c.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",c.ZIP64_CENTRAL_DIRECTORY_END="PK",c.DATA_DESCRIPTOR="PK\b"},{}],11:[function(a,b){"use strict";function c(a,b){this.data=a,b||(this.data=e.string2binary(this.data)),this.length=this.data.length,this.index=0}var d=a("./dataReader"),e=a("./utils");c.prototype=new d,c.prototype.byteAt=function(a){return this.data.charCodeAt(a)},c.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)},c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":4,"./utils":14}],12:[function(a,b,c){var d=a("__browserify_process");if(c.base64=!0,c.array=!0,c.string=!0,c.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,c.nodebuffer=!d.browser,c.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)c.blob=!1;else{var e=new ArrayBuffer(0);try{c.blob=0===new Blob([e],{type:"application/zip"}).size}catch(f){try{var g=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,h=new g;h.append(e),c.blob=0===h.getBlob("application/zip").size}catch(f){c.blob=!1}}}},{__browserify_process:18}],13:[function(a,b){"use strict";function c(a){a&&(this.data=a,this.length=this.data.length,this.index=0)}var d=a("./dataReader");c.prototype=new d,c.prototype.byteAt=function(a){return this.data[a]},c.prototype.lastIndexOfSignature=function(a){for(var b=a.charCodeAt(0),c=a.charCodeAt(1),d=a.charCodeAt(2),e=a.charCodeAt(3),f=this.length-4;f>=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":4}],14:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;c<a.length;++c)b[c]=255&a.charCodeAt(c);return b}function f(a){var b=65536,d=[],e=a.length,f=c.getTypeOf(a),g=0,h=!0;try{switch(f){case"uint8array":String.fromCharCode.apply(null,new Uint8Array(0));break;case"nodebuffer":String.fromCharCode.apply(null,j(0))}}catch(i){h=!1}if(!h){for(var k="",l=0;l<a.length;l++)k+=String.fromCharCode(a[l]);return k}for(;e>g&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;c<a.length;c++)b[c]=a[c];return b}var h=a("./support"),i=a("./compressions"),j=a("./nodeBuffer");c.string2binary=function(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(255&a.charCodeAt(c));return b},c.string2Uint8Array=function(a){return c.transformTo("uint8array",a)},c.uint8Array2String=function(a){return c.transformTo("string",a)},c.string2Blob=function(a){var b=c.transformTo("arraybuffer",a);return c.arrayBuffer2Blob(b)},c.arrayBuffer2Blob=function(a){c.checkSupport("blob");try{return new Blob([a],{type:"application/zip"})}catch(b){try{var d=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,e=new d;return e.append(a),e.getBlob("application/zip")}catch(b){throw new Error("Bug : can't construct the Blob.")}}};var k={};k.string={string:d,array:function(a){return e(a,new Array(a.length))},arraybuffer:function(a){return k.string.uint8array(a).buffer},uint8array:function(a){return e(a,new Uint8Array(a.length))},nodebuffer:function(a){return e(a,j(a.length))}},k.array={string:f,array:d,arraybuffer:function(a){return new Uint8Array(a).buffer},uint8array:function(a){return new Uint8Array(a)},nodebuffer:function(a){return j(a)}},k.arraybuffer={string:function(a){return f(new Uint8Array(a))},array:function(a){return g(new Uint8Array(a),new Array(a.byteLength))},arraybuffer:d,uint8array:function(a){return new Uint8Array(a)},nodebuffer:function(a){return j(new Uint8Array(a))}},k.uint8array={string:f,array:function(a){return g(a,new Array(a.length))},arraybuffer:function(a){return a.buffer},uint8array:d,nodebuffer:function(a){return j(a)}},k.nodebuffer={string:f,array:function(a){return g(a,new Array(a.length))},arraybuffer:function(a){return k.nodebuffer.uint8array(a).buffer},uint8array:function(a){return g(a,new Uint8Array(a.length))},nodebuffer:d},c.transformTo=function(a,b){if(b||(b=""),!a)return b;c.checkSupport(a);var d=c.getTypeOf(b),e=k[d][a](b);return e},c.getTypeOf=function(a){return"string"==typeof a?"string":"[object Array]"===Object.prototype.toString.call(a)?"array":h.nodebuffer&&j.test(a)?"nodebuffer":h.uint8array&&a instanceof Uint8Array?"uint8array":h.arraybuffer&&a instanceof ArrayBuffer?"arraybuffer":void 0},c.checkSupport=function(a){var b=h[a.toLowerCase()];if(!b)throw new Error(a+" is not supported by this browser")},c.MAX_VALUE_16BITS=65535,c.MAX_VALUE_32BITS=-1,c.pretty=function(a){var b,c,d="";for(c=0;c<(a||"").length;c++)b=a.charCodeAt(c),d+="\\x"+(16>b?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":17,"./support":12}],15:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a<this.files.length;a++)b=this.files[a],this.reader.setIndex(b.localHeaderOffset),this.checkSignature(h.LOCAL_FILE_HEADER),b.readLocalPart(this.reader),b.handleUTF8()},readCentralDir:function(){var a;for(this.reader.setIndex(this.centralDirOffset);this.reader.readString(4)===h.CENTRAL_FILE_HEADER;)a=new i({zip64:this.zip64},this.loadOptions),a.readCentralPart(this.reader),this.files.push(a)},readEndOfCentral:function(){var a=this.reader.lastIndexOfSignature(h.CENTRAL_DIRECTORY_END);if(-1===a)throw new Error("Corrupted zip : can't find end of central directory");if(this.reader.setIndex(a),this.checkSignature(h.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===g.MAX_VALUE_16BITS||this.diskWithCentralDirStart===g.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===g.MAX_VALUE_16BITS||this.centralDirRecords===g.MAX_VALUE_16BITS||this.centralDirSize===g.MAX_VALUE_32BITS||this.centralDirOffset===g.MAX_VALUE_32BITS){if(this.zip64=!0,a=this.reader.lastIndexOfSignature(h.ZIP64_CENTRAL_DIRECTORY_LOCATOR),-1===a)throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator");this.reader.setIndex(a),this.checkSignature(h.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(h.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}},prepareReader:function(a){var b=g.getTypeOf(a);this.reader="string"!==b||j.uint8array?"nodebuffer"===b?new e(a):new f(g.transformTo("uint8array",a)):new d(a,this.loadOptions.optimizedBinaryString)},load:function(a){this.prepareReader(a),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},b.exports=c},{"./nodeBufferReader":17,"./signature":10,"./stringReader":11,"./support":12,"./uint8ArrayReader":13,"./utils":14,"./zipEntry":16}],16:[function(a,b){"use strict";function c(a,b){this.options=a,this.loadOptions=b}var d=a("./stringReader"),e=a("./utils"),f=a("./compressedObject"),g=a("./object");c.prototype={isEncrypted:function(){return 1===(1&this.bitFlag)},useUTF8:function(){return 2048===(2048&this.bitFlag)},prepareCompressedContent:function(a,b,c){return function(){var d=a.index;a.setIndex(b);var e=a.readData(c);return a.setIndex(d),e}},prepareContent:function(a,b,c,d,f){return function(){var a=e.transformTo(d.uncompressInputType,this.getCompressedContent()),b=d.uncompress(a);if(b.length!==f)throw new Error("Bug : uncompressed data size mismatch");return b}},readLocalPart:function(a){var b,c;if(a.skip(22),this.fileNameLength=a.readInt(2),c=a.readInt(2),this.fileName=a.readString(this.fileNameLength),a.skip(c),-1==this.compressedSize||-1==this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory (compressedSize == -1 || uncompressedSize == -1)");if(b=e.findCompression(this.compressionMethod),null===b)throw new Error("Corrupted zip : compression "+e.pretty(this.compressionMethod)+" unknown (inner file : "+this.fileName+")");if(this.decompressed=new f,this.decompressed.compressedSize=this.compressedSize,this.decompressed.uncompressedSize=this.uncompressedSize,this.decompressed.crc32=this.crc32,this.decompressed.compressionMethod=this.compressionMethod,this.decompressed.getCompressedContent=this.prepareCompressedContent(a,a.index,this.compressedSize,b),this.decompressed.getContent=this.prepareContent(a,a.index,this.compressedSize,b,this.uncompressedSize),this.loadOptions.checkCRC32&&(this.decompressed=e.transformTo("string",this.decompressed.getContent()),g.crc32(this.decompressed)!==this.crc32))throw new Error("Corrupted zip : CRC32 mismatch")},readCentralPart:function(a){if(this.versionMadeBy=a.readString(2),this.versionNeeded=a.readInt(2),this.bitFlag=a.readInt(2),this.compressionMethod=a.readString(2),this.date=a.readDate(),this.crc32=a.readInt(4),this.compressedSize=a.readInt(4),this.uncompressedSize=a.readInt(4),this.fileNameLength=a.readInt(2),this.extraFieldsLength=a.readInt(2),this.fileCommentLength=a.readInt(2),this.diskNumberStart=a.readInt(2),this.internalFileAttributes=a.readInt(2),this.externalFileAttributes=a.readInt(4),this.localHeaderOffset=a.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");this.fileName=a.readString(this.fileNameLength),this.readExtraFields(a),this.parseZIP64ExtraField(a),this.fileComment=a.readString(this.fileCommentLength),this.dir=!!(16&this.externalFileAttributes)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var a=new d(this.extraFields[1].value);this.uncompressedSize===e.MAX_VALUE_32BITS&&(this.uncompressedSize=a.readInt(8)),this.compressedSize===e.MAX_VALUE_32BITS&&(this.compressedSize=a.readInt(8)),this.localHeaderOffset===e.MAX_VALUE_32BITS&&(this.localHeaderOffset=a.readInt(8)),this.diskNumberStart===e.MAX_VALUE_32BITS&&(this.diskNumberStart=a.readInt(4))}},readExtraFields:function(a){var b,c,d,e=a.index;for(this.extraFields=this.extraFields||{};a.index<e+this.extraFieldsLength;)b=a.readInt(2),c=a.readInt(2),d=a.readString(c),this.extraFields[b]={id:b,length:c,value:d}},handleUTF8:function(){if(this.useUTF8())this.fileName=g.utf8decode(this.fileName),this.fileComment=g.utf8decode(this.fileComment);else{var a=this.findExtraFieldUnicodePath();null!==a&&(this.fileName=a)}},findExtraFieldUnicodePath:function(){var a=this.extraFields[28789];if(a){var b=new d(a.value);return 1!==b.readInt(1)?null:g.crc32(this.fileName)!==b.readInt(4)?null:g.utf8decode(b.readString(a.length-5))}return null}},b.exports=c},{"./compressedObject":2,"./object":9,"./stringReader":11,"./utils":14}],17:[function(){},{}],18:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],19:[function(){/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
(function(){"use strict";function a(a,b){var c=a.split("."),d=n;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||b===l?d=d[e]?d[e]:d[e]={}:d[e]=b}function b(a,b){if(this.index="number"==typeof b?b:0,this.d=0,this.buffer=a instanceof(o?Uint8Array:Array)?a:new(o?Uint8Array:Array)(32768),2*this.buffer.length<=this.index)throw Error("invalid index");this.buffer.length<=this.index&&c(this)}function c(a){var b,c=a.buffer,d=c.length,e=new(o?Uint8Array:Array)(d<<1);if(o)e.set(c);else for(b=0;d>b;++b)e[b]=c[b];return a.buffer=e}function d(a){this.buffer=new(o?Uint16Array:Array)(2*a),this.length=0}function e(a,b){this.e=w,this.f=0,this.input=o&&a instanceof Array?new Uint8Array(a):a,this.c=0,b&&(b.lazy&&(this.f=b.lazy),"number"==typeof b.compressionType&&(this.e=b.compressionType),b.outputBuffer&&(this.b=o&&b.outputBuffer instanceof Array?new Uint8Array(b.outputBuffer):b.outputBuffer),"number"==typeof b.outputIndex&&(this.c=b.outputIndex)),this.b||(this.b=new(o?Uint8Array:Array)(32768))}function f(a,b){this.length=a,this.g=b}function g(a,b){function c(a,b){var c,d=a.g,e=[],f=0;c=z[a.length],e[f++]=65535&c,e[f++]=c>>16&255,e[f++]=c>>24;var g;switch(m){case 1===d:g=[0,d-1,0];break;case 2===d:g=[1,d-2,0];break;case 3===d:g=[2,d-3,0];break;case 4===d:g=[3,d-4,0];break;case 6>=d:g=[4,d-5,1];break;case 8>=d:g=[5,d-7,1];break;case 12>=d:g=[6,d-9,2];break;case 16>=d:g=[7,d-13,2];break;case 24>=d:g=[8,d-17,3];break;case 32>=d:g=[9,d-25,3];break;case 48>=d:g=[10,d-33,4];break;case 64>=d:g=[11,d-49,4];break;case 96>=d:g=[12,d-65,5];break;case 128>=d:g=[13,d-97,5];break;case 192>=d:g=[14,d-129,6];break;case 256>=d:g=[15,d-193,6];break;case 384>=d:g=[16,d-257,7];break;case 512>=d:g=[17,d-385,7];break;case 768>=d:g=[18,d-513,8];break;case 1024>=d:g=[19,d-769,8];break;case 1536>=d:g=[20,d-1025,9];break;case 2048>=d:g=[21,d-1537,9];break;case 3072>=d:g=[22,d-2049,10];break;case 4096>=d:g=[23,d-3073,10];break;case 6144>=d:g=[24,d-4097,11];break;case 8192>=d:g=[25,d-6145,11];break;case 12288>=d:g=[26,d-8193,12];break;case 16384>=d:g=[27,d-12289,12];break;case 24576>=d:g=[28,d-16385,13];break;case 32768>=d:g=[29,d-24577,13];break;default:throw"invalid distance"}c=g,e[f++]=c[0],e[f++]=c[1],e[f++]=c[2];var h,i;for(h=0,i=e.length;i>h;++h)r[s++]=e[h];u[e[0]]++,v[e[3]]++,t=a.length+b-1,n=null}var d,e,f,g,i,j,k,n,p,q={},r=o?new Uint16Array(2*b.length):[],s=0,t=0,u=new(o?Uint32Array:Array)(286),v=new(o?Uint32Array:Array)(30),w=a.f;if(!o){for(f=0;285>=f;)u[f++]=0;for(f=0;29>=f;)v[f++]=0}for(u[256]=1,d=0,e=b.length;e>d;++d){for(f=i=0,g=3;g>f&&d+f!==e;++f)i=i<<8|b[d+f];if(q[i]===l&&(q[i]=[]),j=q[i],!(0<t--)){for(;0<j.length&&32768<d-j[0];)j.shift();if(d+3>=e){for(n&&c(n,-1),f=0,g=e-d;g>f;++f)p=b[d+f],r[s++]=p,++u[p];break}0<j.length?(k=h(b,d,j),n?n.length<k.length?(p=b[d-1],r[s++]=p,++u[p],c(k,0)):c(n,-1):k.length<w?n=k:c(k,0)):n?c(n,-1):(p=b[d],r[s++]=p,++u[p])}j.push(d)}return r[s++]=256,u[256]++,a.j=u,a.i=v,o?r.subarray(0,s):r}function h(a,b,c){var d,e,g,h,i,j,k=0,l=a.length;h=0,j=c.length;a:for(;j>h;h++){if(d=c[j-h-1],g=3,k>3){for(i=k;i>3;i--)if(a[d+i-1]!==a[b+i-1])continue a;g=k}for(;258>g&&l>b+g&&a[d+g]===a[b+g];)++g;if(g>k&&(e=d,k=g),258===g)break}return new f(k,b-e)}function i(a,b){var c,e,f,g,h,i=a.length,k=new d(572),l=new(o?Uint8Array:Array)(i);if(!o)for(g=0;i>g;g++)l[g]=0;for(g=0;i>g;++g)0<a[g]&&k.push(g,a[g]);if(c=Array(k.length/2),e=new(o?Uint32Array:Array)(k.length/2),1===c.length)return l[k.pop().index]=1,l;for(g=0,h=k.length/2;h>g;++g)c[g]=k.pop(),e[g]=c[g].value;for(f=j(e,e.length,b),g=0,h=c.length;h>g;++g)l[c[g].index]=f[g];return l}function j(a,b,c){function d(a){var c=n[a][p[a]];c===b?(d(a+1),d(a+1)):--l[c],++p[a]}var e,f,g,h,i,j=new(o?Uint16Array:Array)(c),k=new(o?Uint8Array:Array)(c),l=new(o?Uint8Array:Array)(b),m=Array(c),n=Array(c),p=Array(c),q=(1<<c)-b,r=1<<c-1;for(j[c-1]=b,f=0;c>f;++f)r>q?k[f]=0:(k[f]=1,q-=r),q<<=1,j[c-2-f]=(j[c-1-f]/2|0)+b;for(j[0]=k[0],m[0]=Array(j[0]),n[0]=Array(j[0]),f=1;c>f;++f)j[f]>2*j[f-1]+k[f]&&(j[f]=2*j[f-1]+k[f]),m[f]=Array(j[f]),n[f]=Array(j[f]);for(e=0;b>e;++e)l[e]=c;for(g=0;g<j[c-1];++g)m[c-1][g]=a[g],n[c-1][g]=g;for(e=0;c>e;++e)p[e]=0;for(1===k[c-1]&&(--l[0],++p[c-1]),f=c-2;f>=0;--f){for(h=e=0,i=p[f+1],g=0;g<j[f];g++)h=m[f+1][i]+m[f+1][i+1],h>a[e]?(m[f][g]=h,n[f][g]=b,i+=2):(m[f][g]=a[e],n[f][g]=e,++e);p[f]=0,1===k[f]&&d(f)}return l}function k(a){var b,c,d,e,f=new(o?Uint16Array:Array)(a.length),g=[],h=[],i=0;for(b=0,c=a.length;c>b;b++)g[a[b]]=(0|g[a[b]])+1;for(b=1,c=16;c>=b;b++)h[b]=i,i+=0|g[b],i<<=1;for(b=0,c=a.length;c>b;b++)for(i=h[a[b]],h[a[b]]+=1,d=f[b]=0,e=a[b];e>d;d++)f[b]=f[b]<<1|1&i,i>>>=1;return f}var l=void 0,m=!0,n=this,o="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;b.prototype.a=function(a,b,d){var e,f=this.buffer,g=this.index,h=this.d,i=f[g];if(d&&b>1&&(a=b>8?(u[255&a]<<24|u[a>>>8&255]<<16|u[a>>>16&255]<<8|u[a>>>24&255])>>32-b:u[a]>>8-b),8>b+h)i=i<<b|a,h+=b;else for(e=0;b>e;++e)i=i<<1|a>>b-e-1&1,8===++h&&(h=0,f[g++]=u[i],i=0,g===f.length&&(f=c(this)));f[g]=i,this.buffer=f,this.d=h,this.index=g},b.prototype.finish=function(){var a,b=this.buffer,c=this.index;return 0<this.d&&(b[c]<<=8-this.d,b[c]=u[b[c]],c++),o?a=b.subarray(0,c):(b.length=c,a=b),a};var p,q=new(o?Uint8Array:Array)(256);for(p=0;256>p;++p){for(var r=p,s=r,t=7,r=r>>>1;r;r>>>=1)s<<=1,s|=1&r,--t;q[p]=(s<<t&255)>>>0}var u=q;d.prototype.getParent=function(a){return 2*((a-2)/4|0)},d.prototype.push=function(a,b){var c,d,e,f=this.buffer;for(c=this.length,f[this.length++]=b,f[this.length++]=a;c>0&&(d=this.getParent(c),f[c]>f[d]);)e=f[c],f[c]=f[d],f[d]=e,e=f[c+1],f[c+1]=f[d+1],f[d+1]=e,c=d;return this.length},d.prototype.pop=function(){var a,b,c,d,e,f=this.buffer;for(b=f[0],a=f[1],this.length-=2,f[0]=f[this.length],f[1]=f[this.length+1],e=0;d=2*e+2,!(d>=this.length)&&(d+2<this.length&&f[d+2]>f[d]&&(d+=2),f[d]>f[e]);)c=f[e],f[e]=f[d],f[d]=c,c=f[e+1],f[e+1]=f[d+1],f[d+1]=c,e=d;return{index:a,value:b,length:this.length}};var v,w=2,x=[];for(v=0;288>v;v++)switch(m){case 143>=v:x.push([v+48,8]);break;case 255>=v:x.push([v-144+400,9]);break;case 279>=v:x.push([v-256+0,7]);break;case 287>=v:x.push([v-280+192,8]);break;default:throw"invalid literal: "+v}e.prototype.h=function(){var a,c,d,e,f=this.input;switch(this.e){case 0:for(d=0,e=f.length;e>d;){c=o?f.subarray(d,d+65535):f.slice(d,d+65535),d+=c.length;var h=c,j=d===e,n=l,p=l,q=l,r=l,s=l,t=this.b,u=this.c;if(o){for(t=new Uint8Array(this.b.buffer);t.length<=u+h.length+5;)t=new Uint8Array(t.length<<1);t.set(this.b)}if(n=j?1:0,t[u++]=0|n,p=h.length,q=~p+65536&65535,t[u++]=255&p,t[u++]=p>>>8&255,t[u++]=255&q,t[u++]=q>>>8&255,o)t.set(h,u),u+=h.length,t=t.subarray(0,u);else{for(r=0,s=h.length;s>r;++r)t[u++]=h[r];t.length=u}this.c=u,this.b=t}break;case 1:var v=new b(o?new Uint8Array(this.b.buffer):this.b,this.c);v.a(1,1,m),v.a(1,2,m);var y,z,A,B=g(this,f);for(y=0,z=B.length;z>y;y++)if(A=B[y],b.prototype.a.apply(v,x[A]),A>256)v.a(B[++y],B[++y],m),v.a(B[++y],5),v.a(B[++y],B[++y],m);else if(256===A)break;this.b=v.finish(),this.c=this.b.length;break;case w:var C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R=new b(o?new Uint8Array(this.b.buffer):this.b,this.c),S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],T=Array(19);for(C=w,R.a(1,1,m),R.a(C,2,m),D=g(this,f),H=i(this.j,15),I=k(H),J=i(this.i,7),K=k(J),E=286;E>257&&0===H[E-1];E--);for(F=30;F>1&&0===J[F-1];F--);var U,V,W,X,Y,Z,$=E,_=F,ab=new(o?Uint32Array:Array)($+_),bb=new(o?Uint32Array:Array)(316),cb=new(o?Uint8Array:Array)(19);for(U=V=0;$>U;U++)ab[V++]=H[U];for(U=0;_>U;U++)ab[V++]=J[U];if(!o)for(U=0,X=cb.length;X>U;++U)cb[U]=0;for(U=Y=0,X=ab.length;X>U;U+=V){for(V=1;X>U+V&&ab[U+V]===ab[U];++V);if(W=V,0===ab[U])if(3>W)for(;0<W--;)bb[Y++]=0,cb[0]++;else for(;W>0;)Z=138>W?W:138,Z>W-3&&W>Z&&(Z=W-3),10>=Z?(bb[Y++]=17,bb[Y++]=Z-3,cb[17]++):(bb[Y++]=18,bb[Y++]=Z-11,cb[18]++),W-=Z;else if(bb[Y++]=ab[U],cb[ab[U]]++,W--,3>W)for(;0<W--;)bb[Y++]=ab[U],cb[ab[U]]++;else for(;W>0;)Z=6>W?W:6,Z>W-3&&W>Z&&(Z=W-3),bb[Y++]=16,bb[Y++]=Z-3,cb[16]++,W-=Z}for(a=o?bb.subarray(0,Y):bb.slice(0,Y),L=i(cb,7),P=0;19>P;P++)T[P]=L[S[P]];for(G=19;G>4&&0===T[G-1];G--);for(M=k(L),R.a(E-257,5,m),R.a(F-1,5,m),R.a(G-4,4,m),P=0;G>P;P++)R.a(T[P],3,m);for(P=0,Q=a.length;Q>P;P++)if(N=a[P],R.a(M[N],L[N],m),N>=16){switch(P++,N){case 16:O=2;break;case 17:O=3;break;case 18:O=7;break;default:throw"invalid code: "+N}R.a(a[P],O,m)}var db,eb,fb,gb,hb,ib,jb,kb,lb=[I,H],mb=[K,J];for(hb=lb[0],ib=lb[1],jb=mb[0],kb=mb[1],db=0,eb=D.length;eb>db;++db)if(fb=D[db],R.a(hb[fb],ib[fb],m),fb>256)R.a(D[++db],D[++db],m),gb=D[++db],R.a(jb[gb],kb[gb],m),R.a(D[++db],D[++db],m);else if(256===fb)break;this.b=R.finish(),this.c=this.b.length;break;default:throw"invalid compression type"}return this.b};var y=function(){function a(a){switch(m){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:throw"invalid length: "+a}}var b,c,d=[];for(b=3;258>=b;b++)c=a(b),d[b]=c[2]<<24|c[1]<<16|c[0];return d}(),z=o?new Uint32Array(y):y;a("Zlib.RawDeflate",e),a("Zlib.RawDeflate.prototype.compress",e.prototype.h);var A,B,C,D,E={NONE:0,FIXED:1,DYNAMIC:w};if(Object.keys)A=Object.keys(E);else for(B in A=[],C=0,E)A[C++]=B;for(C=0,D=A.length;D>C;++C)B=A[C],a("Zlib.RawDeflate.CompressionType."+B,E[B])}).call(this)},{}],20:[function(){/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
(function(){"use strict";function a(a,b){var c=a.split("."),d=g;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d=d[e]?d[e]:d[e]={}:d[e]=b}function b(a){var b,c,d,e,f,g,i,j,k,l,m=a.length,n=0,o=Number.POSITIVE_INFINITY;for(j=0;m>j;++j)a[j]>n&&(n=a[j]),a[j]<o&&(o=a[j]);for(b=1<<n,c=new(h?Uint32Array:Array)(b),d=1,e=0,f=2;n>=d;){for(j=0;m>j;++j)if(a[j]===d){for(g=0,i=e,k=0;d>k;++k)g=g<<1|1&i,i>>=1;for(l=d<<16|j,k=g;b>k;k+=f)c[k]=l;++e}++d,e<<=1,f<<=1}return[c,n,o]}function c(a,b){switch(this.g=[],this.h=32768,this.c=this.f=this.d=this.k=0,this.input=h?new Uint8Array(a):a,this.l=!1,this.i=j,this.q=!1,(b||!(b={}))&&(b.index&&(this.d=b.index),b.bufferSize&&(this.h=b.bufferSize),b.bufferType&&(this.i=b.bufferType),b.resize&&(this.q=b.resize)),this.i){case i:this.a=32768,this.b=new(h?Uint8Array:Array)(32768+this.h+258);break;case j:this.a=0,this.b=new(h?Uint8Array:Array)(this.h),this.e=this.v,this.m=this.s,this.j=this.t;break;default:throw Error("invalid inflate mode")}}function d(a,b){for(var c,d=a.f,e=a.c,f=a.input,g=a.d,h=f.length;b>e;){if(g>=h)throw Error("input buffer is broken");d|=f[g++]<<e,e+=8}return c=d&(1<<b)-1,a.f=d>>>b,a.c=e-b,a.d=g,c}function e(a,b){for(var c,d,e=a.f,f=a.c,g=a.input,h=a.d,i=g.length,j=b[0],k=b[1];k>f&&!(h>=i);)e|=g[h++]<<f,f+=8;return c=j[e&(1<<k)-1],d=c>>>16,a.f=e>>d,a.c=f-d,a.d=h,65535&c}function f(a){function c(a,b,c){var f,g,h,i=this.p;for(h=0;a>h;)switch(f=e(this,b)){case 16:for(g=3+d(this,2);g--;)c[h++]=i;break;case 17:for(g=3+d(this,3);g--;)c[h++]=0;i=0;break;case 18:for(g=11+d(this,7);g--;)c[h++]=0;i=0;break;default:i=c[h++]=f}return this.p=i,c}var f,g,i,j,k=d(a,5)+257,l=d(a,5)+1,m=d(a,4)+4,o=new(h?Uint8Array:Array)(n.length);for(j=0;m>j;++j)o[n[j]]=d(a,3);if(!h)for(j=m,m=o.length;m>j;++j)o[n[j]]=0;f=b(o),g=new(h?Uint8Array:Array)(k),i=new(h?Uint8Array:Array)(l),a.p=0,a.j(b(c.call(a,k,f,g)),b(c.call(a,l,f,i)))}var g=this,h="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView,i=0,j=1;c.prototype.u=function(){for(;!this.l;){var a=d(this,3);switch(1&a&&(this.l=!0),a>>>=1){case 0:var b=this.input,c=this.d,e=this.b,g=this.a,k=b.length,l=void 0,m=void 0,n=e.length,o=void 0;if(this.c=this.f=0,c+1>=k)throw Error("invalid uncompressed block header: LEN");if(l=b[c++]|b[c++]<<8,c+1>=k)throw Error("invalid uncompressed block header: NLEN");if(m=b[c++]|b[c++]<<8,l===~m)throw Error("invalid uncompressed block header: length verify");if(c+l>b.length)throw Error("input buffer is broken");switch(this.i){case i:for(;g+l>e.length;){if(o=n-g,l-=o,h)e.set(b.subarray(c,c+o),g),g+=o,c+=o;else for(;o--;)e[g++]=b[c++];this.a=g,e=this.e(),g=this.a}break;case j:for(;g+l>e.length;)e=this.e({o:2});break;default:throw Error("invalid inflate mode")}if(h)e.set(b.subarray(c,c+l),g),g+=l,c+=l;else for(;l--;)e[g++]=b[c++];this.d=c,this.a=g,this.b=e;break;case 1:this.j(z,B);break;case 2:f(this);break;default:throw Error("unknown BTYPE: "+a)}}return this.m()};var k,l,m=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],n=h?new Uint16Array(m):m,o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],p=h?new Uint16Array(o):o,q=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],r=h?new Uint8Array(q):q,s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],t=h?new Uint16Array(s):s,u=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],v=h?new Uint8Array(u):u,w=new(h?Uint8Array:Array)(288);for(k=0,l=w.length;l>k;++k)w[k]=143>=k?8:255>=k?9:279>=k?7:8;var x,y,z=b(w),A=new(h?Uint8Array:Array)(30);for(x=0,y=A.length;y>x;++x)A[x]=5;var B=b(A);c.prototype.j=function(a,b){var c=this.b,f=this.a;this.n=a;for(var g,h,i,j,k=c.length-258;256!==(g=e(this,a));)if(256>g)f>=k&&(this.a=f,c=this.e(),f=this.a),c[f++]=g;else for(h=g-257,j=p[h],0<r[h]&&(j+=d(this,r[h])),g=e(this,b),i=t[g],0<v[g]&&(i+=d(this,v[g])),f>=k&&(this.a=f,c=this.e(),f=this.a);j--;)c[f]=c[f++-i];for(;8<=this.c;)this.c-=8,this.d--;this.a=f},c.prototype.t=function(a,b){var c=this.b,f=this.a;this.n=a;for(var g,h,i,j,k=c.length;256!==(g=e(this,a));)if(256>g)f>=k&&(c=this.e(),k=c.length),c[f++]=g;else for(h=g-257,j=p[h],0<r[h]&&(j+=d(this,r[h])),g=e(this,b),i=t[g],0<v[g]&&(i+=d(this,v[g])),f+j>k&&(c=this.e(),k=c.length);j--;)c[f]=c[f++-i];for(;8<=this.c;)this.c-=8,this.d--;this.a=f},c.prototype.e=function(){var a,b,c=new(h?Uint8Array:Array)(this.a-32768),d=this.a-32768,e=this.b;if(h)c.set(e.subarray(32768,c.length));else for(a=0,b=c.length;b>a;++a)c[a]=e[a+32768];if(this.g.push(c),this.k+=c.length,h)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=e[d+a];return this.a=32768,e},c.prototype.v=function(a){var b,c,d,e,f=this.input.length/this.d+1|0,g=this.input,i=this.b;return a&&("number"==typeof a.o&&(f=a.o),"number"==typeof a.r&&(f+=a.r)),2>f?(c=(g.length-this.d)/this.n[2],e=258*(c/2)|0,d=e<i.length?i.length+e:i.length<<1):d=i.length*f,h?(b=new Uint8Array(d),b.set(i)):b=i,this.b=b},c.prototype.m=function(){var a,b,c,d,e,f=0,g=this.b,i=this.g,j=new(h?Uint8Array:Array)(this.k+(this.a-32768));if(0===i.length)return h?this.b.subarray(32768,this.a):this.b.slice(32768,this.a);for(b=0,c=i.length;c>b;++b)for(a=i[b],d=0,e=a.length;e>d;++d)j[f++]=a[d];for(b=32768,c=this.a;c>b;++b)j[f++]=g[b];return this.g=[],this.buffer=j},c.prototype.s=function(){var a,b=this.a;return h?this.q?(a=new Uint8Array(b),a.set(this.b.subarray(0,b))):a=this.b.subarray(0,b):(this.b.length>b&&(this.b.length=b),a=this.b),this.buffer=a},a("Zlib.RawInflate",c),a("Zlib.RawInflate.prototype.decompress",c.prototype.u);var C,D,E,F,G={ADAPTIVE:j,BLOCK:i};if(Object.keys)C=Object.keys(G);else for(D in C=[],E=0,G)C[E++]=D;for(E=0,F=C.length;F>E;++E)D=C[E],a("Zlib.RawInflate.BufferType."+D,G[D])}).call(this)},{}]},{},[7])(7)}),void 0===Date.now&&(Date.now=function(){return(new Date).valueOf()});var TWEEN=TWEEN||function(){var a=[];return{REVISION:"12",getAll:function(){return a},removeAll:function(){a=[]},add:function(c){a.push(c)},remove:function(c){c=a.indexOf(c),-1!==c&&a.splice(c,1)},update:function(c){if(0===a.length)return!1;for(var b=0,c=void 0!==c?c:"undefined"!=typeof window&&void 0!==window.performance&&void 0!==window.performance.now?window.performance.now():Date.now();b<a.length;)a[b].update(c)?b++:a.splice(b,1);return!0}}}();TWEEN.Tween=function(a){var k,c={},b={},d={},e=1e3,g=0,h=!1,j=!1,q=0,m=null,v=TWEEN.Easing.Linear.None,w=TWEEN.Interpolation.Linear,n=[],r=null,s=!1,t=null,u=null;for(k in a)c[k]=parseFloat(a[k],10);this.to=function(a,c){return void 0!==c&&(e=c),b=a,this},this.start=function(e){TWEEN.add(this),j=!0,s=!1,m=void 0!==e?e:"undefined"!=typeof window&&void 0!==window.performance&&void 0!==window.performance.now?window.performance.now():Date.now(),m+=q;for(var f in b){if(b[f]instanceof Array){if(0===b[f].length)continue;b[f]=[a[f]].concat(b[f])}c[f]=a[f],!1==c[f]instanceof Array&&(c[f]*=1),d[f]=c[f]||0}return this},this.stop=function(){return j?(TWEEN.remove(this),j=!1,this.stopChainedTweens(),this):this},this.stopChainedTweens=function(){for(var a=0,b=n.length;a<b;a++)n[a].stop()},this.delay=function(a){return q=a,this},this.repeat=function(a){return g=a,this},this.yoyo=function(a){return h=a,this},this.easing=function(a){return v=a,this},this.interpolation=function(a){return w=a,this},this.chain=function(){return n=arguments,this},this.onStart=function(a){return r=a,this},this.onUpdate=function(a){return t=a,this},this.onComplete=function(a){return u=a,this},this.update=function(p){var f;if(p<m)return!0;!1===s&&(null!==r&&r.call(a),s=!0);var i=(p-m)/e,i=1<i?1:i,j=v(i);for(f in b){var k=c[f]||0,l=b[f];l instanceof Array?a[f]=w(l,j):("string"==typeof l&&(l=k+parseFloat(l,10)),"number"==typeof l&&(a[f]=k+(l-k)*j))}if(null!==t&&t.call(a,j),1==i){if(!(0<g)){for(null!==u&&u.call(a),f=0,i=n.length;f<i;f++)n[f].start(p);return!1}isFinite(g)&&g--;for(f in d)"string"==typeof b[f]&&(d[f]+=parseFloat(b[f],10)),h&&(i=d[f],d[f]=b[f],b[f]=i),c[f]=d[f];m=p+q}return!0}},TWEEN.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return 1>(a*=2)?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return 1>(a*=2)?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return 1>(a*=2)?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return 1>(a*=2)?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:1>(a*=2)?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return 1>(a*=2)?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var c,b=.1;return 0===a?0:1===a?1:(!b||1>b?(b=1,c=.1):c=.4*Math.asin(1/b)/(2*Math.PI),-(b*Math.pow(2,10*(a-=1))*Math.sin(2*(a-c)*Math.PI/.4)))},Out:function(a){var c,b=.1;return 0===a?0:1===a?1:(!b||1>b?(b=1,c=.1):c=.4*Math.asin(1/b)/(2*Math.PI),b*Math.pow(2,-10*a)*Math.sin(2*(a-c)*Math.PI/.4)+1)},InOut:function(a){var c,b=.1;return 0===a?0:1===a?1:(!b||1>b?(b=1,c=.1):c=.4*Math.asin(1/b)/(2*Math.PI),1>(a*=2)?-.5*b*Math.pow(2,10*(a-=1))*Math.sin(2*(a-c)*Math.PI/.4):.5*b*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-c)*Math.PI/.4)+1)}},Back:{In:function(a){return a*a*(2.70158*a-1.70158)},Out:function(a){return--a*a*(2.70158*a+1.70158)+1},InOut:function(a){return 1>(a*=2)?.5*a*a*(3.5949095*a-2.5949095):.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)}},Bounce:{In:function(a){return 1-TWEEN.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*TWEEN.Easing.Bounce.In(2*a):.5*TWEEN.Easing.Bounce.Out(2*a-1)+.5}}},TWEEN.Interpolation={Linear:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),g=TWEEN.Interpolation.Utils.Linear;return 0>c?g(a[0],a[1],d):1<c?g(a[b],a[b-1],b-d):g(a[e],a[e+1>b?b:e+1],d-e)},Bezier:function(a,c){var h,b=0,d=a.length-1,e=Math.pow,g=TWEEN.Interpolation.Utils.Bernstein;for(h=0;h<=d;h++)b+=e(1-c,d-h)*e(c,h)*a[h]*g(d,h);return b},CatmullRom:function(a,c){var b=a.length-1,d=b*c,e=Math.floor(d),g=TWEEN.Interpolation.Utils.CatmullRom;return a[0]===a[b]?(0>c&&(e=Math.floor(d=b*(1+c))),g(a[(e-1+b)%b],a[e],a[(e+1)%b],a[(e+2)%b],d-e)):0>c?a[0]-(g(a[0],a[0],a[1],a[1],-d)-a[0]):1<c?a[b]-(g(a[b],a[b],a[b-1],a[b-1],d-b)-a[b]):g(a[e?e-1:0],a[e],a[b<e+1?b:e+1],a[b<e+2?b:e+2],d-e)},Utils:{Linear:function(a,c,b){return(c-a)*b+a},Bernstein:function(a,c){var b=TWEEN.Interpolation.Utils.Factorial;return b(a)/b(c)/b(a-c)},Factorial:function(){var a=[1];return function(c){var d,b=1;if(a[c])return a[c];for(d=c;1<d;d--)b*=d;return a[c]=b}}(),CatmullRom:function(a,c,b,d,e){var a=.5*(b-a),d=.5*(d-c),g=e*e;return(2*c-2*b+a+d)*e*g+(-3*c+3*b-2*a-d)*g+a*e+c}}};var THREE={REVISION:"69"};"object"==typeof module&&(module.exports=THREE),void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0<a?1:0}),THREE.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2},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.MinEquation=103,THREE.MaxEquation=104,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.RGB_PVRTC_4BPPV1_Format=2100,THREE.RGB_PVRTC_2BPPV1_Format=2101,THREE.RGBA_PVRTC_4BPPV1_Format=2102,THREE.RGBA_PVRTC_2BPPV1_Format=2103,THREE.Color=function(a){return 3===arguments.length?this.setRGB(arguments[0],arguments[1],arguments[2]):this.set(a)},THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,set:function(a){return a instanceof THREE.Color?this.copy(a):"number"==typeof a?this.setHex(a):"string"==typeof a&&this.setStyle(a),this},setHex:function(a){return a=Math.floor(a),this.r=(a>>16&255)/255,this.g=(a>>8&255)/255,this.b=(255&a)/255,this},setRGB:function(a,b,c){return this.r=a,this.g=b,this.b=c,this},setHSL:function(a,b,c){if(0===b)this.r=this.g=this.b=c;else{var d=function(a,b,c){return 0>c&&(c+=1),1<c&&(c-=1),c<1/6?a+6*(b-a)*c:.5>c?b:c<2/3?a+6*(b-a)*(2/3-c):a};b=.5>=c?c*(1+b):c+b-c*b,c=2*c-b,this.r=d(c,b,a+1/3),this.g=d(c,b,a),this.b=d(c,b,a-1/3)}return this},setStyle:function(a){return/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.test(a)?(a=/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.exec(a),this.r=Math.min(255,parseInt(a[1],10))/255,this.g=Math.min(255,parseInt(a[2],10))/255,this.b=Math.min(255,parseInt(a[3],10))/255,this):/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.test(a)?(a=/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.exec(a),this.r=Math.min(100,parseInt(a[1],10))/100,this.g=Math.min(100,parseInt(a[2],10))/100,this.b=Math.min(100,parseInt(a[3],10))/100,this):/^\#([0-9a-f]{6})$/i.test(a)?(a=/^\#([0-9a-f]{6})$/i.exec(a),this.setHex(parseInt(a[1],16)),this):/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(a)?(a=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(a),this.setHex(parseInt(a[1]+a[1]+a[2]+a[2]+a[3]+a[3],16)),this):/^(\w+)$/i.test(a)?(this.setHex(THREE.ColorKeywords[a]),this):void 0},copy:function(a){return this.r=a.r,this.g=a.g,this.b=a.b,this},copyGammaToLinear:function(a){return this.r=a.r*a.r,this.g=a.g*a.g,this.b=a.b*a.b,this},copyLinearToGamma:function(a){return this.r=Math.sqrt(a.r),this.g=Math.sqrt(a.g),this.b=Math.sqrt(a.b),this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;return this.r=a*a,this.g=b*b,this.b=c*c,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),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(a){a=a||{h:0,s:0,l:0};var g,b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),h=(f+e)/2;if(f===e)f=g=0;else{var k=e-f,f=.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(c<d?6:0);break;case c:g=(d-b)/k+2;break;case d:g=(b-c)/k+4}g/=6}return a.h=g,a.s=f,a.l=h,a},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(a,b,c){var d=this.getHSL();return d.h+=a,d.s+=b,d.l+=c,this.setHSL(d.h,d.s,d.l),this},add:function(a){return this.r+=a.r,this.g+=a.g,this.b+=a.b,this},addColors:function(a,b){return this.r=a.r+b.r,this.g=a.g+b.g,this.b=a.b+b.b,this},addScalar:function(a){return this.r+=a,this.g+=a,this.b+=a,this},multiply:function(a){return this.r*=a.r,this.g*=a.g,this.b*=a.b,this},multiplyScalar:function(a){return this.r*=a,this.g*=a,this.b*=a,this},lerp:function(a,b){return this.r+=(a.r-this.r)*b,this.g+=(a.g-this.g)*b,this.b+=(a.b-this.b)*b,this},equals:function(a){return a.r===this.r&&a.g===this.g&&a.b===this.b},fromArray:function(a){return this.r=a[0],this.g=a[1],this.b=a[2],this},toArray:function(){return[this.r,this.g,this.b]},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}},THREE.ColorKeywords={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,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},THREE.Quaternion=function(a,b,c,d){this._x=a||0,this._y=b||0,this._z=c||0,this._w=void 0!==d?d:1},THREE.Quaternion.prototype={constructor:THREE.Quaternion,_x:0,_y:0,_z:0,_w:0,get x(){return this._x},set x(a){this._x=a,this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a,this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a,this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a,this.onChangeCallback()},set:function(a,b,c,d){return this._x=a,this._y=b,this._z=c,this._w=d,this.onChangeCallback(),this},copy:function(a){return this._x=a.x,this._y=a.y,this._z=a.z,this._w=a.w,this.onChangeCallback(),this},setFromEuler:function(a,b){if(!1==a instanceof THREE.Euler)throw Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2);return"XYZ"===a.order?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===a.order?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===a.order?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===a.order?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===a.order?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===a.order&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e+f*g*h),!1!==b&&this.onChangeCallback(),this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);return this._x=a.x*d,this._y=a.y*d,this._z=a.z*d,this._w=Math.cos(c),this.onChangeCallback(),this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6],b=b[10],n=c+f+b;return 0<n?(c=.5/Math.sqrt(n+1),this._w=.25/c,this._x=(k-g)*c,this._y=(d-h)*c,this._z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c),this.onChangeCallback(),this},setFromUnitVectors:function(){var a,b;return function(c,d){return void 0===a&&(a=new THREE.Vector3),b=c.dot(d)+1,1e-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d),this._x=a.x,this._y=a.y,this._z=a.z,this._w=b,this.normalize(),this}}(),inverse:function(){return this.conjugate().normalize(),this},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._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 a=this.length();return 0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a),this.onChangeCallback(),this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,n=b._w;return this._x=c*n+f*g+d*k-e*h,this._y=d*n+f*h+e*g-c*k,this._z=e*n+f*k+c*h-d*g,this._w=f*n-c*g-d*h-e*k,this.onChangeCallback(),this},multiplyVector3:function(a){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),a.applyQuaternion(this)},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;if(0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a),1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.acos(g),k=Math.sqrt(1-g*g);return.001>Math.abs(k)?(this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this):(g=Math.sin((1-b)*h)/k,h=Math.sin(b*h)/k,this._w=f*g+this._w*h,this._x=c*g+this._x*h,this._y=d*g+this._y*h,this._z=e*g+this._z*h,this.onChangeCallback(),this)},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){return void 0===b&&(b=0),this._x=a[b],this._y=a[b+1],this._z=a[b+2],this._w=a[b+3],this.onChangeCallback(),this},toArray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this._x,a[b+1]=this._y,a[b+2]=this._z,a[b+3]=this._w,a},onChange:function(a){return this.onChangeCallback=a,this},onChangeCallback:function(){},clone:function(){return new THREE.Quaternion(this._x,this._y,this._z,this._w)}},THREE.Quaternion.slerp=function(a,b,c,d){return c.copy(a).slerp(b,d)},THREE.Vector2=function(a,b){this.x=a||0,this.y=b||0},THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){return this.x=a,this.y=b,this},setX:function(a){return this.x=a,this},setY:function(a){return this.y=a,this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a)}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a)}},copy:function(a){return this.x=a.x,this.y=a.y,this},add:function(a,b){return void 0!==b?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b)):(this.x+=a.x,this.y+=a.y,this)},addVectors:function(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this},addScalar:function(a){return this.x+=a,this.y+=a,this},sub:function(a,b){return void 0!==b?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b)):(this.x-=a.x,this.y-=a.y,this)},subVectors:function(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this},multiply:function(a){return this.x*=a.x,this.y*=a.y,this},multiplyScalar:function(a){return this.x*=a,this.y*=a,this},divide:function(a){return this.x/=a.x,this.y/=a.y,this},divideScalar:function(a){return 0!==a?(a=1/a,this.x*=a,this.y*=a):this.y=this.x=0,this},min:function(a){return this.x>a.x&&(this.x=a.x),this.y>a.y&&(this.y=a.y),this},max:function(a){return this.x<a.x&&(this.x=a.x),this.y<a.y&&(this.y=a.y),this},clamp:function(a,b){return this.x<a.x?this.x=a.x:this.x>b.x&&(this.x=b.x),this.y<a.y?this.y=a.y:this.y>b.y&&(this.y=b.y),this},clampScalar:function(){var a,b;return function(c,d){return void 0===a&&(a=new THREE.Vector2,b=new THREE.Vector2),a.set(c,c),b.set(d,d),this.clamp(a,b)}}(),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=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(a){return this.x*a.x+this.y*a.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(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;return a=this.y-a.y,b*b+a*a},setLength:function(a){var b=this.length();return 0!==b&&a!==b&&this.multiplyScalar(a/b),this},lerp:function(a,b){return this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){return void 0===b&&(b=0),this.x=a[b],this.y=a[b+1],this},toArray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this.x,a[b+1]=this.y,a},clone:function(){return new THREE.Vector2(this.x,this.y)}},THREE.Vector3=function(a,b,c){this.x=a||0,this.y=b||0,this.z=c||0},THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){return this.x=a,this.y=b,this.z=c,this},setX:function(a){return this.x=a,this},setY:function(a){return this.y=a,this},setZ:function(a){return this.z=a,this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a)}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a)}},copy:function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this},add:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b)):(this.x+=a.x,this.y+=a.y,this.z+=a.z,this)},addScalar:function(a){return this.x+=a,this.y+=a,this.z+=a,this},addVectors:function(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z,this},sub:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b)):(this.x-=a.x,this.y-=a.y,this.z-=a.z,this)},subVectors:function(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z,this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b)):(this.x*=a.x,this.y*=a.y,this.z*=a.z,this)},multiplyScalar:function(a){return this.x*=a,this.y*=a,this.z*=a,this},multiplyVectors:function(a,b){return this.x=a.x*b.x,this.y=a.y*b.y,this.z=a.z*b.z,this},applyEuler:function(){var a;return function(b){return!1==b instanceof THREE.Euler&&console.error("THREE.Vector3: .applyEuler() now expects a Euler rotation rather than a Vector3 and order."),void 0===a&&(a=new THREE.Quaternion),this.applyQuaternion(a.setFromEuler(b)),this}}(),applyAxisAngle:function(){var a;return function(b,c){return void 0===a&&(a=new THREE.Quaternion),this.applyQuaternion(a.setFromAxisAngle(b,c)),this}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;return a=a.elements,this.x=a[0]*b+a[3]*c+a[6]*d,this.y=a[1]*b+a[4]*c+a[7]*d,this.z=a[2]*b+a[5]*c+a[8]*d,this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;return a=a.elements,this.x=a[0]*b+a[4]*c+a[8]*d+a[12],this.y=a[1]*b+a[5]*c+a[9]*d+a[13],this.z=a[2]*b+a[6]*c+a[10]*d+a[14],this},applyProjection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);return this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e,this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e,this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e,this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,n=a*d+e*c-f*b,b=-e*b-f*c-g*d;return this.x=h*a+b*-e+k*-g-n*-f,this.y=k*a+b*-f+n*-e-h*-g,this.z=n*a+b*-g+h*-f-k*-e,this},project:function(){var a;return function(b){return void 0===a&&(a=new THREE.Matrix4),a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld)),this.applyProjection(a)}}(),unproject:function(){var a;return function(b){return void 0===a&&(a=new THREE.Matrix4),a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix)),this.applyProjection(a)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z;return a=a.elements,this.x=a[0]*b+a[4]*c+a[8]*d,this.y=a[1]*b+a[5]*c+a[9]*d,this.z=a[2]*b+a[6]*c+a[10]*d,this.normalize(),this},divide:function(a){return this.x/=a.x,this.y/=a.y,this.z/=a.z,this},divideScalar:function(a){return 0!==a?(a=1/a,this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0,this},min:function(a){return this.x>a.x&&(this.x=a.x),this.y>a.y&&(this.y=a.y),this.z>a.z&&(this.z=a.z),this},max:function(a){return this.x<a.x&&(this.x=a.x),this.y<a.y&&(this.y=a.y),this.z<a.z&&(this.z=a.z),this},clamp:function(a,b){return this.x<a.x?this.x=a.x:this.x>b.x&&(this.x=b.x),this.y<a.y?this.y=a.y:this.y>b.y&&(this.y=b.y),this.z<a.z?this.z=a.z:this.z>b.z&&(this.z=b.z),this},clampScalar:function(){
var a,b;return function(c,d){return void 0===a&&(a=new THREE.Vector3,b=new THREE.Vector3),a.set(c,c,c),b.set(d,d,d),this.clamp(a,b)}}(),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=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this.z=0>this.z?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(a){return this.x*a.x+this.y*a.y+this.z*a.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(a){var b=this.length();return 0!==b&&a!==b&&this.multiplyScalar(a/b),this},lerp:function(a,b){return this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this.z+=(a.z-this.z)*b,this},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;return this.x=d*a.z-e*a.y,this.y=e*a.x-c*a.z,this.z=c*a.y-d*a.x,this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;return this.x=d*h-e*g,this.y=e*f-c*h,this.z=c*g-d*f,this},projectOnVector:function(){var a,b;return function(c){return void 0===a&&(a=new THREE.Vector3),a.copy(c).normalize(),b=this.dot(a),this.copy(a).multiplyScalar(b)}}(),projectOnPlane:function(){var a;return function(b){return void 0===a&&(a=new THREE.Vector3),a.copy(this).projectOnVector(b),this.sub(a)}}(),reflect:function(){var a;return function(b){return void 0===a&&(a=new THREE.Vector3),this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){return a=this.dot(a)/(this.length()*a.length()),Math.acos(THREE.Math.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;return a=this.z-a.z,b*b+c*c+a*a},setEulerFromRotationMatrix:function(a,b){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(a,b){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(a){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(a,b)},setFromMatrixPosition:function(a){return this.x=a.elements[12],this.y=a.elements[13],this.z=a.elements[14],this},setFromMatrixScale:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length();return a=this.set(a.elements[8],a.elements[9],a.elements[10]).length(),this.x=b,this.y=c,this.z=a,this},setFromMatrixColumn:function(a,b){var c=4*a,d=b.elements;return this.x=d[c],this.y=d[c+1],this.z=d[c+2],this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){return void 0===b&&(b=0),this.x=a[b],this.y=a[b+1],this.z=a[b+2],this},toArray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this.x,a[b+1]=this.y,a[b+2]=this.z,a},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}},THREE.Vector4=function(a,b,c,d){this.x=a||0,this.y=b||0,this.z=c||0,this.w=void 0!==d?d:1},THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){return this.x=a,this.y=b,this.z=c,this.w=d,this},setX:function(a){return this.x=a,this},setY:function(a){return this.y=a,this},setZ:function(a){return this.z=a,this},setW:function(a){return this.w=a,this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a)}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a)}},copy:function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this.w=void 0!==a.w?a.w:1,this},add:function(a,b){return void 0!==b?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b)):(this.x+=a.x,this.y+=a.y,this.z+=a.z,this.w+=a.w,this)},addScalar:function(a){return this.x+=a,this.y+=a,this.z+=a,this.w+=a,this},addVectors:function(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z,this.w=a.w+b.w,this},sub:function(a,b){return void 0!==b?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b)):(this.x-=a.x,this.y-=a.y,this.z-=a.z,this.w-=a.w,this)},subVectors:function(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z,this.w=a.w-b.w,this},multiplyScalar:function(a){return this.x*=a,this.y*=a,this.z*=a,this.w*=a,this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;return a=a.elements,this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e,this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e,this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e,this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e,this},divideScalar:function(a){return 0!==a?(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a):(this.z=this.y=this.x=0,this.w=1),this},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);return 1e-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b),this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2],b=a[6];var n=a[10];return.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>Math.abs(k-b)?.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+h+n-3)?(this.set(1,0,0,0),this):(a=Math.PI,e=(e+1)/2,h=(h+1)/2,n=(n+1)/2,d=(d+g)/4,f=(f+c)/4,k=(k+b)/4,e>h&&e>n?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):h>n?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>n?(c=b=.707106781,d=0):(d=Math.sqrt(n),b=f/d,c=k/d),this.set(b,c,d,a),this):(a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d)),.001>Math.abs(a)&&(a=1),this.x=(b-k)/a,this.y=(f-c)/a,this.z=(g-d)/a,this.w=Math.acos((e+h+n-1)/2),this)},min:function(a){return this.x>a.x&&(this.x=a.x),this.y>a.y&&(this.y=a.y),this.z>a.z&&(this.z=a.z),this.w>a.w&&(this.w=a.w),this},max:function(a){return this.x<a.x&&(this.x=a.x),this.y<a.y&&(this.y=a.y),this.z<a.z&&(this.z=a.z),this.w<a.w&&(this.w=a.w),this},clamp:function(a,b){return this.x<a.x?this.x=a.x:this.x>b.x&&(this.x=b.x),this.y<a.y?this.y=a.y:this.y>b.y&&(this.y=b.y),this.z<a.z?this.z=a.z:this.z>b.z&&(this.z=b.z),this.w<a.w?this.w=a.w:this.w>b.w&&(this.w=b.w),this},clampScalar:function(){var a,b;return function(c,d){return void 0===a&&(a=new THREE.Vector4,b=new THREE.Vector4),a.set(c,c,c,c),b.set(d,d,d,d),this.clamp(a,b)}}(),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=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z),this.w=0>this.w?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(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.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)},lengthManhattan: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())},setLength:function(a){var b=this.length();return 0!==b&&a!==b&&this.multiplyScalar(a/b),this},lerp:function(a,b){return this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this.z+=(a.z-this.z)*b,this.w+=(a.w-this.w)*b,this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){return void 0===b&&(b=0),this.x=a[b],this.y=a[b+1],this.z=a[b+2],this.w=a[b+3],this},toArray:function(a,b){return void 0===a&&(a=[]),void 0===b&&(b=0),a[b]=this.x,a[b+1]=this.y,a[b+2]=this.z,a[b+3]=this.w,a},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}},THREE.Euler=function(a,b,c,d){this._x=a||0,this._y=b||0,this._z=c||0,this._order=d||THREE.Euler.DefaultOrder},THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" "),THREE.Euler.DefaultOrder="XYZ",THREE.Euler.prototype={constructor:THREE.Euler,_x:0,_y:0,_z:0,_order:THREE.Euler.DefaultOrder,get x(){return this._x},set x(a){this._x=a,this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a,this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a,this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a,this.onChangeCallback()},set:function(a,b,c,d){return this._x=a,this._y=b,this._z=c,this._order=d||this._order,this.onChangeCallback(),this},copy:function(a){return this._x=a._x,this._y=a._y,this._z=a._z,this._order=a._order,this.onChangeCallback(),this},setFromRotationMatrix:function(a,b){var c=THREE.Math.clamp,d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],k=d[5],n=d[9],p=d[2],q=d[6],d=d[10];return b=b||this._order,"XYZ"===b?(this._y=Math.asin(c(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-n,d),this._z=Math.atan2(-f,e)):(this._x=Math.atan2(q,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-c(n,-1,1)),.99999>Math.abs(n)?(this._y=Math.atan2(g,d),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-p,e),this._z=0)):"ZXY"===b?(this._x=Math.asin(c(q,-1,1)),.99999>Math.abs(q)?(this._y=Math.atan2(-p,d),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,e))):"ZYX"===b?(this._y=Math.asin(-c(p,-1,1)),.99999>Math.abs(p)?(this._x=Math.atan2(q,d),this._z=Math.atan2(h,e)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(c(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-n,k),this._y=Math.atan2(-p,e)):(this._x=0,this._y=Math.atan2(g,d))):"XZY"===b?(this._z=Math.asin(-c(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(q,k),this._y=Math.atan2(g,e)):(this._x=Math.atan2(-n,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b),this._order=b,this.onChangeCallback(),this},setFromQuaternion:function(a,b,c){var d=THREE.Math.clamp,e=a.x*a.x,f=a.y*a.y,g=a.z*a.z,h=a.w*a.w;return b=b||this._order,"XYZ"===b?(this._x=Math.atan2(2*(a.x*a.w-a.y*a.z),h-e-f+g),this._y=Math.asin(d(2*(a.x*a.z+a.y*a.w),-1,1)),this._z=Math.atan2(2*(a.z*a.w-a.x*a.y),h+e-f-g)):"YXZ"===b?(this._x=Math.asin(d(2*(a.x*a.w-a.y*a.z),-1,1)),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),h-e-f+g),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),h-e+f-g)):"ZXY"===b?(this._x=Math.asin(d(2*(a.x*a.w+a.y*a.z),-1,1)),this._y=Math.atan2(2*(a.y*a.w-a.z*a.x),h-e-f+g),this._z=Math.atan2(2*(a.z*a.w-a.x*a.y),h-e+f-g)):"ZYX"===b?(this._x=Math.atan2(2*(a.x*a.w+a.z*a.y),h-e-f+g),this._y=Math.asin(d(2*(a.y*a.w-a.x*a.z),-1,1)),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),h+e-f-g)):"YZX"===b?(this._x=Math.atan2(2*(a.x*a.w-a.z*a.y),h-e+f-g),this._y=Math.atan2(2*(a.y*a.w-a.x*a.z),h+e-f-g),this._z=Math.asin(d(2*(a.x*a.y+a.z*a.w),-1,1))):"XZY"===b?(this._x=Math.atan2(2*(a.x*a.w+a.y*a.z),h-e+f-g),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),h+e-f-g),this._z=Math.asin(d(2*(a.z*a.w-a.x*a.y),-1,1))):console.warn("THREE.Euler: .setFromQuaternion() given unsupported order: "+b),this._order=b,!1!==c&&this.onChangeCallback(),this},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this),this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){return this._x=a[0],this._y=a[1],this._z=a[2],void 0!==a[3]&&(this._order=a[3]),this.onChangeCallback(),this},toArray:function(){return[this._x,this._y,this._z,this._order]},onChange:function(a){return this.onChangeCallback=a,this},onChangeCallback:function(){},clone:function(){return new THREE.Euler(this._x,this._y,this._z,this._order)}},THREE.Line3=function(a,b){this.start=void 0!==a?a:new THREE.Vector3,this.end=void 0!==b?b:new THREE.Vector3},THREE.Line3.prototype={constructor:THREE.Line3,set:function(a,b){return this.start.copy(a),this.end.copy(b),this},copy:function(a){return this.start.copy(a.start),this.end.copy(a.end),this},center:function(a){return(a||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){return(a||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a,b){var c=b||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d){a.subVectors(c,this.start),b.subVectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;return d&&(e=THREE.Math.clamp(e,0,1)),e}}(),closestPointToPoint:function(a,b,c){return a=this.closestPointToPointParameter(a,b),c=c||new THREE.Vector3,this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){return this.start.applyMatrix4(a),this.end.applyMatrix4(a),this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)},clone:function(){return(new THREE.Line3).copy(this)}},THREE.Box2=function(a,b){this.min=void 0!==a?a:new THREE.Vector2(1/0,1/0),this.max=void 0!==b?b:new THREE.Vector2((-(1/0)),(-(1/0)))},THREE.Box2.prototype={constructor:THREE.Box2,set:function(a,b){return this.min.copy(a),this.max.copy(b),this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new THREE.Vector2;return function(b,c){var d=a.copy(c).multiplyScalar(.5);return this.min.copy(b).sub(d),this.max.copy(b).add(d),this}}(),copy:function(a){return this.min.copy(a.min),this.max.copy(a.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-(1/0),this},empty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},center:function(a){return(a||new THREE.Vector2).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new THREE.Vector2).subVectors(this.max,this.min)},expandByPoint:function(a){return this.min.min(a),this.max.max(a),this},expandByVector:function(a){return this.min.sub(a),this.max.add(a),this},expandByScalar:function(a){return this.min.addScalar(-a),this.max.addScalar(a),this},containsPoint:function(a){return!(a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y)},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,b){return(b||new THREE.Vector2).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},isIntersectionBox:function(a){return!(a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y)},clampPoint:function(a,b){return(b||new THREE.Vector2).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector2;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){return this.min.max(a.min),this.max.min(a.max),this},union:function(a){return this.min.min(a.min),this.max.max(a.max),this},translate:function(a){return this.min.add(a),this.max.add(a),this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)},clone:function(){return(new THREE.Box2).copy(this)}},THREE.Box3=function(a,b){this.min=void 0!==a?a:new THREE.Vector3(1/0,1/0,1/0),this.max=void 0!==b?b:new THREE.Vector3((-(1/0)),(-(1/0)),(-(1/0)))},THREE.Box3.prototype={constructor:THREE.Box3,set:function(a,b){return this.min.copy(a),this.max.copy(b),this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new THREE.Vector3;return function(b,c){var d=a.copy(c).multiplyScalar(.5);return this.min.copy(b).sub(d),this.max.copy(b).add(d),this}}(),setFromObject:function(){var a=new THREE.Vector3;return function(b){var c=this;return b.updateMatrixWorld(!0),this.makeEmpty(),b.traverse(function(b){var e=b.geometry;if(void 0!==e)if(e instanceof THREE.Geometry)for(var f=e.vertices,e=0,g=f.length;e<g;e++)a.copy(f[e]),a.applyMatrix4(b.matrixWorld),c.expandByPoint(a);else if(e instanceof THREE.BufferGeometry&&void 0!==e.attributes.position)for(f=e.attributes.position.array,e=0,g=f.length;e<g;e+=3)a.set(f[e],f[e+1],f[e+2]),a.applyMatrix4(b.matrixWorld),c.expandByPoint(a)}),this}}(),copy:function(a){return this.min.copy(a.min),this.max.copy(a.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-(1/0),this},empty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},center:function(a){return(a||new THREE.Vector3).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new THREE.Vector3).subVectors(this.max,this.min)},expandByPoint:function(a){return this.min.min(a),this.max.max(a),this},expandByVector:function(a){return this.min.sub(a),this.max.add(a),this},expandByScalar:function(a){return this.min.addScalar(-a),this.max.addScalar(a),this},containsPoint:function(a){return!(a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||a.z<this.min.z||a.z>this.max.z)},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getParameter:function(a,b){return(b||new THREE.Vector3).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},isIntersectionBox:function(a){return!(a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y||a.max.z<this.min.z||a.min.z>this.max.z)},clampPoint:function(a,b){return(b||new THREE.Vector3).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector3;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new THREE.Vector3;return function(b){return b=b||new THREE.Sphere,b.center=this.center(),b.radius=.5*this.size(a).length(),b}}(),intersect:function(a){return this.min.max(a.min),this.max.min(a.max),this},union:function(a){return this.min.min(a.min),this.max.max(a.max),this},applyMatrix4:function(){var a=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(b){return a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b),a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b),a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b),a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b),a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b),a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b),a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b),a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b),this.makeEmpty(),this.setFromPoints(a),this}}(),translate:function(a){return this.min.add(a),this.max.add(a),this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)},clone:function(){return(new THREE.Box3).copy(this)}},THREE.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")},THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(a,b,c,d,e,f,g,h,k){var n=this.elements;return n[0]=a,n[3]=b,n[6]=c,n[1]=d,n[4]=e,n[7]=f,n[2]=g,n[5]=h,n[8]=k,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},copy:function(a){return a=a.elements,this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]),this},multiplyVector3:function(a){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),a.applyMatrix3(this)},multiplyVector3Array:function(a){return console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(a)},applyToVector3Array:function(){var a=new THREE.Vector3;return function(b,c,d){void 0===c&&(c=0),void 0===d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.x=b[c],a.y=b[c+1],a.z=b[c+2],a.applyMatrix3(this),b[c]=a.x,b[c+1]=a.y,b[c+2]=a.z;return b}}(),multiplyScalar:function(a){var b=this.elements;return b[0]*=a,b[3]*=a,b[6]*=a,b[1]*=a,b[4]*=a,b[7]*=a,b[2]*=a,b[5]*=a,b[8]*=a,this},determinant:function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],k=a[7],a=a[8];return b*f*a-b*g*k-c*e*a+c*g*h+d*e*k-d*f*h},getInverse:function(a,b){var c=a.elements,d=this.elements;if(d[0]=c[10]*c[5]-c[6]*c[9],d[1]=-c[10]*c[1]+c[2]*c[9],d[2]=c[6]*c[1]-c[2]*c[5],d[3]=-c[10]*c[4]+c[6]*c[8],d[4]=c[10]*c[0]-c[2]*c[8],d[5]=-c[6]*c[0]+c[2]*c[4],d[6]=c[9]*c[4]-c[5]*c[8],d[7]=-c[9]*c[0]+c[1]*c[8],d[8]=c[5]*c[0]-c[1]*c[4],c=c[0]*d[0]+c[1]*d[3]+c[2]*d[6],0===c){if(b)throw Error("Matrix3.getInverse(): can't invert matrix, determinant is 0");return console.warn("Matrix3.getInverse(): can't invert matrix, determinant is 0"),this.identity(),this}return this.multiplyScalar(1/c),this},transpose:function(){var a,b=this.elements;return a=b[1],b[1]=b[3],b[3]=a,a=b[2],b[2]=b[6],b[6]=a,a=b[5],b[5]=b[7],b[7]=a,this},flattenToArrayOffset:function(a,b){var c=this.elements;return a[b]=c[0],a[b+1]=c[1],a[b+2]=c[2],a[b+3]=c[3],a[b+4]=c[4],a[b+5]=c[5],a[b+6]=c[6],a[b+7]=c[7],a[b+8]=c[8],a},getNormalMatrix:function(a){return this.getInverse(a).transpose(),this},transposeIntoArray:function(a){var b=this.elements;return a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=b[5],a[8]=b[8],this},fromArray:function(a){return this.elements.set(a),this},toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]]},clone:function(){return(new THREE.Matrix3).fromArray(this.elements)}},THREE.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")},THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,k,n,p,q,m,r,t,s){var u=this.elements;return u[0]=a,u[4]=b,u[8]=c,u[12]=d,u[1]=e,u[5]=f,u[9]=g,u[13]=h,u[2]=k,u[6]=n,u[10]=p,u[14]=q,u[3]=m,u[7]=r,u[11]=t,u[15]=s,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},copy:function(a){return this.elements.set(a.elements),this},extractPosition:function(a){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(a)},copyPosition:function(a){var b=this.elements;return a=a.elements,b[12]=a[12],b[13]=a[13],b[14]=a[14],this},extractRotation:function(){var a=new THREE.Vector3;return function(b){var c=this.elements;b=b.elements;var d=1/a.set(b[0],b[1],b[2]).length(),e=1/a.set(b[4],b[5],b[6]).length(),f=1/a.set(b[8],b[9],b[10]).length();return c[0]=b[0]*d,c[1]=b[1]*d,c[2]=b[2]*d,c[4]=b[4]*e,c[5]=b[5]*e,c[6]=b[6]*e,c[8]=b[8]*f,c[9]=b[9]*f,c[10]=b[10]*f,this}}(),makeRotationFromEuler:function(a){!1==a instanceof THREE.Euler&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,n=c*h,p=c*e;b[0]=g*h,b[4]=-g*e,b[8]=d,b[1]=k+n*d,b[5]=a-p*d,b[9]=-c*g,b[2]=p-a*d,b[6]=n+k*d,b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,n=d*h,p=d*e,b[0]=a+p*c,b[4]=n*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-n,b[6]=p+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,n=d*h,p=d*e,b[0]=a-p*c,b[4]=-f*e,b[8]=n+k*c,b[1]=k+n*c,b[5]=f*h,b[9]=p-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,n=c*h,p=c*e,b[0]=g*h,b[4]=n*d-k,b[8]=a*d+p,b[1]=g*e,b[5]=p*d+a,b[9]=k*d-n,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,n=c*g,p=c*d,b[0]=g*h,b[4]=p-a*e,b[8]=n*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+n,b[10]=a-p*e):"XZY"===a.order&&(a=f*g,k=f*d,n=c*g,p=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+p,b[5]=f*h,b[9]=k*e-n,b[2]=n*e-k,b[6]=c*h,b[10]=p*e+a);return b[3]=0,b[7]=0,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,this},setRotationFromQuaternion:function(a){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(a)},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var n=c*h,c=c*k,p=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;return b[0]=1-(p+e),b[4]=n-f,b[8]=c+h,b[1]=n+f,b[5]=1-(a+e),b[9]=d-g,b[2]=c-h,b[6]=d+g,b[10]=1-(a+p),b[3]=0,b[7]=0,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,this},lookAt:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f){var g=this.elements;return c.subVectors(d,e).normalize(),0===c.length()&&(c.z=1),a.crossVectors(f,c).normalize(),0===a.length()&&(c.x+=1e-4,a.crossVectors(f,c).normalize()),b.crossVectors(c,a),g[0]=a.x,g[4]=b.x,g[8]=c.x,g[1]=a.y,g[5]=b.y,g[9]=c.y,g[2]=a.z,g[6]=b.z,g[10]=c.z,this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],n=c[1],p=c[5],q=c[9],m=c[13],r=c[2],t=c[6],s=c[10],u=c[14],v=c[3],y=c[7],G=c[11],c=c[15],w=d[0],K=d[4],x=d[8],D=d[12],E=d[1],A=d[5],B=d[9],F=d[13],R=d[2],H=d[6],C=d[10],T=d[14],Q=d[3],O=d[7],S=d[11],d=d[15];return e[0]=f*w+g*E+h*R+k*Q,e[4]=f*K+g*A+h*H+k*O,e[8]=f*x+g*B+h*C+k*S,e[12]=f*D+g*F+h*T+k*d,e[1]=n*w+p*E+q*R+m*Q,e[5]=n*K+p*A+q*H+m*O,e[9]=n*x+p*B+q*C+m*S,e[13]=n*D+p*F+q*T+m*d,e[2]=r*w+t*E+s*R+u*Q,e[6]=r*K+t*A+s*H+u*O,e[10]=r*x+t*B+s*C+u*S,e[14]=r*D+t*F+s*T+u*d,e[3]=v*w+y*E+G*R+c*Q,e[7]=v*K+y*A+G*H+c*O,e[11]=v*x+y*B+G*C+c*S,e[15]=v*D+y*F+G*T+c*d,this},multiplyToArray:function(a,b,c){var d=this.elements;return this.multiplyMatrices(a,b),c[0]=d[0],c[1]=d[1],c[2]=d[2],c[3]=d[3],c[4]=d[4],c[5]=d[5],c[6]=d[6],c[7]=d[7],c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15],this},multiplyScalar:function(a){var b=this.elements;return b[0]*=a,b[4]*=a,b[8]*=a,b[12]*=a,b[1]*=a,b[5]*=a,b[9]*=a,b[13]*=a,b[2]*=a,b[6]*=a,b[10]*=a,b[14]*=a,b[3]*=a,b[7]*=a,b[11]*=a,b[15]*=a,this},multiplyVector3:function(a){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."),a.applyProjection(this)},multiplyVector4:function(a){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),a.applyMatrix4(this)},multiplyVector3Array:function(a){return console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(a)},applyToVector3Array:function(){var a=new THREE.Vector3;return function(b,c,d){void 0===c&&(c=0),void 0===d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.x=b[c],a.y=b[c+1],a.z=b[c+2],a.applyMatrix4(this),b[c]=a.x,b[c+1]=a.y,b[c+2]=a.z;return b}}(),rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),a.transformDirection(this)},crossVector:function(a){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),a.applyMatrix4(this)},determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],k=a[13],n=a[2],p=a[6],q=a[10],m=a[14];return a[3]*(+e*h*p-d*k*p-e*g*q+c*k*q+d*g*m-c*h*m)+a[7]*(+b*h*m-b*k*q+e*f*q-d*f*m+d*k*n-e*h*n)+a[11]*(+b*k*p-b*g*m-e*f*p+c*f*m+e*g*n-c*k*n)+a[15]*(-d*g*n-b*h*p+b*g*q+d*f*p-c*f*q+c*h*n)},transpose:function(){var b,a=this.elements;return b=a[1],a[1]=a[4],a[4]=b,b=a[2],a[2]=a[8],a[8]=b,b=a[6],a[6]=a[9],a[9]=b,b=a[3],a[3]=a[12],a[12]=b,b=a[7],a[7]=a[13],a[13]=b,b=a[11],a[11]=a[14],a[14]=b,this},flattenToArrayOffset:function(a,b){var c=this.elements;return a[b]=c[0],a[b+1]=c[1],a[b+2]=c[2],a[b+3]=c[3],a[b+4]=c[4],a[b+5]=c[5],a[b+6]=c[6],a[b+7]=c[7],a[b+8]=c[8],a[b+9]=c[9],a[b+10]=c[10],a[b+11]=c[11],a[b+12]=c[12],a[b+13]=c[13],a[b+14]=c[14],a[b+15]=c[15],a},getPosition:function(){var a=new THREE.Vector3;return function(){console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");var b=this.elements;return a.set(b[12],b[13],b[14])}}(),setPosition:function(a){var b=this.elements;return b[12]=a.x,b[13]=a.y,b[14]=a.z,this},getInverse:function(a,b){var c=this.elements,d=a.elements,e=d[0],f=d[4],g=d[8],h=d[12],k=d[1],n=d[5],p=d[9],q=d[13],m=d[2],r=d[6],t=d[10],s=d[14],u=d[3],v=d[7],y=d[11],d=d[15];if(c[0]=p*s*v-q*t*v+q*r*y-n*s*y-p*r*d+n*t*d,c[4]=h*t*v-g*s*v-h*r*y+f*s*y+g*r*d-f*t*d,c[8]=g*q*v-h*p*v+h*n*y-f*q*y-g*n*d+f*p*d,c[12]=h*p*r-g*q*r-h*n*t+f*q*t+g*n*s-f*p*s,c[1]=q*t*u-p*s*u-q*m*y+k*s*y+p*m*d-k*t*d,c[5]=g*s*u-h*t*u+h*m*y-e*s*y-g*m*d+e*t*d,c[9]=h*p*u-g*q*u-h*k*y+e*q*y+g*k*d-e*p*d,c[13]=g*q*m-h*p*m+h*k*t-e*q*t-g*k*s+e*p*s,c[2]=n*s*u-q*r*u+q*m*v-k*s*v-n*m*d+k*r*d,c[6]=h*r*u-f*s*u-h*m*v+e*s*v+f*m*d-e*r*d,c[10]=f*q*u-h*n*u+h*k*v-e*q*v-f*k*d+e*n*d,c[14]=h*n*m-f*q*m-h*k*r+e*q*r+f*k*s-e*n*s,c[3]=p*r*u-n*t*u-p*m*v+k*t*v+n*m*y-k*r*y,c[7]=f*t*u-g*r*u+g*m*v-e*t*v-f*m*y+e*r*y,c[11]=g*n*u-f*p*u-g*k*v+e*p*v+f*k*y-e*n*y,c[15]=f*p*m-g*n*m+g*k*r-e*p*r-f*k*t+e*n*t,c=e*c[0]+k*c[4]+m*c[8]+u*c[12],0==c){if(b)throw Error("Matrix4.getInverse(): can't invert matrix, determinant is 0");return console.warn("Matrix4.getInverse(): can't invert matrix, determinant is 0"),this.identity(),this}return this.multiplyScalar(1/c),this},translate:function(a){console.warn("THREE.Matrix4: .translate() has been removed.")},rotateX:function(a){console.warn("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(a){console.warn("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(a){console.warn("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(a,b){console.warn("THREE.Matrix4: .rotateByAxis() has been removed.")},scale:function(a){var b=this.elements,c=a.x,d=a.y;return a=a.z,b[0]*=c,b[4]*=d,b[8]*=a,b[1]*=c,b[5]*=d,b[9]*=a,b[2]*=c,b[6]*=d,b[10]*=a,b[3]*=c,b[7]*=d,b[11]*=a,this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],Math.max(a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10])))},makeTranslation:function(a,b,c){return this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1),this},makeRotationX:function(a){var b=Math.cos(a);return a=Math.sin(a),this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1),
this},makeRotationY:function(a){var b=Math.cos(a);return a=Math.sin(a),this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1),this},makeRotationZ:function(a){var b=Math.cos(a);return a=Math.sin(a),this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,k=e*f,n=e*g;return this.set(k*f+c,k*g-d*h,k*h+d*g,0,k*g+d*h,n*g+c,n*h-d*f,0,k*h-d*g,n*h+d*f,e*h*h+c,0,0,0,0,1),this},makeScale:function(a,b,c){return this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1),this},compose:function(a,b,c){return this.makeRotationFromQuaternion(b),this.scale(c),this.setPosition(a),this},decompose:function(){var a=new THREE.Vector3,b=new THREE.Matrix4;return function(c,d,e){var f=this.elements,g=a.set(f[0],f[1],f[2]).length(),h=a.set(f[4],f[5],f[6]).length(),k=a.set(f[8],f[9],f[10]).length();0>this.determinant()&&(g=-g),c.x=f[12],c.y=f[13],c.z=f[14],b.elements.set(this.elements),c=1/g;var f=1/h,n=1/k;return b.elements[0]*=c,b.elements[1]*=c,b.elements[2]*=c,b.elements[4]*=f,b.elements[5]*=f,b.elements[6]*=f,b.elements[8]*=n,b.elements[9]*=n,b.elements[10]*=n,d.setFromRotationMatrix(b),e.x=g,e.y=h,e.z=k,this}}(),makeFrustum:function(a,b,c,d,e,f){var g=this.elements;return g[0]=2*e/(b-a),g[4]=0,g[8]=(b+a)/(b-a),g[12]=0,g[1]=0,g[5]=2*e/(d-c),g[9]=(d+c)/(d-c),g[13]=0,g[2]=0,g[6]=0,g[10]=-(f+e)/(f-e),g[14]=-2*f*e/(f-e),g[3]=0,g[7]=0,g[11]=-1,g[15]=0,this},makePerspective:function(a,b,c,d){a=c*Math.tan(THREE.Math.degToRad(.5*a));var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=b-a,k=c-d,n=f-e;return g[0]=2/h,g[4]=0,g[8]=0,g[12]=-((b+a)/h),g[1]=0,g[5]=2/k,g[9]=0,g[13]=-((c+d)/k),g[2]=0,g[6]=0,g[10]=-2/n,g[14]=-((f+e)/n),g[3]=0,g[7]=0,g[11]=0,g[15]=1,this},fromArray:function(a){return this.elements.set(a),this},toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]]},clone:function(){return(new THREE.Matrix4).fromArray(this.elements)}},THREE.Ray=function(a,b){this.origin=void 0!==a?a:new THREE.Vector3,this.direction=void 0!==b?b:new THREE.Vector3},THREE.Ray.prototype={constructor:THREE.Ray,set:function(a,b){return this.origin.copy(a),this.direction.copy(b),this},copy:function(a){return this.origin.copy(a.origin),this.direction.copy(a.direction),this},at:function(a,b){return(b||new THREE.Vector3).copy(this.direction).multiplyScalar(a).add(this.origin)},recast:function(){var a=new THREE.Vector3;return function(b){return this.origin.copy(this.at(b,a)),this}}(),closestPointToPoint:function(a,b){var c=b||new THREE.Vector3;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(){var a=new THREE.Vector3;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);return 0>c?this.origin.distanceTo(b):(a.copy(this.direction).multiplyScalar(c).add(this.origin),a.distanceTo(b))}}(),distanceSqToSegment:function(a,b,c,d){var e=a.clone().add(b).multiplyScalar(.5),f=b.clone().sub(a).normalize(),g=.5*a.distanceTo(b),h=this.origin.clone().sub(e);a=-this.direction.dot(f),b=h.dot(this.direction);var q,m,k=-h.dot(f),n=h.lengthSq(),p=Math.abs(1-a*a);return 0<=p?(h=a*k-b,q=a*b-k,m=g*p,0<=h?q>=-m?q<=m?(g=1/p,h*=g,q*=g,a=h*(h+a*q+2*b)+q*(a*h+q+2*k)+n):(q=g,h=Math.max(0,-(a*q+b)),a=-h*h+q*(q+2*k)+n):(q=-g,h=Math.max(0,-(a*q+b)),a=-h*h+q*(q+2*k)+n):q<=-m?(h=Math.max(0,-(-a*g+b)),q=0<h?-g:Math.min(Math.max(-g,-k),g),a=-h*h+q*(q+2*k)+n):q<=m?(h=0,q=Math.min(Math.max(-g,-k),g),a=q*(q+2*k)+n):(h=Math.max(0,-(a*g+b)),q=0<h?g:Math.min(Math.max(-g,-k),g),a=-h*h+q*(q+2*k)+n)):(q=0<a?-g:g,h=Math.max(0,-(a*q+b)),a=-h*h+q*(q+2*k)+n),c&&c.copy(this.direction.clone().multiplyScalar(h).add(this.origin)),d&&d.copy(f.clone().multiplyScalar(q).add(e)),a},isIntersectionSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},intersectSphere:function(){var a=new THREE.Vector3;return function(b,c){a.subVectors(b.center,this.origin);var d=a.dot(this.direction),e=a.dot(a)-d*d,f=b.radius*b.radius;return e>f?null:(f=Math.sqrt(f-e),e=d-f,d+=f,0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c))}}(),isIntersectionPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b},distanceToPlane:function(a){var b=a.normal.dot(this.direction);return 0==b?0==a.distanceToPoint(this.origin)?0:null:(a=-(this.origin.dot(a.normal)+a.constant)/b,0<=a?a:null)},intersectPlane:function(a,b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},isIntersectionBox:function(){var a=new THREE.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x,f=1/this.direction.y,g=1/this.direction.z;var h=this.origin;return 0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x),0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y),c>f||e>d?null:((e>c||c!==c)&&(c=e),(f<d||d!==d)&&(d=f),0<=g?(e=(a.min.z-h.z)*g,g*=a.max.z-h.z):(e=(a.max.z-h.z)*g,g*=a.min.z-h.z),c>g||e>d?null:((e>c||c!==c)&&(c=e),(g<d||d!==d)&&(d=g),0>d?null:this.at(0<=c?c:d,b)))},intersectTriangle:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Vector3;return function(e,f,g,h,k){if(b.subVectors(f,e),c.subVectors(g,e),d.crossVectors(b,c),f=this.direction.dot(d),0<f){if(h)return null;h=1}else{if(!(0>f))return null;h=-1,f=-f}return a.subVectors(this.origin,e),e=h*this.direction.dot(c.crossVectors(a,c)),0>e?null:(g=h*this.direction.dot(b.cross(a)),0>g||e+g>f?null:(e=-h*a.dot(d),0>e?null:this.at(e/f,k)))}}(),applyMatrix4:function(a){return this.direction.add(this.origin).applyMatrix4(a),this.origin.applyMatrix4(a),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)},clone:function(){return(new THREE.Ray).copy(this)}},THREE.Sphere=function(a,b){this.center=void 0!==a?a:new THREE.Vector3,this.radius=void 0!==b?b:0},THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){return this.center.copy(a),this.radius=b,this},setFromPoints:function(){var a=new THREE.Box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).center(d);for(var e=0,f=0,g=b.length;f<g;f++)e=Math.max(e,d.distanceToSquared(b[f]));return this.radius=Math.sqrt(e),this}}(),copy:function(a){return this.center.copy(a.center),this.radius=a.radius,this},empty:function(){return 0>=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new THREE.Vector3;return d.copy(a),c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center)),d},getBoundingBox:function(a){return a=a||new THREE.Box3,a.set(this.center,this.center),a.expandByScalar(this.radius),a},applyMatrix4:function(a){return this.center.applyMatrix4(a),this.radius*=a.getMaxScaleOnAxis(),this},translate:function(a){return this.center.add(a),this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius},clone:function(){return(new THREE.Sphere).copy(this)}},THREE.Frustum=function(a,b,c,d,e,f){this.planes=[void 0!==a?a:new THREE.Plane,void 0!==b?b:new THREE.Plane,void 0!==c?c:new THREE.Plane,void 0!==d?d:new THREE.Plane,void 0!==e?e:new THREE.Plane,void 0!==f?f:new THREE.Plane]},THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var g=this.planes;return g[0].copy(a),g[1].copy(b),g[2].copy(c),g[3].copy(d),g[4].copy(e),g[5].copy(f),this},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],n=c[7],p=c[8],q=c[9],m=c[10],r=c[11],t=c[12],s=c[13],u=c[14],c=c[15];return b[0].setComponents(f-a,n-g,r-p,c-t).normalize(),b[1].setComponents(f+a,n+g,r+p,c+t).normalize(),b[2].setComponents(f+d,n+h,r+q,c+s).normalize(),b[3].setComponents(f-d,n-h,r-q,c-s).normalize(),b[4].setComponents(f-e,n-k,r-m,c-u).normalize(),b[5].setComponents(f+e,n+k,r+m,c+u).normalize(),this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;return null===c.boundingSphere&&c.computeBoundingSphere(),a.copy(c.boundingSphere),a.applyMatrix4(b.matrixWorld),this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)<a)return!1;return!0},intersectsBox:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){for(var d=this.planes,e=0;6>e;e++){var f=d[e];a.x=0<f.normal.x?c.min.x:c.max.x,b.x=0<f.normal.x?c.max.x:c.min.x,a.y=0<f.normal.y?c.min.y:c.max.y,b.y=0<f.normal.y?c.max.y:c.min.y,a.z=0<f.normal.z?c.min.z:c.max.z,b.z=0<f.normal.z?c.max.z:c.min.z;var g=f.distanceToPoint(a),f=f.distanceToPoint(b);if(0>g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0},clone:function(){return(new THREE.Frustum).copy(this)}},THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0),this.constant=void 0!==b?b:0},THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){return this.normal.copy(a),this.constant=b,this},setComponents:function(a,b,c,d){return this.normal.set(a,b,c),this.constant=d,this},setFromNormalAndCoplanarPoint:function(a,b){return this.normal.copy(a),this.constant=-b.dot(this.normal),this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){return d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize(),this.setFromNormalAndCoplanarPoint(d,c),this}}(),copy:function(a){return this.normal.copy(a.normal),this.constant=a.constant,this},normalize:function(){var a=1/this.normal.length();return this.normal.multiplyScalar(a),this.constant*=a,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b||new THREE.Vector3).copy(this.normal).multiplyScalar(c)},isIntersectionLine:function(a){var b=this.distanceToPoint(a.start);return a=this.distanceToPoint(a.end),0>b&&0<a||0>a&&0<b},intersectLine:function(){var a=new THREE.Vector3;return function(b,c){var d=c||new THREE.Vector3,e=b.delta(a),f=this.normal.dot(e);return 0!=f?(f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1<f?void 0:d.copy(e).multiplyScalar(f).add(b.start)):0==this.distanceToPoint(b.start)?d.copy(b.start):void 0}}(),coplanarPoint:function(a){return(a||new THREE.Vector3).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(d,e){var f=e||c.getNormalMatrix(d),f=a.copy(this.normal).applyMatrix3(f),g=this.coplanarPoint(b);return g.applyMatrix4(d),this.setFromNormalAndCoplanarPoint(f,g),this}}(),translate:function(a){return this.constant-=a.dot(this.normal),this},equals:function(a){return a.normal.equals(this.normal)&&a.constant==this.constant},clone:function(){return(new THREE.Plane).copy(this)}},THREE.Math={generateUUID:function(){var d,a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),c=0;return function(){for(var e=0;36>e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=15&c,c>>=4,b[e]=a[19==e?3&d|8:d]);return b.join("")}}(),clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return a<=b?0:a>=c?1:(a=(a-b)/(c-b),a*a*(3-2*a))},smootherstep:function(a,b,c){return a<=b?0:a>=c?1:(a=(a-b)/(c-b),a*a*a*(a*(6*a-15)+10))},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(){var a=Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}(),isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a}},THREE.Spline=function(a){function b(a,b,c,d,e,f,g){return a=.5*(c-a),d=.5*(d-b),(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var e,f,g,h,k,n,p,q,m,c=[],d={x:0,y:0,z:0};this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}},this.getPoint=function(a){return e=(this.points.length-1)*a,f=Math.floor(e),g=e-f,c[0]=0===f?f:f-1,c[1]=f,c[2]=f>this.points.length-2?this.points.length-1:f+1,c[3]=f>this.points.length-3?this.points.length-1:f+2,n=this.points[c[0]],p=this.points[c[1]],q=this.points[c[2]],m=this.points[c[3]],h=g*g,k=g*h,d.x=b(n.x,p.x,q.x,m.x,g,h,k),d.y=b(n.y,p.y,q.y,m.y,g,h,k),d.z=b(n.z,p.z,q.z,m.z,g,h,k),d},this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d},this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],k=0;for(h[0]=0,a||(a=100),c=this.points.length*a,f.copy(this.points[0]),a=1;a<c;a++)b=a/c,d=this.getPoint(b),g.copy(d),k+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=k,e=b);return h[h.length]=k,{chunks:h,total:k}},this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],k=new THREE.Vector3,m=this.getLength();for(h.push(k.copy(this.points[0]).clone()),b=1;b<this.points.length;b++){for(c=m.chunks[b]-m.chunks[b-1],g=Math.ceil(a*c/m.total),e=(b-1)/(this.points.length-1),f=b/(this.points.length-1),c=1;c<g-1;c++)d=e+1/g*c*(f-e),d=this.getPoint(d),h.push(k.copy(d).clone());h.push(k.copy(this.points[b]).clone())}this.points=h}},THREE.Triangle=function(a,b,c){this.a=void 0!==a?a:new THREE.Vector3,this.b=void 0!==b?b:new THREE.Vector3,this.c=void 0!==c?c:new THREE.Vector3},THREE.Triangle.normal=function(){var a=new THREE.Vector3;return function(b,c,d,e){return e=e||new THREE.Vector3,e.subVectors(d,c),a.subVectors(b,c),e.cross(a),b=e.lengthSq(),0<b?e.multiplyScalar(1/Math.sqrt(b)):e.set(0,0,0)}}(),THREE.Triangle.barycoordFromPoint=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f,g,h){a.subVectors(g,e),b.subVectors(f,e),c.subVectors(d,e),d=a.dot(a),e=a.dot(b),f=a.dot(c);var k=b.dot(b);g=b.dot(c);var n=d*k-e*e;return h=h||new THREE.Vector3,0==n?h.set(-2,-1,-1):(n=1/n,k=(k*f-e*g)*n,d=(d*g-e*f)*n,h.set(1-k-d,d,k))}}(),THREE.Triangle.containsPoint=function(){var a=new THREE.Vector3;return function(b,c,d,e){return b=THREE.Triangle.barycoordFromPoint(b,c,d,e,a),0<=b.x&&0<=b.y&&1>=b.x+b.y}}(),THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(a,b,c){return this.a.copy(a),this.b.copy(b),this.c.copy(c),this},setFromPointsAndIndices:function(a,b,c,d){return this.a.copy(a[b]),this.b.copy(a[c]),this.c.copy(a[d]),this},copy:function(a){return this.a.copy(a.a),this.b.copy(a.b),this.c.copy(a.c),this},area:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){return a.subVectors(this.c,this.b),b.subVectors(this.a,this.b),.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return THREE.Triangle.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return THREE.Triangle.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return THREE.Triangle.containsPoint(a,this.a,this.b,this.c)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)},clone:function(){return(new THREE.Triangle).copy(this)}},THREE.Clock=function(a){this.autoStart=void 0===a||a,this.elapsedTime=this.oldTime=this.startTime=0,this.running=!1},THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=this.startTime=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now(),this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var a=0;if(this.autoStart&&!this.running&&this.start(),this.running){var b=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now(),a=.001*(b-this.oldTime);this.oldTime=b,this.elapsedTime+=a}return a}},THREE.EventDispatcher=function(){},THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(a){a.addEventListener=THREE.EventDispatcher.prototype.addEventListener,a.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener,a.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener,a.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]),-1===c[a].indexOf(b)&&c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c){var d=c.indexOf(b);-1!==d&&c.splice(d,1)}}},dispatchEvent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var c=[],d=b.length,e=0;e<d;e++)c[e]=b[e];for(e=0;e<d;e++)c[e].call(this,a)}}}},function(a){a.Raycaster=function(b,c,f,g){this.ray=new a.Ray(b,c),this.near=f||0,this.far=g||1/0,this.params={Sprite:{},Mesh:{},PointCloud:{threshold:1},LOD:{},Line:{}}};var b=function(a,b){return a.distance-b.distance},c=function(a,b,f,g){if(a.raycast(b,f),!0===g){a=a.children,g=0;for(var h=a.length;g<h;g++)c(a[g],b,f,!0)}};a.Raycaster.prototype={constructor:a.Raycaster,precision:1e-4,linePrecision:1,set:function(a,b){this.ray.set(a,b)},intersectObject:function(a,e){var f=[];return c(a,this,f,e),f.sort(b),f},intersectObjects:function(a,e){var f=[];if(!1==a instanceof Array)return console.log("THREE.Raycaster.intersectObjects: objects is not an Array."),f;for(var g=0,h=a.length;g<h;g++)c(a[g],this,f,e);return f.sort(b),f}}}(THREE),THREE.Object3D=function(){Object.defineProperty(this,"id",{value:THREE.Object3DIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.type="Object3D",this.parent=void 0,this.children=[],this.up=THREE.Object3D.DefaultUp.clone();var a=new THREE.Vector3,b=new THREE.Euler,c=new THREE.Quaternion,d=new THREE.Vector3(1,1,1);b.onChange(function(){c.setFromEuler(b,!1)}),c.onChange(function(){b.setFromQuaternion(c,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:b},quaternion:{enumerable:!0,value:c},scale:{enumerable:!0,value:d}}),this.renderDepth=null,this.rotationAutoUpdate=!0,this.matrix=new THREE.Matrix4,this.matrixWorld=new THREE.Matrix4,this.matrixAutoUpdate=!0,this.matrixWorldNeedsUpdate=!1,this.visible=!0,this.receiveShadow=this.castShadow=!1,this.frustumCulled=!0,this.userData={}},THREE.Object3D.DefaultUp=new THREE.Vector3(0,1,0),THREE.Object3D.prototype={constructor:THREE.Object3D,get eulerOrder(){return console.warn("THREE.Object3D: .eulerOrder has been moved to .rotation.order."),this.rotation.order},set eulerOrder(a){console.warn("THREE.Object3D: .eulerOrder has been moved to .rotation.order."),this.rotation.order=a},get useQuaternion(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set useQuaternion(a){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(){var a=new THREE.Quaternion;return function(b,c){return a.setFromAxisAngle(b,c),this.quaternion.multiply(a),this}}(),rotateX:function(){var a=new THREE.Vector3(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new THREE.Vector3;return function(b,c){return a.copy(b).applyQuaternion(this.quaternion),this.position.add(a.multiplyScalar(c)),this}}(),translate:function(a,b){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(b,a)},translateX:function(){var a=new THREE.Vector3(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.translateOnAxis(a,b)}}(),translateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new THREE.Matrix4;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),lookAt:function(){var a=new THREE.Matrix4;return function(b){a.lookAt(b,this.position,this.up),this.quaternion.setFromRotationMatrix(a)}}(),add:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.add(arguments[b]);return this}return a===this?(console.error("THREE.Object3D.add:",a,"can't be added as a child of itself."),this):(a instanceof THREE.Object3D?(void 0!==a.parent&&a.parent.remove(a),a.parent=this,a.dispatchEvent({type:"added"}),this.children.push(a)):console.error("THREE.Object3D.add:",a,"is not an instance of THREE.Object3D."),this)},remove:function(a){if(1<arguments.length)for(var b=0;b<arguments.length;b++)this.remove(arguments[b]);b=this.children.indexOf(a),-1!==b&&(a.parent=void 0,a.dispatchEvent({type:"removed"}),this.children.splice(b,1))},getChildByName:function(a,b){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(a,b)},getObjectById:function(a,b){if(this.id===a)return this;for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c].getObjectById(a,b);if(void 0!==e)return e}},getObjectByName:function(a,b){if(this.name===a)return this;for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c].getObjectByName(a,b);if(void 0!==e)return e}},getWorldPosition:function(a){return a=a||new THREE.Vector3,this.updateMatrixWorld(!0),a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){return c=c||new THREE.Quaternion,this.updateMatrixWorld(!0),this.matrixWorld.decompose(a,c,b),c}}(),getWorldRotation:function(){var a=new THREE.Quaternion;return function(b){return b=b||new THREE.Euler,this.getWorldQuaternion(a),b.setFromQuaternion(a,this.rotation.order,!1)}}(),getWorldScale:function(){var a=new THREE.Vector3,b=new THREE.Quaternion;return function(c){return c=c||new THREE.Vector3,this.updateMatrixWorld(!0),this.matrixWorld.decompose(a,b,c),c}}(),getWorldDirection:function(){var a=new THREE.Quaternion;return function(b){return b=b||new THREE.Vector3,this.getWorldQuaternion(a),b.set(0,0,1).applyQuaternion(a)}}(),raycast:function(){},traverse:function(a){a(this);for(var b=0,c=this.children.length;b<c;b++)this.children[b].traverse(a)},traverseVisible:function(a){if(!1!==this.visible){a(this);for(var b=0,c=this.children.length;b<c;b++)this.children[b].traverseVisible(a)}},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){!0===this.matrixAutoUpdate&&this.updateMatrix(),!0!==this.matrixWorldNeedsUpdate&&!0!==a||(void 0===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0);for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},toJSON:function(){var a={metadata:{version:4.3,type:"Object",generator:"ObjectExporter"}},b={},c=function(c){if(void 0===a.geometries&&(a.geometries=[]),void 0===b[c.uuid]){var d=c.toJSON();delete d.metadata,b[c.uuid]=d,a.geometries.push(d)}return c.uuid},d={},e=function(b){if(void 0===a.materials&&(a.materials=[]),void 0===d[b.uuid]){var c=b.toJSON();delete c.metadata,d[b.uuid]=c,a.materials.push(c)}return b.uuid},f=function(a){var b={};if(b.uuid=a.uuid,b.type=a.type,""!==a.name&&(b.name=a.name),"{}"!==JSON.stringify(a.userData)&&(b.userData=a.userData),!0!==a.visible&&(b.visible=a.visible),a instanceof THREE.PerspectiveCamera?(b.fov=a.fov,b.aspect=a.aspect,b.near=a.near,b.far=a.far):a instanceof THREE.OrthographicCamera?(b.left=a.left,b.right=a.right,b.top=a.top,b.bottom=a.bottom,b.near=a.near,b.far=a.far):a instanceof THREE.AmbientLight?b.color=a.color.getHex():a instanceof THREE.DirectionalLight?(b.color=a.color.getHex(),b.intensity=a.intensity):a instanceof THREE.PointLight?(b.color=a.color.getHex(),b.intensity=a.intensity,b.distance=a.distance):a instanceof THREE.SpotLight?(b.color=a.color.getHex(),b.intensity=a.intensity,b.distance=a.distance,b.angle=a.angle,b.exponent=a.exponent):a instanceof THREE.HemisphereLight?(b.color=a.color.getHex(),b.groundColor=a.groundColor.getHex()):a instanceof THREE.Mesh?(b.geometry=c(a.geometry),b.material=e(a.material)):a instanceof THREE.Line?(b.geometry=c(a.geometry),b.material=e(a.material)):a instanceof THREE.Sprite&&(b.material=e(a.material)),b.matrix=a.matrix.toArray(),0<a.children.length){b.children=[];for(var d=0;d<a.children.length;d++)b.children.push(f(a.children[d]))}return b};return a.object=f(this),a},clone:function(a,b){if(void 0===a&&(a=new THREE.Object3D),void 0===b&&(b=!0),a.name=this.name,a.up.copy(this.up),a.position.copy(this.position),a.quaternion.copy(this.quaternion),a.scale.copy(this.scale),a.renderDepth=this.renderDepth,a.rotationAutoUpdate=this.rotationAutoUpdate,a.matrix.copy(this.matrix),a.matrixWorld.copy(this.matrixWorld),a.matrixAutoUpdate=this.matrixAutoUpdate,a.matrixWorldNeedsUpdate=this.matrixWorldNeedsUpdate,a.visible=this.visible,a.castShadow=this.castShadow,a.receiveShadow=this.receiveShadow,a.frustumCulled=this.frustumCulled,a.userData=JSON.parse(JSON.stringify(this.userData)),!0===b)for(var c=0;c<this.children.length;c++)a.add(this.children[c].clone());return a}},THREE.EventDispatcher.prototype.apply(THREE.Object3D.prototype),THREE.Object3DIdCount=0,THREE.Projector=function(){console.warn("THREE.Projector has been moved to /examples/renderers/Projector.js."),this.projectVector=function(a,b){console.warn("THREE.Projector: .projectVector() is now vector.project()."),a.project(b)},this.unprojectVector=function(a,b){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),a.unproject(b)},this.pickingRay=function(a,b){console.error("THREE.Projector: .pickingRay() has been removed.")}},THREE.Face3=function(a,b,c,d,e,f){this.a=a,this.b=b,this.c=c,this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3,this.vertexNormals=d instanceof Array?d:[],this.color=e instanceof THREE.Color?e:new THREE.Color,this.vertexColors=e instanceof Array?e:[],this.vertexTangents=[],this.materialIndex=void 0!==f?f:0},THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal),a.color.copy(this.color),a.materialIndex=this.materialIndex;for(var b=0,c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();for(b=0,c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();for(b=0,c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();return a}},THREE.Face4=function(a,b,c,d,e,f,g){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new THREE.Face3(a,b,c,e,f,g)},THREE.BufferAttribute=function(a,b){this.array=a,this.itemSize=b,this.needsUpdate=!1},THREE.BufferAttribute.prototype={constructor:THREE.BufferAttribute,get length(){return this.array.length},copyAt:function(a,b,c){a*=this.itemSize,c*=b.itemSize;for(var d=0,e=this.itemSize;d<e;d++)this.array[a+d]=b.array[c+d]},set:function(a){return this.array.set(a),this},setX:function(a,b){return this.array[a*this.itemSize]=b,this},setY:function(a,b){return this.array[a*this.itemSize+1]=b,this},setZ:function(a,b){return this.array[a*this.itemSize+2]=b,this},setXY:function(a,b,c){return a*=this.itemSize,this.array[a]=b,this.array[a+1]=c,this},setXYZ:function(a,b,c,d){return a*=this.itemSize,this.array[a]=b,this.array[a+1]=c,this.array[a+2]=d,this},setXYZW:function(a,b,c,d,e){return a*=this.itemSize,this.array[a]=b,this.array[a+1]=c,this.array[a+2]=d,this.array[a+3]=e,this},clone:function(){return new THREE.BufferAttribute(new this.array.constructor(this.array),this.itemSize)}},THREE.Int8Attribute=function(a,b){return console.warn("THREE.Int8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Uint8Attribute=function(a,b){return console.warn("THREE.Uint8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Uint8ClampedAttribute=function(a,b){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Int16Attribute=function(a,b){return console.warn("THREE.Int16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Uint16Attribute=function(a,b){return console.warn("THREE.Uint16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Int32Attribute=function(a,b){return console.warn("THREE.Int32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Uint32Attribute=function(a,b){return console.warn("THREE.Uint32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Float32Attribute=function(a,b){return console.warn("THREE.Float32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.Float64Attribute=function(a,b){return console.warn("THREE.Float64Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(a,b)},THREE.BufferGeometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.type="BufferGeometry",this.attributes={},this.attributesKeys=[],this.offsets=this.drawcalls=[],this.boundingSphere=this.boundingBox=null},THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,addAttribute:function(a,b,c){!1==b instanceof THREE.BufferAttribute?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.attributes[a]={array:b,itemSize:c}):(this.attributes[a]=b,this.attributesKeys=Object.keys(this.attributes));
},getAttribute:function(a){return this.attributes[a]},addDrawCall:function(a,b,c){this.drawcalls.push({start:a,count:b,index:void 0!==c?c:0})},applyMatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applyToVector3Array(b.array),b.needsUpdate=!0),b=this.attributes.normal,void 0!==b&&((new THREE.Matrix3).getNormalMatrix(a).applyToVector3Array(b.array),b.needsUpdate=!0)},center:function(){},fromGeometry:function(a,b){b=b||{vertexColors:THREE.NoColors};var c=a.vertices,d=a.faces,e=a.faceVertexUvs,f=b.vertexColors,g=0<e[0].length,h=3==d[0].vertexNormals.length,k=new Float32Array(9*d.length);this.addAttribute("position",new THREE.BufferAttribute(k,3));var n=new Float32Array(9*d.length);if(this.addAttribute("normal",new THREE.BufferAttribute(n,3)),f!==THREE.NoColors){var p=new Float32Array(9*d.length);this.addAttribute("color",new THREE.BufferAttribute(p,3))}if(!0===g){var q=new Float32Array(6*d.length);this.addAttribute("uv",new THREE.BufferAttribute(q,2))}for(var m=0,r=0,t=0;m<d.length;m++,r+=6,t+=9){var s=d[m],u=c[s.a],v=c[s.b],y=c[s.c];k[t]=u.x,k[t+1]=u.y,k[t+2]=u.z,k[t+3]=v.x,k[t+4]=v.y,k[t+5]=v.z,k[t+6]=y.x,k[t+7]=y.y,k[t+8]=y.z,!0===h?(u=s.vertexNormals[0],v=s.vertexNormals[1],y=s.vertexNormals[2],n[t]=u.x,n[t+1]=u.y,n[t+2]=u.z,n[t+3]=v.x,n[t+4]=v.y,n[t+5]=v.z,n[t+6]=y.x,n[t+7]=y.y,n[t+8]=y.z):(u=s.normal,n[t]=u.x,n[t+1]=u.y,n[t+2]=u.z,n[t+3]=u.x,n[t+4]=u.y,n[t+5]=u.z,n[t+6]=u.x,n[t+7]=u.y,n[t+8]=u.z),f===THREE.FaceColors?(s=s.color,p[t]=s.r,p[t+1]=s.g,p[t+2]=s.b,p[t+3]=s.r,p[t+4]=s.g,p[t+5]=s.b,p[t+6]=s.r,p[t+7]=s.g,p[t+8]=s.b):f===THREE.VertexColors&&(u=s.vertexColors[0],v=s.vertexColors[1],s=s.vertexColors[2],p[t]=u.r,p[t+1]=u.g,p[t+2]=u.b,p[t+3]=v.r,p[t+4]=v.g,p[t+5]=v.b,p[t+6]=s.r,p[t+7]=s.g,p[t+8]=s.b),!0===g&&(s=e[0][m][0],u=e[0][m][1],v=e[0][m][2],q[r]=s.x,q[r+1]=s.y,q[r+2]=u.x,q[r+3]=u.y,q[r+4]=v.x,q[r+5]=v.y)}return this.computeBoundingSphere(),this},computeBoundingBox:function(){var a=new THREE.Vector3;return function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var b=this.attributes.position.array;if(b){var c=this.boundingBox;c.makeEmpty();for(var d=0,e=b.length;d<e;d+=3)a.set(b[d],b[d+1],b[d+2]),c.expandByPoint(a)}void 0!==b&&0!==b.length||(this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.')}}(),computeBoundingSphere:function(){var a=new THREE.Box3,b=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var c=this.attributes.position.array;if(c){a.makeEmpty();for(var d=this.boundingSphere.center,e=0,f=c.length;e<f;e+=3)b.set(c[e],c[e+1],c[e+2]),a.expandByPoint(b);a.center(d);for(var g=0,e=0,f=c.length;e<f;e+=3)b.set(c[e],c[e+1],c[e+2]),g=Math.max(g,d.distanceToSquared(b));this.boundingSphere.radius=Math.sqrt(g),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.')}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var a=this.attributes;if(a.position){var b=a.position.array;if(void 0===a.normal)this.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(b.length),3));else for(var c=a.normal.array,d=0,e=c.length;d<e;d++)c[d]=0;var f,g,h,c=a.normal.array,k=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,q=new THREE.Vector3,m=new THREE.Vector3;if(a.index)for(var r=a.index.array,t=0<this.offsets.length?this.offsets:[{start:0,count:r.length,index:0}],s=0,u=t.length;s<u;++s){e=t[s].start,f=t[s].count;for(var v=t[s].index,d=e,e=e+f;d<e;d+=3)f=3*(v+r[d]),g=3*(v+r[d+1]),h=3*(v+r[d+2]),k.fromArray(b,f),n.fromArray(b,g),p.fromArray(b,h),q.subVectors(p,n),m.subVectors(k,n),q.cross(m),c[f]+=q.x,c[f+1]+=q.y,c[f+2]+=q.z,c[g]+=q.x,c[g+1]+=q.y,c[g+2]+=q.z,c[h]+=q.x,c[h+1]+=q.y,c[h+2]+=q.z}else for(d=0,e=b.length;d<e;d+=9)k.fromArray(b,d),n.fromArray(b,d+3),p.fromArray(b,d+6),q.subVectors(p,n),m.subVectors(k,n),q.cross(m),c[d]=q.x,c[d+1]=q.y,c[d+2]=q.z,c[d+3]=q.x,c[d+4]=q.y,c[d+5]=q.z,c[d+6]=q.x,c[d+7]=q.y,c[d+8]=q.z;this.normalizeNormals(),a.normal.needsUpdate=!0}},computeTangents:function(){function a(a,b,c){q.fromArray(d,3*a),m.fromArray(d,3*b),r.fromArray(d,3*c),t.fromArray(f,2*a),s.fromArray(f,2*b),u.fromArray(f,2*c),v=m.x-q.x,y=r.x-q.x,G=m.y-q.y,w=r.y-q.y,K=m.z-q.z,x=r.z-q.z,D=s.x-t.x,E=u.x-t.x,A=s.y-t.y,B=u.y-t.y,F=1/(D*B-E*A),R.set((B*v-A*y)*F,(B*G-A*w)*F,(B*K-A*x)*F),H.set((D*y-E*v)*F,(D*w-E*G)*F,(D*x-E*K)*F),k[a].add(R),k[b].add(R),k[c].add(R),n[a].add(H),n[b].add(H),n[c].add(H)}function b(a){ya.fromArray(e,3*a),P.copy(ya),Fa=k[a],la.copy(Fa),la.sub(ya.multiplyScalar(ya.dot(Fa))).normalize(),ma.crossVectors(P,Fa),za=ma.dot(n[a]),Ga=0>za?-1:1,h[4*a]=la.x,h[4*a+1]=la.y,h[4*a+2]=la.z,h[4*a+3]=Ga}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var c=this.attributes.index.array,d=this.attributes.position.array,e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&this.addAttribute("tangent",new THREE.BufferAttribute(new Float32Array(4*g),4));for(var h=this.attributes.tangent.array,k=[],n=[],p=0;p<g;p++)k[p]=new THREE.Vector3,n[p]=new THREE.Vector3;var v,y,G,w,K,x,D,E,A,B,F,C,T,Q,O,S,q=new THREE.Vector3,m=new THREE.Vector3,r=new THREE.Vector3,t=new THREE.Vector2,s=new THREE.Vector2,u=new THREE.Vector2,R=new THREE.Vector3,H=new THREE.Vector3;0===this.drawcalls.length&&this.addDrawCall(0,c.length,0);var X=this.drawcalls,p=0;for(T=X.length;p<T;++p){C=X[p].start,Q=X[p].count;var Y=X[p].index,g=C;for(C+=Q;g<C;g+=3)Q=Y+c[g],O=Y+c[g+1],S=Y+c[g+2],a(Q,O,S)}var Ga,Fa,za,la=new THREE.Vector3,ma=new THREE.Vector3,ya=new THREE.Vector3,P=new THREE.Vector3,p=0;for(T=X.length;p<T;++p)for(C=X[p].start,Q=X[p].count,Y=X[p].index,g=C,C+=Q;g<C;g+=3)Q=Y+c[g],O=Y+c[g+1],S=Y+c[g+2],b(Q),b(O),b(S)}},computeOffsets:function(a){var b=a;void 0===a&&(b=65535),Date.now(),a=this.attributes.index.array;for(var c=this.attributes.position.array,d=a.length/3,e=new Uint16Array(a.length),f=0,g=0,h=[{start:0,count:0,index:0}],k=h[0],n=0,p=0,q=new Int32Array(6),m=new Int32Array(c.length),r=new Int32Array(c.length),t=0;t<c.length;t++)m[t]=-1,r[t]=-1;for(c=0;c<d;c++){for(var s=p=0;3>s;s++)t=a[3*c+s],-1==m[t]?(q[2*s]=t,q[2*s+1]=-1,p++):m[t]<k.index?(q[2*s]=t,q[2*s+1]=-1,n++):(q[2*s]=t,q[2*s+1]=m[t]);if(g+p>k.index+b)for(k={start:f,count:0,index:g},h.push(k),p=0;6>p;p+=2)s=q[p+1],-1<s&&s<k.index&&(q[p+1]=-1);for(p=0;6>p;p+=2)t=q[p],s=q[p+1],-1===s&&(s=g++),m[t]=s,r[s]=t,e[f++]=s-k.index,k.count++}return this.reorderBuffers(e,r,g),this.offsets=h},merge:function(){console.log("BufferGeometry.merge(): TODO")},normalizeNormals:function(){for(var b,c,d,a=this.attributes.normal.array,e=0,f=a.length;e<f;e+=3)b=a[e],c=a[e+1],d=a[e+2],b=1/Math.sqrt(b*b+c*c+d*d),a[e]*=b,a[e+1]*=b,a[e+2]*=b},reorderBuffers:function(a,b,c){var e,d={};for(e in this.attributes)"index"!=e&&(d[e]=new this.attributes[e].array.constructor(this.attributes[e].itemSize*c));for(var f=0;f<c;f++){var g=b[f];for(e in this.attributes)if("index"!=e)for(var h=this.attributes[e].array,k=this.attributes[e].itemSize,n=d[e],p=0;p<k;p++)n[f*k+p]=h[g*k+p]}this.attributes.index.array=a;for(e in this.attributes)"index"!=e&&(this.attributes[e].array=d[e],this.attributes[e].numItems=this.attributes[e].itemSize*c)},toJSON:function(){var e,a={metadata:{version:4,type:"BufferGeometry",generator:"BufferGeometryExporter"},uuid:this.uuid,type:this.type,data:{attributes:{}}},b=this.attributes,c=this.offsets,d=this.boundingSphere;for(e in b){for(var f=b[e],g=[],h=f.array,k=0,n=h.length;k<n;k++)g[k]=h[k];a.data.attributes[e]={itemSize:f.itemSize,type:f.array.constructor.name,array:g}}return 0<c.length&&(a.data.offsets=JSON.parse(JSON.stringify(c))),null!==d&&(a.data.boundingSphere={center:d.center.toArray(),radius:d.radius}),a},clone:function(){var b,a=new THREE.BufferGeometry;for(b in this.attributes)a.addAttribute(b,this.attributes[b].clone());b=0;for(var c=this.offsets.length;b<c;b++){var d=this.offsets[b];a.offsets.push({start:d.start,index:d.index,count:d.count})}return a},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.BufferGeometry.prototype),THREE.Geometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphColors=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingSphere=this.boundingBox=null,this.hasTangents=!1,this.dynamic=!0,this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.tangentsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.elementsNeedUpdate=this.verticesNeedUpdate=!1},THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){for(var b=(new THREE.Matrix3).getNormalMatrix(a),c=0,d=this.vertices.length;c<d;c++)this.vertices[c].applyMatrix4(a);for(c=0,d=this.faces.length;c<d;c++){a=this.faces[c],a.normal.applyMatrix3(b).normalize();for(var e=0,f=a.vertexNormals.length;e<f;e++)a.vertexNormals[e].applyMatrix3(b).normalize()}this.boundingBox instanceof THREE.Box3&&this.computeBoundingBox(),this.boundingSphere instanceof THREE.Sphere&&this.computeBoundingSphere()},fromBufferGeometry:function(a){for(var b=this,c=a.attributes,d=c.position.array,e=void 0!==c.index?c.index.array:void 0,f=void 0!==c.normal?c.normal.array:void 0,g=void 0!==c.color?c.color.array:void 0,h=void 0!==c.uv?c.uv.array:void 0,k=[],n=[],p=c=0;c<d.length;c+=3,p+=2)b.vertices.push(new THREE.Vector3(d[c],d[c+1],d[c+2])),void 0!==f&&k.push(new THREE.Vector3(f[c],f[c+1],f[c+2])),void 0!==g&&b.colors.push(new THREE.Color(g[c],g[c+1],g[c+2])),void 0!==h&&n.push(new THREE.Vector2(h[p],h[p+1]));if(h=function(a,c,d){var e=void 0!==f?[k[a].clone(),k[c].clone(),k[d].clone()]:[],h=void 0!==g?[b.colors[a].clone(),b.colors[c].clone(),b.colors[d].clone()]:[];b.faces.push(new THREE.Face3(a,c,d,e,h)),b.faceVertexUvs[0].push([n[a],n[c],n[d]])},void 0!==e)for(c=0;c<e.length;c+=3)h(e[c],e[c+1],e[c+2]);else for(c=0;c<d.length/3;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone()),null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone()),this},center:function(){this.computeBoundingBox();var a=new THREE.Vector3;return a.addVectors(this.boundingBox.min,this.boundingBox.max),a.multiplyScalar(-.5),this.applyMatrix((new THREE.Matrix4).makeTranslation(a.x,a.y,a.z)),this.computeBoundingBox(),a},computeFaceNormals:function(){for(var a=new THREE.Vector3,b=new THREE.Vector3,c=0,d=this.faces.length;c<d;c++){var e=this.faces[c],f=this.vertices[e.a],g=this.vertices[e.b];a.subVectors(this.vertices[e.c],g),b.subVectors(f,g),a.cross(b),a.normalize(),e.normal.copy(a)}},computeVertexNormals:function(a){var b,c,d;for(d=Array(this.vertices.length),b=0,c=this.vertices.length;b<c;b++)d[b]=new THREE.Vector3;if(a){var e,f,g,h=new THREE.Vector3,k=new THREE.Vector3;for(new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,a=0,b=this.faces.length;a<b;a++)c=this.faces[a],e=this.vertices[c.a],f=this.vertices[c.b],g=this.vertices[c.c],h.subVectors(g,f),k.subVectors(e,f),h.cross(k),d[c.a].add(h),d[c.b].add(h),d[c.c].add(h)}else for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d[c.a].add(c.normal),d[c.b].add(c.normal),d[c.c].add(c.normal);for(b=0,c=this.vertices.length;b<c;b++)d[b].normalize();for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c.vertexNormals[0]=d[c.a].clone(),c.vertexNormals[1]=d[c.b].clone(),c.vertexNormals[2]=d[c.c].clone()},computeMorphNormals:function(){var a,b,c,d,e;for(c=0,d=this.faces.length;c<d;c++)for(e=this.faces[c],e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone(),e.__originalVertexNormals||(e.__originalVertexNormals=[]),a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone();var f=new THREE.Geometry;for(f.faces=this.faces,a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={},this.morphNormals[a].faceNormals=[],this.morphNormals[a].vertexNormals=[],e=this.morphNormals[a].faceNormals;var h,k,g=this.morphNormals[a].vertexNormals;for(c=0,d=this.faces.length;c<d;c++)h=new THREE.Vector3,k={a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3},e.push(h),g.push(k)}for(g=this.morphNormals[a],f.vertices=this.morphTargets[a].vertices,f.computeFaceNormals(),f.computeVertexNormals(),c=0,d=this.faces.length;c<d;c++)e=this.faces[c],h=g.faceNormals[c],k=g.vertexNormals[c],h.copy(e.normal),k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){var a,b,c,d,e,f,g,h,k,n,p,q,m,r,t,s,u,v=[],y=[];c=new THREE.Vector3;var G=new THREE.Vector3,w=new THREE.Vector3,K=new THREE.Vector3,x=new THREE.Vector3;for(a=0,b=this.vertices.length;a<b;a++)v[a]=new THREE.Vector3,y[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)e=this.faces[a],f=this.faceVertexUvs[0][a],d=e.a,u=e.b,e=e.c,g=this.vertices[d],h=this.vertices[u],k=this.vertices[e],n=f[0],p=f[1],q=f[2],f=h.x-g.x,m=k.x-g.x,r=h.y-g.y,t=k.y-g.y,h=h.z-g.z,g=k.z-g.z,k=p.x-n.x,s=q.x-n.x,p=p.y-n.y,n=q.y-n.y,q=1/(k*n-s*p),c.set((n*f-p*m)*q,(n*r-p*t)*q,(n*h-p*g)*q),G.set((k*m-s*f)*q,(k*t-s*r)*q,(k*g-s*h)*q),v[d].add(c),v[u].add(c),v[e].add(c),y[d].add(G),y[u].add(G),y[e].add(G);for(G=["a","b","c","d"],a=0,b=this.faces.length;a<b;a++)for(e=this.faces[a],c=0;c<Math.min(e.vertexNormals.length,3);c++)x.copy(e.vertexNormals[c]),d=e[G[c]],u=v[d],w.copy(u),w.sub(x.multiplyScalar(x.dot(u))).normalize(),K.crossVectors(e.vertexNormals[c],u),d=K.dot(y[d]),d=0>d?-1:1,e.vertexTangents[c]=new THREE.Vector4(w.x,w.y,w.z,d);this.hasTangents=!0},computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;c<d;c++)0<c&&(a+=b[c].distanceTo(b[c-1])),this.lineDistances[c]=a},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere),this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,b,c){if(!1==a instanceof THREE.Geometry)console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",a);else{var d,e=this.vertices.length,f=this.vertices,g=a.vertices,h=this.faces,k=a.faces,n=this.faceVertexUvs[0];a=a.faceVertexUvs[0],void 0===c&&(c=0),void 0!==b&&(d=(new THREE.Matrix3).getNormalMatrix(b));for(var p=0,q=g.length;p<q;p++){var m=g[p].clone();void 0!==b&&m.applyMatrix4(b),f.push(m)}for(p=0,q=k.length;p<q;p++){var r,g=k[p],t=g.vertexNormals,s=g.vertexColors,m=new THREE.Face3(g.a+e,g.b+e,g.c+e);for(m.normal.copy(g.normal),void 0!==d&&m.normal.applyMatrix3(d).normalize(),b=0,f=t.length;b<f;b++)r=t[b].clone(),void 0!==d&&r.applyMatrix3(d).normalize(),m.vertexNormals.push(r);for(m.color.copy(g.color),b=0,f=s.length;b<f;b++)r=s[b],m.vertexColors.push(r.clone());m.materialIndex=g.materialIndex+c,h.push(m)}for(p=0,q=a.length;p<q;p++)if(c=a[p],d=[],void 0!==c){for(b=0,f=c.length;b<f;b++)d.push(new THREE.Vector2(c[b].x,c[b].y));n.push(d)}}},mergeVertices:function(){var d,f,g,a={},b=[],c=[],e=Math.pow(10,4);for(f=0,g=this.vertices.length;f<g;f++)d=this.vertices[f],d=Math.round(d.x*e)+"_"+Math.round(d.y*e)+"_"+Math.round(d.z*e),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];for(a=[],f=0,g=this.faces.length;f<g;f++)for(e=this.faces[f],e.a=c[e.a],e.b=c[e.b],e.c=c[e.c],e=[e.a,e.b,e.c],d=0;3>d;d++)if(e[d]==e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.faceVertexUvs.length;c<g;c++)this.faceVertexUvs[c].splice(e,1);return f=this.vertices.length-b.length,this.vertices=b,f},toJSON:function(){function a(a,b,c){return c?a|1<<b:a&~(1<<b)}function b(a){var b=a.x.toString()+a.y.toString()+a.z.toString();return void 0!==n[b]?n[b]:(n[b]=k.length/3,k.push(a.x,a.y,a.z),n[b])}function c(a){var b=a.r.toString()+a.g.toString()+a.b.toString();return void 0!==q[b]?q[b]:(q[b]=p.length,p.push(a.getHex()),q[b])}function d(a){var b=a.x.toString()+a.y.toString();return void 0!==r[b]?r[b]:(r[b]=m.length/2,m.push(a.x,a.y),r[b])}var e={metadata:{version:4,type:"BufferGeometry",generator:"BufferGeometryExporter"},uuid:this.uuid,type:this.type};if(""!==this.name&&(e.name=this.name),void 0!==this.parameters){var g,f=this.parameters;for(g in f)void 0!==f[g]&&(e[g]=f[g]);return e}for(f=[],g=0;g<this.vertices.length;g++){var h=this.vertices[g];f.push(h.x,h.y,h.z)}var h=[],k=[],n={},p=[],q={},m=[],r={};for(g=0;g<this.faces.length;g++){var t=this.faces[g],s=void 0!==this.faceVertexUvs[0][g],u=0<t.normal.length(),v=0<t.vertexNormals.length,y=1!==t.color.r||1!==t.color.g||1!==t.color.b,G=0<t.vertexColors.length,w=0,w=a(w,0,0),w=a(w,1,!1),w=a(w,2,!1),w=a(w,3,s),w=a(w,4,u),w=a(w,5,v),w=a(w,6,y),w=a(w,7,G);h.push(w),h.push(t.a,t.b,t.c),s&&(s=this.faceVertexUvs[0][g],h.push(d(s[0]),d(s[1]),d(s[2]))),u&&h.push(b(t.normal)),v&&(u=t.vertexNormals,h.push(b(u[0]),b(u[1]),b(u[2]))),y&&h.push(c(t.color)),G&&(t=t.vertexColors,h.push(c(t[0]),c(t[1]),c(t[2])))}return e.data={},e.data.vertices=f,e.data.normals=k,0<p.length&&(e.data.colors=p),0<m.length&&(e.data.uvs=[m]),e.data.faces=h,e},clone:function(){for(var a=new THREE.Geometry,b=this.vertices,c=0,d=b.length;c<d;c++)a.vertices.push(b[c].clone());for(b=this.faces,c=0,d=b.length;c<d;c++)a.faces.push(b[c].clone());for(b=this.faceVertexUvs[0],c=0,d=b.length;c<d;c++){for(var e=b[c],f=[],g=0,h=e.length;g<h;g++)f.push(new THREE.Vector2(e[g].x,e[g].y));a.faceVertexUvs[0].push(f)}return a},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.Geometry.prototype),THREE.GeometryIdCount=0,THREE.Camera=function(){THREE.Object3D.call(this),this.type="Camera",this.matrixWorldInverse=new THREE.Matrix4,this.projectionMatrix=new THREE.Matrix4},THREE.Camera.prototype=Object.create(THREE.Object3D.prototype),THREE.Camera.prototype.getWorldDirection=function(){var a=new THREE.Quaternion;return function(b){return b=b||new THREE.Vector3,this.getWorldQuaternion(a),b.set(0,0,-1).applyQuaternion(a)}}(),THREE.Camera.prototype.lookAt=function(){var a=new THREE.Matrix4;return function(b){a.lookAt(this.position,b,this.up),this.quaternion.setFromRotationMatrix(a)}}(),THREE.Camera.prototype.clone=function(a){return void 0===a&&(a=new THREE.Camera),THREE.Object3D.prototype.clone.call(this,a),a.matrixWorldInverse.copy(this.matrixWorldInverse),a.projectionMatrix.copy(this.projectionMatrix),a},THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this),this.type="CubeCamera";var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0),d.lookAt(new THREE.Vector3(1,0,0)),this.add(d);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,-1,0),e.lookAt(new THREE.Vector3((-1),0,0)),this.add(e);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,0,1),f.lookAt(new THREE.Vector3(0,1,0)),this.add(f);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1),g.lookAt(new THREE.Vector3(0,(-1),0)),this.add(g);var h=new THREE.PerspectiveCamera(90,1,a,b);h.up.set(0,-1,0),h.lookAt(new THREE.Vector3(0,0,1)),this.add(h);var k=new THREE.PerspectiveCamera(90,1,a,b);k.up.set(0,-1,0),k.lookAt(new THREE.Vector3(0,0,(-1))),this.add(k),this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter}),this.updateCubeMap=function(a,b){var c=this.renderTarget,m=c.generateMipmaps;c.generateMipmaps=!1,c.activeCubeFace=0,a.render(b,d,c),c.activeCubeFace=1,a.render(b,e,c),c.activeCubeFace=2,a.render(b,f,c),c.activeCubeFace=3,a.render(b,g,c),c.activeCubeFace=4,a.render(b,h,c),c.generateMipmaps=m,c.activeCubeFace=5,a.render(b,k,c)}},THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype),THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this),this.type="OrthographicCamera",this.zoom=1,this.left=a,this.right=b,this.top=c,this.bottom=d,this.near=void 0!==e?e:.1,this.far=void 0!==f?f:2e3,this.updateProjectionMatrix()},THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype),THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){var a=(this.right-this.left)/(2*this.zoom),b=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,d=(this.top+this.bottom)/2;this.projectionMatrix.makeOrthographic(c-a,c+a,d+b,d-b,this.near,this.far)},THREE.OrthographicCamera.prototype.clone=function(){var a=new THREE.OrthographicCamera;return THREE.Camera.prototype.clone.call(this,a),a.zoom=this.zoom,a.left=this.left,a.right=this.right,a.top=this.top,a.bottom=this.bottom,a.near=this.near,a.far=this.far,a.projectionMatrix.copy(this.projectionMatrix),a},THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this),this.type="PerspectiveCamera",this.zoom=1,this.fov=void 0!==a?a:50,this.aspect=void 0!==b?b:1,this.near=void 0!==c?c:.1,this.far=void 0!==d?d:2e3,this.updateProjectionMatrix()},THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype),THREE.PerspectiveCamera.prototype.setLens=function(a,b){void 0===b&&(b=24),this.fov=2*THREE.Math.radToDeg(Math.atan(b/(2*a))),this.updateProjectionMatrix()},THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a,this.fullHeight=b,this.x=c,this.y=d,this.width=e,this.height=f,this.updateProjectionMatrix()},THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var a=THREE.Math.radToDeg(2*Math.atan(Math.tan(.5*THREE.Math.degToRad(this.fov))/this.zoom));if(this.fullWidth){var b=this.fullWidth/this.fullHeight,a=Math.tan(THREE.Math.degToRad(.5*a))*this.near,c=-a,d=b*c,b=Math.abs(b*a-d),c=Math.abs(a-c);this.projectionMatrix.makeFrustum(d+this.x*b/this.fullWidth,d+(this.x+this.width)*b/this.fullWidth,a-(this.y+this.height)*c/this.fullHeight,a-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(a,this.aspect,this.near,this.far)},THREE.PerspectiveCamera.prototype.clone=function(){var a=new THREE.PerspectiveCamera;return THREE.Camera.prototype.clone.call(this,a),a.zoom=this.zoom,a.fov=this.fov,a.aspect=this.aspect,a.near=this.near,a.far=this.far,a.projectionMatrix.copy(this.projectionMatrix),a},THREE.Light=function(a){THREE.Object3D.call(this),this.type="Light",this.color=new THREE.Color(a)},THREE.Light.prototype=Object.create(THREE.Object3D.prototype),THREE.Light.prototype.clone=function(a){return void 0===a&&(a=new THREE.Light),THREE.Object3D.prototype.clone.call(this,a),a.color.copy(this.color),a},THREE.AmbientLight=function(a){THREE.Light.call(this,a),this.type="AmbientLight"},THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype),THREE.AmbientLight.prototype.clone=function(){var a=new THREE.AmbientLight;return THREE.Light.prototype.clone.call(this,a),a},THREE.AreaLight=function(a,b){THREE.Light.call(this,a),this.type="AreaLight",this.normal=new THREE.Vector3(0,(-1),0),this.right=new THREE.Vector3(1,0,0),this.intensity=void 0!==b?b:1,this.height=this.width=1,this.constantAttenuation=1.5,this.linearAttenuation=.5,this.quadraticAttenuation=.1},THREE.AreaLight.prototype=Object.create(THREE.Light.prototype),THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a),this.type="DirectionalLight",this.position.set(0,1,0),this.target=new THREE.Object3D,this.intensity=void 0!==b?b:1,this.onlyShadow=this.castShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraLeft=-500,this.shadowCameraTop=this.shadowCameraRight=500,this.shadowCameraBottom=-500,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapHeight=this.shadowMapWidth=512,this.shadowCascade=!1,this.shadowCascadeOffset=new THREE.Vector3(0,0,(-1e3)),this.shadowCascadeCount=2,this.shadowCascadeBias=[0,0,0],this.shadowCascadeWidth=[512,512,512],this.shadowCascadeHeight=[512,512,512],this.shadowCascadeNearZ=[-1,.99,.998],this.shadowCascadeFarZ=[.99,.998,1],this.shadowCascadeArray=[],this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null},THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype),THREE.DirectionalLight.prototype.clone=function(){var a=new THREE.DirectionalLight;return THREE.Light.prototype.clone.call(this,a),a.target=this.target.clone(),a.intensity=this.intensity,a.castShadow=this.castShadow,a.onlyShadow=this.onlyShadow,a.shadowCameraNear=this.shadowCameraNear,a.shadowCameraFar=this.shadowCameraFar,a.shadowCameraLeft=this.shadowCameraLeft,a.shadowCameraRight=this.shadowCameraRight,a.shadowCameraTop=this.shadowCameraTop,a.shadowCameraBottom=this.shadowCameraBottom,a.shadowCameraVisible=this.shadowCameraVisible,a.shadowBias=this.shadowBias,a.shadowDarkness=this.shadowDarkness,a.shadowMapWidth=this.shadowMapWidth,a.shadowMapHeight=this.shadowMapHeight,a.shadowCascade=this.shadowCascade,a.shadowCascadeOffset.copy(this.shadowCascadeOffset),a.shadowCascadeCount=this.shadowCascadeCount,a.shadowCascadeBias=this.shadowCascadeBias.slice(0),a.shadowCascadeWidth=this.shadowCascadeWidth.slice(0),a.shadowCascadeHeight=this.shadowCascadeHeight.slice(0),a.shadowCascadeNearZ=this.shadowCascadeNearZ.slice(0),a.shadowCascadeFarZ=this.shadowCascadeFarZ.slice(0),a},THREE.HemisphereLight=function(a,b,c){THREE.Light.call(this,a),this.type="HemisphereLight",this.position.set(0,100,0),this.groundColor=new THREE.Color(b),this.intensity=void 0!==c?c:1},THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype),THREE.HemisphereLight.prototype.clone=function(){var a=new THREE.HemisphereLight;return THREE.Light.prototype.clone.call(this,a),a.groundColor.copy(this.groundColor),a.intensity=this.intensity,a},THREE.PointLight=function(a,b,c){THREE.Light.call(this,a),this.type="PointLight",this.intensity=void 0!==b?b:1,this.distance=void 0!==c?c:0},THREE.PointLight.prototype=Object.create(THREE.Light.prototype),THREE.PointLight.prototype.clone=function(){var a=new THREE.PointLight;return THREE.Light.prototype.clone.call(this,a),a.intensity=this.intensity,a.distance=this.distance,a},THREE.SpotLight=function(a,b,c,d,e){THREE.Light.call(this,a),this.type="SpotLight",this.position.set(0,1,0),this.target=new THREE.Object3D,this.intensity=void 0!==b?b:1,this.distance=void 0!==c?c:0,this.angle=void 0!==d?d:Math.PI/3,this.exponent=void 0!==e?e:10,this.onlyShadow=this.castShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraFov=50,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapHeight=this.shadowMapWidth=512,this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null},THREE.SpotLight.prototype=Object.create(THREE.Light.prototype),THREE.SpotLight.prototype.clone=function(){var a=new THREE.SpotLight;return THREE.Light.prototype.clone.call(this,a),a.target=this.target.clone(),a.intensity=this.intensity,a.distance=this.distance,a.angle=this.angle,a.exponent=this.exponent,a.castShadow=this.castShadow,a.onlyShadow=this.onlyShadow,a.shadowCameraNear=this.shadowCameraNear,a.shadowCameraFar=this.shadowCameraFar,a.shadowCameraFov=this.shadowCameraFov,a.shadowCameraVisible=this.shadowCameraVisible,a.shadowBias=this.shadowBias,a.shadowDarkness=this.shadowDarkness,a.shadowMapWidth=this.shadowMapWidth,a.shadowMapHeight=this.shadowMapHeight,a},THREE.Cache=function(){this.files={}},THREE.Cache.prototype={constructor:THREE.Cache,add:function(a,b){this.files[a]=b},get:function(a){return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}},THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null,this.imageLoader=new THREE.ImageLoader,this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}},THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:void 0,addStatusElement:function(){var a=document.createElement("div");return a.style.position="absolute",a.style.right="0px",a.style.top="0px",a.style.fontSize="0.8em",a.style.textAlign="left",a.style.background="rgba(0,0,0,0.25)",a.style.color="#fff",a.style.width="120px",a.style.padding="0.5em 0.5em 0.5em 0.5em",a.style.zIndex=1e3,a.innerHTML="Loading ...",a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/a.total).toFixed(0)+"%"):b+((a.loaded/1024).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){return a=a.split("/"),1===a.length?"./":(a.pop(),a.join("/")+"/")},initMaterials:function(a,b){for(var c=[],d=0;d<a.length;++d)c[d]=this.createMaterial(a[d],b);return c},needsTangents:function(a){for(var b=0,c=a.length;b<c;b++)if(a[b]instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){return a=Math.log(a)/Math.LN2,Math.pow(2,Math.round(a))}function d(a,d,e,g,h,k,s){var v,u=b+e,y=THREE.Loader.Handlers.get(u);null!==y?v=y.load(u):(v=new THREE.Texture,y=f.imageLoader,y.crossOrigin=f.crossOrigin,y.load(u,function(a){if(!1===THREE.Math.isPowerOfTwo(a.width)||!1===THREE.Math.isPowerOfTwo(a.height)){var b=c(a.width),d=c(a.height),e=document.createElement("canvas");e.width=b,e.height=d,e.getContext("2d").drawImage(a,0,0,b,d),v.image=e}else v.image=a;v.needsUpdate=!0})),v.sourceFile=e,g&&(v.repeat.set(g[0],g[1]),1!==g[0]&&(v.wrapS=THREE.RepeatWrapping),1!==g[1]&&(v.wrapT=THREE.RepeatWrapping)),h&&v.offset.set(h[0],h[1]),k&&(e={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping},void 0!==e[k[0]]&&(v.wrapS=e[k[0]]),void 0!==e[k[1]]&&(v.wrapT=e[k[1]])),s&&(v.anisotropy=s),a[d]=v}function e(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]}var f=this,g="MeshLambertMaterial",h={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:!1};if(a.shading){var k=a.shading.toLowerCase();"phong"===k?g="MeshPhongMaterial":"basic"===k&&(g="MeshBasicMaterial")}return void 0!==a.blending&&void 0!==THREE[a.blending]&&(h.blending=THREE[a.blending]),(void 0!==a.transparent||1>a.opacity)&&(h.transparent=a.transparent),void 0!==a.depthTest&&(h.depthTest=a.depthTest),void 0!==a.depthWrite&&(h.depthWrite=a.depthWrite),void 0!==a.visible&&(h.visible=a.visible),void 0!==a.flipSided&&(h.side=THREE.BackSide),void 0!==a.doubleSided&&(h.side=THREE.DoubleSide),void 0!==a.wireframe&&(h.wireframe=a.wireframe),void 0!==a.vertexColors&&("face"===a.vertexColors?h.vertexColors=THREE.FaceColors:a.vertexColors&&(h.vertexColors=THREE.VertexColors)),a.colorDiffuse?h.color=e(a.colorDiffuse):a.DbgColor&&(h.color=a.DbgColor),a.colorSpecular&&(h.specular=e(a.colorSpecular)),a.colorAmbient&&(h.ambient=e(a.colorAmbient)),a.colorEmissive&&(h.emissive=e(a.colorEmissive)),a.transparency&&(h.opacity=a.transparency),a.specularCoef&&(h.shininess=a.specularCoef),a.mapDiffuse&&b&&d(h,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy),a.mapLight&&b&&d(h,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy),a.mapBump&&b&&d(h,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy),a.mapNormal&&b&&d(h,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy),a.mapSpecular&&b&&d(h,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy),a.mapAlpha&&b&&d(h,"alphaMap",a.mapAlpha,a.mapAlphaRepeat,a.mapAlphaOffset,a.mapAlphaWrap,a.mapAlphaAnisotropy),
a.mapBumpScale&&(h.bumpScale=a.mapBumpScale),a.mapNormal?(g=THREE.ShaderLib.normalmap,k=THREE.UniformsUtils.clone(g.uniforms),k.tNormal.value=h.normalMap,a.mapNormalFactor&&k.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor),h.map&&(k.tDiffuse.value=h.map,k.enableDiffuse.value=!0),h.specularMap&&(k.tSpecular.value=h.specularMap,k.enableSpecular.value=!0),h.lightMap&&(k.tAO.value=h.lightMap,k.enableAO.value=!0),k.diffuse.value.setHex(h.color),k.specular.value.setHex(h.specular),k.ambient.value.setHex(h.ambient),k.shininess.value=h.shininess,void 0!==h.opacity&&(k.opacity.value=h.opacity),g=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:k,lights:!0,fog:!0}),h.transparent&&(g.transparent=!0)):g=new THREE[g](h),void 0!==a.DbgName&&(g.name=a.DbgName),g}},THREE.Loader.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=0,c=this.handlers.length;b<c;b+=2){var d=this.handlers[b+1];if(this.handlers[b].test(a))return d}return null}},THREE.XHRLoader=function(a){this.cache=new THREE.Cache,this.manager=void 0!==a?a:THREE.DefaultLoadingManager},THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(a,b,c,d){var e=this,f=e.cache.get(a);void 0!==f?b&&b(f):(f=new XMLHttpRequest,f.open("GET",a,!0),f.addEventListener("load",function(c){e.cache.add(a,this.response),b&&b(this.response),e.manager.itemEnd(a)},!1),void 0!==c&&f.addEventListener("progress",function(a){c(a)},!1),void 0!==d&&f.addEventListener("error",function(a){d(a)},!1),void 0!==this.crossOrigin&&(f.crossOrigin=this.crossOrigin),void 0!==this.responseType&&(f.responseType=this.responseType),f.send(null),e.manager.itemStart(a))},setResponseType:function(a){this.responseType=a},setCrossOrigin:function(a){this.crossOrigin=a}},THREE.ImageLoader=function(a){this.cache=new THREE.Cache,this.manager=void 0!==a?a:THREE.DefaultLoadingManager},THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b,c,d){var e=this,f=e.cache.get(a);return void 0===f?(f=document.createElement("img"),void 0!==b&&f.addEventListener("load",function(c){e.cache.add(a,this),b(this),e.manager.itemEnd(a)},!1),void 0!==c&&f.addEventListener("progress",function(a){c(a)},!1),void 0!==d&&f.addEventListener("error",function(a){d(a)},!1),void 0!==this.crossOrigin&&(f.crossOrigin=this.crossOrigin),f.src=a,e.manager.itemStart(a),f):void b(f)},setCrossOrigin:function(a){this.crossOrigin=a}},THREE.JSONLoader=function(a){THREE.Loader.call(this,a),this.withCredentials=!1},THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype),THREE.JSONLoader.prototype.load=function(a,b,c){c=c&&"string"==typeof c?c:this.extractUrlBase(a),this.onLoadStart(),this.loadAjaxJSON(this,a,b,c)},THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.onreadystatechange=function(){if(f.readyState===f.DONE)if(200===f.status||0===f.status){if(f.responseText){var h=JSON.parse(f.responseText);if(void 0!==h.metadata&&"scene"===h.metadata.type)return void console.error('THREE.JSONLoader: "'+b+'" seems to be a Scene. Use THREE.SceneLoader instead.');h=a.parse(h,d),c(h.geometry,h.materials)}else console.error('THREE.JSONLoader: "'+b+'" seems to be unreachable or the file is empty.');a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load \""+b+'" ('+f.status+")");else f.readyState===f.LOADING?e&&(0===g&&(g=f.getResponseHeader("Content-Length")),e({total:g,loaded:f.responseText.length})):f.readyState===f.HEADERS_RECEIVED&&void 0!==e&&(g=f.getResponseHeader("Content-Length"))},f.open("GET",b,!0),f.withCredentials=this.withCredentials,f.send(null)},THREE.JSONLoader.prototype.parse=function(a,b){var c=new THREE.Geometry,d=void 0!==a.scale?1/a.scale:1;return function(b){var d,g,h,k,n,p,q,m,r,t,s,u,v,y=a.faces;p=a.vertices;var G=a.normals,w=a.colors,K=0;if(void 0!==a.uvs){for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&K++;for(d=0;d<K;d++)c.faceVertexUvs[d]=[]}for(k=0,n=p.length;k<n;)d=new THREE.Vector3,d.x=p[k++]*b,d.y=p[k++]*b,d.z=p[k++]*b,c.vertices.push(d);for(k=0,n=y.length;k<n;)if(b=y[k++],r=1&b,h=2&b,d=8&b,q=16&b,t=32&b,p=64&b,b&=128,r){if(r=new THREE.Face3,r.a=y[k],r.b=y[k+1],r.c=y[k+3],s=new THREE.Face3,s.a=y[k+1],s.b=y[k+2],s.c=y[k+3],k+=4,h&&(h=y[k++],r.materialIndex=h,s.materialIndex=h),h=c.faces.length,d)for(d=0;d<K;d++)for(u=a.uvs[d],c.faceVertexUvs[d][h]=[],c.faceVertexUvs[d][h+1]=[],g=0;4>g;g++)m=y[k++],v=u[2*m],m=u[2*m+1],v=new THREE.Vector2(v,m),2!==g&&c.faceVertexUvs[d][h].push(v),0!==g&&c.faceVertexUvs[d][h+1].push(v);if(q&&(q=3*y[k++],r.normal.set(G[q++],G[q++],G[q]),s.normal.copy(r.normal)),t)for(d=0;4>d;d++)q=3*y[k++],t=new THREE.Vector3(G[q++],G[q++],G[q]),2!==d&&r.vertexNormals.push(t),0!==d&&s.vertexNormals.push(t);if(p&&(p=y[k++],p=w[p],r.color.setHex(p),s.color.setHex(p)),b)for(d=0;4>d;d++)p=y[k++],p=w[p],2!==d&&r.vertexColors.push(new THREE.Color(p)),0!==d&&s.vertexColors.push(new THREE.Color(p));c.faces.push(r),c.faces.push(s)}else{if(r=new THREE.Face3,r.a=y[k++],r.b=y[k++],r.c=y[k++],h&&(h=y[k++],r.materialIndex=h),h=c.faces.length,d)for(d=0;d<K;d++)for(u=a.uvs[d],c.faceVertexUvs[d][h]=[],g=0;3>g;g++)m=y[k++],v=u[2*m],m=u[2*m+1],v=new THREE.Vector2(v,m),c.faceVertexUvs[d][h].push(v);if(q&&(q=3*y[k++],r.normal.set(G[q++],G[q++],G[q])),t)for(d=0;3>d;d++)q=3*y[k++],t=new THREE.Vector3(G[q++],G[q++],G[q]),r.vertexNormals.push(t);if(p&&(p=y[k++],r.color.setHex(w[p])),b)for(d=0;3>d;d++)p=y[k++],r.vertexColors.push(new THREE.Color(w[p]));c.faces.push(r)}}(d),function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;d<g;d+=b)c.skinWeights.push(new THREE.Vector4(a.skinWeights[d],1<b?a.skinWeights[d+1]:0,2<b?a.skinWeights[d+2]:0,3<b?a.skinWeights[d+3]:0));if(a.skinIndices)for(d=0,g=a.skinIndices.length;d<g;d+=b)c.skinIndices.push(new THREE.Vector4(a.skinIndices[d],1<b?a.skinIndices[d+1]:0,2<b?a.skinIndices[d+2]:0,3<b?a.skinIndices[d+3]:0));c.bones=a.bones,c.bones&&0<c.bones.length&&(c.skinWeights.length!==c.skinIndices.length||c.skinIndices.length!==c.vertices.length)&&console.warn("When skinning, number of vertices ("+c.vertices.length+"), skinIndices ("+c.skinIndices.length+"), and skinWeights ("+c.skinWeights.length+") should match."),c.animation=a.animation,c.animations=a.animations}(),function(b){if(void 0!==a.morphTargets){var d,g,h,k,n,p;for(d=0,g=a.morphTargets.length;d<g;d++)for(c.morphTargets[d]={},c.morphTargets[d].name=a.morphTargets[d].name,c.morphTargets[d].vertices=[],n=c.morphTargets[d].vertices,p=a.morphTargets[d].vertices,h=0,k=p.length;h<k;h+=3){var q=new THREE.Vector3;q.x=p[h]*b,q.y=p[h+1]*b,q.z=p[h+2]*b,n.push(q)}}if(void 0!==a.morphColors)for(d=0,g=a.morphColors.length;d<g;d++)for(c.morphColors[d]={},c.morphColors[d].name=a.morphColors[d].name,c.morphColors[d].colors=[],k=c.morphColors[d].colors,n=a.morphColors[d].colors,b=0,h=n.length;b<h;b+=3)p=new THREE.Color(16755200),p.setRGB(n[b],n[b+1],n[b+2]),k.push(p)}(d),c.computeFaceNormals(),c.computeBoundingSphere(),void 0===a.materials||0===a.materials.length?{geometry:c}:(d=this.initMaterials(a.materials,b),this.needsTangents(d)&&c.computeTangents(),{geometry:c,materials:d})},THREE.LoadingManager=function(a,b,c){var d=this,e=0,f=0;this.onLoad=a,this.onProgress=b,this.onError=c,this.itemStart=function(a){f++},this.itemEnd=function(a){e++,void 0!==d.onProgress&&d.onProgress(a,e,f),e===f&&void 0!==d.onLoad&&d.onLoad()}},THREE.DefaultLoadingManager=new THREE.LoadingManager,THREE.BufferGeometryLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager},THREE.BufferGeometryLoader.prototype={constructor:THREE.BufferGeometryLoader,load:function(a,b,c,d){var e=this,f=new THREE.XHRLoader;f.setCrossOrigin(this.crossOrigin),f.load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setCrossOrigin:function(a){this.crossOrigin=a},parse:function(a){var d,b=new THREE.BufferGeometry,c=a.attributes;for(d in c){var e=c[d],f=new self[e.type](e.array);b.addAttribute(d,new THREE.BufferAttribute(f,e.itemSize))}return c=a.offsets,void 0!==c&&(b.offsets=JSON.parse(JSON.stringify(c))),a=a.boundingSphere,void 0!==a&&(c=new THREE.Vector3,void 0!==a.center&&c.fromArray(a.center),b.boundingSphere=new THREE.Sphere(c,a.radius)),b}},THREE.MaterialLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager},THREE.MaterialLoader.prototype={constructor:THREE.MaterialLoader,load:function(a,b,c,d){var e=this,f=new THREE.XHRLoader;f.setCrossOrigin(this.crossOrigin),f.load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setCrossOrigin:function(a){this.crossOrigin=a},parse:function(a){var b=new THREE[a.type];if(void 0!==a.color&&b.color.setHex(a.color),void 0!==a.ambient&&b.ambient.setHex(a.ambient),void 0!==a.emissive&&b.emissive.setHex(a.emissive),void 0!==a.specular&&b.specular.setHex(a.specular),void 0!==a.shininess&&(b.shininess=a.shininess),void 0!==a.uniforms&&(b.uniforms=a.uniforms),void 0!==a.vertexShader&&(b.vertexShader=a.vertexShader),void 0!==a.fragmentShader&&(b.fragmentShader=a.fragmentShader),void 0!==a.vertexColors&&(b.vertexColors=a.vertexColors),void 0!==a.shading&&(b.shading=a.shading),void 0!==a.blending&&(b.blending=a.blending),void 0!==a.side&&(b.side=a.side),void 0!==a.opacity&&(b.opacity=a.opacity),void 0!==a.transparent&&(b.transparent=a.transparent),void 0!==a.wireframe&&(b.wireframe=a.wireframe),void 0!==a.materials)for(var c=0,d=a.materials.length;c<d;c++)b.materials.push(this.parse(a.materials[c]));return b}},THREE.ObjectLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager},THREE.ObjectLoader.prototype={constructor:THREE.ObjectLoader,load:function(a,b,c,d){var e=this,f=new THREE.XHRLoader(e.manager);f.setCrossOrigin(this.crossOrigin),f.load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setCrossOrigin:function(a){this.crossOrigin=a},parse:function(a){var b=this.parseGeometries(a.geometries),c=this.parseMaterials(a.materials);return this.parseObject(a.object,b,c)},parseGeometries:function(a){var b={};if(void 0!==a)for(var c=new THREE.JSONLoader,d=new THREE.BufferGeometryLoader,e=0,f=a.length;e<f;e++){var g,h=a[e];switch(h.type){case"PlaneGeometry":g=new THREE.PlaneGeometry(h.width,h.height,h.widthSegments,h.heightSegments);break;case"BoxGeometry":case"CubeGeometry":g=new THREE.BoxGeometry(h.width,h.height,h.depth,h.widthSegments,h.heightSegments,h.depthSegments);break;case"CircleGeometry":g=new THREE.CircleGeometry(h.radius,h.segments);break;case"CylinderGeometry":g=new THREE.CylinderGeometry(h.radiusTop,h.radiusBottom,h.height,h.radialSegments,h.heightSegments,h.openEnded);break;case"SphereGeometry":g=new THREE.SphereGeometry(h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case"IcosahedronGeometry":g=new THREE.IcosahedronGeometry(h.radius,h.detail);break;case"TorusGeometry":g=new THREE.TorusGeometry(h.radius,h.tube,h.radialSegments,h.tubularSegments,h.arc);break;case"TorusKnotGeometry":g=new THREE.TorusKnotGeometry(h.radius,h.tube,h.radialSegments,h.tubularSegments,h.p,h.q,h.heightScale);break;case"BufferGeometry":g=d.parse(h.data);break;case"Geometry":g=c.parse(h.data).geometry}g.uuid=h.uuid,void 0!==h.name&&(g.name=h.name),b[h.uuid]=g}return b},parseMaterials:function(a){var b={};if(void 0!==a)for(var c=new THREE.MaterialLoader,d=0,e=a.length;d<e;d++){var f=a[d],g=c.parse(f);g.uuid=f.uuid,void 0!==f.name&&(g.name=f.name),b[f.uuid]=g}return b},parseObject:function(){var a=new THREE.Matrix4;return function(b,c,d){var e;switch(b.type){case"Scene":e=new THREE.Scene;break;case"PerspectiveCamera":e=new THREE.PerspectiveCamera(b.fov,b.aspect,b.near,b.far);break;case"OrthographicCamera":e=new THREE.OrthographicCamera(b.left,b.right,b.top,b.bottom,b.near,b.far);break;case"AmbientLight":e=new THREE.AmbientLight(b.color);break;case"DirectionalLight":e=new THREE.DirectionalLight(b.color,b.intensity);break;case"PointLight":e=new THREE.PointLight(b.color,b.intensity,b.distance);break;case"SpotLight":e=new THREE.SpotLight(b.color,b.intensity,b.distance,b.angle,b.exponent);break;case"HemisphereLight":e=new THREE.HemisphereLight(b.color,b.groundColor,b.intensity);break;case"Mesh":e=c[b.geometry];var f=d[b.material];void 0===e&&console.warn("THREE.ObjectLoader: Undefined geometry",b.geometry),void 0===f&&console.warn("THREE.ObjectLoader: Undefined material",b.material),e=new THREE.Mesh(e,f);break;case"Line":e=c[b.geometry],f=d[b.material],void 0===e&&console.warn("THREE.ObjectLoader: Undefined geometry",b.geometry),void 0===f&&console.warn("THREE.ObjectLoader: Undefined material",b.material),e=new THREE.Line(e,f);break;case"Sprite":f=d[b.material],void 0===f&&console.warn("THREE.ObjectLoader: Undefined material",b.material),e=new THREE.Sprite(f);break;case"Group":e=new THREE.Group;break;default:e=new THREE.Object3D}if(e.uuid=b.uuid,void 0!==b.name&&(e.name=b.name),void 0!==b.matrix?(a.fromArray(b.matrix),a.decompose(e.position,e.quaternion,e.scale)):(void 0!==b.position&&e.position.fromArray(b.position),void 0!==b.rotation&&e.rotation.fromArray(b.rotation),void 0!==b.scale&&e.scale.fromArray(b.scale)),void 0!==b.visible&&(e.visible=b.visible),void 0!==b.userData&&(e.userData=b.userData),void 0!==b.children)for(var g in b.children)e.add(this.parseObject(b.children[g],c,d));return e}}()},THREE.TextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager},THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a,b,c,d){var e=new THREE.ImageLoader(this.manager);e.setCrossOrigin(this.crossOrigin),e.load(a,function(a){a=new THREE.Texture(a),a.needsUpdate=!0,void 0!==b&&b(a)},c,d)},setCrossOrigin:function(a){this.crossOrigin=a}},THREE.CompressedTextureLoader=function(){this._parser=null},THREE.CompressedTextureLoader.prototype={constructor:THREE.CompressedTextureLoader,load:function(a,b,c){var d=this,e=[],f=new THREE.CompressedTexture;f.image=e;var g=new THREE.XHRLoader;if(g.setResponseType("arraybuffer"),a instanceof Array){var h=0;c=function(c){g.load(a[c],function(a){a=d._parser(a,!0),e[c]={width:a.width,height:a.height,format:a.format,mipmaps:a.mipmaps},h+=1,6===h&&(1==a.mipmapCount&&(f.minFilter=THREE.LinearFilter),f.format=a.format,f.needsUpdate=!0,b&&b(f))})};for(var k=0,n=a.length;k<n;++k)c(k)}else g.load(a,function(a){if(a=d._parser(a,!0),a.isCubemap)for(var c=a.mipmaps.length/a.mipmapCount,g=0;g<c;g++){e[g]={mipmaps:[]};for(var h=0;h<a.mipmapCount;h++)e[g].mipmaps.push(a.mipmaps[g*a.mipmapCount+h]),e[g].format=a.format,e[g].width=a.width,e[g].height=a.height}else f.image.width=a.width,f.image.height=a.height,f.mipmaps=a.mipmaps;1===a.mipmapCount&&(f.minFilter=THREE.LinearFilter),f.format=a.format,f.needsUpdate=!0,b&&b(f)});return f}},THREE.Material=function(){Object.defineProperty(this,"id",{value:THREE.MaterialIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.type="Material",this.side=THREE.FrontSide,this.opacity=1,this.transparent=!1,this.blending=THREE.NormalBlending,this.blendSrc=THREE.SrcAlphaFactor,this.blendDst=THREE.OneMinusSrcAlphaFactor,this.blendEquation=THREE.AddEquation,this.depthWrite=this.depthTest=!0,this.polygonOffset=!1,this.overdraw=this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0,this.needsUpdate=this.visible=!0},THREE.Material.prototype={constructor:THREE.Material,setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else if(b in this){var d=this[b];d instanceof THREE.Color?d.set(c):d instanceof THREE.Vector3&&c instanceof THREE.Vector3?d.copy(c):this[b]="overdraw"==b?Number(c):c}}},toJSON:function(){var a={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type};return""!==this.name&&(a.name=this.name),this instanceof THREE.MeshBasicMaterial?(a.color=this.color.getHex(),this.vertexColors!==THREE.NoColors&&(a.vertexColors=this.vertexColors),this.blending!==THREE.NormalBlending&&(a.blending=this.blending),this.side!==THREE.FrontSide&&(a.side=this.side)):this instanceof THREE.MeshLambertMaterial?(a.color=this.color.getHex(),a.ambient=this.ambient.getHex(),a.emissive=this.emissive.getHex(),this.vertexColors!==THREE.NoColors&&(a.vertexColors=this.vertexColors),this.blending!==THREE.NormalBlending&&(a.blending=this.blending),this.side!==THREE.FrontSide&&(a.side=this.side)):this instanceof THREE.MeshPhongMaterial?(a.color=this.color.getHex(),a.ambient=this.ambient.getHex(),a.emissive=this.emissive.getHex(),a.specular=this.specular.getHex(),a.shininess=this.shininess,this.vertexColors!==THREE.NoColors&&(a.vertexColors=this.vertexColors),this.blending!==THREE.NormalBlending&&(a.blending=this.blending),this.side!==THREE.FrontSide&&(a.side=this.side)):this instanceof THREE.MeshNormalMaterial?(this.shading!==THREE.FlatShading&&(a.shading=this.shading),this.blending!==THREE.NormalBlending&&(a.blending=this.blending),this.side!==THREE.FrontSide&&(a.side=this.side)):this instanceof THREE.MeshDepthMaterial?(this.blending!==THREE.NormalBlending&&(a.blending=this.blending),this.side!==THREE.FrontSide&&(a.side=this.side)):this instanceof THREE.ShaderMaterial?(a.uniforms=this.uniforms,a.vertexShader=this.vertexShader,a.fragmentShader=this.fragmentShader):this instanceof THREE.SpriteMaterial&&(a.color=this.color.getHex()),1>this.opacity&&(a.opacity=this.opacity),!1!==this.transparent&&(a.transparent=this.transparent),!1!==this.wireframe&&(a.wireframe=this.wireframe),a},clone:function(a){return void 0===a&&(a=new THREE.Material),a.name=this.name,a.side=this.side,a.opacity=this.opacity,a.transparent=this.transparent,a.blending=this.blending,a.blendSrc=this.blendSrc,a.blendDst=this.blendDst,a.blendEquation=this.blendEquation,a.depthTest=this.depthTest,a.depthWrite=this.depthWrite,a.polygonOffset=this.polygonOffset,a.polygonOffsetFactor=this.polygonOffsetFactor,a.polygonOffsetUnits=this.polygonOffsetUnits,a.alphaTest=this.alphaTest,a.overdraw=this.overdraw,a.visible=this.visible,a},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.Material.prototype),THREE.MaterialIdCount=0,THREE.LineBasicMaterial=function(a){THREE.Material.call(this),this.type="LineBasicMaterial",this.color=new THREE.Color(16777215),this.linewidth=1,this.linejoin=this.linecap="round",this.vertexColors=THREE.NoColors,this.fog=!0,this.setValues(a)},THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype),THREE.LineBasicMaterial.prototype.clone=function(){var a=new THREE.LineBasicMaterial;return THREE.Material.prototype.clone.call(this,a),a.color.copy(this.color),a.linewidth=this.linewidth,a.linecap=this.linecap,a.linejoin=this.linejoin,a.vertexColors=this.vertexColors,a.fog=this.fog,a},THREE.LineDashedMaterial=function(a){THREE.Material.call(this),this.type="LineDashedMaterial",this.color=new THREE.Color(16777215),this.scale=this.linewidth=1,this.dashSize=3,this.gapSize=1,this.vertexColors=!1,this.fog=!0,this.setValues(a)},THREE.LineDashedMaterial.prototype=Object.create(THREE.Material.prototype),THREE.LineDashedMaterial.prototype.clone=function(){var a=new THREE.LineDashedMaterial;return THREE.Material.prototype.clone.call(this,a),a.color.copy(this.color),a.linewidth=this.linewidth,a.scale=this.scale,a.dashSize=this.dashSize,a.gapSize=this.gapSize,a.vertexColors=this.vertexColors,a.fog=this.fog,a},THREE.MeshBasicMaterial=function(a){THREE.Material.call(this),this.type="MeshBasicMaterial",this.color=new THREE.Color(16777215),this.envMap=this.alphaMap=this.specularMap=this.lightMap=this.map=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=THREE.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.vertexColors=THREE.NoColors,this.morphTargets=this.skinning=!1,this.setValues(a)},THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshBasicMaterial.prototype.clone=function(){var a=new THREE.MeshBasicMaterial;return THREE.Material.prototype.clone.call(this,a),a.color.copy(this.color),a.map=this.map,a.lightMap=this.lightMap,a.specularMap=this.specularMap,a.alphaMap=this.alphaMap,a.envMap=this.envMap,a.combine=this.combine,a.reflectivity=this.reflectivity,a.refractionRatio=this.refractionRatio,a.fog=this.fog,a.shading=this.shading,a.wireframe=this.wireframe,a.wireframeLinewidth=this.wireframeLinewidth,a.wireframeLinecap=this.wireframeLinecap,a.wireframeLinejoin=this.wireframeLinejoin,a.vertexColors=this.vertexColors,a.skinning=this.skinning,a.morphTargets=this.morphTargets,a},THREE.MeshLambertMaterial=function(a){THREE.Material.call(this),this.type="MeshLambertMaterial",this.color=new THREE.Color(16777215),this.ambient=new THREE.Color(16777215),this.emissive=new THREE.Color(0),this.wrapAround=!1,this.wrapRGB=new THREE.Vector3(1,1,1),this.envMap=this.alphaMap=this.specularMap=this.lightMap=this.map=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=THREE.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.vertexColors=THREE.NoColors,this.morphNormals=this.morphTargets=this.skinning=!1,this.setValues(a)},THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshLambertMaterial.prototype.clone=function(){var a=new THREE.MeshLambertMaterial;return THREE.Material.prototype.clone.call(this,a),a.color.copy(this.color),a.ambient.copy(this.ambient),a.emissive.copy(this.emissive),a.wrapAround=this.wrapAround,a.wrapRGB.copy(this.wrapRGB),a.map=this.map,a.lightMap=this.lightMap,a.specularMap=this.specularMap,a.alphaMap=this.alphaMap,a.envMap=this.envMap,a.combine=this.combine,a.reflectivity=this.reflectivity,a.refractionRatio=this.refractionRatio,a.fog=this.fog,a.shading=this.shading,a.wireframe=this.wireframe,a.wireframeLinewidth=this.wireframeLinewidth,a.wireframeLinecap=this.wireframeLinecap,a.wireframeLinejoin=this.wireframeLinejoin,a.vertexColors=this.vertexColors,a.skinning=this.skinning,a.morphTargets=this.morphTargets,a.morphNormals=this.morphNormals,a},THREE.MeshPhongMaterial=function(a){THREE.Material.call(this),this.type="MeshPhongMaterial",this.color=new THREE.Color(16777215),this.ambient=new THREE.Color(16777215),this.emissive=new THREE.Color(0),this.specular=new THREE.Color(1118481),this.shininess=30,this.wrapAround=this.metal=!1,this.wrapRGB=new THREE.Vector3(1,1,1),this.bumpMap=this.lightMap=this.map=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new THREE.Vector2(1,1),this.envMap=this.alphaMap=this.specularMap=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=THREE.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.vertexColors=THREE.NoColors,this.morphNormals=this.morphTargets=this.skinning=!1,this.setValues(a)},THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshPhongMaterial.prototype.clone=function(){var a=new THREE.MeshPhongMaterial;return THREE.Material.prototype.clone.call(this,a),a.color.copy(this.color),a.ambient.copy(this.ambient),a.emissive.copy(this.emissive),a.specular.copy(this.specular),a.shininess=this.shininess,a.metal=this.metal,a.wrapAround=this.wrapAround,a.wrapRGB.copy(this.wrapRGB),a.map=this.map,a.lightMap=this.lightMap,a.bumpMap=this.bumpMap,a.bumpScale=this.bumpScale,a.normalMap=this.normalMap,a.normalScale.copy(this.normalScale),a.specularMap=this.specularMap,a.alphaMap=this.alphaMap,a.envMap=this.envMap,a.combine=this.combine,a.reflectivity=this.reflectivity,a.refractionRatio=this.refractionRatio,a.fog=this.fog,a.shading=this.shading,a.wireframe=this.wireframe,a.wireframeLinewidth=this.wireframeLinewidth,a.wireframeLinecap=this.wireframeLinecap,a.wireframeLinejoin=this.wireframeLinejoin,a.vertexColors=this.vertexColors,a.skinning=this.skinning,a.morphTargets=this.morphTargets,a.morphNormals=this.morphNormals,a},THREE.MeshDepthMaterial=function(a){THREE.Material.call(this),this.type="MeshDepthMaterial",this.wireframe=this.morphTargets=!1,this.wireframeLinewidth=1,this.setValues(a)},THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshDepthMaterial.prototype.clone=function(){var a=new THREE.MeshDepthMaterial;return THREE.Material.prototype.clone.call(this,a),a.wireframe=this.wireframe,a.wireframeLinewidth=this.wireframeLinewidth,a},THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a),this.type="MeshNormalMaterial",this.shading=THREE.FlatShading,this.wireframe=!1,this.wireframeLinewidth=1,this.morphTargets=!1,this.setValues(a)},THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshNormalMaterial.prototype.clone=function(){var a=new THREE.MeshNormalMaterial;return THREE.Material.prototype.clone.call(this,a),a.shading=this.shading,a.wireframe=this.wireframe,a.wireframeLinewidth=this.wireframeLinewidth,a},THREE.MeshFaceMaterial=function(a){this.uuid=THREE.Math.generateUUID(),this.type="MeshFaceMaterial",this.materials=a instanceof Array?a:[]},THREE.MeshFaceMaterial.prototype={constructor:THREE.MeshFaceMaterial,toJSON:function(){for(var a={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},b=0,c=this.materials.length;b<c;b++)a.materials.push(this.materials[b].toJSON());return a},clone:function(){for(var a=new THREE.MeshFaceMaterial,b=0;b<this.materials.length;b++)a.materials.push(this.materials[b].clone());return a}},THREE.PointCloudMaterial=function(a){THREE.Material.call(this),this.type="PointCloudMaterial",this.color=new THREE.Color(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.vertexColors=THREE.NoColors,this.fog=!0,this.setValues(a)},THREE.PointCloudMaterial.prototype=Object.create(THREE.Material.prototype),THREE.PointCloudMaterial.prototype.clone=function(){var a=new THREE.PointCloudMaterial;return THREE.Material.prototype.clone.call(this,a),a.color.copy(this.color),a.map=this.map,a.size=this.size,a.sizeAttenuation=this.sizeAttenuation,a.vertexColors=this.vertexColors,a.fog=this.fog,a},THREE.ParticleBasicMaterial=function(a){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointCloudMaterial."),new THREE.PointCloudMaterial(a)},THREE.ParticleSystemMaterial=function(a){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointCloudMaterial."),new THREE.PointCloudMaterial(a)},THREE.ShaderMaterial=function(a){THREE.Material.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.attributes=null,this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.shading=THREE.SmoothShading,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.lights=this.fog=!1,this.vertexColors=THREE.NoColors,this.morphNormals=this.morphTargets=this.skinning=!1,this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.setValues(a)},THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype),THREE.ShaderMaterial.prototype.clone=function(){var a=new THREE.ShaderMaterial;return THREE.Material.prototype.clone.call(this,a),a.fragmentShader=this.fragmentShader,a.vertexShader=this.vertexShader,a.uniforms=THREE.UniformsUtils.clone(this.uniforms),a.attributes=this.attributes,a.defines=this.defines,a.shading=this.shading,a.wireframe=this.wireframe,a.wireframeLinewidth=this.wireframeLinewidth,a.fog=this.fog,a.lights=this.lights,a.vertexColors=this.vertexColors,a.skinning=this.skinning,a.morphTargets=this.morphTargets,a.morphNormals=this.morphNormals,a},THREE.RawShaderMaterial=function(a){THREE.ShaderMaterial.call(this,a),this.type="RawShaderMaterial"},THREE.RawShaderMaterial.prototype=Object.create(THREE.ShaderMaterial.prototype),THREE.RawShaderMaterial.prototype.clone=function(){var a=new THREE.RawShaderMaterial;return THREE.ShaderMaterial.prototype.clone.call(this,a),a},THREE.SpriteMaterial=function(a){THREE.Material.call(this),this.type="SpriteMaterial",this.color=new THREE.Color(16777215),this.map=null,this.rotation=0,this.fog=!1,this.setValues(a)},THREE.SpriteMaterial.prototype=Object.create(THREE.Material.prototype),THREE.SpriteMaterial.prototype.clone=function(){var a=new THREE.SpriteMaterial;return THREE.Material.prototype.clone.call(this,a),a.color.copy(this.color),a.map=this.map,a.rotation=this.rotation,a.fog=this.fog,a},THREE.Texture=function(a,b,c,d,e,f,g,h,k){Object.defineProperty(this,"id",{value:THREE.TextureIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.image=void 0!==a?a:THREE.Texture.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==b?b:THREE.Texture.DEFAULT_MAPPING,this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping,this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping,this.magFilter=void 0!==e?e:THREE.LinearFilter,this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter,this.anisotropy=void 0!==k?k:1,this.format=void 0!==g?g:THREE.RGBAFormat,this.type=void 0!==h?h: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.DEFAULT_IMAGE=void 0,THREE.Texture.DEFAULT_MAPPING=new THREE.UVMapping,THREE.Texture.prototype={constructor:THREE.Texture,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update(),this._needsUpdate=a},clone:function(a){return void 0===a&&(a=new THREE.Texture),a.image=this.image,a.mipmaps=this.mipmaps.slice(0),a.mapping=this.mapping,a.wrapS=this.wrapS,a.wrapT=this.wrapT,a.magFilter=this.magFilter,a.minFilter=this.minFilter,a.anisotropy=this.anisotropy,a.format=this.format,a.type=this.type,a.offset.copy(this.offset),a.repeat.copy(this.repeat),a.generateMipmaps=this.generateMipmaps,a.premultiplyAlpha=this.premultiplyAlpha,a.flipY=this.flipY,a.unpackAlignment=this.unpackAlignment,a},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype),THREE.TextureIdCount=0,THREE.CubeTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k),this.images=a},THREE.CubeTexture.prototype=Object.create(THREE.Texture.prototype),THREE.CubeTexture.clone=function(a){return void 0===a&&(a=new THREE.CubeTexture),THREE.Texture.prototype.clone.call(this,a),a.images=this.images,a},THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,k,n,p){THREE.Texture.call(this,null,f,g,h,k,n,d,e,p),this.image={width:b,height:c},this.mipmaps=a,this.generateMipmaps=this.flipY=!1},THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype),THREE.CompressedTexture.prototype.clone=function(){var a=new THREE.CompressedTexture;return THREE.Texture.prototype.clone.call(this,a),a},THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,n,p){THREE.Texture.call(this,null,f,g,h,k,n,d,e,p),this.image={data:a,width:b,height:c}},THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype),THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture;return THREE.Texture.prototype.clone.call(this,a),a},THREE.VideoTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k),this.generateMipmaps=!1;var n=this,p=function(){requestAnimationFrame(p),a.readyState===a.HAVE_ENOUGH_DATA&&(n.needsUpdate=!0)};p()},THREE.VideoTexture.prototype=Object.create(THREE.Texture.prototype),THREE.Group=function(){THREE.Object3D.call(this),this.type="Group"},THREE.Group.prototype=Object.create(THREE.Object3D.prototype),THREE.PointCloud=function(a,b){THREE.Object3D.call(this),this.type="PointCloud",this.geometry=void 0!==a?a:new THREE.Geometry,this.material=void 0!==b?b:new THREE.PointCloudMaterial({
color:16777215*Math.random()}),this.sortParticles=!1},THREE.PointCloud.prototype=Object.create(THREE.Object3D.prototype),THREE.PointCloud.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray;return function(c,d){var e=this,f=e.geometry,g=c.params.PointCloud.threshold;if(a.getInverse(this.matrixWorld),b.copy(c.ray).applyMatrix4(a),null===f.boundingBox||!1!==b.isIntersectionBox(f.boundingBox)){var h=g/((this.scale.x+this.scale.y+this.scale.z)/3),k=new THREE.Vector3,g=function(a,f){var g=b.distanceToPoint(a);if(g<h){var k=b.closestPointToPoint(a);k.applyMatrix4(e.matrixWorld);var m=c.ray.origin.distanceTo(k);d.push({distance:m,distanceToRay:g,point:k.clone(),index:f,face:null,object:e})}};if(f instanceof THREE.BufferGeometry){var n=f.attributes,p=n.position.array;if(void 0!==n.index){var n=n.index.array,q=f.offsets;0===q.length&&(q=[{start:0,count:n.length,index:0}]);for(var m=0,r=q.length;m<r;++m)for(var t=q[m].start,s=q[m].index,f=t,t=t+q[m].count;f<t;f++){var u=s+n[f];k.fromArray(p,3*u),g(k,u)}}else for(n=p.length/3,f=0;f<n;f++)k.set(p[3*f],p[3*f+1],p[3*f+2]),g(k,f)}else for(k=this.geometry.vertices,f=0;f<k.length;f++)g(k[f],f)}}}(),THREE.PointCloud.prototype.clone=function(a){return void 0===a&&(a=new THREE.PointCloud(this.geometry,this.material)),a.sortParticles=this.sortParticles,THREE.Object3D.prototype.clone.call(this,a),a},THREE.ParticleSystem=function(a,b){return console.warn("THREE.ParticleSystem has been renamed to THREE.PointCloud."),new THREE.PointCloud(a,b)},THREE.Line=function(a,b,c){THREE.Object3D.call(this),this.type="Line",this.geometry=void 0!==a?a:new THREE.Geometry,this.material=void 0!==b?b:new THREE.LineBasicMaterial({color:16777215*Math.random()}),this.mode=void 0!==c?c:THREE.LineStrip},THREE.LineStrip=0,THREE.LinePieces=1,THREE.Line.prototype=Object.create(THREE.Object3D.prototype),THREE.Line.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere;return function(d,e){var f=d.linePrecision,f=f*f,g=this.geometry;if(null===g.boundingSphere&&g.computeBoundingSphere(),c.copy(g.boundingSphere),c.applyMatrix4(this.matrixWorld),!1!==d.ray.isIntersectionSphere(c)&&(a.getInverse(this.matrixWorld),b.copy(d.ray).applyMatrix4(a),g instanceof THREE.Geometry))for(var g=g.vertices,h=g.length,k=new THREE.Vector3,n=new THREE.Vector3,p=this.mode===THREE.LineStrip?1:2,q=0;q<h-1;q+=p)if(!(b.distanceSqToSegment(g[q],g[q+1],n,k)>f)){var m=b.origin.distanceTo(n);m<d.near||m>d.far||e.push({distance:m,point:k.clone().applyMatrix4(this.matrixWorld),face:null,faceIndex:null,object:this})}}}(),THREE.Line.prototype.clone=function(a){return void 0===a&&(a=new THREE.Line(this.geometry,this.material,this.mode)),THREE.Object3D.prototype.clone.call(this,a),a},THREE.Mesh=function(a,b){THREE.Object3D.call(this),this.type="Mesh",this.geometry=void 0!==a?a:new THREE.Geometry,this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random()}),this.updateMorphTargets()},THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype),THREE.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0<this.geometry.morphTargets.length){this.morphTargetBase=-1,this.morphTargetForcedOrder=[],this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var a=0,b=this.geometry.morphTargets.length;a<b;a++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[a].name]=a}},THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){return void 0!==this.morphTargetDictionary[a]?this.morphTargetDictionary[a]:(console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0."),0)},THREE.Mesh.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3;return function(g,h){var k=this.geometry;if(null===k.boundingSphere&&k.computeBoundingSphere(),c.copy(k.boundingSphere),c.applyMatrix4(this.matrixWorld),!1!==g.ray.isIntersectionSphere(c)&&(a.getInverse(this.matrixWorld),b.copy(g.ray).applyMatrix4(a),null===k.boundingBox||!1!==b.isIntersectionBox(k.boundingBox)))if(k instanceof THREE.BufferGeometry){var n=this.material;if(void 0!==n){var q,m,p=k.attributes,r=g.precision;if(void 0!==p.index){var t=p.index.array,s=p.position.array,u=k.offsets;0===u.length&&(u=[{start:0,count:t.length,index:0}]);for(var v=0,y=u.length;v<y;++v)for(var p=u[v].start,G=u[v].index,k=p,w=p+u[v].count;k<w;k+=3){p=G+t[k],q=G+t[k+1],m=G+t[k+2],d.fromArray(s,3*p),e.fromArray(s,3*q),f.fromArray(s,3*m);var K=n.side===THREE.BackSide?b.intersectTriangle(f,e,d,!0):b.intersectTriangle(d,e,f,n.side!==THREE.DoubleSide);if(null!==K){K.applyMatrix4(this.matrixWorld);var x=g.ray.origin.distanceTo(K);x<r||x<g.near||x>g.far||h.push({distance:x,point:K,face:new THREE.Face3(p,q,m,THREE.Triangle.normal(d,e,f)),faceIndex:null,object:this})}}}else for(s=p.position.array,t=k=0,w=s.length;k<w;k+=3,t+=9)p=k,q=k+1,m=k+2,d.fromArray(s,t),e.fromArray(s,t+3),f.fromArray(s,t+6),K=n.side===THREE.BackSide?b.intersectTriangle(f,e,d,!0):b.intersectTriangle(d,e,f,n.side!==THREE.DoubleSide),null!==K&&(K.applyMatrix4(this.matrixWorld),x=g.ray.origin.distanceTo(K),x<r||x<g.near||x>g.far||h.push({distance:x,point:K,face:new THREE.Face3(p,q,m,THREE.Triangle.normal(d,e,f)),faceIndex:null,object:this}))}}else if(k instanceof THREE.Geometry)for(t=this.material instanceof THREE.MeshFaceMaterial,s=!0===t?this.material.materials:null,r=g.precision,u=k.vertices,v=0,y=k.faces.length;v<y;v++)if(G=k.faces[v],n=!0===t?s[G.materialIndex]:this.material,void 0!==n){if(p=u[G.a],q=u[G.b],m=u[G.c],!0===n.morphTargets){K=k.morphTargets,x=this.morphTargetInfluences,d.set(0,0,0),e.set(0,0,0),f.set(0,0,0);for(var w=0,D=K.length;w<D;w++){var E=x[w];if(0!==E){var A=K[w].vertices;d.x+=(A[G.a].x-p.x)*E,d.y+=(A[G.a].y-p.y)*E,d.z+=(A[G.a].z-p.z)*E,e.x+=(A[G.b].x-q.x)*E,e.y+=(A[G.b].y-q.y)*E,e.z+=(A[G.b].z-q.z)*E,f.x+=(A[G.c].x-m.x)*E,f.y+=(A[G.c].y-m.y)*E,f.z+=(A[G.c].z-m.z)*E}}d.add(p),e.add(q),f.add(m),p=d,q=e,m=f}K=n.side===THREE.BackSide?b.intersectTriangle(m,q,p,!0):b.intersectTriangle(p,q,m,n.side!==THREE.DoubleSide),null!==K&&(K.applyMatrix4(this.matrixWorld),x=g.ray.origin.distanceTo(K),x<r||x<g.near||x>g.far||h.push({distance:x,point:K,face:G,faceIndex:v,object:this}))}}}(),THREE.Mesh.prototype.clone=function(a,b){return void 0===a&&(a=new THREE.Mesh(this.geometry,this.material)),THREE.Object3D.prototype.clone.call(this,a,b),a},THREE.Bone=function(a){THREE.Object3D.call(this),this.skin=a},THREE.Bone.prototype=Object.create(THREE.Object3D.prototype),THREE.Skeleton=function(a,b,c){if(this.useVertexTexture=void 0===c||c,this.identityMatrix=new THREE.Matrix4,a=a||[],this.bones=a.slice(0),this.useVertexTexture?(this.boneTextureHeight=this.boneTextureWidth=a=256<this.bones.length?64:64<this.bones.length?32:16<this.bones.length?16:8,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new THREE.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,THREE.RGBAFormat,THREE.FloatType),this.boneTexture.minFilter=THREE.NearestFilter,this.boneTexture.magFilter=THREE.NearestFilter,this.boneTexture.generateMipmaps=!1,this.boneTexture.flipY=!1):this.boneMatrices=new Float32Array(16*this.bones.length),void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[],b=0,a=this.bones.length;b<a;b++)this.boneInverses.push(new THREE.Matrix4)},THREE.Skeleton.prototype.calculateInverses=function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<b;a++){var c=new THREE.Matrix4;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld),this.boneInverses.push(c)}},THREE.Skeleton.prototype.pose=function(){for(var a,b=0,c=this.bones.length;b<c;b++)(a=this.bones[b])&&a.matrixWorld.getInverse(this.boneInverses[b]);for(b=0,c=this.bones.length;b<c;b++)(a=this.bones[b])&&(a.parent?(a.matrix.getInverse(a.parent.matrixWorld),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale))},THREE.Skeleton.prototype.update=function(){var a=new THREE.Matrix4;return function(){for(var b=0,c=this.bones.length;b<c;b++)a.multiplyMatrices(this.bones[b]?this.bones[b].matrixWorld:this.identityMatrix,this.boneInverses[b]),a.flattenToArrayOffset(this.boneMatrices,16*b);this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}}(),THREE.SkinnedMesh=function(a,b,c){if(THREE.Mesh.call(this,a,b),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new THREE.Matrix4,this.bindMatrixInverse=new THREE.Matrix4,a=[],this.geometry&&void 0!==this.geometry.bones){for(var d,e,f,g,h=0,k=this.geometry.bones.length;h<k;++h)d=this.geometry.bones[h],e=d.pos,f=d.rotq,g=d.scl,b=new THREE.Bone(this),a.push(b),b.name=d.name,b.position.set(e[0],e[1],e[2]),b.quaternion.set(f[0],f[1],f[2],f[3]),void 0!==g?b.scale.set(g[0],g[1],g[2]):b.scale.set(1,1,1);for(h=0,k=this.geometry.bones.length;h<k;++h)d=this.geometry.bones[h],-1!==d.parent?a[d.parent].add(a[h]):this.add(a[h])}this.normalizeSkinWeights(),this.updateMatrixWorld(!0),this.bind(new THREE.Skeleton(a,(void 0),c))},THREE.SkinnedMesh.prototype=Object.create(THREE.Mesh.prototype),THREE.SkinnedMesh.prototype.bind=function(a,b){this.skeleton=a,void 0===b&&(this.updateMatrixWorld(!0),b=this.matrixWorld),this.bindMatrix.copy(b),this.bindMatrixInverse.getInverse(b)},THREE.SkinnedMesh.prototype.pose=function(){this.skeleton.pose()},THREE.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof THREE.Geometry)for(var a=0;a<this.geometry.skinIndices.length;a++){var b=this.geometry.skinWeights[a],c=1/b.lengthManhattan();1/0!==c?b.multiplyScalar(c):b.set(1)}},THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){THREE.Mesh.prototype.updateMatrixWorld.call(this,!0),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh unreckognized bindMode: "+this.bindMode)},THREE.SkinnedMesh.prototype.clone=function(a){return void 0===a&&(a=new THREE.SkinnedMesh(this.geometry,this.material,this.useVertexTexture)),THREE.Mesh.prototype.clone.call(this,a),a},THREE.MorphAnimMesh=function(a,b){THREE.Mesh.call(this,a,b),this.type="MorphAnimMesh",this.duration=1e3,this.mirroredLoop=!1,this.currentKeyframe=this.lastKeyframe=this.time=0,this.direction=1,this.directionBackwards=!1,this.setFrameRange(0,this.geometry.morphTargets.length-1)},THREE.MorphAnimMesh.prototype=Object.create(THREE.Mesh.prototype),THREE.MorphAnimMesh.prototype.setFrameRange=function(a,b){this.startKeyframe=a,this.endKeyframe=b,this.length=this.endKeyframe-this.startKeyframe+1},THREE.MorphAnimMesh.prototype.setDirectionForward=function(){this.direction=1,this.directionBackwards=!1},THREE.MorphAnimMesh.prototype.setDirectionBackward=function(){this.direction=-1,this.directionBackwards=!0},THREE.MorphAnimMesh.prototype.parseAnimations=function(){var a=this.geometry;a.animations||(a.animations={});for(var b,c=a.animations,d=/([a-z]+)_?(\d+)/,e=0,f=a.morphTargets.length;e<f;e++){var g=a.morphTargets[e].name.match(d);if(g&&1<g.length){g=g[1],c[g]||(c[g]={start:1/0,end:-(1/0)});var h=c[g];e<h.start&&(h.start=e),e>h.end&&(h.end=e),b||(b=g)}}a.firstAnimation=b},THREE.MorphAnimMesh.prototype.setAnimationLabel=function(a,b,c){this.geometry.animations||(this.geometry.animations={}),this.geometry.animations[a]={start:b,end:c}},THREE.MorphAnimMesh.prototype.playAnimation=function(a,b){var c=this.geometry.animations[a];c?(this.setFrameRange(c.start,c.end),this.duration=(c.end-c.start)/b*1e3,this.time=0):console.warn("animation["+a+"] undefined")},THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var b=this.duration/this.length;this.time+=this.direction*a,this.mirroredLoop?(this.time>this.duration||0>this.time)&&(this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),0>this.time&&(this.time=0,this.directionBackwards=!1)):(this.time%=this.duration,0>this.time&&(this.time+=this.duration)),a=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/b),0,this.length-1),a!==this.currentKeyframe&&(this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a),b=this.time%b/b,this.directionBackwards&&(b=1-b),this.morphTargetInfluences[this.currentKeyframe]=b,this.morphTargetInfluences[this.lastKeyframe]=1-b},THREE.MorphAnimMesh.prototype.interpolateTargets=function(a,b,c){for(var d=this.morphTargetInfluences,e=0,f=d.length;e<f;e++)d[e]=0;-1<a&&(d[a]=1-c),-1<b&&(d[b]=c)},THREE.MorphAnimMesh.prototype.clone=function(a){return void 0===a&&(a=new THREE.MorphAnimMesh(this.geometry,this.material)),a.duration=this.duration,a.mirroredLoop=this.mirroredLoop,a.time=this.time,a.lastKeyframe=this.lastKeyframe,a.currentKeyframe=this.currentKeyframe,a.direction=this.direction,a.directionBackwards=this.directionBackwards,THREE.Mesh.prototype.clone.call(this,a),a},THREE.LOD=function(){THREE.Object3D.call(this),this.objects=[]},THREE.LOD.prototype=Object.create(THREE.Object3D.prototype),THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0),b=Math.abs(b);for(var c=0;c<this.objects.length&&!(b<this.objects[c].distance);c++);this.objects.splice(c,0,{distance:b,object:a}),this.add(a)},THREE.LOD.prototype.getObjectForDistance=function(a){for(var b=1,c=this.objects.length;b<c&&!(a<this.objects[b].distance);b++);return this.objects[b-1].object},THREE.LOD.prototype.raycast=function(){var a=new THREE.Vector3;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.origin.distanceTo(a);this.getObjectForDistance(d).raycast(b,c)}}(),THREE.LOD.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){if(1<this.objects.length){a.setFromMatrixPosition(c.matrixWorld),b.setFromMatrixPosition(this.matrixWorld),c=a.distanceTo(b),this.objects[0].object.visible=!0;for(var d=1,e=this.objects.length;d<e&&c>=this.objects[d].distance;d++)this.objects[d-1].object.visible=!1,this.objects[d].object.visible=!0;for(;d<e;d++)this.objects[d].object.visible=!1}}}(),THREE.LOD.prototype.clone=function(a){void 0===a&&(a=new THREE.LOD),THREE.Object3D.prototype.clone.call(this,a);for(var b=0,c=this.objects.length;b<c;b++){var d=this.objects[b].object.clone();d.visible=0===b,a.addLevel(d,this.objects[b].distance)}return a},THREE.Sprite=function(){var a=new Uint16Array([0,1,2,0,2,3]),b=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),c=new Float32Array([0,0,1,0,1,1,0,1]),d=new THREE.BufferGeometry;return d.addAttribute("index",new THREE.BufferAttribute(a,1)),d.addAttribute("position",new THREE.BufferAttribute(b,3)),d.addAttribute("uv",new THREE.BufferAttribute(c,2)),function(a){THREE.Object3D.call(this),this.type="Sprite",this.geometry=d,this.material=void 0!==a?a:new THREE.SpriteMaterial}}(),THREE.Sprite.prototype=Object.create(THREE.Object3D.prototype),THREE.Sprite.prototype.raycast=function(){var a=new THREE.Vector3;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.distanceToPoint(a);d>this.scale.x||c.push({distance:d,point:this.position,face:null,object:this})}}(),THREE.Sprite.prototype.clone=function(a){return void 0===a&&(a=new THREE.Sprite(this.material)),THREE.Object3D.prototype.clone.call(this,a),a},THREE.Particle=THREE.Sprite,THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this),this.lensFlares=[],this.positionScreen=new THREE.Vector3,this.customUpdateCallback=void 0,void 0!==a&&this.add(a,b,c,d,e)},THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype),THREE.LensFlare.prototype.add=function(a,b,c,d,e,f){void 0===b&&(b=-1),void 0===c&&(c=0),void 0===f&&(f=1),void 0===e&&(e=new THREE.Color(16777215)),void 0===d&&(d=THREE.NormalBlending),c=Math.min(c,Math.max(0,c)),this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:f,color:e,blending:d})},THREE.LensFlare.prototype.updateLensFlares=function(){var a,c,b=this.lensFlares.length,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;a<b;a++)c=this.lensFlares[a],c.x=this.positionScreen.x+d*c.distance,c.y=this.positionScreen.y+e*c.distance,c.wantedRotation=c.x*Math.PI*.25,c.rotation+=.25*(c.wantedRotation-c.rotation)},THREE.Scene=function(){THREE.Object3D.call(this),this.type="Scene",this.overrideMaterial=this.fog=null,this.autoUpdate=!0},THREE.Scene.prototype=Object.create(THREE.Object3D.prototype),THREE.Scene.prototype.clone=function(a){return void 0===a&&(a=new THREE.Scene),THREE.Object3D.prototype.clone.call(this,a),null!==this.fog&&(a.fog=this.fog.clone()),null!==this.overrideMaterial&&(a.overrideMaterial=this.overrideMaterial.clone()),a.autoUpdate=this.autoUpdate,a.matrixAutoUpdate=this.matrixAutoUpdate,a},THREE.Fog=function(a,b,c){this.name="",this.color=new THREE.Color(a),this.near=void 0!==b?b:1,this.far=void 0!==c?c:1e3},THREE.Fog.prototype.clone=function(){return new THREE.Fog(this.color.getHex(),this.near,this.far)},THREE.FogExp2=function(a,b){this.name="",this.color=new THREE.Color(a),this.density=void 0!==b?b:25e-5},THREE.FogExp2.prototype.clone=function(){return new THREE.FogExp2(this.color.getHex(),this.density)},THREE.ShaderChunk={},THREE.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n\n\tif ( gl_FragColor.a < ALPHATEST ) discard;\n\n#endif\n",THREE.ShaderChunk.lights_lambert_vertex="vLightFront = vec3( 0.0 );\n\n#ifdef DOUBLE_SIDED\n\n\tvLightBack = vec3( 0.0 );\n\n#endif\n\ntransformedNormal = normalize( transformedNormal );\n\n#if MAX_DIR_LIGHTS > 0\n\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\n\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\tvec3 dirVector = normalize( lDirection.xyz );\n\n\tfloat dotProduct = dot( transformedNormal, dirVector );\n\tvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n\t\t#endif\n\n\t#endif\n\n\t#ifdef WRAP_AROUND\n\n\t\tvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\tdirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tdirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n\n\t\t#endif\n\n\t#endif\n\n\tvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n\n\t#endif\n\n}\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz - mvPosition.xyz;\n\n\t\tfloat lDistance = 1.0;\n\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\n\n\t\tlVector = normalize( lVector );\n\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\n\t\tvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\tvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\tpointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n\n\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\tpointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t\tvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n\n\t\t#endif\n\n\t}\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz - mvPosition.xyz;\n\n\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );\n\n\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\n\t\t\tspotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );\n\n\t\t\tfloat lDistance = 1.0;\n\t\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\t\tlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\n\n\t\t\tlVector = normalize( lVector );\n\n\t\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\t\t\tvec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\tvec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n\t\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\t\tvec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\tvec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\t\tspotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );\n\n\t\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\t\tspotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;\n\n\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\tvLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;\n\n\t\t\t#endif\n\n\t\t}\n\n\t}\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\n\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\tvec3 lVector = normalize( lDirection.xyz );\n\n\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\n\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\t\tfloat hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;\n\n\t\tvLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );\n\n\t\t#endif\n\n\t}\n\n#endif\n\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n\n#ifdef DOUBLE_SIDED\n\n\tvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n\n#endif",THREE.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif",THREE.ShaderChunk.default_vertex="vec4 mvPosition;\n\n#ifdef USE_SKINNING\n\n\tmvPosition = modelViewMatrix * skinned;\n\n#endif\n\n#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )\n\n\tmvPosition = modelViewMatrix * vec4( morphed, 1.0 );\n\n#endif\n\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )\n\n\tmvPosition = modelViewMatrix * vec4( position, 1.0 );\n\n#endif\n\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.map_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n\tvarying vec2 vUv;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif",THREE.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n\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\n\t#ifdef USE_MORPHNORMALS\n\n\tvec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n\n\t#else\n\n\tvec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n\n\t#endif\n\n#endif\n",THREE.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\n\t#endif\n\n\tuniform float logDepthBufFC;\n\n#endif",THREE.ShaderChunk.lightmap_pars_vertex="#ifdef USE_LIGHTMAP\n\n\tvarying vec2 vUv2;\n\n#endif",THREE.ShaderChunk.lights_phong_fragment="vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n\n#ifdef DOUBLE_SIDED\n\n\tnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\n#endif\n\n#ifdef USE_NORMALMAP\n\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tvec3 pointDiffuse = vec3( 0.0 );\n\tvec3 pointSpecular = vec3( 0.0 );\n\n\tfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\n\t\tfloat lDistance = 1.0;\n\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\n\n\t\tlVector = normalize( lVector );\n\n\t\t\t\t// diffuse\n\n\t\tfloat dotProduct = dot( normal, lVector );\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\tfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n\t\t\tvec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n\n\t\t#else\n\n\t\t\tfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n\n\t\t#endif\n\n\t\tpointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\n\n\t\t\t\t// specular\n\n\t\tvec3 pointHalfVector = normalize( lVector + viewPosition );\n\t\tfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\n\t\tfloat pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n\n\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, pointHalfVector ), 0.0 ), 5.0 );\n\t\tpointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;\n\n\t}\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tvec3 spotDiffuse = vec3( 0.0 );\n\tvec3 spotSpecular = vec3( 0.0 );\n\n\tfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\n\t\tfloat lDistance = 1.0;\n\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\n\n\t\tlVector = normalize( lVector );\n\n\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\n\n\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\n\t\t\tspotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );\n\n\t\t\t\t\t// diffuse\n\n\t\t\tfloat dotProduct = dot( normal, lVector );\n\n\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\tfloat spotDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\t\tfloat spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n\t\t\t\tvec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n\n\t\t\t#else\n\n\t\t\t\tfloat spotDiffuseWeight = max( dotProduct, 0.0 );\n\n\t\t\t#endif\n\n\t\t\tspotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;\n\n\t\t\t\t\t// specular\n\n\t\t\tvec3 spotHalfVector = normalize( lVector + viewPosition );\n\t\t\tfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\n\t\t\tfloat spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n\n\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, spotHalfVector ), 0.0 ), 5.0 );\n\t\t\tspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;\n\n\t\t}\n\n\t}\n\n#endif\n\n#if MAX_DIR_LIGHTS > 0\n\n\tvec3 dirDiffuse = vec3( 0.0 );\n\tvec3 dirSpecular = vec3( 0.0 );\n\n\tfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\n\t\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\t\tvec3 dirVector = normalize( lDirection.xyz );\n\n\t\t\t\t// diffuse\n\n\t\tfloat dotProduct = dot( normal, dirVector );\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\tfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n\t\t\tvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n\n\t\t#else\n\n\t\t\tfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n\n\t\t#endif\n\n\t\tdirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\n\n\t\t// specular\n\n\t\tvec3 dirHalfVector = normalize( dirVector + viewPosition );\n\t\tfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\n\t\tfloat dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n\n\t\t/*\n\t\t// fresnel term from skin shader\n\t\tconst float F0 = 0.128;\n\n\t\tfloat base = 1.0 - dot( viewPosition, dirHalfVector );\n\t\tfloat exponential = pow( base, 5.0 );\n\n\t\tfloat fresnel = exponential + F0 * ( 1.0 - exponential );\n\t\t*/\n\n\t\t/*\n\t\t// fresnel term from fresnel shader\n\t\tconst float mFresnelBias = 0.08;\n\t\tconst float mFresnelScale = 0.3;\n\t\tconst float mFresnelPower = 5.0;\n\n\t\tfloat fresnel = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( -viewPosition ), normal ), mFresnelPower );\n\t\t*/\n\n\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\t// \t\tdirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization * fresnel;\n\n\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );\n\t\tdirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n\n\n\t}\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tvec3 hemiDiffuse = vec3( 0.0 );\n\tvec3 hemiSpecular = vec3( 0.0 );\n\n\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\n\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\tvec3 lVector = normalize( lDirection.xyz );\n\n\t\t// diffuse\n\n\t\tfloat dotProduct = dot( normal, lVector );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\n\t\tvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\n\t\themiDiffuse += diffuse * hemiColor;\n\n\t\t// specular (sky light)\n\n\t\tvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\n\t\tfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\n\t\tfloat hemiSpecularWeightSky = specularStrength * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );\n\n\t\t// specular (ground light)\n\n\t\tvec3 lVectorGround = -lVector;\n\n\t\tvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\n\t\tfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\n\t\tfloat hemiSpecularWeightGround = specularStrength * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );\n\n\t\tfloat dotProductGround = dot( normal, lVectorGround );\n\n\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\tvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );\n\t\tvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );\n\t\themiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n\n\t}\n\n#endif\n\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n\n#if MAX_DIR_LIGHTS > 0\n\n\ttotalDiffuse += dirDiffuse;\n\ttotalSpecular += dirSpecular;\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\ttotalDiffuse += hemiDiffuse;\n\ttotalSpecular += hemiSpecular;\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\ttotalDiffuse += pointDiffuse;\n\ttotalSpecular += pointSpecular;\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\ttotalDiffuse += spotDiffuse;\n\ttotalSpecular += spotSpecular;\n\n#endif\n\n#ifdef METAL\n\n\tgl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );\n\n#else\n\n\tgl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n\n#endif",
THREE.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n\n#endif",THREE.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\n\tvec3 morphedNormal = vec3( 0.0 );\n\n\tmorphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tmorphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tmorphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tmorphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n\n\tmorphedNormal += normal;\n\n#endif",THREE.ShaderChunk.envmap_pars_fragment="#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\tuniform samplerCube envMap;\n\tuniform float flipEnvMap;\n\tuniform int combine;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\tuniform bool useRefract;\n\t\tuniform float refractionRatio;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\n\t#endif\n\n#endif",THREE.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n\n#endif",THREE.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n\t\t\t// Per-Pixel Tangent Space Normal Mapping\n\t\t\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n",THREE.ShaderChunk.lights_phong_pars_vertex="#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n\tvarying vec3 vWorldPosition;\n\n#endif\n",THREE.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\n\tvarying vec2 vUv2;\n\tuniform sampler2D lightMap;\n\n#endif",THREE.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n\n\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\n\t\tvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n\n\t}\n\n#endif",THREE.ShaderChunk.lights_phong_vertex="#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n\tvWorldPosition = worldPosition.xyz;\n\n#endif",THREE.ShaderChunk.map_fragment="#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\t#ifdef GAMMA_INPUT\n\n\t\ttexelColor.xyz *= texelColor.xyz;\n\n\t#endif\n\n\tgl_FragColor = gl_FragColor * texelColor;\n\n#endif",THREE.ShaderChunk.lightmap_vertex="#ifdef USE_LIGHTMAP\n\n\tvUv2 = uv2;\n\n#endif",THREE.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n\n\tgl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n\n#endif",THREE.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",THREE.ShaderChunk.color_vertex="#ifdef USE_COLOR\n\n\t#ifdef GAMMA_INPUT\n\n\t\tvColor = color * color;\n\n\t#else\n\n\t\tvColor = color;\n\n\t#endif\n\n#endif",THREE.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n\n\t#ifdef USE_MORPHTARGETS\n\n\tvec4 skinVertex = bindMatrix * vec4( morphed, 1.0 );\n\n\t#else\n\n\tvec4 skinVertex = bindMatrix * vec4( position, 1.0 );\n\n\t#endif\n\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\tskinned = bindMatrixInverse * skinned;\n\n#endif\n",THREE.ShaderChunk.envmap_pars_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )\n\n\tvarying vec3 vReflect;\n\n\tuniform float refractionRatio;\n\tuniform bool useRefract;\n\n#endif\n",THREE.ShaderChunk.linear_to_gamma_fragment="#ifdef GAMMA_OUTPUT\n\n\tgl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n\n#endif",THREE.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif",THREE.ShaderChunk.lights_lambert_pars_vertex="uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 emissive;\n\nuniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#ifdef WRAP_AROUND\n\n\tuniform vec3 wrapRGB;\n\n#endif\n",THREE.ShaderChunk.map_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n\n#endif\n",THREE.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n\n\tvec3 reflectVec;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\n\t\t// http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\n\t\tvec3 worldNormal = normalize( vec3( vec4( normal, 0.0 ) * viewMatrix ) );\n\n\t\tif ( useRefract ) {\n\n\t\t\treflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t} else { \n\n\t\t\treflectVec = reflect( cameraToVertex, worldNormal );\n\n\t\t}\n\n\t#else\n\n\t\treflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\t\tvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#else\n\n\t\tvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#endif\n\n\t#ifdef GAMMA_INPUT\n\n\t\tcubeColor.xyz *= cubeColor.xyz;\n\n\t#endif\n\n\tif ( combine == 1 ) {\n\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );\n\n\t} else if ( combine == 2 ) {\n\n\t\tgl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;\n\n\t} else {\n\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );\n\n\t}\n\n#endif",THREE.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif",THREE.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\n\tgl_Position.z = log2(max(1e-6, gl_Position.w + 1.0)) * logDepthBufFC;\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\n#else\n\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\n\t#endif\n\n#endif",THREE.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif",THREE.ShaderChunk.specularmap_fragment="float specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif",THREE.ShaderChunk.fog_fragment="#ifdef USE_FOG\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\n\t#else\n\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\n\t#endif\n\n\t#ifdef FOG_EXP2\n\n\t\tconst float LOG2 = 1.442695;\n\t\tfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\n\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\n\t#endif\n\t\n\tgl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n\n#endif",THREE.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t\t\t// Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen\n\t\t\t//\thttp://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html\n\n\t\t\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\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\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif",THREE.ShaderChunk.defaultnormal_vertex="vec3 objectNormal;\n\n#ifdef USE_SKINNING\n\n\tobjectNormal = skinnedNormal.xyz;\n\n#endif\n\n#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )\n\n\tobjectNormal = morphedNormal;\n\n#endif\n\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )\n\n\tobjectNormal = normal;\n\n#endif\n\n#ifdef FLIP_SIDED\n\n\tobjectNormal = -objectNormal;\n\n#endif\n\nvec3 transformedNormal = normalMatrix * objectNormal;",THREE.ShaderChunk.lights_phong_pars_fragment="uniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n\tvarying vec3 vWorldPosition;\n\n#endif\n\n#ifdef WRAP_AROUND\n\n\tuniform vec3 wrapRGB;\n\n#endif\n\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n\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\n#endif",THREE.ShaderChunk.map_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n\n#endif",THREE.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n\n\tgl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n\n#endif",THREE.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\n\tvarying vec4 vShadowCoord[ MAX_SHADOWS ];\n\tuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n\n#endif",THREE.ShaderChunk.color_fragment="#ifdef USE_COLOR\n\n\tgl_FragColor = gl_FragColor * vec4( vColor, 1.0 );\n\n#endif",THREE.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\n\tvec3 morphed = vec3( 0.0 );\n\tmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\tmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\tmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\tmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\tmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\tmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\tmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\tmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n\tmorphed += position;\n\n#endif",THREE.ShaderChunk.envmap_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )\n\n\tvec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;\n\tworldNormal = normalize( worldNormal );\n\n\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\tif ( useRefract ) {\n\n\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t} else {\n\n\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t}\n\n#endif",THREE.ShaderChunk.shadowmap_fragment="#ifdef USE_SHADOWMAP\n\n\t#ifdef SHADOWMAP_DEBUG\n\n\t\tvec3 frustumColors[3];\n\t\tfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\n\t\tfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\n\t\tfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n\n\t#endif\n\n\t#ifdef SHADOWMAP_CASCADE\n\n\t\tint inFrustumCount = 0;\n\n\t#endif\n\n\tfloat fDepth;\n\tvec3 shadowColor = vec3( 1.0 );\n\n\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\n\t\tvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\n\n\t\t\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t\t\t// if ( all( something, something ) ) using this instead\n\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\n\t\t\t\t// don't shadow pixels outside of light frustum\n\t\t\t\t// use just first frustum (for cascades)\n\t\t\t\t// don't shadow pixels behind far plane of light frustum\n\n\t\t#ifdef SHADOWMAP_CASCADE\n\n\t\t\tinFrustumCount += int( inFrustum );\n\t\t\tbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n\n\t\t#else\n\n\t\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\t#endif\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t\tshadowCoord.z += shadowBias[ i ];\n\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\t\t\t\t// Percentage-close filtering\n\t\t\t\t\t\t// (9 pixel kernel)\n\t\t\t\t\t\t// http://fabiensanglard.net/shadowmappingPCF/\n\n\t\t\t\tfloat shadow = 0.0;\n\n\t\t/*\n\t\t\t\t\t\t// nested loops breaks shader compiler / validator on some ATI cards when using OpenGL\n\t\t\t\t\t\t// must enroll loop manually\n\n\t\t\t\tfor ( float y = -1.25; y <= 1.25; y += 1.25 )\n\t\t\t\t\tfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\n\n\t\t\t\t\t\tvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\n\n\t\t\t\t\t\t\t\t// doesn't seem to produce any noticeable visual difference compared to simple texture2D lookup\n\t\t\t\t\t\t\t\t//vec4 rgbaDepth = texture2DProj( shadowMap[ i ], vec4( vShadowCoord[ i ].w * ( vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy ), 0.05, vShadowCoord[ i ].w ) );\n\n\t\t\t\t\t\tfloat fDepth = unpackDepth( rgbaDepth );\n\n\t\t\t\t\t\tif ( fDepth < shadowCoord.z )\n\t\t\t\t\t\t\tshadow += 1.0;\n\n\t\t\t\t}\n\n\t\t\t\tshadow /= 9.0;\n\n\t\t*/\n\n\t\t\t\tconst float shadowDelta = 1.0 / 9.0;\n\n\t\t\t\tfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n\t\t\t\tfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\n\t\t\t\tfloat dx0 = -1.25 * xPixelOffset;\n\t\t\t\tfloat dy0 = -1.25 * yPixelOffset;\n\t\t\t\tfloat dx1 = 1.25 * xPixelOffset;\n\t\t\t\tfloat dy1 = 1.25 * yPixelOffset;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\n\t\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\t\t\t\t// Percentage-close filtering\n\t\t\t\t\t\t// (9 pixel kernel)\n\t\t\t\t\t\t// http://fabiensanglard.net/shadowmappingPCF/\n\n\t\t\t\tfloat shadow = 0.0;\n\n\t\t\t\tfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n\t\t\t\tfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\n\t\t\t\tfloat dx0 = -1.0 * xPixelOffset;\n\t\t\t\tfloat dy0 = -1.0 * yPixelOffset;\n\t\t\t\tfloat dx1 = 1.0 * xPixelOffset;\n\t\t\t\tfloat dy1 = 1.0 * yPixelOffset;\n\n\t\t\t\tmat3 shadowKernel;\n\t\t\t\tmat3 depthKernel;\n\n\t\t\t\tdepthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n\t\t\t\tdepthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n\t\t\t\tdepthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n\t\t\t\tdepthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n\t\t\t\tdepthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n\t\t\t\tdepthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n\t\t\t\tdepthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n\t\t\t\tdepthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n\t\t\t\tdepthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n\n\t\t\t\tvec3 shadowZ = vec3( shadowCoord.z );\n\t\t\t\tshadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));\n\t\t\t\tshadowKernel[0] *= vec3(0.25);\n\n\t\t\t\tshadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));\n\t\t\t\tshadowKernel[1] *= vec3(0.25);\n\n\t\t\t\tshadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));\n\t\t\t\tshadowKernel[2] *= vec3(0.25);\n\n\t\t\t\tvec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );\n\n\t\t\t\tshadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );\n\t\t\t\tshadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );\n\n\t\t\t\tvec4 shadowValues;\n\t\t\t\tshadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );\n\t\t\t\tshadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );\n\t\t\t\tshadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );\n\t\t\t\tshadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );\n\n\t\t\t\tshadow = dot( shadowValues, vec4( 1.0 ) );\n\n\t\t\t\tshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\n\t\t\t#else\n\n\t\t\t\tvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\n\t\t\t\tfloat fDepth = unpackDepth( rgbaDepth );\n\n\t\t\t\tif ( fDepth < shadowCoord.z )\n\n\t\t// spot with multiple shadows is darker\n\n\t\t\t\t\tshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n\n\t\t// spot with multiple shadows has the same color as single shadow spot\n\n\t\t// \t\t\t\t\tshadowColor = min( shadowColor, vec3( shadowDarkness[ i ] ) );\n\n\t\t\t#endif\n\n\t\t}\n\n\n\t\t#ifdef SHADOWMAP_DEBUG\n\n\t\t\t#ifdef SHADOWMAP_CASCADE\n\n\t\t\t\tif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n\n\t\t\t#else\n\n\t\t\t\tif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t}\n\n\t#ifdef GAMMA_OUTPUT\n\n\t\tshadowColor *= shadowColor;\n\n\t#endif\n\n\tgl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n\n#endif\n",THREE.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\n\t#ifdef USE_SKINNING\n\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\n\t#endif\n\n\t#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\n\n\t\tvec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );\n\n\t#endif\n\n\t#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\n\n\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\n\t#endif\n\n#endif",THREE.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\n\tuniform sampler2D shadowMap[ MAX_SHADOWS ];\n\tuniform vec2 shadowMapSize[ MAX_SHADOWS ];\n\n\tuniform float shadowDarkness[ MAX_SHADOWS ];\n\tuniform float shadowBias[ MAX_SHADOWS ];\n\n\tvarying vec4 vShadowCoord[ MAX_SHADOWS ];\n\n\tfloat unpackDepth( const in vec4 rgba_depth ) {\n\n\t\tconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\t\tfloat depth = dot( rgba_depth, bit_shift );\n\t\treturn depth;\n\n\t}\n\n#endif",THREE.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\n\t\t\ty = dy * ( y + 0.5 );\n\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\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneGlobalMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n",THREE.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n\n\tuniform float logDepthBufFC;\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\t#extension GL_EXT_frag_depth : enable\n\t\tvarying float vFragDepth;\n\n\t#endif\n\n#endif",THREE.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n\n\tgl_FragColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n",THREE.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n",THREE.UniformsUtils={merge:function(a){for(var b={},c=0;c<a.length;c++){var e,d=this.clone(a[c]);for(e in d)b[e]=d[e]}return b},clone:function(a){var c,b={};for(c in a){b[c]={};for(var d in a[c]){var e=a[c][d];b[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector2||e instanceof THREE.Vector3||e instanceof THREE.Vector4||e instanceof THREE.Matrix4||e instanceof THREE.Texture?e.clone():e instanceof Array?e.slice():e}}return b}},THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:null},specularMap:{type:"t",value:null},alphaMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},bump:{bumpMap:{type:"t",value:null},bumpScale:{type:"f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new THREE.Vector2(1,1)}},fog:{fogDensity:{type:"f",value:25e-5},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},hemisphereLightDirection:{type:"fv",value:[]},hemisphereLightSkyColor:{type:"fv",value:[]},hemisphereLightGroundColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]},spotLightColor:{type:"fv",value:[]},spotLightPosition:{type:"fv",value:[]},spotLightDirection:{type:"fv",value:[]},spotLightDistance:{type:"fv1",value:[]},spotLightAngleCos:{type:"fv1",value:[]},spotLightExponent:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:null},fogDensity:{type:"f",value:25e-5},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},fogColor:{type:"c",value:new THREE.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:[]},shadowMapSize:{type:"v2v",value:[]},shadowBias:{type:"fv1",value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}},THREE.ShaderLib={basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinbase_vertex,"\t#ifdef USE_ENVMAP",THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,"\t#endif",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( vec3( 1.0 ), opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,"\t#ifdef DOUBLE_SIDED\n\t\tif ( gl_FrontFacing )\n\t\t\tgl_FragColor.xyz *= vLightFront;\n\t\telse\n\t\t\tgl_FragColor.xyz *= vLightBack;\n\t#else\n\t\tgl_FragColor.xyz *= vLightFront;\n\t#endif",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.bump,THREE.UniformsLib.normalmap,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["#define PHONG\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,"\tvNormal = normalize( transformedNormal );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"\tvViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),
fragmentShader:["#define PHONG\nuniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.bumpmap_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( vec3( 1.0 ), opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\tgl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},dashed:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,{scale:{type:"f",value:1},dashSize:{type:"f",value:1},totalSize:{type:"f",value:2}}]),vertexShader:["uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tgl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2e3},opacity:{type:"f",value:1}},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float mNear;\nuniform float mFar;\nuniform float opacity;",THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\tfloat color = 1.0 - smoothstep( mNear, mFar, depth );\n\tgl_FragColor = vec4( vec3( color ), opacity );\n}"].join("\n")},normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;",THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vNormal;",THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},normalmap:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},enableDisplacement:{type:"i",value:0},tDisplacement:{type:"t",value:null},tDiffuse:{type:"t",value:null},tCube:{type:"t",value:null},tNormal:{type:"t",value:null},tSpecular:{type:"t",value:null},tAO:{type:"t",value:null},uNormalScale:{type:"v2",value:new THREE.Vector2(1,1)},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},diffuse:{type:"c",value:new THREE.Color(16777215)},specular:{type:"c",value:new THREE.Color(1118481)},ambient:{type:"c",value:new THREE.Color(16777215)},shininess:{type:"f",value:30},opacity:{type:"f",value:1},useRefract:{type:"i",value:0},refractionRatio:{type:"f",value:.98},reflectivity:{type:"f",value:.5},uOffset:{type:"v2",value:new THREE.Vector2(0,0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,1)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),fragmentShader:["uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform vec2 uNormalScale;\nuniform bool useRefract;\nuniform float refractionRatio;\nuniform float reflectivity;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\n\tuniform vec3 wrapRGB;\n#endif\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\tgl_FragColor = vec4( vec3( 1.0 ), opacity );\n\tvec3 specularTex = vec3( 1.0 );\n\tvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\n\tnormalTex.xy *= uNormalScale;\n\tnormalTex = normalize( normalTex );\n\tif( enableDiffuse ) {\n\t\t#ifdef GAMMA_INPUT\n\t\t\tvec4 texelColor = texture2D( tDiffuse, vUv );\n\t\t\ttexelColor.xyz *= texelColor.xyz;\n\t\t\tgl_FragColor = gl_FragColor * texelColor;\n\t\t#else\n\t\t\tgl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\n\t\t#endif\n\t}\n\tif( enableAO ) {\n\t\t#ifdef GAMMA_INPUT\n\t\t\tvec4 aoColor = texture2D( tAO, vUv );\n\t\t\taoColor.xyz *= aoColor.xyz;\n\t\t\tgl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;\n\t\t#else\n\t\t\tgl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\n\t\t#endif\n\t}",THREE.ShaderChunk.alphatest_fragment,"\tif( enableSpecular )\n\t\tspecularTex = texture2D( tSpecular, vUv ).xyz;\n\tmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );\n\tvec3 finalNormal = tsb * normalTex;\n\t#ifdef FLIP_SIDED\n\t\tfinalNormal = -finalNormal;\n\t#endif\n\tvec3 normal = normalize( finalNormal );\n\tvec3 viewPosition = normalize( vViewPosition );\n\t#if MAX_POINT_LIGHTS > 0\n\t\tvec3 pointDiffuse = vec3( 0.0 );\n\t\tvec3 pointSpecular = vec3( 0.0 );\n\t\tfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\t\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\t\tvec3 pointVector = lPosition.xyz + vViewPosition.xyz;\n\t\t\tfloat pointDistance = 1.0;\n\t\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\t\tpointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );\n\t\t\tpointVector = normalize( pointVector );\n\t\t\t#ifdef WRAP_AROUND\n\t\t\t\tfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );\n\t\t\t\tfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );\n\t\t\t\tvec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n\t\t\t#else\n\t\t\t\tfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\n\t\t\t#endif\n\t\t\tpointDiffuse += pointDistance * pointLightColor[ i ] * diffuse * pointDiffuseWeight;\n\t\t\tvec3 pointHalfVector = normalize( pointVector + viewPosition );\n\t\t\tfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\n\t\t\tfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( pointVector, pointHalfVector ), 0.0 ), 5.0 );\n\t\t\tpointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;\n\t\t}\n\t#endif\n\t#if MAX_SPOT_LIGHTS > 0\n\t\tvec3 spotDiffuse = vec3( 0.0 );\n\t\tvec3 spotSpecular = vec3( 0.0 );\n\t\tfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\t\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\t\tvec3 spotVector = lPosition.xyz + vViewPosition.xyz;\n\t\t\tfloat spotDistance = 1.0;\n\t\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\t\tspotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );\n\t\t\tspotVector = normalize( spotVector );\n\t\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\n\t\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\t\t\t\tspotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );\n\t\t\t\t#ifdef WRAP_AROUND\n\t\t\t\t\tfloat spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );\n\t\t\t\t\tfloat spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );\n\t\t\t\t\tvec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n\t\t\t\t#else\n\t\t\t\t\tfloat spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );\n\t\t\t\t#endif\n\t\t\t\tspotDiffuse += spotDistance * spotLightColor[ i ] * diffuse * spotDiffuseWeight * spotEffect;\n\t\t\t\tvec3 spotHalfVector = normalize( spotVector + viewPosition );\n\t\t\t\tfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\n\t\t\t\tfloat spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n\t\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\t\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( spotVector, spotHalfVector ), 0.0 ), 5.0 );\n\t\t\t\tspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;\n\t\t\t}\n\t\t}\n\t#endif\n\t#if MAX_DIR_LIGHTS > 0\n\t\tvec3 dirDiffuse = vec3( 0.0 );\n\t\tvec3 dirSpecular = vec3( 0.0 );\n\t\tfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\n\t\t\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\t\t\tvec3 dirVector = normalize( lDirection.xyz );\n\t\t\t#ifdef WRAP_AROUND\n\t\t\t\tfloat directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );\n\t\t\t\tfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\n\t\t\t\tvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n\t\t\t#else\n\t\t\t\tfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n\t\t\t#endif\n\t\t\tdirDiffuse += directionalLightColor[ i ] * diffuse * dirDiffuseWeight;\n\t\t\tvec3 dirHalfVector = normalize( dirVector + viewPosition );\n\t\t\tfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\n\t\t\tfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );\n\t\t\tdirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n\t\t}\n\t#endif\n\t#if MAX_HEMI_LIGHTS > 0\n\t\tvec3 hemiDiffuse = vec3( 0.0 );\n\t\tvec3 hemiSpecular = vec3( 0.0 );\n\t\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\t\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\t\tvec3 lVector = normalize( lDirection.xyz );\n\t\t\tfloat dotProduct = dot( normal, lVector );\n\t\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\t\t\tvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\t\t\themiDiffuse += diffuse * hemiColor;\n\t\t\tvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\n\t\t\tfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\n\t\t\tfloat hemiSpecularWeightSky = specularTex.r * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );\n\t\t\tvec3 lVectorGround = -lVector;\n\t\t\tvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\n\t\t\tfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\n\t\t\tfloat hemiSpecularWeightGround = specularTex.r * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );\n\t\t\tfloat dotProductGround = dot( normal, lVectorGround );\n\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\t\t\tvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );\n\t\t\tvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );\n\t\t\themiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n\t\t}\n\t#endif\n\tvec3 totalDiffuse = vec3( 0.0 );\n\tvec3 totalSpecular = vec3( 0.0 );\n\t#if MAX_DIR_LIGHTS > 0\n\t\ttotalDiffuse += dirDiffuse;\n\t\ttotalSpecular += dirSpecular;\n\t#endif\n\t#if MAX_HEMI_LIGHTS > 0\n\t\ttotalDiffuse += hemiDiffuse;\n\t\ttotalSpecular += hemiSpecular;\n\t#endif\n\t#if MAX_POINT_LIGHTS > 0\n\t\ttotalDiffuse += pointDiffuse;\n\t\ttotalSpecular += pointSpecular;\n\t#endif\n\t#if MAX_SPOT_LIGHTS > 0\n\t\ttotalDiffuse += spotDiffuse;\n\t\ttotalSpecular += spotSpecular;\n\t#endif\n\t#ifdef METAL\n\t\tgl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n\t#else\n\t\tgl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n\t#endif\n\tif ( enableReflection ) {\n\t\tvec3 vReflect;\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tif ( useRefract ) {\n\t\t\tvReflect = refract( cameraToVertex, normal, refractionRatio );\n\t\t} else {\n\t\t\tvReflect = reflect( cameraToVertex, normal );\n\t\t}\n\t\tvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n\t\t#ifdef GAMMA_INPUT\n\t\t\tcubeColor.xyz *= cubeColor.xyz;\n\t\t#endif\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * reflectivity );\n\t}",THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\nuniform bool enableDisplacement;\n#ifdef VERTEX_TEXTURES\n\tuniform sampler2D tDisplacement;\n\tuniform float uDisplacementScale;\n\tuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;",THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,"\t#ifdef USE_SKINNING\n\t\tvNormal = normalize( normalMatrix * skinnedNormal.xyz );\n\t\tvec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );\n\t\tvTangent = normalize( normalMatrix * skinnedTangent.xyz );\n\t#else\n\t\tvNormal = normalize( normalMatrix * normal );\n\t\tvTangent = normalize( normalMatrix * tangent.xyz );\n\t#endif\n\tvBinormal = normalize( cross( vNormal, vTangent ) * tangent.w );\n\tvUv = uv * uRepeat + uOffset;\n\tvec3 displacedPosition;\n\t#ifdef VERTEX_TEXTURES\n\t\tif ( enableDisplacement ) {\n\t\t\tvec3 dv = texture2D( tDisplacement, uv ).xyz;\n\t\t\tfloat df = uDisplacementScale * dv.x + uDisplacementBias;\n\t\t\tdisplacedPosition = position + normalize( normal ) * df;\n\t\t} else {\n\t\t\t#ifdef USE_SKINNING\n\t\t\t\tvec4 skinVertex = bindMatrix * vec4( position, 1.0 );\n\t\t\t\tvec4 skinned = vec4( 0.0 );\n\t\t\t\tskinned += boneMatX * skinVertex * skinWeight.x;\n\t\t\t\tskinned += boneMatY * skinVertex * skinWeight.y;\n\t\t\t\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\t\t\t\tskinned += boneMatW * skinVertex * skinWeight.w;\n\t\t\t\tskinned = bindMatrixInverse * skinned;\n\t\t\t\tdisplacedPosition = skinned.xyz;\n\t\t\t#else\n\t\t\t\tdisplacedPosition = position;\n\t\t\t#endif\n\t\t}\n\t#else\n\t\t#ifdef USE_SKINNING\n\t\t\tvec4 skinVertex = bindMatrix * vec4( position, 1.0 );\n\t\t\tvec4 skinned = vec4( 0.0 );\n\t\t\tskinned += boneMatX * skinVertex * skinWeight.x;\n\t\t\tskinned += boneMatY * skinVertex * skinWeight.y;\n\t\t\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\t\t\tskinned += boneMatW * skinVertex * skinWeight.w;\n\t\t\tskinned = bindMatrixInverse * skinned;\n\t\t\tdisplacedPosition = skinned.xyz;\n\t\t#else\n\t\t\tdisplacedPosition = position;\n\t\t#endif\n\t#endif\n\tvec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );\n\tvec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.logdepthbuf_vertex,"\tvWorldPosition = worldPosition.xyz;\n\tvViewPosition = -mvPosition.xyz;\n\t#ifdef USE_SHADOWMAP\n\t\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\t\t\tvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n\t\t}\n\t#endif\n}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\tvWorldPosition = worldPosition.xyz;\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:[THREE.ShaderChunk.logdepthbuf_pars_fragment,"vec4 pack_depth( const in float depth ) {\n\tconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nvoid main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragDepthEXT );\n\t#else\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n\t#endif\n}"].join("\n")}},THREE.WebGLRenderer=function(a){function b(a){var b=a.geometry;a=a.material;var c=b.vertices.length;if(a.attributes){void 0===b.__webglCustomAttributesList&&(b.__webglCustomAttributesList=[]);for(var d in a.attributes){var e=a.attributes[d];if(!e.__webglInitialized||e.createUniqueBuffers){e.__webglInitialized=!0;var f=1;"v2"===e.type?f=2:"v3"===e.type?f=3:"v4"===e.type?f=4:"c"===e.type&&(f=3),e.size=f,e.array=new Float32Array(c*f),e.buffer=l.createBuffer(),e.buffer.belongsToAttribute=d,e.needsUpdate=!0}b.__webglCustomAttributesList.push(e)}}}function c(a,b){var c=b.geometry,e=a.faces3,f=3*e.length,g=1*e.length,h=3*e.length,e=d(b,a);a.__vertexArray=new Float32Array(3*f),a.__normalArray=new Float32Array(3*f),a.__colorArray=new Float32Array(3*f),a.__uvArray=new Float32Array(2*f),1<c.faceVertexUvs.length&&(a.__uv2Array=new Float32Array(2*f)),c.hasTangents&&(a.__tangentArray=new Float32Array(4*f)),b.geometry.skinWeights.length&&b.geometry.skinIndices.length&&(a.__skinIndexArray=new Float32Array(4*f),a.__skinWeightArray=new Float32Array(4*f)),c=null!==pa.get("OES_element_index_uint")&&21845<g?Uint32Array:Uint16Array,a.__typeArray=c,a.__faceArray=new c(3*g),a.__lineArray=new c(2*h);var k;if(a.numMorphTargets)for(a.__morphTargetsArrays=[],c=0,k=a.numMorphTargets;c<k;c++)a.__morphTargetsArrays.push(new Float32Array(3*f));if(a.numMorphNormals)for(a.__morphNormalsArrays=[],c=0,k=a.numMorphNormals;c<k;c++)a.__morphNormalsArrays.push(new Float32Array(3*f));if(a.__webglFaceCount=3*g,a.__webglLineCount=2*h,e.attributes){void 0===a.__webglCustomAttributesList&&(a.__webglCustomAttributesList=[]);for(var m in e.attributes){var n,g=e.attributes[m],h={};for(n in g)h[n]=g[n];h.__webglInitialized&&!h.createUniqueBuffers||(h.__webglInitialized=!0,c=1,"v2"===h.type?c=2:"v3"===h.type?c=3:"v4"===h.type?c=4:"c"===h.type&&(c=3),h.size=c,h.array=new Float32Array(f*c),h.buffer=l.createBuffer(),h.buffer.belongsToAttribute=m,g.needsUpdate=!0,h.__original=g),a.__webglCustomAttributesList.push(h)}}a.__inittedArrays=!0}function d(a,b){return a.material instanceof THREE.MeshFaceMaterial?a.material.materials[b.materialIndex]:a.material}function e(a,b,c,d){c=c.attributes;var e=b.attributes;b=b.attributesKeys;for(var f=0,k=b.length;f<k;f++){var m=b[f],n=e[m];if(0<=n){var p=c[m];void 0!==p?(m=p.itemSize,l.bindBuffer(l.ARRAY_BUFFER,p.buffer),g(n),l.vertexAttribPointer(n,m,l.FLOAT,!1,0,d*m*4)):void 0!==a.defaultAttributeValues&&(2===a.defaultAttributeValues[m].length?l.vertexAttrib2fv(n,a.defaultAttributeValues[m]):3===a.defaultAttributeValues[m].length&&l.vertexAttrib3fv(n,a.defaultAttributeValues[m]))}}h()}function f(){for(var a=0,b=wb.length;a<b;a++)wb[a]=0}function g(a){wb[a]=1,0===ib[a]&&(l.enableVertexAttribArray(a),ib[a]=1)}function h(){for(var a=0,b=ib.length;a<b;a++)ib[a]!==wb[a]&&(l.disableVertexAttribArray(a),ib[a]=0)}function k(a,b){return a.material.id!==b.material.id?b.material.id-a.material.id:a.z!==b.z?b.z-a.z:a.id-b.id}function n(a,b){return a.z!==b.z?a.z-b.z:a.id-b.id}function p(a,b){return b[0]-a[0]}function q(a,e){if(!1!==e.visible){if(!(e instanceof THREE.Scene||e instanceof THREE.Group)){void 0===e.__webglInit&&(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrix=new THREE.Matrix3,e.addEventListener("removed",Hc));var f=e.geometry;if(void 0!==f&&void 0===f.__webglInit&&(f.__webglInit=!0,f.addEventListener("dispose",Ic),!(f instanceof THREE.BufferGeometry)))if(e instanceof THREE.Mesh)s(a,e,f);else if(e instanceof THREE.Line){if(void 0===f.__webglVertexBuffer){f.__webglVertexBuffer=l.createBuffer(),f.__webglColorBuffer=l.createBuffer(),f.__webglLineDistanceBuffer=l.createBuffer(),J.info.memory.geometries++;var g=f.vertices.length;f.__vertexArray=new Float32Array(3*g),f.__colorArray=new Float32Array(3*g),f.__lineDistanceArray=new Float32Array(1*g),f.__webglLineCount=g,b(e),f.verticesNeedUpdate=!0,f.colorsNeedUpdate=!0,f.lineDistancesNeedUpdate=!0}}else if(e instanceof THREE.PointCloud&&void 0===f.__webglVertexBuffer){f.__webglVertexBuffer=l.createBuffer(),f.__webglColorBuffer=l.createBuffer(),J.info.memory.geometries++;var h=f.vertices.length;f.__vertexArray=new Float32Array(3*h),f.__colorArray=new Float32Array(3*h),f.__sortArray=[],f.__webglParticleCount=h,b(e),f.verticesNeedUpdate=!0,f.colorsNeedUpdate=!0}if(void 0===e.__webglActive)if(e.__webglActive=!0,e instanceof THREE.Mesh){if(f instanceof THREE.BufferGeometry)u(ob,f,e);else if(f instanceof THREE.Geometry)for(var k=xb[f.id],m=0,n=k.length;m<n;m++)u(ob,k[m],e)}else e instanceof THREE.Line||e instanceof THREE.PointCloud?u(ob,f,e):(e instanceof THREE.ImmediateRenderObject||e.immediateRenderCallback)&&jb.push({id:null,object:e,opaque:null,transparent:null,z:0});if(e instanceof THREE.Light)cb.push(e);else if(e instanceof THREE.Sprite)yb.push(e);else if(e instanceof THREE.LensFlare)Ra.push(e);else{var t=ob[e.id];if(t&&(!1===e.frustumCulled||!0===Ec.intersectsObject(e))){var w,G,r=e.geometry;if(r instanceof THREE.BufferGeometry)for(var x=r.attributes,D=r.attributesKeys,E=0,B=D.length;E<B;E++){var A=D[E],K=x[A];if(void 0===K.buffer&&(K.buffer=l.createBuffer(),K.needsUpdate=!0),!0===K.needsUpdate){var F="index"===A?l.ELEMENT_ARRAY_BUFFER:l.ARRAY_BUFFER;l.bindBuffer(F,K.buffer),l.bufferData(F,K.array,l.STATIC_DRAW),K.needsUpdate=!1}}else if(e instanceof THREE.Mesh){!0===r.groupsNeedUpdate&&s(a,e,r);for(var H=xb[r.id],O=0,Q=H.length;O<Q;O++){var R=H[O];if(G=d(e,R),!0===r.groupsNeedUpdate&&c(R,e),w=G.attributes&&v(G),r.verticesNeedUpdate||r.morphTargetsNeedUpdate||r.elementsNeedUpdate||r.uvsNeedUpdate||r.normalsNeedUpdate||r.colorsNeedUpdate||r.tangentsNeedUpdate||w){var C=R,P=e,S=l.DYNAMIC_DRAW,T=!r.dynamic,X=G;if(C.__inittedArrays){var bb=X&&void 0!==X.shading&&X.shading===THREE.SmoothShading,M=void 0,ea=void 0,Y=void 0,ca=void 0,ma=void 0,pa=void 0,sa=void 0,Fa=void 0,la=void 0,hb=void 0,za=void 0,aa=void 0,$=void 0,Z=void 0,ya=void 0,qa=void 0,L=void 0,Ga=void 0,na=void 0,nc=void 0,ia=void 0,oc=void 0,pc=void 0,qc=void 0,Ba=void 0,zb=void 0,Ab=void 0,Ha=void 0,Bb=void 0,Aa=void 0,va=void 0,Cb=void 0,Oa=void 0,Qb=void 0,Ma=void 0,ib=void 0,Ya=void 0,Za=void 0,uc=void 0,Rb=void 0,db=0,eb=0,qb=0,rb=0,Db=0,Sa=0,Ca=0,Pa=0,Ka=0,ja=0,ta=0,I=0,Ia=void 0,Qa=C.__vertexArray,sb=C.__uvArray,fb=C.__uv2Array,Ta=C.__normalArray,ra=C.__tangentArray,La=C.__colorArray,Ua=C.__skinIndexArray,Va=C.__skinWeightArray,Eb=C.__morphTargetsArrays,Jc=C.__morphNormalsArrays,Kb=C.__webglCustomAttributesList,z=void 0,Sb=C.__faceArray,Ja=C.__lineArray,wa=P.geometry,$a=wa.elementsNeedUpdate,Kc=wa.uvsNeedUpdate,ec=wa.normalsNeedUpdate,da=wa.tangentsNeedUpdate,wb=wa.colorsNeedUpdate,U=wa.morphTargetsNeedUpdate,fa=wa.vertices,N=C.faces3,xa=wa.faces,ua=wa.faceVertexUvs[0],Lc=wa.faceVertexUvs[1],Fc=wa.skinIndices,Tb=wa.skinWeights,kb=wa.morphTargets,Da=wa.morphNormals;if(wa.verticesNeedUpdate){for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],aa=fa[ca.a],$=fa[ca.b],Z=fa[ca.c],Qa[eb]=aa.x,Qa[eb+1]=aa.y,Qa[eb+2]=aa.z,Qa[eb+3]=$.x,Qa[eb+4]=$.y,Qa[eb+5]=$.z,Qa[eb+6]=Z.x,Qa[eb+7]=Z.y,Qa[eb+8]=Z.z,eb+=9;l.bindBuffer(l.ARRAY_BUFFER,C.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,Qa,S)}if(U)for(Ma=0,ib=kb.length;Ma<ib;Ma++){for(M=ta=0,ea=N.length;M<ea;M++)uc=N[M],ca=xa[uc],aa=kb[Ma].vertices[ca.a],$=kb[Ma].vertices[ca.b],Z=kb[Ma].vertices[ca.c],Ya=Eb[Ma],Ya[ta]=aa.x,Ya[ta+1]=aa.y,Ya[ta+2]=aa.z,Ya[ta+3]=$.x,Ya[ta+4]=$.y,Ya[ta+5]=$.z,Ya[ta+6]=Z.x,Ya[ta+7]=Z.y,Ya[ta+8]=Z.z,X.morphNormals&&(bb?(Rb=Da[Ma].vertexNormals[uc],Ga=Rb.a,na=Rb.b,nc=Rb.c):nc=na=Ga=Da[Ma].faceNormals[uc],Za=Jc[Ma],Za[ta]=Ga.x,Za[ta+1]=Ga.y,Za[ta+2]=Ga.z,Za[ta+3]=na.x,Za[ta+4]=na.y,Za[ta+5]=na.z,Za[ta+6]=nc.x,Za[ta+7]=nc.y,Za[ta+8]=nc.z),ta+=9;l.bindBuffer(l.ARRAY_BUFFER,C.__webglMorphTargetsBuffers[Ma]),l.bufferData(l.ARRAY_BUFFER,Eb[Ma],S),X.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,C.__webglMorphNormalsBuffers[Ma]),l.bufferData(l.ARRAY_BUFFER,Jc[Ma],S))}if(Tb.length){for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],qc=Tb[ca.a],Ba=Tb[ca.b],zb=Tb[ca.c],Va[ja]=qc.x,Va[ja+1]=qc.y,Va[ja+2]=qc.z,Va[ja+3]=qc.w,Va[ja+4]=Ba.x,Va[ja+5]=Ba.y,Va[ja+6]=Ba.z,Va[ja+7]=Ba.w,Va[ja+8]=zb.x,Va[ja+9]=zb.y,Va[ja+10]=zb.z,Va[ja+11]=zb.w,Ab=Fc[ca.a],Ha=Fc[ca.b],Bb=Fc[ca.c],Ua[ja]=Ab.x,Ua[ja+1]=Ab.y,Ua[ja+2]=Ab.z,Ua[ja+3]=Ab.w,Ua[ja+4]=Ha.x,Ua[ja+5]=Ha.y,Ua[ja+6]=Ha.z,Ua[ja+7]=Ha.w,Ua[ja+8]=Bb.x,Ua[ja+9]=Bb.y,Ua[ja+10]=Bb.z,Ua[ja+11]=Bb.w,ja+=12;0<ja&&(l.bindBuffer(l.ARRAY_BUFFER,C.__webglSkinIndicesBuffer),l.bufferData(l.ARRAY_BUFFER,Ua,S),l.bindBuffer(l.ARRAY_BUFFER,C.__webglSkinWeightsBuffer),l.bufferData(l.ARRAY_BUFFER,Va,S))}if(wb){for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],sa=ca.vertexColors,Fa=ca.color,3===sa.length&&X.vertexColors===THREE.VertexColors?(ia=sa[0],oc=sa[1],pc=sa[2]):pc=oc=ia=Fa,La[Ka]=ia.r,La[Ka+1]=ia.g,La[Ka+2]=ia.b,La[Ka+3]=oc.r,La[Ka+4]=oc.g,La[Ka+5]=oc.b,La[Ka+6]=pc.r,La[Ka+7]=pc.g,La[Ka+8]=pc.b,Ka+=9;0<Ka&&(l.bindBuffer(l.ARRAY_BUFFER,C.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,La,S))}if(da&&wa.hasTangents){for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],la=ca.vertexTangents,ya=la[0],qa=la[1],L=la[2],ra[Ca]=ya.x,ra[Ca+1]=ya.y,ra[Ca+2]=ya.z,ra[Ca+3]=ya.w,ra[Ca+4]=qa.x,ra[Ca+5]=qa.y,ra[Ca+6]=qa.z,ra[Ca+7]=qa.w,ra[Ca+8]=L.x,ra[Ca+9]=L.y,ra[Ca+10]=L.z,ra[Ca+11]=L.w,Ca+=12;l.bindBuffer(l.ARRAY_BUFFER,C.__webglTangentBuffer),l.bufferData(l.ARRAY_BUFFER,ra,S)}if(ec){for(M=0,ea=N.length;M<ea;M++)if(ca=xa[N[M]],ma=ca.vertexNormals,pa=ca.normal,3===ma.length&&bb)for(Aa=0;3>Aa;Aa++)Cb=ma[Aa],Ta[Sa]=Cb.x,Ta[Sa+1]=Cb.y,Ta[Sa+2]=Cb.z,Sa+=3;else for(Aa=0;3>Aa;Aa++)Ta[Sa]=pa.x,Ta[Sa+1]=pa.y,Ta[Sa+2]=pa.z,Sa+=3;l.bindBuffer(l.ARRAY_BUFFER,C.__webglNormalBuffer),l.bufferData(l.ARRAY_BUFFER,Ta,S)}if(Kc&&ua){for(M=0,ea=N.length;M<ea;M++)if(Y=N[M],hb=ua[Y],void 0!==hb)for(Aa=0;3>Aa;Aa++)Oa=hb[Aa],sb[qb]=Oa.x,sb[qb+1]=Oa.y,qb+=2;0<qb&&(l.bindBuffer(l.ARRAY_BUFFER,C.__webglUVBuffer),l.bufferData(l.ARRAY_BUFFER,sb,S))}if(Kc&&Lc){for(M=0,ea=N.length;M<ea;M++)if(Y=N[M],za=Lc[Y],void 0!==za)for(Aa=0;3>Aa;Aa++)Qb=za[Aa],fb[rb]=Qb.x,fb[rb+1]=Qb.y,rb+=2;0<rb&&(l.bindBuffer(l.ARRAY_BUFFER,C.__webglUV2Buffer),l.bufferData(l.ARRAY_BUFFER,fb,S))}if($a){for(M=0,ea=N.length;M<ea;M++)Sb[Db]=db,Sb[Db+1]=db+1,Sb[Db+2]=db+2,Db+=3,Ja[Pa]=db,Ja[Pa+1]=db+1,Ja[Pa+2]=db,Ja[Pa+3]=db+2,Ja[Pa+4]=db+1,Ja[Pa+5]=db+2,Pa+=6,db+=3;l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,C.__webglFaceBuffer),l.bufferData(l.ELEMENT_ARRAY_BUFFER,Sb,S),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,C.__webglLineBuffer),
l.bufferData(l.ELEMENT_ARRAY_BUFFER,Ja,S)}if(Kb)for(Aa=0,va=Kb.length;Aa<va;Aa++)if(z=Kb[Aa],z.__original.needsUpdate){if(I=0,1===z.size){if(void 0===z.boundTo||"vertices"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],z.array[I]=z.value[ca.a],z.array[I+1]=z.value[ca.b],z.array[I+2]=z.value[ca.c],I+=3;else if("faces"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)Ia=z.value[N[M]],z.array[I]=Ia,z.array[I+1]=Ia,z.array[I+2]=Ia,I+=3}else if(2===z.size){if(void 0===z.boundTo||"vertices"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],aa=z.value[ca.a],$=z.value[ca.b],Z=z.value[ca.c],z.array[I]=aa.x,z.array[I+1]=aa.y,z.array[I+2]=$.x,z.array[I+3]=$.y,z.array[I+4]=Z.x,z.array[I+5]=Z.y,I+=6;else if("faces"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)Z=$=aa=Ia=z.value[N[M]],z.array[I]=aa.x,z.array[I+1]=aa.y,z.array[I+2]=$.x,z.array[I+3]=$.y,z.array[I+4]=Z.x,z.array[I+5]=Z.y,I+=6}else if(3===z.size){var ka;if(ka="c"===z.type?["r","g","b"]:["x","y","z"],void 0===z.boundTo||"vertices"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],aa=z.value[ca.a],$=z.value[ca.b],Z=z.value[ca.c],z.array[I]=aa[ka[0]],z.array[I+1]=aa[ka[1]],z.array[I+2]=aa[ka[2]],z.array[I+3]=$[ka[0]],z.array[I+4]=$[ka[1]],z.array[I+5]=$[ka[2]],z.array[I+6]=Z[ka[0]],z.array[I+7]=Z[ka[1]],z.array[I+8]=Z[ka[2]],I+=9;else if("faces"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)Z=$=aa=Ia=z.value[N[M]],z.array[I]=aa[ka[0]],z.array[I+1]=aa[ka[1]],z.array[I+2]=aa[ka[2]],z.array[I+3]=$[ka[0]],z.array[I+4]=$[ka[1]],z.array[I+5]=$[ka[2]],z.array[I+6]=Z[ka[0]],z.array[I+7]=Z[ka[1]],z.array[I+8]=Z[ka[2]],I+=9;else if("faceVertices"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)Ia=z.value[N[M]],aa=Ia[0],$=Ia[1],Z=Ia[2],z.array[I]=aa[ka[0]],z.array[I+1]=aa[ka[1]],z.array[I+2]=aa[ka[2]],z.array[I+3]=$[ka[0]],z.array[I+4]=$[ka[1]],z.array[I+5]=$[ka[2]],z.array[I+6]=Z[ka[0]],z.array[I+7]=Z[ka[1]],z.array[I+8]=Z[ka[2]],I+=9}else if(4===z.size)if(void 0===z.boundTo||"vertices"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)ca=xa[N[M]],aa=z.value[ca.a],$=z.value[ca.b],Z=z.value[ca.c],z.array[I]=aa.x,z.array[I+1]=aa.y,z.array[I+2]=aa.z,z.array[I+3]=aa.w,z.array[I+4]=$.x,z.array[I+5]=$.y,z.array[I+6]=$.z,z.array[I+7]=$.w,z.array[I+8]=Z.x,z.array[I+9]=Z.y,z.array[I+10]=Z.z,z.array[I+11]=Z.w,I+=12;else if("faces"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)Z=$=aa=Ia=z.value[N[M]],z.array[I]=aa.x,z.array[I+1]=aa.y,z.array[I+2]=aa.z,z.array[I+3]=aa.w,z.array[I+4]=$.x,z.array[I+5]=$.y,z.array[I+6]=$.z,z.array[I+7]=$.w,z.array[I+8]=Z.x,z.array[I+9]=Z.y,z.array[I+10]=Z.z,z.array[I+11]=Z.w,I+=12;else if("faceVertices"===z.boundTo)for(M=0,ea=N.length;M<ea;M++)Ia=z.value[N[M]],aa=Ia[0],$=Ia[1],Z=Ia[2],z.array[I]=aa.x,z.array[I+1]=aa.y,z.array[I+2]=aa.z,z.array[I+3]=aa.w,z.array[I+4]=$.x,z.array[I+5]=$.y,z.array[I+6]=$.z,z.array[I+7]=$.w,z.array[I+8]=Z.x,z.array[I+9]=Z.y,z.array[I+10]=Z.z,z.array[I+11]=Z.w,I+=12;l.bindBuffer(l.ARRAY_BUFFER,z.buffer),l.bufferData(l.ARRAY_BUFFER,z.array,S)}T&&(delete C.__inittedArrays,delete C.__colorArray,delete C.__normalArray,delete C.__tangentArray,delete C.__uvArray,delete C.__uv2Array,delete C.__faceArray,delete C.__vertexArray,delete C.__lineArray,delete C.__skinIndexArray,delete C.__skinWeightArray)}}}r.verticesNeedUpdate=!1,r.morphTargetsNeedUpdate=!1,r.elementsNeedUpdate=!1,r.uvsNeedUpdate=!1,r.normalsNeedUpdate=!1,r.colorsNeedUpdate=!1,r.tangentsNeedUpdate=!1,G.attributes&&y(G)}else if(e instanceof THREE.Line){if(G=d(e,r),w=G.attributes&&v(G),r.verticesNeedUpdate||r.colorsNeedUpdate||r.lineDistancesNeedUpdate||w){var ab,Fb,gb,$b,ga,vc,yc,Lb,Ea,hc,Wa,oa,Zb=l.DYNAMIC_DRAW,dc=r.vertices,fc=r.colors,Pb=r.lineDistances,kc=dc.length,lc=fc.length,mc=Pb.length,wc=r.__vertexArray,xc=r.__colorArray,jc=r.__lineDistanceArray,sc=r.colorsNeedUpdate,tc=r.lineDistancesNeedUpdate,gc=r.__webglCustomAttributesList;if(r.verticesNeedUpdate){for(ab=0;ab<kc;ab++)$b=dc[ab],ga=3*ab,wc[ga]=$b.x,wc[ga+1]=$b.y,wc[ga+2]=$b.z;l.bindBuffer(l.ARRAY_BUFFER,r.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,wc,Zb)}if(sc){for(Fb=0;Fb<lc;Fb++)vc=fc[Fb],ga=3*Fb,xc[ga]=vc.r,xc[ga+1]=vc.g,xc[ga+2]=vc.b;l.bindBuffer(l.ARRAY_BUFFER,r.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,xc,Zb)}if(tc){for(gb=0;gb<mc;gb++)jc[gb]=Pb[gb];l.bindBuffer(l.ARRAY_BUFFER,r.__webglLineDistanceBuffer),l.bufferData(l.ARRAY_BUFFER,jc,Zb)}if(gc)for(yc=0,Lb=gc.length;yc<Lb;yc++)if(oa=gc[yc],oa.needsUpdate&&(void 0===oa.boundTo||"vertices"===oa.boundTo)){if(ga=0,hc=oa.value.length,1===oa.size)for(Ea=0;Ea<hc;Ea++)oa.array[Ea]=oa.value[Ea];else if(2===oa.size)for(Ea=0;Ea<hc;Ea++)Wa=oa.value[Ea],oa.array[ga]=Wa.x,oa.array[ga+1]=Wa.y,ga+=2;else if(3===oa.size)if("c"===oa.type)for(Ea=0;Ea<hc;Ea++)Wa=oa.value[Ea],oa.array[ga]=Wa.r,oa.array[ga+1]=Wa.g,oa.array[ga+2]=Wa.b,ga+=3;else for(Ea=0;Ea<hc;Ea++)Wa=oa.value[Ea],oa.array[ga]=Wa.x,oa.array[ga+1]=Wa.y,oa.array[ga+2]=Wa.z,ga+=3;else if(4===oa.size)for(Ea=0;Ea<hc;Ea++)Wa=oa.value[Ea],oa.array[ga]=Wa.x,oa.array[ga+1]=Wa.y,oa.array[ga+2]=Wa.z,oa.array[ga+3]=Wa.w,ga+=4;l.bindBuffer(l.ARRAY_BUFFER,oa.buffer),l.bufferData(l.ARRAY_BUFFER,oa.array,Zb)}}r.verticesNeedUpdate=!1,r.colorsNeedUpdate=!1,r.lineDistancesNeedUpdate=!1,G.attributes&&y(G)}else if(e instanceof THREE.PointCloud){if(G=d(e,r),w=G.attributes&&v(G),r.verticesNeedUpdate||r.colorsNeedUpdate||e.sortParticles||w){var Xa,tb,ub,W,vb,Ub,lb,ic,ba,mb,ha,V,Mb=l.DYNAMIC_DRAW,zc=r.vertices,pb=zc.length,Nb=r.colors,Ob=Nb.length,ac=r.__vertexArray,bc=r.__colorArray,Gb=r.__sortArray,Xb=r.verticesNeedUpdate,Yb=r.colorsNeedUpdate,Hb=r.__webglCustomAttributesList;if(e.sortParticles){for(Gc.copy(Ac),Gc.multiply(e.matrixWorld),Xa=0;Xa<pb;Xa++)ub=zc[Xa],Na.copy(ub),Na.applyProjection(Gc),Gb[Xa]=[Na.z,Xa];for(Gb.sort(p),Xa=0;Xa<pb;Xa++)ub=zc[Gb[Xa][1]],W=3*Xa,ac[W]=ub.x,ac[W+1]=ub.y,ac[W+2]=ub.z;for(tb=0;tb<Ob;tb++)W=3*tb,Ub=Nb[Gb[tb][1]],bc[W]=Ub.r,bc[W+1]=Ub.g,bc[W+2]=Ub.b;if(Hb)for(lb=0,ic=Hb.length;lb<ic;lb++)if(V=Hb[lb],void 0===V.boundTo||"vertices"===V.boundTo)if(W=0,mb=V.value.length,1===V.size)for(ba=0;ba<mb;ba++)vb=Gb[ba][1],V.array[ba]=V.value[vb];else if(2===V.size)for(ba=0;ba<mb;ba++)vb=Gb[ba][1],ha=V.value[vb],V.array[W]=ha.x,V.array[W+1]=ha.y,W+=2;else if(3===V.size)if("c"===V.type)for(ba=0;ba<mb;ba++)vb=Gb[ba][1],ha=V.value[vb],V.array[W]=ha.r,V.array[W+1]=ha.g,V.array[W+2]=ha.b,W+=3;else for(ba=0;ba<mb;ba++)vb=Gb[ba][1],ha=V.value[vb],V.array[W]=ha.x,V.array[W+1]=ha.y,V.array[W+2]=ha.z,W+=3;else if(4===V.size)for(ba=0;ba<mb;ba++)vb=Gb[ba][1],ha=V.value[vb],V.array[W]=ha.x,V.array[W+1]=ha.y,V.array[W+2]=ha.z,V.array[W+3]=ha.w,W+=4}else{if(Xb)for(Xa=0;Xa<pb;Xa++)ub=zc[Xa],W=3*Xa,ac[W]=ub.x,ac[W+1]=ub.y,ac[W+2]=ub.z;if(Yb)for(tb=0;tb<Ob;tb++)Ub=Nb[tb],W=3*tb,bc[W]=Ub.r,bc[W+1]=Ub.g,bc[W+2]=Ub.b;if(Hb)for(lb=0,ic=Hb.length;lb<ic;lb++)if(V=Hb[lb],V.needsUpdate&&(void 0===V.boundTo||"vertices"===V.boundTo))if(mb=V.value.length,W=0,1===V.size)for(ba=0;ba<mb;ba++)V.array[ba]=V.value[ba];else if(2===V.size)for(ba=0;ba<mb;ba++)ha=V.value[ba],V.array[W]=ha.x,V.array[W+1]=ha.y,W+=2;else if(3===V.size)if("c"===V.type)for(ba=0;ba<mb;ba++)ha=V.value[ba],V.array[W]=ha.r,V.array[W+1]=ha.g,V.array[W+2]=ha.b,W+=3;else for(ba=0;ba<mb;ba++)ha=V.value[ba],V.array[W]=ha.x,V.array[W+1]=ha.y,V.array[W+2]=ha.z,W+=3;else if(4===V.size)for(ba=0;ba<mb;ba++)ha=V.value[ba],V.array[W]=ha.x,V.array[W+1]=ha.y,V.array[W+2]=ha.z,V.array[W+3]=ha.w,W+=4}if((Xb||e.sortParticles)&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,ac,Mb)),(Yb||e.sortParticles)&&(l.bindBuffer(l.ARRAY_BUFFER,r.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,bc,Mb)),Hb)for(lb=0,ic=Hb.length;lb<ic;lb++)V=Hb[lb],(V.needsUpdate||e.sortParticles)&&(l.bindBuffer(l.ARRAY_BUFFER,V.buffer),l.bufferData(l.ARRAY_BUFFER,V.array,Mb))}r.verticesNeedUpdate=!1,r.colorsNeedUpdate=!1,G.attributes&&y(G)}for(var cc=0,nb=t.length;cc<nb;cc++){var Bc=t[cc],Vb=Bc,rc=Vb.object,Cc=Vb.buffer,Dc=rc.geometry,Wb=rc.material;Wb instanceof THREE.MeshFaceMaterial?(Wb=Wb.materials[Dc instanceof THREE.BufferGeometry?0:Cc.materialIndex],Vb.material=Wb,Wb.transparent?Ib.push(Vb):Jb.push(Vb)):Wb&&(Vb.material=Wb,Wb.transparent?Ib.push(Vb):Jb.push(Vb)),Bc.render=!0,!0===J.sortObjects&&(null!==e.renderDepth?Bc.z=e.renderDepth:(Na.setFromMatrixPosition(e.matrixWorld),Na.applyProjection(Ac),Bc.z=Na.z))}}}}for(cc=0,nb=e.children.length;cc<nb;cc++)q(a,e.children[cc])}}function m(a,b,c,d,e,f){for(var g,h=a.length-1;-1!==h;h--){g=a[h];var k=g.object,l=g.buffer;if(x(k,b),f)g=f;else{if(g=g.material,!g)continue;e&&J.setBlending(g.blending,g.blendEquation,g.blendSrc,g.blendDst),J.setDepthTest(g.depthTest),J.setDepthWrite(g.depthWrite),B(g.polygonOffset,g.polygonOffsetFactor,g.polygonOffsetUnits)}J.setMaterialFaces(g),l instanceof THREE.BufferGeometry?J.renderBufferDirect(b,c,d,g,l,k):J.renderBuffer(b,c,d,g,l,k)}}function r(a,b,c,d,e,f,g){for(var h,k=0,l=a.length;k<l;k++){h=a[k];var m=h.object;if(m.visible){if(g)h=g;else{if(h=h[b],!h)continue;f&&J.setBlending(h.blending,h.blendEquation,h.blendSrc,h.blendDst),J.setDepthTest(h.depthTest),J.setDepthWrite(h.depthWrite),B(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}J.renderImmediateObject(c,d,e,h,m)}}}function t(a){var b=a.object.material;b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function s(a,b,d){var e=b.material,f=!1;if(void 0===xb[d.id]||!0===d.groupsNeedUpdate){delete ob[b.id],a=xb;for(var k,p,g=d.id,e=e instanceof THREE.MeshFaceMaterial,h=pa.get("OES_element_index_uint")?4294967296:65535,f={},m=d.morphTargets.length,n=d.morphNormals.length,r={},q=[],t=0,s=d.faces.length;t<s;t++){k=d.faces[t];var v=e?k.materialIndex:0;v in f||(f[v]={hash:v,counter:0}),k=f[v].hash+"_"+f[v].counter,k in r||(p={id:rc++,faces3:[],materialIndex:v,vertices:0,numMorphTargets:m,numMorphNormals:n},r[k]=p,q.push(p)),r[k].vertices+3>h&&(f[v].counter+=1,k=f[v].hash+"_"+f[v].counter,k in r||(p={id:rc++,faces3:[],materialIndex:v,vertices:0,numMorphTargets:m,numMorphNormals:n},r[k]=p,q.push(p))),r[k].faces3.push(t),r[k].vertices+=3}a[g]=q,d.groupsNeedUpdate=!1}for(a=xb[d.id],g=0,e=a.length;g<e;g++){if(h=a[g],void 0===h.__webglVertexBuffer){if(f=h,f.__webglVertexBuffer=l.createBuffer(),f.__webglNormalBuffer=l.createBuffer(),f.__webglTangentBuffer=l.createBuffer(),f.__webglColorBuffer=l.createBuffer(),f.__webglUVBuffer=l.createBuffer(),f.__webglUV2Buffer=l.createBuffer(),f.__webglSkinIndicesBuffer=l.createBuffer(),f.__webglSkinWeightsBuffer=l.createBuffer(),f.__webglFaceBuffer=l.createBuffer(),f.__webglLineBuffer=l.createBuffer(),n=m=void 0,f.numMorphTargets)for(f.__webglMorphTargetsBuffers=[],m=0,n=f.numMorphTargets;m<n;m++)f.__webglMorphTargetsBuffers.push(l.createBuffer());if(f.numMorphNormals)for(f.__webglMorphNormalsBuffers=[],m=0,n=f.numMorphNormals;m<n;m++)f.__webglMorphNormalsBuffers.push(l.createBuffer());J.info.memory.geometries++,c(h,b),d.verticesNeedUpdate=!0,d.morphTargetsNeedUpdate=!0,d.elementsNeedUpdate=!0,d.uvsNeedUpdate=!0,d.normalsNeedUpdate=!0,d.tangentsNeedUpdate=!0,f=d.colorsNeedUpdate=!0}else f=!1;(f||void 0===b.__webglActive)&&u(ob,h,b)}b.__webglActive=!0}function u(a,b,c){var d=c.id;a[d]=a[d]||[],a[d].push({id:d,buffer:b,object:c,material:null,z:0})}function v(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function y(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function G(a,b,c,d,e){var f,g,h,k;if(dc=0,d.needsUpdate){d.program&&Cc(d),d.addEventListener("dispose",Dc);var m;if(d instanceof THREE.MeshDepthMaterial?m="depth":d instanceof THREE.MeshNormalMaterial?m="normal":d instanceof THREE.MeshBasicMaterial?m="basic":d instanceof THREE.MeshLambertMaterial?m="lambert":d instanceof THREE.MeshPhongMaterial?m="phong":d instanceof THREE.LineBasicMaterial?m="basic":d instanceof THREE.LineDashedMaterial?m="dashed":d instanceof THREE.PointCloudMaterial&&(m="particle_basic"),m){var n=THREE.ShaderLib[m];d.__webglShader={uniforms:THREE.UniformsUtils.clone(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader}}else d.__webglShader={uniforms:d.uniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader};for(var p=0,r=0,q=0,t=0,s=0,u=b.length;s<u;s++){var v=b[s];v.onlyShadow||!1===v.visible||(v instanceof THREE.DirectionalLight&&p++,v instanceof THREE.PointLight&&r++,v instanceof THREE.SpotLight&&q++,v instanceof THREE.HemisphereLight&&t++)}f=p,g=r,h=q,k=t;for(var y,G=0,x=0,B=b.length;x<B;x++){var A=b[x];A.castShadow&&(A instanceof THREE.SpotLight&&G++,A instanceof THREE.DirectionalLight&&!A.shadowCascade&&G++)}y=G;var C;if(jc&&e&&e.skeleton&&e.skeleton.useVertexTexture)C=1024;else{var H=l.getParameter(l.MAX_VERTEX_UNIFORM_VECTORS),S=Math.floor((H-20)/4);void 0!==e&&e instanceof THREE.SkinnedMesh&&(S=Math.min(e.skeleton.bones.length,S),S<e.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+e.skeleton.bones.length+", this GPU supports just "+S+" (try OpenGL instead of ANGLE)")),C=S}var P={precision:X,supportsVertexTextures:sc,map:!!d.map,envMap:!!d.envMap,lightMap:!!d.lightMap,bumpMap:!!d.bumpMap,normalMap:!!d.normalMap,specularMap:!!d.specularMap,alphaMap:!!d.alphaMap,vertexColors:d.vertexColors,fog:c,useFog:d.fog,fogExp:c instanceof THREE.FogExp2,sizeAttenuation:d.sizeAttenuation,logarithmicDepthBuffer:Fa,skinning:d.skinning,maxBones:C,useVertexTexture:jc&&e&&e.skeleton&&e.skeleton.useVertexTexture,morphTargets:d.morphTargets,morphNormals:d.morphNormals,maxMorphTargets:J.maxMorphTargets,maxMorphNormals:J.maxMorphNormals,maxDirLights:f,maxPointLights:g,maxSpotLights:h,maxHemiLights:k,maxShadows:y,shadowMapEnabled:J.shadowMapEnabled&&e.receiveShadow&&0<y,shadowMapType:J.shadowMapType,shadowMapDebug:J.shadowMapDebug,shadowMapCascade:J.shadowMapCascade,alphaTest:d.alphaTest,metal:d.metal,wrapAround:d.wrapAround,doubleSided:d.side===THREE.DoubleSide,flipSided:d.side===THREE.BackSide},T=[];if(m?T.push(m):(T.push(d.fragmentShader),T.push(d.vertexShader)),void 0!==d.defines)for(var bb in d.defines)T.push(bb),T.push(d.defines[bb]);for(bb in P)T.push(bb),T.push(P[bb]);for(var Y,M=T.join(),jb=0,ca=hb.length;jb<ca;jb++){var cb=hb[jb];if(cb.code===M){Y=cb,Y.usedTimes++;break}}void 0===Y&&(Y=new THREE.WebGLProgram(J,M,d,P),hb.push(Y),J.info.memory.programs=hb.length),d.program=Y;var ob=Y.attributes;if(d.morphTargets){d.numSupportedMorphTargets=0;for(var ma,pa="morphTarget",la=0;la<J.maxMorphTargets;la++)ma=pa+la,0<=ob[ma]&&d.numSupportedMorphTargets++}if(d.morphNormals)for(d.numSupportedMorphNormals=0,pa="morphNormal",la=0;la<J.maxMorphNormals;la++)ma=pa+la,0<=ob[ma]&&d.numSupportedMorphNormals++;d.uniformsList=[];for(var Jb in d.__webglShader.uniforms){var za=d.program.uniforms[Jb];za&&d.uniformsList.push([d.__webglShader.uniforms[Jb],za])}d.needsUpdate=!1}d.morphTargets&&!e.__webglMorphTargetInfluences&&(e.__webglMorphTargetInfluences=new Float32Array(J.maxMorphTargets));var aa=!1,$=!1,Z=!1,yb=d.program,qa=yb.uniforms,L=d.__webglShader.uniforms;if(yb.id!==tc&&(l.useProgram(yb.program),tc=yb.id,Z=$=aa=!0),d.id!==Kb&&(-1===Kb&&(Z=!0),Kb=d.id,$=!0),(aa||a!==ec)&&(l.uniformMatrix4fv(qa.projectionMatrix,!1,a.projectionMatrix.elements),Fa&&l.uniform1f(qa.logDepthBufFC,2/(Math.log(a.far+1)/Math.LN2)),a!==ec&&(ec=a),(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==qa.cameraPosition&&(Na.setFromMatrixPosition(a.matrixWorld),l.uniform3f(qa.cameraPosition,Na.x,Na.y,Na.z)),(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==qa.viewMatrix&&l.uniformMatrix4fv(qa.viewMatrix,!1,a.matrixWorldInverse.elements)),d.skinning)if(e.bindMatrix&&null!==qa.bindMatrix&&l.uniformMatrix4fv(qa.bindMatrix,!1,e.bindMatrix.elements),e.bindMatrixInverse&&null!==qa.bindMatrixInverse&&l.uniformMatrix4fv(qa.bindMatrixInverse,!1,e.bindMatrixInverse.elements),jc&&e.skeleton&&e.skeleton.useVertexTexture){if(null!==qa.boneTexture){var Ib=K();l.uniform1i(qa.boneTexture,Ib),J.setTexture(e.skeleton.boneTexture,Ib)}null!==qa.boneTextureWidth&&l.uniform1i(qa.boneTextureWidth,e.skeleton.boneTextureWidth),null!==qa.boneTextureHeight&&l.uniform1i(qa.boneTextureHeight,e.skeleton.boneTextureHeight)}else e.skeleton&&e.skeleton.boneMatrices&&null!==qa.boneGlobalMatrices&&l.uniformMatrix4fv(qa.boneGlobalMatrices,!1,e.skeleton.boneMatrices);if($){if(c&&d.fog&&(L.fogColor.value=c.color,c instanceof THREE.Fog?(L.fogNear.value=c.near,L.fogFar.value=c.far):c instanceof THREE.FogExp2&&(L.fogDensity.value=c.density)),d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(fc){var na,Ra,ia,Ba,zb,Ab,Ha,Bb,Aa,Z=!0,ya=0,Ga=0,Oa=0,va=Mc,Cb=va.directional.colors,ib=va.directional.positions,Qb=va.point.colors,Ma=va.point.positions,xb=va.point.distances,Ya=va.spot.colors,Za=va.spot.positions,Mb=va.spot.distances,Rb=va.spot.directions,db=va.spot.anglesCos,eb=va.spot.exponents,qb=va.hemi.skyColors,rb=va.hemi.groundColors,Db=va.hemi.positions,Sa=0,Ca=0,Pa=0,Ka=0,ja=0,ta=0,I=0,Ia=0,Qa=0,sb=0,fb=0,Ta=0;for(na=0,Ra=b.length;na<Ra;na++)ia=b[na],ia.onlyShadow||(Ba=ia.color,Ha=ia.intensity,Aa=ia.distance,ia instanceof THREE.AmbientLight?ia.visible&&(J.gammaInput?(ya+=Ba.r*Ba.r,Ga+=Ba.g*Ba.g,Oa+=Ba.b*Ba.b):(ya+=Ba.r,Ga+=Ba.g,Oa+=Ba.b)):ia instanceof THREE.DirectionalLight?(ja+=1,ia.visible&&(sa.setFromMatrixPosition(ia.matrixWorld),Na.setFromMatrixPosition(ia.target.matrixWorld),sa.sub(Na),sa.normalize(),Qa=3*Sa,ib[Qa]=sa.x,ib[Qa+1]=sa.y,ib[Qa+2]=sa.z,J.gammaInput?D(Cb,Qa,Ba,Ha*Ha):E(Cb,Qa,Ba,Ha),Sa+=1)):ia instanceof THREE.PointLight?(ta+=1,ia.visible&&(sb=3*Ca,J.gammaInput?D(Qb,sb,Ba,Ha*Ha):E(Qb,sb,Ba,Ha),Na.setFromMatrixPosition(ia.matrixWorld),Ma[sb]=Na.x,Ma[sb+1]=Na.y,Ma[sb+2]=Na.z,xb[Ca]=Aa,Ca+=1)):ia instanceof THREE.SpotLight?(I+=1,ia.visible&&(fb=3*Pa,J.gammaInput?D(Ya,fb,Ba,Ha*Ha):E(Ya,fb,Ba,Ha),sa.setFromMatrixPosition(ia.matrixWorld),Za[fb]=sa.x,Za[fb+1]=sa.y,Za[fb+2]=sa.z,Mb[Pa]=Aa,Na.setFromMatrixPosition(ia.target.matrixWorld),sa.sub(Na),sa.normalize(),Rb[fb]=sa.x,Rb[fb+1]=sa.y,Rb[fb+2]=sa.z,db[Pa]=Math.cos(ia.angle),eb[Pa]=ia.exponent,Pa+=1)):ia instanceof THREE.HemisphereLight&&(Ia+=1,ia.visible&&(sa.setFromMatrixPosition(ia.matrixWorld),sa.normalize(),Ta=3*Ka,Db[Ta]=sa.x,Db[Ta+1]=sa.y,Db[Ta+2]=sa.z,zb=ia.color,Ab=ia.groundColor,J.gammaInput?(Bb=Ha*Ha,D(qb,Ta,zb,Bb),D(rb,Ta,Ab,Bb)):(E(qb,Ta,zb,Ha),E(rb,Ta,Ab,Ha)),Ka+=1)));for(na=3*Sa,Ra=Math.max(Cb.length,3*ja);na<Ra;na++)Cb[na]=0;for(na=3*Ca,Ra=Math.max(Qb.length,3*ta);na<Ra;na++)Qb[na]=0;for(na=3*Pa,Ra=Math.max(Ya.length,3*I);na<Ra;na++)Ya[na]=0;for(na=3*Ka,Ra=Math.max(qb.length,3*Ia);na<Ra;na++)qb[na]=0;for(na=3*Ka,Ra=Math.max(rb.length,3*Ia);na<Ra;na++)rb[na]=0;va.directional.length=Sa,va.point.length=Ca,va.spot.length=Pa,va.hemi.length=Ka,va.ambient[0]=ya,va.ambient[1]=Ga,va.ambient[2]=Oa,fc=!1}if(Z){var ra=Mc;L.ambientLightColor.value=ra.ambient,L.directionalLightColor.value=ra.directional.colors,L.directionalLightDirection.value=ra.directional.positions,L.pointLightColor.value=ra.point.colors,L.pointLightPosition.value=ra.point.positions,L.pointLightDistance.value=ra.point.distances,L.spotLightColor.value=ra.spot.colors,L.spotLightPosition.value=ra.spot.positions,L.spotLightDistance.value=ra.spot.distances,L.spotLightDirection.value=ra.spot.directions,L.spotLightAngleCos.value=ra.spot.anglesCos,L.spotLightExponent.value=ra.spot.exponents,L.hemisphereLightSkyColor.value=ra.hemi.skyColors,L.hemisphereLightGroundColor.value=ra.hemi.groundColors,L.hemisphereLightDirection.value=ra.hemi.positions,w(L,!0)}else w(L,!1)}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){L.opacity.value=d.opacity,J.gammaInput?L.diffuse.value.copyGammaToLinear(d.color):L.diffuse.value=d.color,L.map.value=d.map,L.lightMap.value=d.lightMap,L.specularMap.value=d.specularMap,L.alphaMap.value=d.alphaMap,d.bumpMap&&(L.bumpMap.value=d.bumpMap,L.bumpScale.value=d.bumpScale),d.normalMap&&(L.normalMap.value=d.normalMap,L.normalScale.value.copy(d.normalScale));var La;if(d.map?La=d.map:d.specularMap?La=d.specularMap:d.normalMap?La=d.normalMap:d.bumpMap?La=d.bumpMap:d.alphaMap&&(La=d.alphaMap),void 0!==La){var Ua=La.offset,Va=La.repeat;L.offsetRepeat.value.set(Ua.x,Ua.y,Va.x,Va.y)}L.envMap.value=d.envMap,L.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,L.reflectivity.value=d.reflectivity,L.refractionRatio.value=d.refractionRatio,L.combine.value=d.combine,L.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping}if(d instanceof THREE.LineBasicMaterial?(L.diffuse.value=d.color,L.opacity.value=d.opacity):d instanceof THREE.LineDashedMaterial?(L.diffuse.value=d.color,L.opacity.value=d.opacity,L.dashSize.value=d.dashSize,L.totalSize.value=d.dashSize+d.gapSize,L.scale.value=d.scale):d instanceof THREE.PointCloudMaterial?(L.psColor.value=d.color,L.opacity.value=d.opacity,L.size.value=d.size,L.scale.value=O.height/2,L.map.value=d.map):d instanceof THREE.MeshPhongMaterial?(L.shininess.value=d.shininess,J.gammaInput?(L.ambient.value.copyGammaToLinear(d.ambient),L.emissive.value.copyGammaToLinear(d.emissive),L.specular.value.copyGammaToLinear(d.specular)):(L.ambient.value=d.ambient,L.emissive.value=d.emissive,L.specular.value=d.specular),d.wrapAround&&L.wrapRGB.value.copy(d.wrapRGB)):d instanceof THREE.MeshLambertMaterial?(J.gammaInput?(L.ambient.value.copyGammaToLinear(d.ambient),L.emissive.value.copyGammaToLinear(d.emissive)):(L.ambient.value=d.ambient,L.emissive.value=d.emissive),d.wrapAround&&L.wrapRGB.value.copy(d.wrapRGB)):d instanceof THREE.MeshDepthMaterial?(L.mNear.value=a.near,L.mFar.value=a.far,L.opacity.value=d.opacity):d instanceof THREE.MeshNormalMaterial&&(L.opacity.value=d.opacity),e.receiveShadow&&!d._shadowPass&&L.shadowMatrix)for(var Eb=0,pb=0,Nb=b.length;pb<Nb;pb++){var z=b[pb];z.castShadow&&(z instanceof THREE.SpotLight||z instanceof THREE.DirectionalLight&&!z.shadowCascade)&&(L.shadowMap.value[Eb]=z.shadowMap,L.shadowMapSize.value[Eb]=z.shadowMapSize,L.shadowMatrix.value[Eb]=z.shadowMatrix,L.shadowDarkness.value[Eb]=z.shadowDarkness,L.shadowBias.value[Eb]=z.shadowBias,Eb++)}for(var Ja,wa,$a,Sb=d.uniformsList,nb=0,Pb=Sb.length;nb<Pb;nb++){var da=Sb[nb][0];if(!1!==da.needsUpdate){var wb=da.type,U=da.value,fa=Sb[nb][1];switch(wb){case"1i":l.uniform1i(fa,U);break;case"1f":l.uniform1f(fa,U);break;case"2f":l.uniform2f(fa,U[0],U[1]);break;case"3f":l.uniform3f(fa,U[0],U[1],U[2]);break;case"4f":l.uniform4f(fa,U[0],U[1],U[2],U[3]);break;case"1iv":l.uniform1iv(fa,U);break;case"3iv":l.uniform3iv(fa,U);break;case"1fv":l.uniform1fv(fa,U);break;case"2fv":l.uniform2fv(fa,U);break;case"3fv":l.uniform3fv(fa,U);break;case"4fv":l.uniform4fv(fa,U);break;case"Matrix3fv":l.uniformMatrix3fv(fa,!1,U);break;case"Matrix4fv":l.uniformMatrix4fv(fa,!1,U);break;case"i":l.uniform1i(fa,U);break;case"f":l.uniform1f(fa,U);break;case"v2":l.uniform2f(fa,U.x,U.y);break;case"v3":l.uniform3f(fa,U.x,U.y,U.z);break;case"v4":l.uniform4f(fa,U.x,U.y,U.z,U.w);break;case"c":l.uniform3f(fa,U.r,U.g,U.b);break;case"iv1":l.uniform1iv(fa,U);break;case"iv":l.uniform3iv(fa,U);break;case"fv1":l.uniform1fv(fa,U);break;case"fv":l.uniform3fv(fa,U);break;case"v2v":void 0===da._array&&(da._array=new Float32Array(2*U.length));for(var N=0,xa=U.length;N<xa;N++)$a=2*N,da._array[$a]=U[N].x,da._array[$a+1]=U[N].y;l.uniform2fv(fa,da._array);break;case"v3v":for(void 0===da._array&&(da._array=new Float32Array(3*U.length)),N=0,xa=U.length;N<xa;N++)$a=3*N,da._array[$a]=U[N].x,da._array[$a+1]=U[N].y,da._array[$a+2]=U[N].z;l.uniform3fv(fa,da._array);break;case"v4v":for(void 0===da._array&&(da._array=new Float32Array(4*U.length)),N=0,xa=U.length;N<xa;N++)$a=4*N,da._array[$a]=U[N].x,da._array[$a+1]=U[N].y,da._array[$a+2]=U[N].z,da._array[$a+3]=U[N].w;l.uniform4fv(fa,da._array);break;case"m3":l.uniformMatrix3fv(fa,!1,U.elements);break;case"m3v":for(void 0===da._array&&(da._array=new Float32Array(9*U.length)),N=0,xa=U.length;N<xa;N++)U[N].flattenToArrayOffset(da._array,9*N);l.uniformMatrix3fv(fa,!1,da._array);break;case"m4":l.uniformMatrix4fv(fa,!1,U.elements);break;case"m4v":for(void 0===da._array&&(da._array=new Float32Array(16*U.length)),N=0,xa=U.length;N<xa;N++)U[N].flattenToArrayOffset(da._array,16*N);l.uniformMatrix4fv(fa,!1,da._array);break;case"t":if(Ja=U,wa=K(),l.uniform1i(fa,wa),!Ja)continue;if(Ja instanceof THREE.CubeTexture||Ja.image instanceof Array&&6===Ja.image.length){var ua=Ja,Lb=wa;if(6===ua.image.length)if(ua.needsUpdate){ua.image.__webglTextureCube||(ua.addEventListener("dispose",gc),ua.image.__webglTextureCube=l.createTexture(),J.info.memory.textures++),l.activeTexture(l.TEXTURE0+Lb),l.bindTexture(l.TEXTURE_CUBE_MAP,ua.image.__webglTextureCube),l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,ua.flipY);for(var Ob=ua instanceof THREE.CompressedTexture,Tb=ua.image[0]instanceof THREE.DataTexture,kb=[],Da=0;6>Da;Da++)kb[Da]=!J.autoScaleCubemaps||Ob||Tb?Tb?ua.image[Da].image:ua.image[Da]:R(ua.image[Da],$c);var ka=kb[0],Zb=THREE.Math.isPowerOfTwo(ka.width)&&THREE.Math.isPowerOfTwo(ka.height),ab=Q(ua.format),Fb=Q(ua.type);for(F(l.TEXTURE_CUBE_MAP,ua,Zb),Da=0;6>Da;Da++)if(Ob)for(var gb,$b=kb[Da].mipmaps,ga=0,Xb=$b.length;ga<Xb;ga++)gb=$b[ga],ua.format!==THREE.RGBAFormat&&ua.format!==THREE.RGBFormat?-1<Nc().indexOf(ab)?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+Da,ga,ab,gb.width,gb.height,0,gb.data):console.warn("Attempt to load unsupported compressed texture format"):l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+Da,ga,ab,gb.width,gb.height,0,ab,Fb,gb.data);else Tb?l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+Da,0,ab,kb[Da].width,kb[Da].height,0,ab,Fb,kb[Da].data):l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+Da,0,ab,ab,Fb,kb[Da]);ua.generateMipmaps&&Zb&&l.generateMipmap(l.TEXTURE_CUBE_MAP),ua.needsUpdate=!1,ua.onUpdate&&ua.onUpdate()}else l.activeTexture(l.TEXTURE0+Lb),l.bindTexture(l.TEXTURE_CUBE_MAP,ua.image.__webglTextureCube)}else if(Ja instanceof THREE.WebGLRenderTargetCube){var Yb=Ja;l.activeTexture(l.TEXTURE0+wa),l.bindTexture(l.TEXTURE_CUBE_MAP,Yb.__webglTexture)}else J.setTexture(Ja,wa);break;case"tv":for(void 0===da._array&&(da._array=[]),N=0,xa=da.value.length;N<xa;N++)da._array[N]=K();for(l.uniform1iv(fa,da._array),N=0,xa=da.value.length;N<xa;N++)Ja=da.value[N],wa=da._array[N],Ja&&J.setTexture(Ja,wa);break;default:console.warn("THREE.WebGLRenderer: Unknown uniform type: "+wb)}}}}return l.uniformMatrix4fv(qa.modelViewMatrix,!1,e._modelViewMatrix.elements),qa.normalMatrix&&l.uniformMatrix3fv(qa.normalMatrix,!1,e._normalMatrix.elements),null!==qa.modelMatrix&&l.uniformMatrix4fv(qa.modelMatrix,!1,e.matrixWorld.elements),yb}function w(a,b){a.ambientLightColor.needsUpdate=b,a.directionalLightColor.needsUpdate=b,a.directionalLightDirection.needsUpdate=b,a.pointLightColor.needsUpdate=b,a.pointLightPosition.needsUpdate=b,a.pointLightDistance.needsUpdate=b,a.spotLightColor.needsUpdate=b,a.spotLightPosition.needsUpdate=b,a.spotLightDistance.needsUpdate=b,a.spotLightDirection.needsUpdate=b,a.spotLightAngleCos.needsUpdate=b,a.spotLightExponent.needsUpdate=b,a.hemisphereLightSkyColor.needsUpdate=b,a.hemisphereLightGroundColor.needsUpdate=b,a.hemisphereLightDirection.needsUpdate=b}function K(){var a=dc;return a>=Oc&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+Oc),dc+=1,a}function x(a,b){a._modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,a.matrixWorld),a._normalMatrix.getNormalMatrix(a._modelViewMatrix)}function D(a,b,c,d){a[b]=c.r*c.r*d,a[b+1]=c.g*c.g*d,a[b+2]=c.b*c.b*d}function E(a,b,c,d){a[b]=c.r*d,a[b+1]=c.g*d,a[b+2]=c.b*d}function A(a){a!==Pc&&(l.lineWidth(a),Pc=a)}function B(a,b,c){Qc!==a&&(a?l.enable(l.POLYGON_OFFSET_FILL):l.disable(l.POLYGON_OFFSET_FILL),Qc=a),!a||Rc===b&&Sc===c||(l.polygonOffset(b,c),Rc=b,Sc=c)}function F(a,b,c){c?(l.texParameteri(a,l.TEXTURE_WRAP_S,Q(b.wrapS)),l.texParameteri(a,l.TEXTURE_WRAP_T,Q(b.wrapT)),l.texParameteri(a,l.TEXTURE_MAG_FILTER,Q(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,Q(b.minFilter))):(l.texParameteri(a,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texParameteri(a,l.TEXTURE_MAG_FILTER,T(b.magFilter)),l.texParameteri(a,l.TEXTURE_MIN_FILTER,T(b.minFilter))),(c=pa.get("EXT_texture_filter_anisotropic"))&&b.type!==THREE.FloatType&&(1<b.anisotropy||b.__oldAnisotropy)&&(l.texParameterf(a,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,J.getMaxAnisotropy())),b.__oldAnisotropy=b.anisotropy)}function R(a,b){if(a.width>b||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");return d.width=Math.floor(a.width*c),d.height=Math.floor(a.height*c),d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height),console.log("THREE.WebGLRenderer:",a,"is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height+"."),d}return a}function H(a,b){l.bindRenderbuffer(l.RENDERBUFFER,a),b.depthBuffer&&!b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_STENCIL,b.width,b.height),l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a)):l.renderbufferStorage(l.RENDERBUFFER,l.RGBA4,b.width,b.height)}function C(a){a instanceof THREE.WebGLRenderTargetCube?(l.bindTexture(l.TEXTURE_CUBE_MAP,a.__webglTexture),l.generateMipmap(l.TEXTURE_CUBE_MAP),l.bindTexture(l.TEXTURE_CUBE_MAP,null)):(l.bindTexture(l.TEXTURE_2D,a.__webglTexture),l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null))}function T(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?l.NEAREST:l.LINEAR}function Q(a){var b;if(a===THREE.RepeatWrapping)return l.REPEAT;if(a===THREE.ClampToEdgeWrapping)return l.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return l.MIRRORED_REPEAT;if(a===THREE.NearestFilter)return l.NEAREST;if(a===THREE.NearestMipMapNearestFilter)return l.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return l.NEAREST_MIPMAP_LINEAR;if(a===THREE.LinearFilter)return l.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return l.LINEAR_MIPMAP_NEAREST;if(a===THREE.LinearMipMapLinearFilter)return l.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return l.UNSIGNED_BYTE;if(a===THREE.UnsignedShort4444Type)return l.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return l.UNSIGNED_SHORT_5_5_5_1;if(a===THREE.UnsignedShort565Type)return l.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return l.BYTE;if(a===THREE.ShortType)return l.SHORT;if(a===THREE.UnsignedShortType)return l.UNSIGNED_SHORT;if(a===THREE.IntType)return l.INT;if(a===THREE.UnsignedIntType)return l.UNSIGNED_INT;if(a===THREE.FloatType)return l.FLOAT;if(a===THREE.AlphaFormat)return l.ALPHA;if(a===THREE.RGBFormat)return l.RGB;if(a===THREE.RGBAFormat)return l.RGBA;if(a===THREE.LuminanceFormat)return l.LUMINANCE;if(a===THREE.LuminanceAlphaFormat)return l.LUMINANCE_ALPHA;if(a===THREE.AddEquation)return l.FUNC_ADD;if(a===THREE.SubtractEquation)return l.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return l.FUNC_REVERSE_SUBTRACT;if(a===THREE.ZeroFactor)return l.ZERO;if(a===THREE.OneFactor)return l.ONE;if(a===THREE.SrcColorFactor)return l.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return l.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return l.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return l.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return l.DST_ALPHA;if(a===THREE.OneMinusDstAlphaFactor)return l.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return l.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return l.ONE_MINUS_DST_COLOR;if(a===THREE.SrcAlphaSaturateFactor)return l.SRC_ALPHA_SATURATE;if(b=pa.get("WEBGL_compressed_texture_s3tc"),null!==b){if(a===THREE.RGB_S3TC_DXT1_Format)return b.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT1_Format)return b.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT3_Format)return b.COMPRESSED_RGBA_S3TC_DXT3_EXT;
if(a===THREE.RGBA_S3TC_DXT5_Format)return b.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(b=pa.get("WEBGL_compressed_texture_pvrtc"),null!==b){if(a===THREE.RGB_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===THREE.RGB_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===THREE.RGBA_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===THREE.RGBA_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(b=pa.get("EXT_blend_minmax"),null!==b){if(a===THREE.MinEquation)return b.MIN_EXT;if(a===THREE.MaxEquation)return b.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION),a=a||{};var O=void 0!==a.canvas?a.canvas:document.createElement("canvas"),S=void 0!==a.context?a.context:null,X=void 0!==a.precision?a.precision:"highp",Y=void 0!==a.alpha&&a.alpha,la=void 0===a.depth||a.depth,ma=void 0===a.stencil||a.stencil,ya=void 0!==a.antialias&&a.antialias,P=void 0===a.premultipliedAlpha||a.premultipliedAlpha,Ga=void 0!==a.preserveDrawingBuffer&&a.preserveDrawingBuffer,Fa=void 0!==a.logarithmicDepthBuffer&&a.logarithmicDepthBuffer,za=new THREE.Color(0),bb=0,cb=[],ob={},jb=[],Jb=[],Ib=[],yb=[],Ra=[];this.domElement=O,this.context=null,this.devicePixelRatio=void 0!==a.devicePixelRatio?a.devicePixelRatio:void 0!==self.devicePixelRatio?self.devicePixelRatio:1,this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0,this.shadowMapEnabled=this.gammaOutput=this.gammaInput=!1,this.shadowMapType=THREE.PCFShadowMap,this.shadowMapCullFace=THREE.CullFaceFront,this.shadowMapCascade=this.shadowMapDebug=!1,this.maxMorphTargets=8,this.maxMorphNormals=4,this.autoScaleCubemaps=!0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var l,J=this,hb=[],tc=null,Tc=null,Kb=-1,Oa=-1,ec=null,dc=0,Lb=-1,Mb=-1,pb=-1,Nb=-1,Ob=-1,Xb=-1,Yb=-1,nb=-1,Qc=null,Rc=null,Sc=null,Pc=null,Pb=0,kc=0,lc=O.width,mc=O.height,Uc=0,Vc=0,wb=new Uint8Array(16),ib=new Uint8Array(16),Ec=new THREE.Frustum,Ac=new THREE.Matrix4,Gc=new THREE.Matrix4,Na=new THREE.Vector3,sa=new THREE.Vector3,fc=!0,Mc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglesCos:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}};try{var Wc={alpha:Y,depth:la,stencil:ma,antialias:ya,premultipliedAlpha:P,preserveDrawingBuffer:Ga};if(l=S||O.getContext("webgl",Wc)||O.getContext("experimental-webgl",Wc),null===l){if(null!==O.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context."}}catch(ad){console.error(ad)}void 0===l.getShaderPrecisionFormat&&(l.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}});var pa=new THREE.WebGLExtensions(l);pa.get("OES_texture_float"),pa.get("OES_texture_float_linear"),pa.get("OES_standard_derivatives"),Fa&&pa.get("EXT_frag_depth"),l.clearColor(0,0,0,1),l.clearDepth(1),l.clearStencil(0),l.enable(l.DEPTH_TEST),l.depthFunc(l.LEQUAL),l.frontFace(l.CCW),l.cullFace(l.BACK),l.enable(l.CULL_FACE),l.enable(l.BLEND),l.blendEquation(l.FUNC_ADD),l.blendFunc(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA),l.viewport(Pb,kc,lc,mc),l.clearColor(za.r,za.g,za.b,bb),this.context=l;var Oc=l.getParameter(l.MAX_TEXTURE_IMAGE_UNITS),bd=l.getParameter(l.MAX_VERTEX_TEXTURE_IMAGE_UNITS),cd=l.getParameter(l.MAX_TEXTURE_SIZE),$c=l.getParameter(l.MAX_CUBE_MAP_TEXTURE_SIZE),sc=0<bd,jc=sc&&pa.get("OES_texture_float"),dd=l.getShaderPrecisionFormat(l.VERTEX_SHADER,l.HIGH_FLOAT),ed=l.getShaderPrecisionFormat(l.VERTEX_SHADER,l.MEDIUM_FLOAT);l.getShaderPrecisionFormat(l.VERTEX_SHADER,l.LOW_FLOAT);var fd=l.getShaderPrecisionFormat(l.FRAGMENT_SHADER,l.HIGH_FLOAT),gd=l.getShaderPrecisionFormat(l.FRAGMENT_SHADER,l.MEDIUM_FLOAT);l.getShaderPrecisionFormat(l.FRAGMENT_SHADER,l.LOW_FLOAT);var Nc=function(){var a;return function(){if(void 0!==a)return a;if(a=[],pa.get("WEBGL_compressed_texture_pvrtc")||pa.get("WEBGL_compressed_texture_s3tc"))for(var b=l.getParameter(l.COMPRESSED_TEXTURE_FORMATS),c=0;c<b.length;c++)a.push(b[c]);return a}}(),hd=0<dd.precision&&0<fd.precision,Xc=0<ed.precision&&0<gd.precision;"highp"!==X||hd||(Xc?(X="mediump",console.warn("THREE.WebGLRenderer: highp not supported, using mediump.")):(X="lowp",console.warn("THREE.WebGLRenderer: highp and mediump not supported, using lowp."))),"mediump"!==X||Xc||(X="lowp",console.warn("THREE.WebGLRenderer: mediump not supported, using lowp."));var id=new THREE.ShadowMapPlugin(this,cb,ob,jb),jd=new THREE.SpritePlugin(this,yb),kd=new THREE.LensFlarePlugin(this,Ra);this.getContext=function(){return l},this.supportsVertexTextures=function(){return sc},this.supportsFloatTextures=function(){return pa.get("OES_texture_float")},this.supportsStandardDerivatives=function(){return pa.get("OES_standard_derivatives")},this.supportsCompressedTextureS3TC=function(){return pa.get("WEBGL_compressed_texture_s3tc")},this.supportsCompressedTexturePVRTC=function(){return pa.get("WEBGL_compressed_texture_pvrtc")},this.supportsBlendMinMax=function(){return pa.get("EXT_blend_minmax")},this.getMaxAnisotropy=function(){var a;return function(){if(void 0!==a)return a;var b=pa.get("EXT_texture_filter_anisotropic");return a=null!==b?l.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}}(),this.getPrecision=function(){return X},this.setSize=function(a,b,c){O.width=a*this.devicePixelRatio,O.height=b*this.devicePixelRatio,!1!==c&&(O.style.width=a+"px",O.style.height=b+"px"),this.setViewport(0,0,a,b)},this.setViewport=function(a,b,c,d){Pb=a*this.devicePixelRatio,kc=b*this.devicePixelRatio,lc=c*this.devicePixelRatio,mc=d*this.devicePixelRatio,l.viewport(Pb,kc,lc,mc)},this.setScissor=function(a,b,c,d){l.scissor(a*this.devicePixelRatio,b*this.devicePixelRatio,c*this.devicePixelRatio,d*this.devicePixelRatio)},this.enableScissorTest=function(a){a?l.enable(l.SCISSOR_TEST):l.disable(l.SCISSOR_TEST)},this.setClearColor=function(a,b){za.set(a),bb=void 0!==b?b:1,l.clearColor(za.r,za.g,za.b,bb)},this.setClearColorHex=function(a,b){console.warn("THREE.WebGLRenderer: .setClearColorHex() is being removed. Use .setClearColor() instead."),this.setClearColor(a,b)},this.getClearColor=function(){return za},this.getClearAlpha=function(){return bb},this.clear=function(a,b,c){var d=0;(void 0===a||a)&&(d|=l.COLOR_BUFFER_BIT),(void 0===b||b)&&(d|=l.DEPTH_BUFFER_BIT),(void 0===c||c)&&(d|=l.STENCIL_BUFFER_BIT),l.clear(d)},this.clearColor=function(){l.clear(l.COLOR_BUFFER_BIT)},this.clearDepth=function(){l.clear(l.DEPTH_BUFFER_BIT)},this.clearStencil=function(){l.clear(l.STENCIL_BUFFER_BIT)},this.clearTarget=function(a,b,c,d){this.setRenderTarget(a),this.clear(b,c,d)},this.resetGLState=function(){ec=tc=null,Kb=Oa=Mb=Lb=nb=Yb=pb=-1,fc=!0};var Hc=function(a){a.target.traverse(function(a){if(a.removeEventListener("remove",Hc),a instanceof THREE.Mesh||a instanceof THREE.PointCloud||a instanceof THREE.Line)delete ob[a.id];else if(a instanceof THREE.ImmediateRenderObject||a.immediateRenderCallback)for(var b=jb,c=b.length-1;0<=c;c--)b[c].object===a&&b.splice(c,1);delete a.__webglInit,delete a._modelViewMatrix,delete a._normalMatrix,delete a.__webglActive})},Ic=function(a){if(a=a.target,a.removeEventListener("dispose",Ic),delete a.__webglInit,a instanceof THREE.BufferGeometry){for(var b in a.attributes){var c=a.attributes[b];void 0!==c.buffer&&(l.deleteBuffer(c.buffer),delete c.buffer)}J.info.memory.geometries--}else if(b=xb[a.id],void 0!==b){for(var c=0,d=b.length;c<d;c++){var e=b[c];if(void 0!==e.numMorphTargets){for(var f=0,g=e.numMorphTargets;f<g;f++)l.deleteBuffer(e.__webglMorphTargetsBuffers[f]);delete e.__webglMorphTargetsBuffers}if(void 0!==e.numMorphNormals){for(f=0,g=e.numMorphNormals;f<g;f++)l.deleteBuffer(e.__webglMorphNormalsBuffers[f]);delete e.__webglMorphNormalsBuffers}Yc(e)}delete xb[a.id]}else Yc(a);Oa=-1},gc=function(a){a=a.target,a.removeEventListener("dispose",gc),a.image&&a.image.__webglTextureCube?(l.deleteTexture(a.image.__webglTextureCube),delete a.image.__webglTextureCube):void 0!==a.__webglInit&&(l.deleteTexture(a.__webglTexture),delete a.__webglTexture,delete a.__webglInit),J.info.memory.textures--},Zc=function(a){if(a=a.target,a.removeEventListener("dispose",Zc),a&&void 0!==a.__webglTexture){if(l.deleteTexture(a.__webglTexture),delete a.__webglTexture,a instanceof THREE.WebGLRenderTargetCube)for(var b=0;6>b;b++)l.deleteFramebuffer(a.__webglFramebuffer[b]),l.deleteRenderbuffer(a.__webglRenderbuffer[b]);else l.deleteFramebuffer(a.__webglFramebuffer),l.deleteRenderbuffer(a.__webglRenderbuffer);delete a.__webglFramebuffer,delete a.__webglRenderbuffer}J.info.memory.textures--},Dc=function(a){a=a.target,a.removeEventListener("dispose",Dc),Cc(a)},Yc=function(a){for(var b="__webglVertexBuffer __webglNormalBuffer __webglTangentBuffer __webglColorBuffer __webglUVBuffer __webglUV2Buffer __webglSkinIndicesBuffer __webglSkinWeightsBuffer __webglFaceBuffer __webglLineBuffer __webglLineDistanceBuffer".split(" "),c=0,d=b.length;c<d;c++){var e=b[c];void 0!==a[e]&&(l.deleteBuffer(a[e]),delete a[e])}if(void 0!==a.__webglCustomAttributesList){for(e in a.__webglCustomAttributesList)l.deleteBuffer(a.__webglCustomAttributesList[e].buffer);delete a.__webglCustomAttributesList}J.info.memory.geometries--},Cc=function(a){var b=a.program.program;if(void 0!==b){a.program=void 0;var c,d,e=!1;for(a=0,c=hb.length;a<c;a++)if(d=hb[a],d.program===b){d.usedTimes--,0===d.usedTimes&&(e=!0);break}if(!0===e){for(e=[],a=0,c=hb.length;a<c;a++)d=hb[a],d.program!==b&&e.push(d);hb=e,l.deleteProgram(b),J.info.memory.programs--}}};this.renderBufferImmediate=function(a,b,c){if(f(),a.hasPositions&&!a.__webglVertexBuffer&&(a.__webglVertexBuffer=l.createBuffer()),a.hasNormals&&!a.__webglNormalBuffer&&(a.__webglNormalBuffer=l.createBuffer()),a.hasUvs&&!a.__webglUvBuffer&&(a.__webglUvBuffer=l.createBuffer()),a.hasColors&&!a.__webglColorBuffer&&(a.__webglColorBuffer=l.createBuffer()),a.hasPositions&&(l.bindBuffer(l.ARRAY_BUFFER,a.__webglVertexBuffer),l.bufferData(l.ARRAY_BUFFER,a.positionArray,l.DYNAMIC_DRAW),g(b.attributes.position),l.vertexAttribPointer(b.attributes.position,3,l.FLOAT,!1,0,0)),a.hasNormals){if(l.bindBuffer(l.ARRAY_BUFFER,a.__webglNormalBuffer),c.shading===THREE.FlatShading){var d,e,k,m,n,p,r,q,t,s,v,u=3*a.count;for(v=0;v<u;v+=9)s=a.normalArray,d=s[v],e=s[v+1],k=s[v+2],m=s[v+3],p=s[v+4],q=s[v+5],n=s[v+6],r=s[v+7],t=s[v+8],d=(d+m+n)/3,e=(e+p+r)/3,k=(k+q+t)/3,s[v]=d,s[v+1]=e,s[v+2]=k,s[v+3]=d,s[v+4]=e,s[v+5]=k,s[v+6]=d,s[v+7]=e,s[v+8]=k}l.bufferData(l.ARRAY_BUFFER,a.normalArray,l.DYNAMIC_DRAW),g(b.attributes.normal),l.vertexAttribPointer(b.attributes.normal,3,l.FLOAT,!1,0,0)}a.hasUvs&&c.map&&(l.bindBuffer(l.ARRAY_BUFFER,a.__webglUvBuffer),l.bufferData(l.ARRAY_BUFFER,a.uvArray,l.DYNAMIC_DRAW),g(b.attributes.uv),l.vertexAttribPointer(b.attributes.uv,2,l.FLOAT,!1,0,0)),a.hasColors&&c.vertexColors!==THREE.NoColors&&(l.bindBuffer(l.ARRAY_BUFFER,a.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,a.colorArray,l.DYNAMIC_DRAW),g(b.attributes.color),l.vertexAttribPointer(b.attributes.color,3,l.FLOAT,!1,0,0)),h(),l.drawArrays(l.TRIANGLES,0,a.count),a.count=0},this.renderBufferDirect=function(a,b,c,d,g,h){if(!1!==d.visible)if(a=G(a,b,c,d,h),b=!1,c=16777215*g.id+2*a.id+(d.wireframe?1:0),c!==Oa&&(Oa=c,b=!0),b&&f(),h instanceof THREE.Mesh)if(h=!0===d.wireframe?l.LINES:l.TRIANGLES,c=g.attributes.index){var k,m;c.array instanceof Uint32Array&&pa.get("OES_element_index_uint")?(k=l.UNSIGNED_INT,m=4):(k=l.UNSIGNED_SHORT,m=2);var n=g.offsets;if(0===n.length)b&&(e(d,a,g,0),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,c.buffer)),l.drawElements(h,c.array.length,k,0),J.info.render.calls++,J.info.render.vertices+=c.array.length,J.info.render.faces+=c.array.length/3;else{b=!0;for(var p=0,r=n.length;p<r;p++){var q=n[p].index;b&&(e(d,a,g,q),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,c.buffer)),l.drawElements(h,n[p].count,k,n[p].start*m),J.info.render.calls++,J.info.render.vertices+=n[p].count,J.info.render.faces+=n[p].count/3}}}else b&&e(d,a,g,0),d=g.attributes.position,l.drawArrays(h,0,d.array.length/3),J.info.render.calls++,J.info.render.vertices+=d.array.length/3,J.info.render.faces+=d.array.length/9;else if(h instanceof THREE.PointCloud)b&&e(d,a,g,0),d=g.attributes.position,l.drawArrays(l.POINTS,0,d.array.length/3),J.info.render.calls++,J.info.render.points+=d.array.length/3;else if(h instanceof THREE.Line)if(h=h.mode===THREE.LineStrip?l.LINE_STRIP:l.LINES,A(d.linewidth),c=g.attributes.index)if(c.array instanceof Uint32Array?(k=l.UNSIGNED_INT,m=4):(k=l.UNSIGNED_SHORT,m=2),n=g.offsets,0===n.length)b&&(e(d,a,g,0),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,c.buffer)),l.drawElements(h,c.array.length,k,0),J.info.render.calls++,J.info.render.vertices+=c.array.length;else for(1<n.length&&(b=!0),p=0,r=n.length;p<r;p++)q=n[p].index,b&&(e(d,a,g,q),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,c.buffer)),l.drawElements(h,n[p].count,k,n[p].start*m),J.info.render.calls++,J.info.render.vertices+=n[p].count;else b&&e(d,a,g,0),d=g.attributes.position,l.drawArrays(h,0,d.array.length/3),J.info.render.calls++,J.info.render.points+=d.array.length/3},this.renderBuffer=function(a,b,c,d,e,k){if(!1!==d.visible){if(c=G(a,b,c,d,k),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0),c!==Oa&&(Oa=c,a=!0),a&&f(),!d.morphTargets&&0<=b.position)a&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),g(b.position),l.vertexAttribPointer(b.position,3,l.FLOAT,!1,0,0));else if(k.morphTargetBase){if(c=d.program.attributes,-1!==k.morphTargetBase&&0<=c.position?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k.morphTargetBase]),g(c.position),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0)):0<=c.position&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),g(c.position),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0)),k.morphTargetForcedOrder.length)for(var m=0,n=k.morphTargetForcedOrder,r=k.morphTargetInfluences;m<d.numSupportedMorphTargets&&m<n.length;)0<=c["morphTarget"+m]&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[n[m]]),g(c["morphTarget"+m]),l.vertexAttribPointer(c["morphTarget"+m],3,l.FLOAT,!1,0,0)),0<=c["morphNormal"+m]&&d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[n[m]]),g(c["morphNormal"+m]),l.vertexAttribPointer(c["morphNormal"+m],3,l.FLOAT,!1,0,0)),k.__webglMorphTargetInfluences[m]=r[n[m]],m++;else{var q,n=[],r=k.morphTargetInfluences,t=r.length;for(q=0;q<t;q++)m=r[q],0<m&&n.push([m,q]);for(n.length>d.numSupportedMorphTargets?(n.sort(p),n.length=d.numSupportedMorphTargets):n.length>d.numSupportedMorphNormals?n.sort(p):0===n.length&&n.push([0,0]),m=0;m<d.numSupportedMorphTargets;)n[m]?(q=n[m][1],0<=c["morphTarget"+m]&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[q]),g(c["morphTarget"+m]),l.vertexAttribPointer(c["morphTarget"+m],3,l.FLOAT,!1,0,0)),0<=c["morphNormal"+m]&&d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[q]),g(c["morphNormal"+m]),l.vertexAttribPointer(c["morphNormal"+m],3,l.FLOAT,!1,0,0)),k.__webglMorphTargetInfluences[m]=r[q]):k.__webglMorphTargetInfluences[m]=0,m++}null!==d.program.uniforms.morphTargetInfluences&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(c=0,r=e.__webglCustomAttributesList.length;c<r;c++)n=e.__webglCustomAttributesList[c],0<=b[n.buffer.belongsToAttribute]&&(l.bindBuffer(l.ARRAY_BUFFER,n.buffer),g(b[n.buffer.belongsToAttribute]),l.vertexAttribPointer(b[n.buffer.belongsToAttribute],n.size,l.FLOAT,!1,0,0));0<=b.color&&(0<k.geometry.colors.length||0<k.geometry.faces.length?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglColorBuffer),g(b.color),l.vertexAttribPointer(b.color,3,l.FLOAT,!1,0,0)):void 0!==d.defaultAttributeValues&&l.vertexAttrib3fv(b.color,d.defaultAttributeValues.color)),0<=b.normal&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglNormalBuffer),g(b.normal),l.vertexAttribPointer(b.normal,3,l.FLOAT,!1,0,0)),0<=b.tangent&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglTangentBuffer),g(b.tangent),l.vertexAttribPointer(b.tangent,4,l.FLOAT,!1,0,0)),0<=b.uv&&(k.geometry.faceVertexUvs[0]?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUVBuffer),g(b.uv),l.vertexAttribPointer(b.uv,2,l.FLOAT,!1,0,0)):void 0!==d.defaultAttributeValues&&l.vertexAttrib2fv(b.uv,d.defaultAttributeValues.uv)),0<=b.uv2&&(k.geometry.faceVertexUvs[1]?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUV2Buffer),g(b.uv2),l.vertexAttribPointer(b.uv2,2,l.FLOAT,!1,0,0)):void 0!==d.defaultAttributeValues&&l.vertexAttrib2fv(b.uv2,d.defaultAttributeValues.uv2)),d.skinning&&0<=b.skinIndex&&0<=b.skinWeight&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),g(b.skinIndex),l.vertexAttribPointer(b.skinIndex,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),g(b.skinWeight),l.vertexAttribPointer(b.skinWeight,4,l.FLOAT,!1,0,0)),0<=b.lineDistance&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglLineDistanceBuffer),g(b.lineDistance),l.vertexAttribPointer(b.lineDistance,1,l.FLOAT,!1,0,0))}h(),k instanceof THREE.Mesh?(k=e.__typeArray===Uint32Array?l.UNSIGNED_INT:l.UNSIGNED_SHORT,d.wireframe?(A(d.wireframeLinewidth),a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),l.drawElements(l.LINES,e.__webglLineCount,k,0)):(a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),l.drawElements(l.TRIANGLES,e.__webglFaceCount,k,0)),J.info.render.calls++,J.info.render.vertices+=e.__webglFaceCount,J.info.render.faces+=e.__webglFaceCount/3):k instanceof THREE.Line?(k=k.mode===THREE.LineStrip?l.LINE_STRIP:l.LINES,A(d.linewidth),l.drawArrays(k,0,e.__webglLineCount),J.info.render.calls++):k instanceof THREE.PointCloud&&(l.drawArrays(l.POINTS,0,e.__webglParticleCount),J.info.render.calls++,J.info.render.points+=e.__webglParticleCount)}},this.render=function(a,b,c,d){if(!1==b instanceof THREE.Camera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var e=a.fog;Kb=Oa=-1,ec=null,fc=!0,!0===a.autoUpdate&&a.updateMatrixWorld(),void 0===b.parent&&b.updateMatrixWorld(),a.traverse(function(a){a instanceof THREE.SkinnedMesh&&a.skeleton.update()}),b.matrixWorldInverse.getInverse(b.matrixWorld),Ac.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse),Ec.setFromMatrix(Ac),cb.length=0,Jb.length=0,Ib.length=0,yb.length=0,Ra.length=0,q(a,a),!0===J.sortObjects&&(Jb.sort(k),Ib.sort(n)),id.render(a,b),J.info.render.calls=0,J.info.render.vertices=0,J.info.render.faces=0,J.info.render.points=0,this.setRenderTarget(c),(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),d=0;for(var f=jb.length;d<f;d++){var g=jb[d],h=g.object;h.visible&&(x(h,b),t(g))}a.overrideMaterial?(d=a.overrideMaterial,this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst),this.setDepthTest(d.depthTest),this.setDepthWrite(d.depthWrite),B(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits),m(Jb,b,cb,e,!0,d),m(Ib,b,cb,e,!0,d),r(jb,"",b,cb,e,!1,d)):(d=null,this.setBlending(THREE.NoBlending),m(Jb,b,cb,e,!1,d),r(jb,"opaque",b,cb,e,!1,d),m(Ib,b,cb,e,!0,d),r(jb,"transparent",b,cb,e,!0,d)),jd.render(a,b),kd.render(a,b,Uc,Vc),c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&C(c),this.setDepthTest(!0),this.setDepthWrite(!0)}},this.renderImmediateObject=function(a,b,c,d,e){var f=G(a,b,c,d,e);Oa=-1,J.setMaterialFaces(d),e.immediateRenderCallback?e.immediateRenderCallback(f,l,Ec):e.render(function(a){J.renderBufferImmediate(a,f,d)})};var xb={},rc=0;this.setFaceCulling=function(a,b){a===THREE.CullFaceNone?l.disable(l.CULL_FACE):(b===THREE.FrontFaceDirectionCW?l.frontFace(l.CW):l.frontFace(l.CCW),a===THREE.CullFaceBack?l.cullFace(l.BACK):a===THREE.CullFaceFront?l.cullFace(l.FRONT):l.cullFace(l.FRONT_AND_BACK),l.enable(l.CULL_FACE))},this.setMaterialFaces=function(a){var b=a.side===THREE.DoubleSide;a=a.side===THREE.BackSide,Lb!==b&&(b?l.disable(l.CULL_FACE):l.enable(l.CULL_FACE),Lb=b),Mb!==a&&(a?l.frontFace(l.CW):l.frontFace(l.CCW),Mb=a)},this.setDepthTest=function(a){Yb!==a&&(a?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),Yb=a)},this.setDepthWrite=function(a){nb!==a&&(l.depthMask(a),nb=a)},this.setBlending=function(a,b,c,d){a!==pb&&(a===THREE.NoBlending?l.disable(l.BLEND):a===THREE.AdditiveBlending?(l.enable(l.BLEND),l.blendEquation(l.FUNC_ADD),l.blendFunc(l.SRC_ALPHA,l.ONE)):a===THREE.SubtractiveBlending?(l.enable(l.BLEND),l.blendEquation(l.FUNC_ADD),l.blendFunc(l.ZERO,l.ONE_MINUS_SRC_COLOR)):a===THREE.MultiplyBlending?(l.enable(l.BLEND),l.blendEquation(l.FUNC_ADD),l.blendFunc(l.ZERO,l.SRC_COLOR)):a===THREE.CustomBlending?l.enable(l.BLEND):(l.enable(l.BLEND),l.blendEquationSeparate(l.FUNC_ADD,l.FUNC_ADD),l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA)),pb=a),a===THREE.CustomBlending?(b!==Nb&&(l.blendEquation(Q(b)),Nb=b),(c!==Ob||d!==Xb)&&(l.blendFunc(Q(c),Q(d)),Ob=c,Xb=d)):Xb=Ob=Nb=null},this.uploadTexture=function(a){void 0===a.__webglInit&&(a.__webglInit=!0,a.addEventListener("dispose",gc),a.__webglTexture=l.createTexture(),J.info.memory.textures++),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,a.flipY),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha),l.pixelStorei(l.UNPACK_ALIGNMENT,a.unpackAlignment),a.image=R(a.image,cd);var b=a.image,c=THREE.Math.isPowerOfTwo(b.width)&&THREE.Math.isPowerOfTwo(b.height),d=Q(a.format),e=Q(a.type);F(l.TEXTURE_2D,a,c);var f=a.mipmaps;if(a instanceof THREE.DataTexture)if(0<f.length&&c){for(var g=0,h=f.length;g<h;g++)b=f[g],l.texImage2D(l.TEXTURE_2D,g,d,b.width,b.height,0,d,e,b.data);a.generateMipmaps=!1}else l.texImage2D(l.TEXTURE_2D,0,d,b.width,b.height,0,d,e,b.data);else if(a instanceof THREE.CompressedTexture)for(g=0,h=f.length;g<h;g++)b=f[g],a.format!==THREE.RGBAFormat&&a.format!==THREE.RGBFormat?-1<Nc().indexOf(d)?l.compressedTexImage2D(l.TEXTURE_2D,g,d,b.width,b.height,0,b.data):console.warn("Attempt to load unsupported compressed texture format"):l.texImage2D(l.TEXTURE_2D,g,d,b.width,b.height,0,d,e,b.data);else if(0<f.length&&c){for(g=0,h=f.length;g<h;g++)b=f[g],l.texImage2D(l.TEXTURE_2D,g,d,d,e,b);a.generateMipmaps=!1}else l.texImage2D(l.TEXTURE_2D,0,d,d,e,a.image);a.generateMipmaps&&c&&l.generateMipmap(l.TEXTURE_2D),a.needsUpdate=!1,a.onUpdate&&a.onUpdate()},this.setTexture=function(a,b){l.activeTexture(l.TEXTURE0+b),a.needsUpdate?J.uploadTexture(a):l.bindTexture(l.TEXTURE_2D,a.__webglTexture)},this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&void 0===a.__webglFramebuffer){void 0===a.depthBuffer&&(a.depthBuffer=!0),void 0===a.stencilBuffer&&(a.stencilBuffer=!0),a.addEventListener("dispose",Zc),a.__webglTexture=l.createTexture(),J.info.memory.textures++;var c=THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height),d=Q(a.format),e=Q(a.type);if(b){a.__webglFramebuffer=[],a.__webglRenderbuffer=[],l.bindTexture(l.TEXTURE_CUBE_MAP,a.__webglTexture),F(l.TEXTURE_CUBE_MAP,a,c);for(var f=0;6>f;f++){a.__webglFramebuffer[f]=l.createFramebuffer(),a.__webglRenderbuffer[f]=l.createRenderbuffer(),l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=l.TEXTURE_CUBE_MAP_POSITIVE_X+f;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[f]),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,h,g.__webglTexture,0),H(a.__webglRenderbuffer[f],a)}c&&l.generateMipmap(l.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer=l.createFramebuffer(),a.__webglRenderbuffer=a.shareDepthFrom?a.shareDepthFrom.__webglRenderbuffer:l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),F(l.TEXTURE_2D,a,c),l.texImage2D(l.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,d,a.__webglTexture,0),a.shareDepthFrom?a.depthBuffer&&!a.stencilBuffer?l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,a.__webglRenderbuffer):a.depthBuffer&&a.stencilBuffer&&l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,a.__webglRenderbuffer):H(a.__webglRenderbuffer,a),c&&l.generateMipmap(l.TEXTURE_2D);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=lc,a=mc,d=Pb,e=kc),b!==Tc&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(d,e,c,a),Tc=b),Uc=c,Vc=a},this.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},this.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},this.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},this.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}},THREE.WebGLRenderTarget=function(a,b,c){this.width=a,this.height=b,c=c||{},this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping,this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping,this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter,this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter,this.anisotropy=void 0!==c.anisotropy?c.anisotropy:1,this.offset=new THREE.Vector2(0,0),this.repeat=new THREE.Vector2(1,1),this.format=void 0!==c.format?c.format:THREE.RGBAFormat,this.type=void 0!==c.type?c.type:THREE.UnsignedByteType,this.depthBuffer=void 0===c.depthBuffer||c.depthBuffer,this.stencilBuffer=void 0===c.stencilBuffer||c.stencilBuffer,this.generateMipmaps=!0,this.shareDepthFrom=null},THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(a,b){this.width=a,this.height=b},clone:function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);return a.wrapS=this.wrapS,a.wrapT=this.wrapT,a.magFilter=this.magFilter,a.minFilter=this.minFilter,a.anisotropy=this.anisotropy,a.offset.copy(this.offset),a.repeat.copy(this.repeat),a.format=this.format,a.type=this.type,a.depthBuffer=this.depthBuffer,a.stencilBuffer=this.stencilBuffer,a.generateMipmaps=this.generateMipmaps,a.shareDepthFrom=this.shareDepthFrom,a},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype),THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c),this.activeCubeFace=0},THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype),THREE.WebGLExtensions=function(a){var b={};this.get=function(c){if(void 0!==b[c])return b[c];var d;switch(c){case"OES_texture_float":d=a.getExtension("OES_texture_float");break;case"OES_texture_float_linear":d=a.getExtension("OES_texture_float_linear");break;case"OES_standard_derivatives":d=a.getExtension("OES_standard_derivatives");break;case"EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"OES_element_index_uint":d=a.getExtension("OES_element_index_uint");break;case"EXT_blend_minmax":d=a.getExtension("EXT_blend_minmax");break;case"EXT_frag_depth":d=a.getExtension("EXT_frag_depth")}return null===d&&console.log("THREE.WebGLRenderer: "+c+" extension not supported."),b[c]=d}},THREE.WebGLProgram=function(){var a=0;return function(b,c,d,e){var f=b.context,g=d.defines,h=d.__webglShader.uniforms,k=d.attributes,n=d.__webglShader.vertexShader,p=d.__webglShader.fragmentShader,q=d.index0AttributeName;void 0===q&&!0===e.morphTargets&&(q="position");var m="SHADOWMAP_TYPE_BASIC";e.shadowMapType===THREE.PCFShadowMap?m="SHADOWMAP_TYPE_PCF":e.shadowMapType===THREE.PCFSoftShadowMap&&(m="SHADOWMAP_TYPE_PCF_SOFT");var r,t;r=[];for(var s in g)t=g[s],!1!==t&&(t="#define "+s+" "+t,r.push(t));r=r.join("\n"),g=f.createProgram(),d instanceof THREE.RawShaderMaterial?b=d="":(d=["precision "+e.precision+" float;","precision "+e.precision+" int;",r,e.supportsVertexTextures?"#define VERTEX_TEXTURES":"",b.gammaInput?"#define GAMMA_INPUT":"",b.gammaOutput?"#define GAMMA_OUTPUT":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SPOT_LIGHTS "+e.maxSpotLights,"#define MAX_HEMI_LIGHTS "+e.maxHemiLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.useVertexTexture?"#define BONE_TEXTURE":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals?"#define USE_MORPHNORMALS":"",e.wrapAround?"#define WRAP_AROUND":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+m:"",e.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",e.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\n\tattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\n\tattribute vec3 morphTarget0;\n\tattribute vec3 morphTarget1;\n\tattribute vec3 morphTarget2;\n\tattribute vec3 morphTarget3;\n\t#ifdef USE_MORPHNORMALS\n\t\tattribute vec3 morphNormal0;\n\t\tattribute vec3 morphNormal1;\n\t\tattribute vec3 morphNormal2;\n\t\tattribute vec3 morphNormal3;\n\t#else\n\t\tattribute vec3 morphTarget4;\n\t\tattribute vec3 morphTarget5;\n\t\tattribute vec3 morphTarget6;\n\t\tattribute vec3 morphTarget7;\n\t#endif\n#endif\n#ifdef USE_SKINNING\n\tattribute vec4 skinIndex;\n\tattribute vec4 skinWeight;\n#endif\n"].join("\n"),b=["precision "+e.precision+" float;","precision "+e.precision+" int;",e.bumpMap||e.normalMap?"#extension GL_OES_standard_derivatives : enable":"",r,"#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SPOT_LIGHTS "+e.maxSpotLights,"#define MAX_HEMI_LIGHTS "+e.maxHemiLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",b.gammaInput?"#define GAMMA_INPUT":"",b.gammaOutput?"#define GAMMA_OUTPUT":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.vertexColors?"#define USE_COLOR":"",e.metal?"#define METAL":"",e.wrapAround?"#define WRAP_AROUND":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+m:"",e.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",e.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n")),n=new THREE.WebGLShader(f,f.VERTEX_SHADER,d+n),p=new THREE.WebGLShader(f,f.FRAGMENT_SHADER,b+p),f.attachShader(g,n),f.attachShader(g,p),void 0!==q&&f.bindAttribLocation(g,0,q),
f.linkProgram(g),!1===f.getProgramParameter(g,f.LINK_STATUS)&&(console.error("THREE.WebGLProgram: Could not initialise shader."),console.error("gl.VALIDATE_STATUS",f.getProgramParameter(g,f.VALIDATE_STATUS)),console.error("gl.getError()",f.getError())),""!==f.getProgramInfoLog(g)&&console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",f.getProgramInfoLog(g)),f.deleteShader(n),f.deleteShader(p),q="viewMatrix modelViewMatrix projectionMatrix normalMatrix modelMatrix cameraPosition morphTargetInfluences bindMatrix bindMatrixInverse".split(" "),e.useVertexTexture?(q.push("boneTexture"),q.push("boneTextureWidth"),q.push("boneTextureHeight")):q.push("boneGlobalMatrices"),e.logarithmicDepthBuffer&&q.push("logDepthBufFC");for(var u in h)q.push(u);for(h=q,u={},q=0,b=h.length;q<b;q++)m=h[q],u[m]=f.getUniformLocation(g,m);for(this.uniforms=u,q="position normal uv uv2 tangent color skinIndex skinWeight lineDistance".split(" "),h=0;h<e.maxMorphTargets;h++)q.push("morphTarget"+h);for(h=0;h<e.maxMorphNormals;h++)q.push("morphNormal"+h);for(var v in k)q.push(v);for(e=q,k={},v=0,h=e.length;v<h;v++)u=e[v],k[u]=f.getAttribLocation(g,u);return this.attributes=k,this.attributesKeys=Object.keys(this.attributes),this.id=a++,this.code=c,this.usedTimes=1,this.program=g,this.vertexShader=n,this.fragmentShader=p,this}}(),THREE.WebGLShader=function(){var a=function(a){a=a.split("\n");for(var c=0;c<a.length;c++)a[c]=c+1+": "+a[c];return a.join("\n")};return function(b,c,d){return c=b.createShader(c),b.shaderSource(c,d),b.compileShader(c),!1===b.getShaderParameter(c,b.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==b.getShaderInfoLog(c)&&(console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",b.getShaderInfoLog(c)),console.warn(a(d))),c}}(),THREE.LensFlarePlugin=function(a,b){var c,d,e,f,g,h,k,n,p,q,r,t,s,u,v,y,m=a.context;this.render=function(G,w,K,x){if(0!==b.length){G=new THREE.Vector3;var D=x/K,E=.5*K,A=.5*x,B=16/x,F=new THREE.Vector2(B*D,B),R=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1);if(void 0===s){var B=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),C=new Uint16Array([0,1,2,0,2,3]);r=m.createBuffer(),t=m.createBuffer(),m.bindBuffer(m.ARRAY_BUFFER,r),m.bufferData(m.ARRAY_BUFFER,B,m.STATIC_DRAW),m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,t),m.bufferData(m.ELEMENT_ARRAY_BUFFER,C,m.STATIC_DRAW),v=m.createTexture(),y=m.createTexture(),m.bindTexture(m.TEXTURE_2D,v),m.texImage2D(m.TEXTURE_2D,0,m.RGB,16,16,0,m.RGB,m.UNSIGNED_BYTE,null),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST),m.bindTexture(m.TEXTURE_2D,y),m.texImage2D(m.TEXTURE_2D,0,m.RGBA,16,16,0,m.RGBA,m.UNSIGNED_BYTE,null),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST);var B=(u=0<m.getParameter(m.MAX_VERTEX_TEXTURE_IMAGE_UNITS))?{vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = visibility.r / 9.0;\nvVisibility *= 1.0 - visibility.g / 9.0;\nvVisibility *= visibility.b / 9.0;\nvVisibility *= 1.0 - visibility.a / 9.0;\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"uniform lowp int renderType;\nuniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}:{vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform lowp int renderType;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},C=m.createProgram(),T=m.createShader(m.FRAGMENT_SHADER),Q=m.createShader(m.VERTEX_SHADER),O="precision "+a.getPrecision()+" float;\n";m.shaderSource(T,O+B.fragmentShader),m.shaderSource(Q,O+B.vertexShader),m.compileShader(T),m.compileShader(Q),m.attachShader(C,T),m.attachShader(C,Q),m.linkProgram(C),s=C,p=m.getAttribLocation(s,"position"),q=m.getAttribLocation(s,"uv"),c=m.getUniformLocation(s,"renderType"),d=m.getUniformLocation(s,"map"),e=m.getUniformLocation(s,"occlusionMap"),f=m.getUniformLocation(s,"opacity"),g=m.getUniformLocation(s,"color"),h=m.getUniformLocation(s,"scale"),k=m.getUniformLocation(s,"rotation"),n=m.getUniformLocation(s,"screenPosition")}for(m.useProgram(s),m.enableVertexAttribArray(p),m.enableVertexAttribArray(q),m.uniform1i(e,0),m.uniform1i(d,1),m.bindBuffer(m.ARRAY_BUFFER,r),m.vertexAttribPointer(p,2,m.FLOAT,!1,16,0),m.vertexAttribPointer(q,2,m.FLOAT,!1,16,8),m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,t),m.disable(m.CULL_FACE),m.depthMask(!1),C=0,T=b.length;C<T;C++)if(B=16/x,F.set(B*D,B),Q=b[C],G.set(Q.matrixWorld.elements[12],Q.matrixWorld.elements[13],Q.matrixWorld.elements[14]),G.applyMatrix4(w.matrixWorldInverse),G.applyProjection(w.projectionMatrix),R.copy(G),H.x=R.x*E+E,H.y=R.y*A+A,u||0<H.x&&H.x<K&&0<H.y&&H.y<x){m.activeTexture(m.TEXTURE1),m.bindTexture(m.TEXTURE_2D,v),m.copyTexImage2D(m.TEXTURE_2D,0,m.RGB,H.x-8,H.y-8,16,16,0),m.uniform1i(c,0),m.uniform2f(h,F.x,F.y),m.uniform3f(n,R.x,R.y,R.z),m.disable(m.BLEND),m.enable(m.DEPTH_TEST),m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0),m.activeTexture(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,y),m.copyTexImage2D(m.TEXTURE_2D,0,m.RGBA,H.x-8,H.y-8,16,16,0),m.uniform1i(c,1),m.disable(m.DEPTH_TEST),m.activeTexture(m.TEXTURE1),m.bindTexture(m.TEXTURE_2D,v),m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0),Q.positionScreen.copy(R),Q.customUpdateCallback?Q.customUpdateCallback(Q):Q.updateLensFlares(),m.uniform1i(c,2),m.enable(m.BLEND);for(var O=0,S=Q.lensFlares.length;O<S;O++){var X=Q.lensFlares[O];.001<X.opacity&&.001<X.scale&&(R.x=X.x,R.y=X.y,R.z=X.z,B=X.size*X.scale/x,F.x=B*D,F.y=B,m.uniform3f(n,R.x,R.y,R.z),m.uniform2f(h,F.x,F.y),m.uniform1f(k,X.rotation),m.uniform1f(f,X.opacity),m.uniform3f(g,X.color.r,X.color.g,X.color.b),a.setBlending(X.blending,X.blendEquation,X.blendSrc,X.blendDst),a.setTexture(X.texture,1),m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0))}}m.enable(m.CULL_FACE),m.enable(m.DEPTH_TEST),m.depthMask(!0),a.resetGLState()}}},THREE.ShadowMapPlugin=function(a,b,c,d){function e(a,b,d){if(b.visible){var f=c[b.id];if(f&&b.castShadow&&(!1===b.frustumCulled||!0===p.intersectsObject(b)))for(var g=0,h=f.length;g<h;g++){var k=f[g];b._modelViewMatrix.multiplyMatrices(d.matrixWorldInverse,b.matrixWorld),s.push(k)}for(g=0,h=b.children.length;g<h;g++)e(a,b.children[g],d)}}var g,h,k,n,f=a.context,p=new THREE.Frustum,q=new THREE.Matrix4,m=new THREE.Vector3,r=new THREE.Vector3,t=new THREE.Vector3,s=[],u=THREE.ShaderLib.depthRGBA,v=THREE.UniformsUtils.clone(u.uniforms);g=new THREE.ShaderMaterial({uniforms:v,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader}),h=new THREE.ShaderMaterial({uniforms:v,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader,morphTargets:!0}),k=new THREE.ShaderMaterial({uniforms:v,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader,skinning:!0}),n=new THREE.ShaderMaterial({uniforms:v,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader,morphTargets:!0,skinning:!0}),g._shadowPass=!0,h._shadowPass=!0,k._shadowPass=!0,n._shadowPass=!0,this.render=function(c,v){if(!1!==a.shadowMapEnabled){var u,K,x,D,E,A,B,F,R=[];for(D=0,f.clearColor(1,1,1,1),f.disable(f.BLEND),f.enable(f.CULL_FACE),f.frontFace(f.CCW),a.shadowMapCullFace===THREE.CullFaceFront?f.cullFace(f.FRONT):f.cullFace(f.BACK),a.setDepthTest(!0),u=0,K=b.length;u<K;u++)if(x=b[u],x.castShadow)if(x instanceof THREE.DirectionalLight&&x.shadowCascade)for(E=0;E<x.shadowCascadeCount;E++){var H;if(x.shadowCascadeArray[E])H=x.shadowCascadeArray[E];else{B=x;var C=E;H=new THREE.DirectionalLight,H.isVirtual=!0,H.onlyShadow=!0,H.castShadow=!0,H.shadowCameraNear=B.shadowCameraNear,H.shadowCameraFar=B.shadowCameraFar,H.shadowCameraLeft=B.shadowCameraLeft,H.shadowCameraRight=B.shadowCameraRight,H.shadowCameraBottom=B.shadowCameraBottom,H.shadowCameraTop=B.shadowCameraTop,H.shadowCameraVisible=B.shadowCameraVisible,H.shadowDarkness=B.shadowDarkness,H.shadowBias=B.shadowCascadeBias[C],H.shadowMapWidth=B.shadowCascadeWidth[C],H.shadowMapHeight=B.shadowCascadeHeight[C],H.pointsWorld=[],H.pointsFrustum=[],F=H.pointsWorld,A=H.pointsFrustum;for(var T=0;8>T;T++)F[T]=new THREE.Vector3,A[T]=new THREE.Vector3;F=B.shadowCascadeNearZ[C],B=B.shadowCascadeFarZ[C],A[0].set(-1,-1,F),A[1].set(1,-1,F),A[2].set(-1,1,F),A[3].set(1,1,F),A[4].set(-1,-1,B),A[5].set(1,-1,B),A[6].set(-1,1,B),A[7].set(1,1,B),H.originalCamera=v,A=new THREE.Gyroscope,A.position.copy(x.shadowCascadeOffset),A.add(H),A.add(H.target),v.add(A),x.shadowCascadeArray[E]=H,console.log("Created virtualLight",H)}C=x,F=E,B=C.shadowCascadeArray[F],B.position.copy(C.position),B.target.position.copy(C.target.position),B.lookAt(B.target),B.shadowCameraVisible=C.shadowCameraVisible,B.shadowDarkness=C.shadowDarkness,B.shadowBias=C.shadowCascadeBias[F],A=C.shadowCascadeNearZ[F],C=C.shadowCascadeFarZ[F],B=B.pointsFrustum,B[0].z=A,B[1].z=A,B[2].z=A,B[3].z=A,B[4].z=C,B[5].z=C,B[6].z=C,B[7].z=C,R[D]=H,D++}else R[D]=x,D++;for(u=0,K=R.length;u<K;u++){if(x=R[u],x.shadowMap||(E=THREE.LinearFilter,a.shadowMapType===THREE.PCFSoftShadowMap&&(E=THREE.NearestFilter),x.shadowMap=new THREE.WebGLRenderTarget(x.shadowMapWidth,x.shadowMapHeight,{minFilter:E,magFilter:E,format:THREE.RGBAFormat}),x.shadowMapSize=new THREE.Vector2(x.shadowMapWidth,x.shadowMapHeight),x.shadowMatrix=new THREE.Matrix4),!x.shadowCamera){if(x instanceof THREE.SpotLight)x.shadowCamera=new THREE.PerspectiveCamera(x.shadowCameraFov,x.shadowMapWidth/x.shadowMapHeight,x.shadowCameraNear,x.shadowCameraFar);else{if(!(x instanceof THREE.DirectionalLight)){console.error("Unsupported light type for shadow");continue}x.shadowCamera=new THREE.OrthographicCamera(x.shadowCameraLeft,x.shadowCameraRight,x.shadowCameraTop,x.shadowCameraBottom,x.shadowCameraNear,x.shadowCameraFar)}c.add(x.shadowCamera),!0===c.autoUpdate&&c.updateMatrixWorld()}if(x.shadowCameraVisible&&!x.cameraHelper&&(x.cameraHelper=new THREE.CameraHelper(x.shadowCamera),c.add(x.cameraHelper)),x.isVirtual&&H.originalCamera==v){for(E=v,D=x.shadowCamera,A=x.pointsFrustum,B=x.pointsWorld,m.set(1/0,1/0,1/0),r.set(-(1/0),-(1/0),-(1/0)),C=0;8>C;C++)F=B[C],F.copy(A[C]),F.unproject(E),F.applyMatrix4(D.matrixWorldInverse),F.x<m.x&&(m.x=F.x),F.x>r.x&&(r.x=F.x),F.y<m.y&&(m.y=F.y),F.y>r.y&&(r.y=F.y),F.z<m.z&&(m.z=F.z),F.z>r.z&&(r.z=F.z);D.left=m.x,D.right=r.x,D.top=r.y,D.bottom=m.y,D.updateProjectionMatrix()}for(D=x.shadowMap,A=x.shadowMatrix,E=x.shadowCamera,E.position.setFromMatrixPosition(x.matrixWorld),t.setFromMatrixPosition(x.target.matrixWorld),E.lookAt(t),E.updateMatrixWorld(),E.matrixWorldInverse.getInverse(E.matrixWorld),x.cameraHelper&&(x.cameraHelper.visible=x.shadowCameraVisible),x.shadowCameraVisible&&x.cameraHelper.update(),A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply(E.projectionMatrix),A.multiply(E.matrixWorldInverse),q.multiplyMatrices(E.projectionMatrix,E.matrixWorldInverse),p.setFromMatrix(q),a.setRenderTarget(D),a.clear(),s.length=0,e(c,c,E),x=0,D=s.length;x<D;x++)B=s[x],A=B.object,B=B.buffer,C=A.material instanceof THREE.MeshFaceMaterial?A.material.materials[0]:A.material,F=void 0!==A.geometry.morphTargets&&0<A.geometry.morphTargets.length&&C.morphTargets,T=A instanceof THREE.SkinnedMesh&&C.skinning,F=A.customDepthMaterial?A.customDepthMaterial:T?F?n:k:F?h:g,a.setMaterialFaces(C),B instanceof THREE.BufferGeometry?a.renderBufferDirect(E,b,null,F,B,A):a.renderBuffer(E,b,null,F,B,A);for(x=0,D=d.length;x<D;x++)B=d[x],A=B.object,A.visible&&A.castShadow&&(A._modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,A.matrixWorld),a.renderImmediateObject(E,b,null,g,A))}u=a.getClearColor(),K=a.getClearAlpha(),f.clearColor(u.r,u.g,u.b,K),f.enable(f.BLEND),a.shadowMapCullFace===THREE.CullFaceFront&&f.cullFace(f.BACK),a.resetGLState()}}},THREE.SpritePlugin=function(a,b){function G(a,b){return a.z!==b.z?b.z-a.z:b.id-a.id}var c,d,e,f,g,h,k,n,p,q,m,r,t,s,u,v,y,K,x,D,E,w=a.context;this.render=function(A,B){if(0!==b.length){if(void 0===D){var F=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),R=new Uint16Array([0,1,2,0,2,3]);K=w.createBuffer(),x=w.createBuffer(),w.bindBuffer(w.ARRAY_BUFFER,K),w.bufferData(w.ARRAY_BUFFER,F,w.STATIC_DRAW),w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,x),w.bufferData(w.ELEMENT_ARRAY_BUFFER,R,w.STATIC_DRAW);var F=w.createProgram(),R=w.createShader(w.VERTEX_SHADER),H=w.createShader(w.FRAGMENT_SHADER);w.shaderSource(R,["precision "+a.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n")),w.shaderSource(H,["precision "+a.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")),w.compileShader(R),w.compileShader(H),w.attachShader(F,R),w.attachShader(F,H),w.linkProgram(F),D=F,v=w.getAttribLocation(D,"position"),y=w.getAttribLocation(D,"uv"),c=w.getUniformLocation(D,"uvOffset"),d=w.getUniformLocation(D,"uvScale"),e=w.getUniformLocation(D,"rotation"),f=w.getUniformLocation(D,"scale"),g=w.getUniformLocation(D,"color"),h=w.getUniformLocation(D,"map"),k=w.getUniformLocation(D,"opacity"),n=w.getUniformLocation(D,"modelViewMatrix"),p=w.getUniformLocation(D,"projectionMatrix"),q=w.getUniformLocation(D,"fogType"),m=w.getUniformLocation(D,"fogDensity"),r=w.getUniformLocation(D,"fogNear"),t=w.getUniformLocation(D,"fogFar"),s=w.getUniformLocation(D,"fogColor"),u=w.getUniformLocation(D,"alphaTest"),F=document.createElement("canvas"),F.width=8,F.height=8,R=F.getContext("2d"),R.fillStyle="white",R.fillRect(0,0,8,8),E=new THREE.Texture(F),E.needsUpdate=!0}w.useProgram(D),w.enableVertexAttribArray(v),w.enableVertexAttribArray(y),w.disable(w.CULL_FACE),w.enable(w.BLEND),w.bindBuffer(w.ARRAY_BUFFER,K),w.vertexAttribPointer(v,2,w.FLOAT,!1,16,0),w.vertexAttribPointer(y,2,w.FLOAT,!1,16,8),w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,x),w.uniformMatrix4fv(p,!1,B.projectionMatrix.elements),w.activeTexture(w.TEXTURE0),w.uniform1i(h,0),R=F=0,(H=A.fog)?(w.uniform3f(s,H.color.r,H.color.g,H.color.b),H instanceof THREE.Fog?(w.uniform1f(r,H.near),w.uniform1f(t,H.far),w.uniform1i(q,1),R=F=1):H instanceof THREE.FogExp2&&(w.uniform1f(m,H.density),w.uniform1i(q,2),R=F=2)):(w.uniform1i(q,0),R=F=0);for(var H=0,C=b.length;H<C;H++){var T=b[H];T._modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,T.matrixWorld),T.z=null===T.renderDepth?-T._modelViewMatrix.elements[14]:T.renderDepth}b.sort(G);for(var Q=[],H=0,C=b.length;H<C;H++){var T=b[H],O=T.material;w.uniform1f(u,O.alphaTest),w.uniformMatrix4fv(n,!1,T._modelViewMatrix.elements),Q[0]=T.scale.x,Q[1]=T.scale.y,T=0,A.fog&&O.fog&&(T=R),F!==T&&(w.uniform1i(q,T),F=T),null!==O.map?(w.uniform2f(c,O.map.offset.x,O.map.offset.y),w.uniform2f(d,O.map.repeat.x,O.map.repeat.y)):(w.uniform2f(c,0,0),w.uniform2f(d,1,1)),w.uniform1f(k,O.opacity),w.uniform3f(g,O.color.r,O.color.g,O.color.b),w.uniform1f(e,O.rotation),w.uniform2fv(f,Q),a.setBlending(O.blending,O.blendEquation,O.blendSrc,O.blendDst),a.setDepthTest(O.depthTest),a.setDepthWrite(O.depthWrite),O.map&&O.map.image&&O.map.image.width?a.setTexture(O.map,0):a.setTexture(E,0),w.drawElements(w.TRIANGLES,6,w.UNSIGNED_SHORT,0)}w.enable(w.CULL_FACE),a.resetGLState()}}},THREE.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");var d;b instanceof THREE.Mesh&&(b.matrixAutoUpdate&&b.updateMatrix(),d=b.matrix,b=b.geometry),a.merge(b,d,c)},center:function(a){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),a.center()}},THREE.ImageUtils={crossOrigin:void 0,loadTexture:function(a,b,c,d){var e=new THREE.ImageLoader;e.crossOrigin=this.crossOrigin;var f=new THREE.Texture((void 0),b);return e.load(a,function(a){f.image=a,f.needsUpdate=!0,c&&c(f)},void 0,function(a){d&&d(a)}),f.sourceFile=a,f},loadTextureCube:function(a,b,c,d){var e=new THREE.ImageLoader;e.crossOrigin=this.crossOrigin;var f=new THREE.CubeTexture([],b);f.flipY=!1;var g=0;b=function(b){e.load(a[b],function(a){f.images[b]=a,g+=1,6===g&&(f.needsUpdate=!0,c&&c(f))})},d=0;for(var h=a.length;d<h;++d)b(d);return f},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},getNormalMap:function(a,b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};b|=1;var d=a.width,e=a.height,f=document.createElement("canvas");f.width=d,f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,k=g.createImageData(d,e),n=k.data,p=0;p<d;p++)for(var q=0;q<e;q++){var m=0>q-1?0:q-1,r=q+1>e-1?e-1:q+1,t=0>p-1?0:p-1,s=p+1>d-1?d-1:p+1,u=[],v=[0,0,h[4*(q*d+p)]/255*b];for(u.push([-1,0,h[4*(q*d+t)]/255*b]),u.push([-1,-1,h[4*(m*d+t)]/255*b]),u.push([0,-1,h[4*(m*d+p)]/255*b]),u.push([1,-1,h[4*(m*d+s)]/255*b]),u.push([1,0,h[4*(q*d+s)]/255*b]),u.push([1,1,h[4*(r*d+s)]/255*b]),u.push([0,1,h[4*(r*d+p)]/255*b]),u.push([-1,1,h[4*(r*d+t)]/255*b]),m=[],t=u.length,r=0;r<t;r++){var s=u[r],y=u[(r+1)%t],s=[s[0]-v[0],s[1]-v[1],s[2]-v[2]],y=[y[0]-v[0],y[1]-v[1],y[2]-v[2]];m.push(c([s[1]*y[2]-s[2]*y[1],s[2]*y[0]-s[0]*y[2],s[0]*y[1]-s[1]*y[0]]))}for(u=[0,0,0],r=0;r<m.length;r++)u[0]+=m[r][0],u[1]+=m[r][1],u[2]+=m[r][2];u[0]/=m.length,u[1]/=m.length,u[2]/=m.length,v=4*(q*d+p),n[v]=(u[0]+1)/2*255|0,n[v+1]=(u[1]+1)/2*255|0,n[v+2]=255*u[2]|0,n[v+3]=255}return g.putImageData(k,0,0),f},generateDataTexture:function(a,b,c){var d=a*b,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g);c=Math.floor(255*c.b);for(var h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;return a=new THREE.DataTexture(e,a,b,THREE.RGBFormat),a.needsUpdate=!0,a}},THREE.SceneUtils={createMultiMaterialObject:function(a,b){for(var c=new THREE.Object3D,d=0,e=b.length;d<e;d++)c.add(new THREE.Mesh(a,b[d]));return c},detach:function(a,b,c){a.applyMatrix(b.matrixWorld),b.remove(a),c.add(a)},attach:function(a,b,c){var d=new THREE.Matrix4;d.getInverse(c.matrixWorld),a.applyMatrix(d),b.remove(a),c.add(a)}},THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){try{return this.faces[this.face][this.weight][this.style]}catch(a){throw"The font "+this.face+" with "+this.weight+" weight and "+this.style+" style is missing."}},loadFace:function(a){var b=a.familyName.toLowerCase();return this.faces[b]=this.faces[b]||{},this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{},this.faces[b][a.cssFontWeight][a.cssFontStyle]=a,this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){var b=this.getFace(),c=this.size/b.resolution,d=0,e=String(a).split(""),f=e.length,g=[];for(a=0;a<f;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h),d=d+h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var g,h,k,n,p,q,m,r,t,s,u,f=[],v=b.glyphs[a]||b.glyphs["?"];if(v){if(v.o)for(b=v._cachedOutline||(v._cachedOutline=v.o.split(" ")),n=b.length,a=0;a<n;)switch(k=b[a++]){case"m":k=b[a++]*c+d,p=b[a++]*c,e.moveTo(k,p);break;case"l":k=b[a++]*c+d,p=b[a++]*c,e.lineTo(k,p);break;case"q":if(k=b[a++]*c+d,p=b[a++]*c,r=b[a++]*c+d,t=b[a++]*c,e.quadraticCurveTo(r,t,k,p),g=f[f.length-1])for(q=g.x,m=g.y,g=1,h=this.divisions;g<=h;g++){var y=g/h;THREE.Shape.Utils.b2(y,q,r,k),THREE.Shape.Utils.b2(y,m,t,p)}break;case"b":if(k=b[a++]*c+d,p=b[a++]*c,r=b[a++]*c+d,t=b[a++]*c,s=b[a++]*c+d,u=b[a++]*c,e.bezierCurveTo(r,t,s,u,k,p),g=f[f.length-1])for(q=g.x,m=g.y,g=1,h=this.divisions;g<=h;g++)y=g/h,THREE.Shape.Utils.b3(y,q,r,s,k),THREE.Shape.Utils.b3(y,m,t,u,p)}return{offset:v.ha*c,path:e}}}},THREE.FontUtils.generateShapes=function(a,b){b=b||{};var c=void 0!==b.curveSegments?b.curveSegments:4,d=void 0!==b.font?b.font:"helvetiker",e=void 0!==b.weight?b.weight:"normal",f=void 0!==b.style?b.style:"normal";for(THREE.FontUtils.size=void 0!==b.size?b.size:100,THREE.FontUtils.divisions=c,THREE.FontUtils.face=d,THREE.FontUtils.weight=e,THREE.FontUtils.style=f,c=THREE.FontUtils.drawText(a).paths,d=[],e=0,f=c.length;e<f;e++)Array.prototype.push.apply(d,c[e].toShapes());return d},function(a){var b=function(a){for(var b=a.length,e=0,f=b-1,g=0;g<b;f=g++)e+=a[f].x*a[g].y-a[g].x*a[f].y;return.5*e};return a.Triangulate=function(a,d){var e=a.length;if(3>e)return null;var k,n,p,f=[],g=[],h=[];if(0<b(a))for(n=0;n<e;n++)g[n]=n;else for(n=0;n<e;n++)g[n]=e-1-n;var q=2*e;for(n=e-1;2<e;){if(0>=q--){console.log("Warning, unable to triangulate polygon!");break}k=n,e<=k&&(k=0),n=k+1,e<=n&&(n=0),p=n+1,e<=p&&(p=0);var m;a:{var r=m=void 0,t=void 0,s=void 0,u=void 0,v=void 0,y=void 0,G=void 0,w=void 0,r=a[g[k]].x,t=a[g[k]].y,s=a[g[n]].x,u=a[g[n]].y,v=a[g[p]].x,y=a[g[p]].y;if(1e-10>(s-r)*(y-t)-(u-t)*(v-r))m=!1;else{var K=void 0,x=void 0,D=void 0,E=void 0,A=void 0,B=void 0,F=void 0,R=void 0,H=void 0,C=void 0,H=R=F=w=G=void 0,K=v-s,x=y-u,D=r-v,E=t-y,A=s-r,B=u-t;for(m=0;m<e;m++)if(G=a[g[m]].x,w=a[g[m]].y,!(G===r&&w===t||G===s&&w===u||G===v&&w===y)&&(F=G-r,R=w-t,H=G-s,C=w-u,G-=v,w-=y,H=K*C-x*H,F=A*R-B*F,R=D*w-E*G,-1e-10<=H&&-1e-10<=R&&-1e-10<=F)){m=!1;break a}m=!0}}if(m){for(f.push([a[g[k]],a[g[n]],a[g[p]]]),h.push([g[k],g[n],g[p]]),k=n,p=n+1;p<e;k++,p++)g[k]=g[p];e--,q=2*e}}return d?h:f},a.Triangulate.area=b,a}(THREE.FontUtils),self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace},THREE.typeface_js=self._typeface_js,THREE.Audio=function(a){THREE.Object3D.call(this),this.type="Audio",this.context=a.context,this.source=this.context.createBufferSource(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.panner=this.context.createPanner(),this.panner.connect(this.gain)},THREE.Audio.prototype=Object.create(THREE.Object3D.prototype),THREE.Audio.prototype.load=function(a){var b=this,c=new XMLHttpRequest;return c.open("GET",a,!0),c.responseType="arraybuffer",c.onload=function(a){b.context.decodeAudioData(this.response,function(a){b.source.buffer=a,b.source.connect(b.panner),b.source.start(0)})},c.send(),this},THREE.Audio.prototype.setLoop=function(a){this.source.loop=a},THREE.Audio.prototype.setRefDistance=function(a){this.panner.refDistance=a},THREE.Audio.prototype.setRolloffFactor=function(a){this.panner.rolloffFactor=a},THREE.Audio.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3;return function(b){THREE.Object3D.prototype.updateMatrixWorld.call(this,b),a.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(a.x,a.y,a.z)}}(),THREE.AudioListener=function(){THREE.Object3D.call(this),this.type="AudioListener",this.context=new(window.AudioContext||window.webkitAudioContext)},THREE.AudioListener.prototype=Object.create(THREE.Object3D.prototype),THREE.AudioListener.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3,b=new THREE.Quaternion,c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3;return function(g){THREE.Object3D.prototype.updateMatrixWorld.call(this,g),g=this.context.listener,this.matrixWorld.decompose(a,b,c),d.set(0,0,-1).applyQuaternion(b),e.subVectors(a,f),g.setPosition(a.x,a.y,a.z),g.setOrientation(d.x,d.y,d.z,this.up.x,this.up.y,this.up.z),g.setVelocity(e.x,e.y,e.z),f.copy(a)}}(),THREE.Curve=function(){},THREE.Curve.prototype.getPoint=function(a){return console.log("Warning, getPoint() not implemented!"),null},THREE.Curve.prototype.getPointAt=function(a){return a=this.getUtoTmapping(a),this.getPoint(a)},THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c},THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c},THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]},THREE.Curve.prototype.getLengths=function(a){if(a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var c,e,b=[],d=this.getPoint(0),f=0;for(b.push(0),e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b},THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0,this.getLengths()},THREE.Curve.prototype.getUtoTmapping=function(a,b){var f,c=this.getLengths(),d=0,e=c.length;f=b?b:a*c[e-1];for(var k,g=0,h=e-1;g<=h;)if(d=Math.floor(g+(h-g)/2),k=c[d]-f,0>k)g=d+1;else{if(!(0<k)){h=d;break}h=d-1}return d=h,c[d]==f?d/(e-1):(g=c[d],c=(d+(f-g)/(c[d+1]-g))/(e-1))},THREE.Curve.prototype.getTangent=function(a){var b=a-1e-4;return a+=1e-4,0>b&&(b=0),1<a&&(a=1),b=this.getPoint(b),this.getPoint(a).clone().sub(b).normalize()},THREE.Curve.prototype.getTangentAt=function(a){return a=this.getUtoTmapping(a),this.getTangent(a)},THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a,b,c,d,e){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){a=.5*(c-a),d=.5*(d-b);var f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}},THREE.Curve.create=function(a,b){return a.prototype=Object.create(THREE.Curve.prototype),a.prototype.getPoint=b,a},THREE.CurvePath=function(){this.curves=[],this.bends=[],this.autoClose=!1},THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype),THREE.CurvePath.prototype.add=function(a){this.curves.push(a)},THREE.CurvePath.prototype.checkConnection=function(){},THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))},THREE.CurvePath.prototype.getPoint=function(a){var b=a*this.getLength(),c=this.getCurveLengths();for(a=0;a<c.length;){if(c[a]>=b)return b=c[a]-b,a=this.curves[a],b=1-b/a.getLength(),a.getPointAt(b);a++}return null},THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]},THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var c,a=[],b=0,d=this.curves.length;for(c=0;c<d;c++)b+=this.curves[c].getLength(),a.push(b);return this.cacheLengths=a},THREE.CurvePath.prototype.getBoundingBox=function(){var b,c,d,e,f,g,a=this.getPoints();b=c=Number.NEGATIVE_INFINITY,e=f=Number.POSITIVE_INFINITY;var h,k,n,p,q=a[0]instanceof THREE.Vector3;for(p=q?new THREE.Vector3:new THREE.Vector2,k=0,n=a.length;k<n;k++)h=a[k],h.x>b?b=h.x:h.x<e&&(e=h.x),h.y>c?c=h.y:h.y<f&&(f=h.y),q&&(h.z>d?d=h.z:h.z<g&&(g=h.z)),p.add(h);return a={minX:e,minY:f,maxX:b,maxY:c},q&&(a.maxZ=d,a.minZ=g),a},THREE.CurvePath.prototype.createPointsGeometry=function(a){return a=this.getPoints(a,!0),this.createGeometry(a)},THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){return a=this.getSpacedPoints(a,!0),this.createGeometry(a)},THREE.CurvePath.prototype.createGeometry=function(a){for(var b=new THREE.Geometry,c=0;c<a.length;c++)b.vertices.push(new THREE.Vector3(a[c].x,a[c].y,a[c].z||0));return b},THREE.CurvePath.prototype.addWrapPath=function(a){this.bends.push(a)},THREE.CurvePath.prototype.getTransformedPoints=function(a,b){var d,e,c=this.getPoints(a);for(b||(b=this.bends),d=0,e=b.length;d<e;d++)c=this.getWrapPoints(c,b[d]);return c},THREE.CurvePath.prototype.getTransformedSpacedPoints=function(a,b){var d,e,c=this.getSpacedPoints(a);for(b||(b=this.bends),d=0,e=b.length;d<e;d++)c=this.getWrapPoints(c,b[d]);return c},THREE.CurvePath.prototype.getWrapPoints=function(a,b){var d,e,f,g,h,k,c=this.getBoundingBox();for(d=0,e=a.length;d<e;d++)f=a[d],g=f.x,h=f.y,k=g/c.maxX,k=b.getUtoTmapping(k,g),g=b.getPoint(k),k=b.getTangent(k),k.set(-k.y,k.x).multiplyScalar(h),f.x=g.x+k.x,f.y=g.y+k.y;return a},THREE.Gyroscope=function(){
THREE.Object3D.call(this)},THREE.Gyroscope.prototype=Object.create(THREE.Object3D.prototype),THREE.Gyroscope.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3,b=new THREE.Quaternion,c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Quaternion,f=new THREE.Vector3;return function(g){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||g)&&(this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(d,e,f),this.matrix.decompose(a,b,c),this.matrixWorld.compose(d,b,f)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,g=!0);for(var h=0,k=this.children.length;h<k;h++)this.children[h].updateMatrixWorld(g)}}(),THREE.Path=function(a){THREE.CurvePath.call(this),this.actions=[],a&&this.fromPoints(a)},THREE.Path.prototype=Object.create(THREE.CurvePath.prototype),THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc",ELLIPSE:"ellipse"},THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)},THREE.Path.prototype.moveTo=function(a,b){var c=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:c})},THREE.Path.prototype.lineTo=function(a,b){var c=Array.prototype.slice.call(arguments),d=this.actions[this.actions.length-1].args,d=new THREE.LineCurve(new THREE.Vector2(d[d.length-2],d[d.length-1]),new THREE.Vector2(a,b));this.curves.push(d),this.actions.push({action:THREE.PathActions.LINE_TO,args:c})},THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var e=Array.prototype.slice.call(arguments),f=this.actions[this.actions.length-1].args,f=new THREE.QuadraticBezierCurve(new THREE.Vector2(f[f.length-2],f[f.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d));this.curves.push(f),this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:e})},THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args,h=new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f));this.curves.push(h),this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})},THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a),c=new THREE.SplineCurve(c),this.curves.push(c),this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})},THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=this.actions[this.actions.length-1].args;this.absarc(a+g[g.length-2],b+g[g.length-1],c,d,e,f)},THREE.Path.prototype.absarc=function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)},THREE.Path.prototype.ellipse=function(a,b,c,d,e,f,g){var h=this.actions[this.actions.length-1].args;this.absellipse(a+h[h.length-2],b+h[h.length-1],c,d,e,f,g)},THREE.Path.prototype.absellipse=function(a,b,c,d,e,f,g){var h=Array.prototype.slice.call(arguments),k=new THREE.EllipseCurve(a,b,c,d,e,f,g);this.curves.push(k),k=k.getPoint(1),h.push(k.x),h.push(k.y),this.actions.push({action:THREE.PathActions.ELLIPSE,args:h})},THREE.Path.prototype.getSpacedPoints=function(a,b){a||(a=40);for(var c=[],d=0;d<a;d++)c.push(this.getPoint(d/a));return c},THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints)return console.log("tata"),this.getSpacedPoints(a,b);a=a||12;var d,e,f,g,h,k,n,p,q,m,r,t,s,c=[];for(d=0,e=this.actions.length;d<e;d++)switch(f=this.actions[d],g=f.action,f=f.args,g){case THREE.PathActions.MOVE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:for(h=f[2],k=f[3],q=f[0],m=f[1],0<c.length?(g=c[c.length-1],r=g.x,t=g.y):(g=this.actions[d-1].args,r=g[g.length-2],t=g[g.length-1]),f=1;f<=a;f++)s=f/a,g=THREE.Shape.Utils.b2(s,r,q,h),s=THREE.Shape.Utils.b2(s,t,m,k),c.push(new THREE.Vector2(g,s));break;case THREE.PathActions.BEZIER_CURVE_TO:for(h=f[4],k=f[5],q=f[0],m=f[1],n=f[2],p=f[3],0<c.length?(g=c[c.length-1],r=g.x,t=g.y):(g=this.actions[d-1].args,r=g[g.length-2],t=g[g.length-1]),f=1;f<=a;f++)s=f/a,g=THREE.Shape.Utils.b3(s,r,q,n,h),s=THREE.Shape.Utils.b3(s,t,m,p,k),c.push(new THREE.Vector2(g,s));break;case THREE.PathActions.CSPLINE_THRU:for(g=this.actions[d-1].args,s=[new THREE.Vector2(g[g.length-2],g[g.length-1])],g=a*f[0].length,s=s.concat(f[0]),s=new THREE.SplineCurve(s),f=1;f<=g;f++)c.push(s.getPointAt(f/g));break;case THREE.PathActions.ARC:for(h=f[0],k=f[1],m=f[2],n=f[3],g=f[4],q=!!f[5],r=g-n,t=2*a,f=1;f<=t;f++)s=f/t,q||(s=1-s),s=n+s*r,g=h+m*Math.cos(s),s=k+m*Math.sin(s),c.push(new THREE.Vector2(g,s));break;case THREE.PathActions.ELLIPSE:for(h=f[0],k=f[1],m=f[2],p=f[3],n=f[4],g=f[5],q=!!f[6],r=g-n,t=2*a,f=1;f<=t;f++)s=f/t,q||(s=1-s),s=n+s*r,g=h+m*Math.cos(s),s=k+p*Math.sin(s),c.push(new THREE.Vector2(g,s))}return d=c[c.length-1],1e-10>Math.abs(d.x-c[0].x)&&1e-10>Math.abs(d.y-c[0].y)&&c.splice(c.length-1,1),b&&c.push(c[0]),c},THREE.Path.prototype.toShapes=function(a,b){function c(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=new THREE.Shape;f.actions=e.actions,f.curves=e.curves,b.push(f)}return b}function d(a,b){for(var c=b.length,d=!1,e=c-1,f=0;f<c;e=f++){var g=b[e],h=b[f],k=h.x-g.x,m=h.y-g.y;if(1e-10<Math.abs(m)){if(0>m&&(g=b[f],k=-k,h=b[e],m=-m),!(a.y<g.y||a.y>h.y))if(a.y==g.y){if(a.x==g.x)return!0}else{if(e=m*(a.x-g.x)-k*(a.y-g.y),0==e)return!0;0>e||(d=!d)}}else if(a.y==g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=function(a){var b,c,d,e,f=[],g=new THREE.Path;for(b=0,c=a.length;b<c;b++)d=a[b],e=d.args,d=d.action,d==THREE.PathActions.MOVE_TO&&0!=g.actions.length&&(f.push(g),g=new THREE.Path),g[d].apply(g,e);return 0!=g.actions.length&&f.push(g),f}(this.actions);if(0==e.length)return[];if(!0===b)return c(e);var f,g,h,k=[];if(1==e.length)return g=e[0],h=new THREE.Shape,h.actions=g.actions,h.curves=g.curves,k.push(h),k;var n=!THREE.Shape.Utils.isClockWise(e[0].getPoints()),n=a?!n:n;h=[];var r,p=[],q=[],m=0;p[m]=void 0,q[m]=[];var t,s;for(t=0,s=e.length;t<s;t++)g=e[t],r=g.getPoints(),f=THREE.Shape.Utils.isClockWise(r),(f=a?!f:f)?(!n&&p[m]&&m++,p[m]={s:new THREE.Shape,p:r},p[m].s.actions=g.actions,p[m].s.curves=g.curves,n&&m++,q[m]=[]):q[m].push({h:g,p:r[0]});if(!p[0])return c(e);if(1<p.length){for(t=!1,s=[],g=0,e=p.length;g<e;g++)h[g]=[];for(g=0,e=p.length;g<e;g++)for(f=q[g],n=0;n<f.length;n++){m=f[n],r=!0;for(var u=0;u<p.length;u++)d(m.p,p[u].p)&&(g!=u&&s.push({froms:g,tos:u,hole:n}),r?(r=!1,h[u].push(m)):t=!0);r&&h[g].push(m)}0<s.length&&(t||(q=h))}for(t=0,s=p.length;t<s;t++)for(h=p[t].s,k.push(h),g=q[t],e=0,f=g.length;e<f;e++)h.holes.push(g[e].h);return k},THREE.Shape=function(){THREE.Path.apply(this,arguments),this.holes=[]},THREE.Shape.prototype=Object.create(THREE.Path.prototype),THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)},THREE.Shape.prototype.makeGeometry=function(a){return new THREE.ShapeGeometry(this,a)},THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d},THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d},THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}},THREE.Shape.prototype.extractPoints=function(a){return this.useSpacedPoints?this.extractAllSpacedPoints(a):this.extractAllPoints(a)},THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}},THREE.Shape.Utils={triangulateShape:function(a,b){function c(a,b,c){return a.x!=b.x?a.x<b.x?a.x<=c.x&&c.x<=b.x:b.x<=c.x&&c.x<=a.x:a.y<b.y?a.y<=c.y&&c.y<=b.y:b.y<=c.y&&c.y<=a.y}function d(a,b,d,e,f){var g=b.x-a.x,h=b.y-a.y,k=e.x-d.x,n=e.y-d.y,p=a.x-d.x,q=a.y-d.y,D=h*k-g*n,E=h*p-g*q;if(1e-10<Math.abs(D)){if(0<D){if(0>E||E>D)return[];if(k=n*p-k*q,0>k||k>D)return[]}else{if(0<E||E<D)return[];if(k=n*p-k*q,0<k||k<D)return[]}return 0==k?!f||0!=E&&E!=D?[a]:[]:k==D?!f||0!=E&&E!=D?[b]:[]:0==E?[d]:E==D?[e]:(f=k/D,[{x:a.x+f*g,y:a.y+f*h}])}return 0!=E||n*p!=k*q?[]:(h=0==g&&0==h,k=0==k&&0==n,h&&k?a.x!=d.x||a.y!=d.y?[]:[a]:h?c(d,e,a)?[a]:[]:k?c(a,b,d)?[d]:[]:(0!=g?(a.x<b.x?(g=a,k=a.x,h=b,a=b.x):(g=b,k=b.x,h=a,a=a.x),d.x<e.x?(b=d,D=d.x,n=e,d=e.x):(b=e,D=e.x,n=d,d=d.x)):(a.y<b.y?(g=a,k=a.y,h=b,a=b.y):(g=b,k=b.y,h=a,a=a.y),d.y<e.y?(b=d,D=d.y,n=e,d=e.y):(b=e,D=e.y,n=d,d=d.y)),k<=D?a<D?[]:a==D?f?[]:[b]:a<=d?[b,h]:[b,n]:k>d?[]:k==d?f?[]:[g]:a<=d?[g,h]:[g,n]))}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x,c=c.y-a.y;var g=d.x-a.x;return d=d.y-a.y,a=e*c-f*b,e=e*d-f*g,1e-10<Math.abs(a)?(b=g*c-d*b,0<a?0<=e&&0<=b:0<=e||0<=b):0<e}var f,g,h,k,n,p={};for(h=a.concat(),f=0,g=b.length;f<g;f++)Array.prototype.push.apply(h,b[f]);for(f=0,g=h.length;f<g;f++)n=h[f].x+":"+h[f].y,void 0!==p[n]&&console.log("Duplicate point",n),p[n]=f;f=function(a,b){function c(a,b){var d=h.length-1,f=a-1;0>f&&(f=d);var g=a+1;return g>d&&(g=0),!!(d=e(h[a],h[f],h[g],k[b]))&&(d=k.length-1,f=b-1,0>f&&(f=d),g=b+1,g>d&&(g=0),!!(d=e(k[b],k[f],k[g],h[a])))}function f(a,b){var c,e;for(c=0;c<h.length;c++)if(e=c+1,e%=h.length,e=d(a,b,h[c],h[e],!0),0<e.length)return!0;return!1}function g(a,c){var e,f,h,k;for(e=0;e<n.length;e++)for(f=b[n[e]],h=0;h<f.length;h++)if(k=h+1,k%=f.length,k=d(a,c,f[h],f[k],!0),0<k.length)return!0;return!1}var k,p,q,x,D,E,B,F,R,h=a.concat(),n=[],A=[],H=0;for(p=b.length;H<p;H++)n.push(H);B=0;for(var C=2*n.length;0<n.length;){if(C--,0>C){console.log("Infinite Loop! Holes left:"+n.length+", Probably Hole outside Shape!");break}for(q=B;q<h.length;q++){for(x=h[q],p=-1,H=0;H<n.length;H++)if(D=n[H],E=x.x+":"+x.y+":"+D,void 0===A[E]){for(k=b[D],F=0;F<k.length;F++)if(D=k[F],c(q,F)&&!f(x,D)&&!g(x,D)){p=F,n.splice(H,1),B=h.slice(0,q+1),D=h.slice(q),F=k.slice(p),R=k.slice(0,p+1),h=B.concat(F).concat(R).concat(D),B=q;break}if(0<=p)break;A[E]=!0}if(0<=p)break}}return h}(a,b);var q=THREE.FontUtils.Triangulate(f,!1);for(f=0,g=q.length;f<g;f++)for(k=q[f],h=0;3>h;h++)n=k[h].x+":"+k[h].y,n=p[n],void 0!==n&&(k[h]=n);return q.concat()},isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+this.b3p3(a,e)}},THREE.LineCurve=function(a,b){this.v1=a,this.v2=b},THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype),THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().sub(this.v1);return b.multiplyScalar(a).add(this.v1),b},THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)},THREE.LineCurve.prototype.getTangent=function(a){return this.v2.clone().sub(this.v1).normalize()},THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a,this.v1=b,this.v2=c},THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype),THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b=new THREE.Vector2;return b.x=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x),b.y=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y),b},THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b=new THREE.Vector2;return b.x=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x),b.y=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y),b.normalize()},THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a,this.v1=b,this.v2=c,this.v3=d},THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype),THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;return b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),new THREE.Vector2(b,a)},THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;return b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b=new THREE.Vector2(b,a),b.normalize(),b},THREE.SplineCurve=function(a){this.points=void 0==a?[]:a},THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype),THREE.SplineCurve.prototype.getPoint=function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=new THREE.Vector2;return c.x=THREE.Curve.Utils.interpolate(d.x,e.x,f.x,b.x,a),c.y=THREE.Curve.Utils.interpolate(d.y,e.y,f.y,b.y,a),c},THREE.EllipseCurve=function(a,b,c,d,e,f,g){this.aX=a,this.aY=b,this.xRadius=c,this.yRadius=d,this.aStartAngle=e,this.aEndAngle=f,this.aClockwise=g},THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype),THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;return 0>b&&(b+=2*Math.PI),b>2*Math.PI&&(b-=2*Math.PI),a=!0===this.aClockwise?this.aEndAngle+(1-a)*(2*Math.PI-b):this.aStartAngle+a*b,b=new THREE.Vector2,b.x=this.aX+this.xRadius*Math.cos(a),b.y=this.aY+this.yRadius*Math.sin(a),b},THREE.ArcCurve=function(a,b,c,d,e,f){THREE.EllipseCurve.call(this,a,b,c,c,d,e,f)},THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype),THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a,this.v2=b},function(a){var b=new THREE.Vector3;return b.subVectors(this.v2,this.v1),b.multiplyScalar(a),b.add(this.v1),b}),THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a,this.v1=b,this.v2=c},function(a){var b=new THREE.Vector3;return b.x=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x),b.y=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y),b.z=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z),b}),THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a,this.v1=b,this.v2=c,this.v3=d},function(a){var b=new THREE.Vector3;return b.x=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b.y=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b.z=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z),b}),THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=new THREE.Vector3;return c.x=THREE.Curve.Utils.interpolate(d.x,e.x,f.x,b.x,a),c.y=THREE.Curve.Utils.interpolate(d.y,e.y,f.y,b.y,a),c.z=THREE.Curve.Utils.interpolate(d.z,e.z,f.z,b.z,a),c}),THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-0;var c=Math.floor(a);a-=c;var c=c+(0<c?0:(Math.floor(Math.abs(c)/b.length)+1)*b.length),d=b[(c-1)%b.length],e=b[c%b.length],f=b[(c+1)%b.length],b=b[(c+2)%b.length],c=new THREE.Vector3;return c.x=THREE.Curve.Utils.interpolate(d.x,e.x,f.x,b.x,a),c.y=THREE.Curve.Utils.interpolate(d.y,e.y,f.y,b.y,a),c.z=THREE.Curve.Utils.interpolate(d.z,e.z,f.z,b.z,a),c}),THREE.AnimationHandler={LINEAR:0,CATMULLROM:1,CATMULLROM_FORWARD:2,add:function(){console.warn("THREE.AnimationHandler.add() has been deprecated.")},get:function(){console.warn("THREE.AnimationHandler.get() has been deprecated.")},remove:function(){console.warn("THREE.AnimationHandler.remove() has been deprecated.")},animations:[],init:function(a){if(!0!==a.initialized){for(var b=0;b<a.hierarchy.length;b++){for(var c=0;c<a.hierarchy[b].keys.length;c++)if(0>a.hierarchy[b].keys[c].time&&(a.hierarchy[b].keys[c].time=0),void 0!==a.hierarchy[b].keys[c].rot&&!(a.hierarchy[b].keys[c].rot instanceof THREE.Quaternion)){var d=a.hierarchy[b].keys[c].rot;a.hierarchy[b].keys[c].rot=(new THREE.Quaternion).fromArray(d)}if(a.hierarchy[b].keys.length&&void 0!==a.hierarchy[b].keys[0].morphTargets){for(d={},c=0;c<a.hierarchy[b].keys.length;c++)for(var e=0;e<a.hierarchy[b].keys[c].morphTargets.length;e++){var f=a.hierarchy[b].keys[c].morphTargets[e];d[f]=-1}for(a.hierarchy[b].usedMorphTargets=d,c=0;c<a.hierarchy[b].keys.length;c++){var g={};for(f in d){for(e=0;e<a.hierarchy[b].keys[c].morphTargets.length;e++)if(a.hierarchy[b].keys[c].morphTargets[e]===f){g[f]=a.hierarchy[b].keys[c].morphTargetsInfluences[e];break}e===a.hierarchy[b].keys[c].morphTargets.length&&(g[f]=0)}a.hierarchy[b].keys[c].morphTargetsInfluences=g}}for(c=1;c<a.hierarchy[b].keys.length;c++)a.hierarchy[b].keys[c].time===a.hierarchy[b].keys[c-1].time&&(a.hierarchy[b].keys.splice(c,1),c--);for(c=0;c<a.hierarchy[b].keys.length;c++)a.hierarchy[b].keys[c].index=c}return a.initialized=!0,a}},parse:function(a){var b=function(a,c){c.push(a);for(var d=0;d<a.children.length;d++)b(a.children[d],c)},c=[];if(a instanceof THREE.SkinnedMesh)for(var d=0;d<a.skeleton.bones.length;d++)c.push(a.skeleton.bones[d]);else b(a,c);return c},play:function(a){-1===this.animations.indexOf(a)&&this.animations.push(a)},stop:function(a){a=this.animations.indexOf(a),-1!==a&&this.animations.splice(a,1)},update:function(a){for(var b=0;b<this.animations.length;b++)this.animations[b].resetBlendWeights();for(b=0;b<this.animations.length;b++)this.animations[b].update(a)}},THREE.Animation=function(a,b){this.root=a,this.data=THREE.AnimationHandler.init(b),this.hierarchy=THREE.AnimationHandler.parse(a),this.currentTime=0,this.timeScale=1,this.isPlaying=!1,this.loop=!0,this.weight=0,this.interpolationType=THREE.AnimationHandler.LINEAR},THREE.Animation.prototype.keyTypes=["pos","rot","scl"],THREE.Animation.prototype.play=function(a,b){this.currentTime=void 0!==a?a:0,this.weight=void 0!==b?b:1,this.isPlaying=!0,this.reset(),THREE.AnimationHandler.play(this)},THREE.Animation.prototype.stop=function(){this.isPlaying=!1,THREE.AnimationHandler.stop(this)},THREE.Animation.prototype.reset=function(){for(var a=0,b=this.hierarchy.length;a<b;a++){var c=this.hierarchy[a];c.matrixAutoUpdate=!0,void 0===c.animationCache&&(c.animationCache={animations:{},blending:{positionWeight:0,quaternionWeight:0,scaleWeight:0}}),void 0===c.animationCache.animations[this.data.name]&&(c.animationCache.animations[this.data.name]={},c.animationCache.animations[this.data.name].prevKey={pos:0,rot:0,scl:0},c.animationCache.animations[this.data.name].nextKey={pos:0,rot:0,scl:0},c.animationCache.animations[this.data.name].originalMatrix=c.matrix);for(var c=c.animationCache.animations[this.data.name],d=0;3>d;d++){for(var e=this.keyTypes[d],f=this.data.hierarchy[a].keys[0],g=this.getNextKeyWith(e,a,1);g.time<this.currentTime&&g.index>f.index;)f=g,g=this.getNextKeyWith(e,a,g.index+1);c.prevKey[e]=f,c.nextKey[e]=g}}},THREE.Animation.prototype.resetBlendWeights=function(){for(var a=0,b=this.hierarchy.length;a<b;a++){var c=this.hierarchy[a];void 0!==c.animationCache&&(c.animationCache.blending.positionWeight=0,c.animationCache.blending.quaternionWeight=0,c.animationCache.blending.scaleWeight=0)}},THREE.Animation.prototype.update=function(){var a=[],b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Quaternion,e=function(a,b){var e,q,m,r,t,s,c=[],d=[];return e=(a.length-1)*b,q=Math.floor(e),e-=q,c[0]=0===q?q:q-1,c[1]=q,c[2]=q>a.length-2?q:q+1,c[3]=q>a.length-3?q:q+2,q=a[c[0]],r=a[c[1]],t=a[c[2]],s=a[c[3]],c=e*e,m=e*c,d[0]=f(q[0],r[0],t[0],s[0],e,c,m),d[1]=f(q[1],r[1],t[1],s[1],e,c,m),d[2]=f(q[2],r[2],t[2],s[2],e,c,m),d},f=function(a,b,c,d,e,f,m){return a=.5*(c-a),d=.5*(d-b),(2*(b-c)+a+d)*m+(-3*(b-c)-2*a-d)*f+a*e+b};return function(f){if(!1!==this.isPlaying&&(this.currentTime+=f*this.timeScale,0!==this.weight)){if(f=this.data.length,this.currentTime>f||0>this.currentTime){if(!this.loop)return void this.stop();this.currentTime%=f,0>this.currentTime&&(this.currentTime+=f),this.reset()}f=0;for(var h=this.hierarchy.length;f<h;f++)for(var k=this.hierarchy[f],n=k.animationCache.animations[this.data.name],p=k.animationCache.blending,q=0;3>q;q++){var m=this.keyTypes[q],r=n.prevKey[m],t=n.nextKey[m];if(0<this.timeScale&&t.time<=this.currentTime||0>this.timeScale&&r.time>=this.currentTime){for(r=this.data.hierarchy[f].keys[0],t=this.getNextKeyWith(m,f,1);t.time<this.currentTime&&t.index>r.index;)r=t,t=this.getNextKeyWith(m,f,t.index+1);n.prevKey[m]=r,n.nextKey[m]=t}k.matrixAutoUpdate=!0,k.matrixWorldNeedsUpdate=!0;var s=(this.currentTime-r.time)/(t.time-r.time),u=r[m],v=t[m];0>s&&(s=0),1<s&&(s=1),"pos"===m?this.interpolationType===THREE.AnimationHandler.LINEAR?(c.x=u[0]+(v[0]-u[0])*s,c.y=u[1]+(v[1]-u[1])*s,c.z=u[2]+(v[2]-u[2])*s,r=this.weight/(this.weight+p.positionWeight),k.position.lerp(c,r),p.positionWeight+=this.weight):this.interpolationType!==THREE.AnimationHandler.CATMULLROM&&this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD||(a[0]=this.getPrevKeyWith("pos",f,r.index-1).pos,a[1]=u,a[2]=v,a[3]=this.getNextKeyWith("pos",f,t.index+1).pos,s=.33*s+.33,t=e(a,s),r=this.weight/(this.weight+p.positionWeight),p.positionWeight+=this.weight,m=k.position,m.x+=(t[0]-m.x)*r,m.y+=(t[1]-m.y)*r,m.z+=(t[2]-m.z)*r,this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD&&(s=e(a,1.01*s),b.set(s[0],s[1],s[2]),b.sub(m),b.y=0,b.normalize(),s=Math.atan2(b.x,b.z),k.rotation.set(0,s,0))):"rot"===m?(THREE.Quaternion.slerp(u,v,d,s),0===p.quaternionWeight?(k.quaternion.copy(d),p.quaternionWeight=this.weight):(r=this.weight/(this.weight+p.quaternionWeight),THREE.Quaternion.slerp(k.quaternion,d,k.quaternion,r),p.quaternionWeight+=this.weight)):"scl"===m&&(c.x=u[0]+(v[0]-u[0])*s,c.y=u[1]+(v[1]-u[1])*s,c.z=u[2]+(v[2]-u[2])*s,r=this.weight/(this.weight+p.scaleWeight),k.scale.lerp(c,r),p.scaleWeight+=this.weight)}return!0}}}(),THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[0]},THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?0<c?c:0:0<=c?c:c+d.length;0<=c;c--)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[d.length-1]},THREE.KeyFrameAnimation=function(a){this.root=a.node,this.data=THREE.AnimationHandler.init(a),this.hierarchy=THREE.AnimationHandler.parse(this.root),this.currentTime=0,this.timeScale=.001,this.isPlaying=!1,this.loop=this.isPaused=!0,a=0;for(var b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var f=c[e],g=this.getNextKeyWith(f,a,0);g&&g.apply(f)}d.matrixAutoUpdate=!1,this.data.hierarchy[a].node.updateMatrix(),d.matrixWorldNeedsUpdate=!0}}},THREE.KeyFrameAnimation.prototype.play=function(a){if(this.currentTime=void 0!==a?a:0,!1===this.isPlaying){this.isPlaying=!0;var c,d,b=this.hierarchy.length;for(a=0;a<b;a++)c=this.hierarchy[a],d=this.data.hierarchy[a],void 0===d.animationCache&&(d.animationCache={},d.animationCache.prevKey=null,d.animationCache.nextKey=null,d.animationCache.originalMatrix=c.matrix),c=this.data.hierarchy[a].keys,c.length&&(d.animationCache.prevKey=c[0],d.animationCache.nextKey=c[1],this.startTime=Math.min(c[0].time,this.startTime),this.endTime=Math.max(c[c.length-1].time,this.endTime));this.update(0)}this.isPaused=!1,THREE.AnimationHandler.play(this)},THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=!1,THREE.AnimationHandler.stop(this);for(var a=0;a<this.data.hierarchy.length;a++){var b=this.hierarchy[a],c=this.data.hierarchy[a];if(void 0!==c.animationCache){var d=c.animationCache.originalMatrix;d.copy(b.matrix),b.matrix=d,delete c.animationCache}}},THREE.KeyFrameAnimation.prototype.update=function(a){if(!1!==this.isPlaying){this.currentTime+=a*this.timeScale,a=this.data.length,!0===this.loop&&this.currentTime>a&&(this.currentTime%=a),this.currentTime=Math.min(this.currentTime,a),a=0;for(var b=this.hierarchy.length;a<b;a++){var c=this.hierarchy[a],d=this.data.hierarchy[a],e=d.keys,d=d.animationCache;if(e.length){var f=d.prevKey,g=d.nextKey;if(g.time<=this.currentTime){for(;g.time<this.currentTime&&g.index>f.index;)f=g,g=e[f.index+1];d.prevKey=f,d.nextKey=g}g.time>=this.currentTime?f.interpolate(g,this.currentTime):f.interpolate(g,g.time),this.data.hierarchy[a].node.updateMatrix(),c.matrixWorldNeedsUpdate=!0}}}},THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){for(b=this.data.hierarchy[b].keys,c%=b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]},THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){for(b=this.data.hierarchy[b].keys,c=0<=c?c:c+b.length;0<=c;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]},THREE.MorphAnimation=function(a){this.mesh=a,this.frames=a.morphTargetInfluences.length,this.currentTime=0,this.duration=1e3,this.loop=!0,this.isPlaying=!1},THREE.MorphAnimation.prototype={play:function(){this.isPlaying=!0},pause:function(){this.isPlaying=!1},update:function(){var a=0,b=0;return function(c){if(!1!==this.isPlaying){this.currentTime+=c,!0===this.loop&&this.currentTime>this.duration&&(this.currentTime%=this.duration),this.currentTime=Math.min(this.currentTime,this.duration),c=this.duration/this.frames;var d=Math.floor(this.currentTime/c);d!=b&&(this.mesh.morphTargetInfluences[a]=0,this.mesh.morphTargetInfluences[b]=1,this.mesh.morphTargetInfluences[d]=0,a=b,b=d),this.mesh.morphTargetInfluences[d]=this.currentTime%c/c,this.mesh.morphTargetInfluences[a]=1-this.mesh.morphTargetInfluences[d]}}}()},THREE.BoxGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,s){var u,v=h.widthSegments,y=h.heightSegments,G=e/2,w=f/2,K=h.vertices.length;"x"===a&&"y"===b||"y"===a&&"x"===b?u="z":"x"===a&&"z"===b||"z"===a&&"x"===b?(u="y",y=h.depthSegments):("z"===a&&"y"===b||"y"===a&&"z"===b)&&(u="x",v=h.depthSegments);var x=v+1,D=y+1,E=e/v,A=f/y,B=new THREE.Vector3;for(B[u]=0<g?1:-1,e=0;e<D;e++)for(f=0;f<x;f++){var F=new THREE.Vector3;F[a]=(f*E-G)*c,F[b]=(e*A-w)*d,F[u]=g,h.vertices.push(F)}for(e=0;e<y;e++)for(f=0;f<v;f++)w=f+x*e,a=f+x*(e+1),b=f+1+x*(e+1),c=f+1+x*e,d=new THREE.Vector2(f/v,1-e/y),g=new THREE.Vector2(f/v,1-(e+1)/y),u=new THREE.Vector2((f+1)/v,1-(e+1)/y),G=new THREE.Vector2((f+1)/v,1-e/y),w=new THREE.Face3(w+K,a+K,c+K),w.normal.copy(B),w.vertexNormals.push(B.clone(),B.clone(),B.clone()),w.materialIndex=s,h.faces.push(w),h.faceVertexUvs[0].push([d,g,G]),w=new THREE.Face3(a+K,b+K,c+K),w.normal.copy(B),w.vertexNormals.push(B.clone(),B.clone(),B.clone()),w.materialIndex=s,h.faces.push(w),h.faceVertexUvs[0].push([g.clone(),u,G.clone()])}THREE.Geometry.call(this),this.type="BoxGeometry",this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f},this.widthSegments=d||1,this.heightSegments=e||1,this.depthSegments=f||1;var h=this;d=a/2,e=b/2,f=c/2,g("z","y",-1,-1,c,b,d,0),g("z","y",1,-1,c,b,-d,1),g("x","z",1,1,a,c,e,2),g("x","z",1,-1,a,c,-e,3),g("x","y",1,-1,a,b,f,4),g("x","y",-1,-1,a,b,-f,5),this.mergeVertices()},THREE.BoxGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this),this.type="CircleGeometry",this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d},a=a||50,b=void 0!==b?Math.max(3,b):8,c=void 0!==c?c:0,d=void 0!==d?d:2*Math.PI;var e,f=[];e=new THREE.Vector3;var g=new THREE.Vector2(.5,.5);for(this.vertices.push(e),f.push(g),e=0;e<=b;e++){var h=new THREE.Vector3,k=c+e/b*d;h.x=a*Math.cos(k),h.y=a*Math.sin(k),this.vertices.push(h),f.push(new THREE.Vector2((h.x/a+1)/2,(h.y/a+1)/2))}for(c=new THREE.Vector3(0,0,1),e=1;e<=b;e++)this.faces.push(new THREE.Face3(e,e+1,0,[c.clone(),c.clone(),c.clone()])),this.faceVertexUvs[0].push([f[e].clone(),f[e+1].clone(),g.clone()]);this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)},THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.CubeGeometry=function(a,b,c,d,e,f){return console.warn("THREE.CubeGeometry has been renamed to THREE.BoxGeometry."),new THREE.BoxGeometry(a,b,c,d,e,f)},THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f},a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,d=d||8,e=e||1,f=void 0!==f&&f;var h,k,g=c/2,n=[],p=[];for(k=0;k<=e;k++){var q=[],m=[],r=k/e,t=r*(b-a)+a;for(h=0;h<=d;h++){var s=h/d,u=new THREE.Vector3;u.x=t*Math.sin(s*Math.PI*2),u.y=-r*c+g,u.z=t*Math.cos(s*Math.PI*2),this.vertices.push(u),q.push(this.vertices.length-1),m.push(new THREE.Vector2(s,1-r))}n.push(q),p.push(m)}for(c=(b-a)/c,h=0;h<d;h++)for(0!==a?(q=this.vertices[n[0][h]].clone(),m=this.vertices[n[0][h+1]].clone()):(q=this.vertices[n[1][h]].clone(),m=this.vertices[n[1][h+1]].clone()),q.setY(Math.sqrt(q.x*q.x+q.z*q.z)*c).normalize(),m.setY(Math.sqrt(m.x*m.x+m.z*m.z)*c).normalize(),k=0;k<e;k++){var r=n[k][h],t=n[k+1][h],s=n[k+1][h+1],u=n[k][h+1],v=q.clone(),y=q.clone(),G=m.clone(),w=m.clone(),K=p[k][h].clone(),x=p[k+1][h].clone(),D=p[k+1][h+1].clone(),E=p[k][h+1].clone();this.faces.push(new THREE.Face3(r,t,u,[v,y,w])),this.faceVertexUvs[0].push([K,x,E]),this.faces.push(new THREE.Face3(t,s,u,[y.clone(),G,w.clone()])),this.faceVertexUvs[0].push([x.clone(),D,E.clone()])}if(!1===f&&0<a)for(this.vertices.push(new THREE.Vector3(0,g,0)),h=0;h<d;h++)r=n[0][h],t=n[0][h+1],s=this.vertices.length-1,v=new THREE.Vector3(0,1,0),y=new THREE.Vector3(0,1,0),G=new THREE.Vector3(0,1,0),K=p[0][h].clone(),x=p[0][h+1].clone(),D=new THREE.Vector2(x.x,0),this.faces.push(new THREE.Face3(r,t,s,[v,y,G])),this.faceVertexUvs[0].push([K,x,D]);if(!1===f&&0<b)for(this.vertices.push(new THREE.Vector3(0,(-g),0)),h=0;h<d;h++)r=n[k][h+1],t=n[k][h],s=this.vertices.length-1,v=new THREE.Vector3(0,(-1),0),y=new THREE.Vector3(0,(-1),0),G=new THREE.Vector3(0,(-1),0),K=p[k][h+1].clone(),x=p[k][h].clone(),D=new THREE.Vector2(x.x,1),this.faces.push(new THREE.Face3(r,t,s,[v,y,G])),this.faceVertexUvs[0].push([K,x,D]);this.computeFaceNormals()},THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.ExtrudeGeometry=function(a,b){"undefined"!=typeof a&&(THREE.Geometry.call(this),this.type="ExtrudeGeometry",a=a instanceof Array?a:[a],this.addShapeList(a,b),this.computeFaceNormals())},THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)},THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){return b||console.log("die"),b.clone().multiplyScalar(c).add(a)}function d(a,b,c){var d=1,d=a.x-b.x,e=a.y-b.y,f=c.x-a.x,g=c.y-a.y,h=d*d+e*e;if(1e-10<Math.abs(d*g-e*f)){var k=Math.sqrt(h),m=Math.sqrt(f*f+g*g),h=b.x-e/k;if(b=b.y+d/k,f=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f),c=h+d*f-a.x,a=b+e*f-a.y,d=c*c+a*a,2>=d)return new THREE.Vector2(c,a);d=Math.sqrt(d/2)}else a=!1,1e-10<d?1e-10<f&&(a=!0):-1e-10>d?-1e-10>f&&(a=!0):Math.sign(e)==Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(P=a.length;0<=--P;){c=P,d=P-1,0>d&&(d=a.length-1);for(var e=0,f=r+2*p,e=0;e<f;e++){var g=la*e,h=la*(e+1),k=b+c+g,g=b+d+g,m=b+d+h,h=b+c+h,k=k+R,g=g+R,m=m+R,h=h+R;F.faces.push(new THREE.Face3(k,g,h,null,null,y)),F.faces.push(new THREE.Face3(g,m,h,null,null,y)),k=G.generateSideWallUV(F,k,g,m,h),
F.faceVertexUvs[0].push([k[0],k[1],k[3]]),F.faceVertexUvs[0].push([k[1],k[2],k[3]])}}}function f(a,b,c){F.vertices.push(new THREE.Vector3(a,b,c))}function g(a,b,c){a+=R,b+=R,c+=R,F.faces.push(new THREE.Face3(a,b,c,null,null,v)),a=G.generateTopUV(F,a,b,c),F.faceVertexUvs[0].push(a)}var s,w,K,x,D,h=void 0!==b.amount?b.amount:100,k=void 0!==b.bevelThickness?b.bevelThickness:6,n=void 0!==b.bevelSize?b.bevelSize:k-2,p=void 0!==b.bevelSegments?b.bevelSegments:3,q=void 0===b.bevelEnabled||b.bevelEnabled,m=void 0!==b.curveSegments?b.curveSegments:12,r=void 0!==b.steps?b.steps:1,t=b.extrudePath,u=!1,v=b.material,y=b.extrudeMaterial,G=void 0!==b.UVGenerator?b.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator;t&&(s=t.getSpacedPoints(r),u=!0,q=!1,w=void 0!==b.frames?b.frames:new THREE.TubeGeometry.FrenetFrames(t,r,(!1)),K=new THREE.Vector3,x=new THREE.Vector3,D=new THREE.Vector3),q||(n=k=p=0);var E,A,B,F=this,R=this.vertices.length,t=a.extractPoints(m),m=t.shape,H=t.holes;if(t=!THREE.Shape.Utils.isClockWise(m)){for(m=m.reverse(),A=0,B=H.length;A<B;A++)E=H[A],THREE.Shape.Utils.isClockWise(E)&&(H[A]=E.reverse());t=!1}var C=THREE.Shape.Utils.triangulateShape(m,H),T=m;for(A=0,B=H.length;A<B;A++)E=H[A],m=m.concat(E);var Q,O,S,X,Y,ma,la=m.length,ya=C.length,t=[],P=0;for(S=T.length,Q=S-1,O=P+1;P<S;P++,Q++,O++)Q===S&&(Q=0),O===S&&(O=0),t[P]=d(T[P],T[Q],T[O]);var Fa,Ga=[],za=t.concat();for(A=0,B=H.length;A<B;A++){for(E=H[A],Fa=[],P=0,S=E.length,Q=S-1,O=P+1;P<S;P++,Q++,O++)Q===S&&(Q=0),O===S&&(O=0),Fa[P]=d(E[P],E[Q],E[O]);Ga.push(Fa),za=za.concat(Fa)}for(Q=0;Q<p;Q++){for(S=Q/p,X=k*(1-S),O=n*Math.sin(S*Math.PI/2),P=0,S=T.length;P<S;P++)Y=c(T[P],t[P],O),f(Y.x,Y.y,-X);for(A=0,B=H.length;A<B;A++)for(E=H[A],Fa=Ga[A],P=0,S=E.length;P<S;P++)Y=c(E[P],Fa[P],O),f(Y.x,Y.y,-X)}for(O=n,P=0;P<la;P++)Y=q?c(m[P],za[P],O):m[P],u?(x.copy(w.normals[0]).multiplyScalar(Y.x),K.copy(w.binormals[0]).multiplyScalar(Y.y),D.copy(s[0]).add(x).add(K),f(D.x,D.y,D.z)):f(Y.x,Y.y,0);for(S=1;S<=r;S++)for(P=0;P<la;P++)Y=q?c(m[P],za[P],O):m[P],u?(x.copy(w.normals[S]).multiplyScalar(Y.x),K.copy(w.binormals[S]).multiplyScalar(Y.y),D.copy(s[S]).add(x).add(K),f(D.x,D.y,D.z)):f(Y.x,Y.y,h/r*S);for(Q=p-1;0<=Q;Q--){for(S=Q/p,X=k*(1-S),O=n*Math.sin(S*Math.PI/2),P=0,S=T.length;P<S;P++)Y=c(T[P],t[P],O),f(Y.x,Y.y,h+X);for(A=0,B=H.length;A<B;A++)for(E=H[A],Fa=Ga[A],P=0,S=E.length;P<S;P++)Y=c(E[P],Fa[P],O),u?f(Y.x,Y.y+s[r-1].y,s[r-1].x+X):f(Y.x,Y.y,h+X)}!function(){if(q){var a;for(a=0*la,P=0;P<ya;P++)ma=C[P],g(ma[2]+a,ma[1]+a,ma[0]+a);for(a=r+2*p,a*=la,P=0;P<ya;P++)ma=C[P],g(ma[0]+a,ma[1]+a,ma[2]+a)}else{for(P=0;P<ya;P++)ma=C[P],g(ma[2],ma[1],ma[0]);for(P=0;P<ya;P++)ma=C[P],g(ma[0]+la*r,ma[1]+la*r,ma[2]+la*r)}}(),function(){var a=0;for(e(T,a),a+=T.length,A=0,B=H.length;A<B;A++)E=H[A],e(E,a),a+=E.length}()},THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d){return a=a.vertices,b=a[b],c=a[c],d=a[d],[new THREE.Vector2(b.x,b.y),new THREE.Vector2(c.x,c.y),new THREE.Vector2(d.x,d.y)]},generateSideWallUV:function(a,b,c,d,e){return a=a.vertices,b=a[b],c=a[c],d=a[d],e=a[e],.01>Math.abs(b.y-c.y)?[new THREE.Vector2(b.x,1-b.z),new THREE.Vector2(c.x,1-c.z),new THREE.Vector2(d.x,1-d.z),new THREE.Vector2(e.x,1-e.z)]:[new THREE.Vector2(b.y,1-b.z),new THREE.Vector2(c.y,1-c.z),new THREE.Vector2(d.y,1-d.z),new THREE.Vector2(e.y,1-e.z)]}},THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this),this.type="ShapeGeometry",!1==a instanceof Array&&(a=[a]),this.addShapeList(a,b),this.computeFaceNormals()},THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c<d;c++)this.addShape(a[c],b);return this},THREE.ShapeGeometry.prototype.addShape=function(a,b){void 0===b&&(b={});var e,f,g,c=b.material,d=void 0===b.UVGenerator?THREE.ExtrudeGeometry.WorldUVGenerator:b.UVGenerator,h=this.vertices.length;e=a.extractPoints(void 0!==b.curveSegments?b.curveSegments:12);var k=e.shape,n=e.holes;if(!THREE.Shape.Utils.isClockWise(k))for(k=k.reverse(),e=0,f=n.length;e<f;e++)g=n[e],THREE.Shape.Utils.isClockWise(g)&&(n[e]=g.reverse());var p=THREE.Shape.Utils.triangulateShape(k,n);for(e=0,f=n.length;e<f;e++)g=n[e],k=k.concat(g);for(n=k.length,f=p.length,e=0;e<n;e++)g=k[e],this.vertices.push(new THREE.Vector3(g.x,g.y,0));for(e=0;e<f;e++)n=p[e],k=n[0]+h,g=n[1]+h,n=n[2]+h,this.faces.push(new THREE.Face3(k,g,n,null,null,c)),this.faceVertexUvs[0].push(d.generateTopUV(this,k,g,n))},THREE.LatheGeometry=function(a,b,c,d){THREE.Geometry.call(this),this.type="LatheGeometry",this.parameters={points:a,segments:b,phiStart:c,phiLength:d},b=b||12,c=c||0,d=d||2*Math.PI;for(var e=1/(a.length-1),f=1/b,g=0,h=b;g<=h;g++)for(var k=c+g*f*d,n=Math.cos(k),p=Math.sin(k),k=0,q=a.length;k<q;k++){var m=a[k],r=new THREE.Vector3;r.x=n*m.x-p*m.y,r.y=p*m.x+n*m.y,r.z=m.z,this.vertices.push(r)}for(c=a.length,g=0,h=b;g<h;g++)for(k=0,q=a.length-1;k<q;k++){b=p=k+c*g,d=p+c;var n=p+1+c,p=p+1,m=g*f,r=k*e,t=m+f,s=r+e;this.faces.push(new THREE.Face3(b,d,p)),this.faceVertexUvs[0].push([new THREE.Vector2(m,r),new THREE.Vector2(t,r),new THREE.Vector2(m,s)]),this.faces.push(new THREE.Face3(d,n,p)),this.faceVertexUvs[0].push([new THREE.Vector2(t,r),new THREE.Vector2(t,s),new THREE.Vector2(m,s)])}this.mergeVertices(),this.computeFaceNormals(),this.computeVertexNormals()},THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.PlaneGeometry=function(a,b,c,d){console.info("THREE.PlaneGeometry: Consider using THREE.PlaneBufferGeometry for lower memory footprint."),THREE.Geometry.call(this),this.type="PlaneGeometry",this.parameters={width:a,height:b,widthSegments:c,heightSegments:d},this.fromBufferGeometry(new THREE.PlaneBufferGeometry(a,b,c,d))},THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.PlaneBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this),this.type="PlaneBufferGeometry",this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};var e=a/2,f=b/2;c=c||1,d=d||1;var g=c+1,h=d+1,k=a/c,n=b/d;b=new Float32Array(g*h*3),a=new Float32Array(g*h*3);for(var p=new Float32Array(g*h*2),q=0,m=0,r=0;r<h;r++)for(var t=r*n-f,s=0;s<g;s++)b[q]=s*k-e,b[q+1]=-t,a[q+2]=1,p[m]=s/c,p[m+1]=1-r/d,q+=3,m+=2;for(q=0,e=new(65535<b.length/3?Uint32Array:Uint16Array)(c*d*6),r=0;r<d;r++)for(s=0;s<c;s++)f=s+g*(r+1),h=s+1+g*(r+1),k=s+1+g*r,e[q]=s+g*r,e[q+1]=f,e[q+2]=k,e[q+3]=f,e[q+4]=h,e[q+5]=k,q+=6;this.addAttribute("index",new THREE.BufferAttribute(e,1)),this.addAttribute("position",new THREE.BufferAttribute(b,3)),this.addAttribute("normal",new THREE.BufferAttribute(a,3)),this.addAttribute("uv",new THREE.BufferAttribute(p,2))},THREE.PlaneBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.RingGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this),this.type="RingGeometry",this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f},a=a||0,b=b||50,e=void 0!==e?e:0,f=void 0!==f?f:2*Math.PI,c=void 0!==c?Math.max(3,c):8,d=void 0!==d?Math.max(1,d):8;var g,h=[],k=a,n=(b-a)/d;for(a=0;a<d+1;a++){for(g=0;g<c+1;g++){var p=new THREE.Vector3,q=e+g/c*f;p.x=k*Math.cos(q),p.y=k*Math.sin(q),this.vertices.push(p),h.push(new THREE.Vector2((p.x/b+1)/2,(p.y/b+1)/2))}k+=n}for(b=new THREE.Vector3(0,0,1),a=0;a<d;a++)for(e=a*(c+1),g=0;g<c;g++)f=q=g+e,n=q+c+1,p=q+c+2,this.faces.push(new THREE.Face3(f,n,p,[b.clone(),b.clone(),b.clone()])),this.faceVertexUvs[0].push([h[f].clone(),h[n].clone(),h[p].clone()]),f=q,n=q+c+2,p=q+1,this.faces.push(new THREE.Face3(f,n,p,[b.clone(),b.clone(),b.clone()])),this.faceVertexUvs[0].push([h[f].clone(),h[n].clone(),h[p].clone()]);this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,k)},THREE.RingGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this),this.type="SphereGeometry",this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g},a=a||50,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),d=void 0!==d?d:0,e=void 0!==e?e:2*Math.PI,f=void 0!==f?f:0,g=void 0!==g?g:Math.PI;var h,k,n=[],p=[];for(k=0;k<=c;k++){var q=[],m=[];for(h=0;h<=b;h++){var r=h/b,t=k/c,s=new THREE.Vector3;s.x=-a*Math.cos(d+r*e)*Math.sin(f+t*g),s.y=a*Math.cos(f+t*g),s.z=a*Math.sin(d+r*e)*Math.sin(f+t*g),this.vertices.push(s),q.push(this.vertices.length-1),m.push(new THREE.Vector2(r,1-t))}n.push(q),p.push(m)}for(k=0;k<c;k++)for(h=0;h<b;h++){d=n[k][h+1],e=n[k][h],f=n[k+1][h],g=n[k+1][h+1];var q=this.vertices[d].clone().normalize(),m=this.vertices[e].clone().normalize(),r=this.vertices[f].clone().normalize(),t=this.vertices[g].clone().normalize(),s=p[k][h+1].clone(),u=p[k][h].clone(),v=p[k+1][h].clone(),y=p[k+1][h+1].clone();Math.abs(this.vertices[d].y)===a?(s.x=(s.x+u.x)/2,this.faces.push(new THREE.Face3(d,f,g,[q,r,t])),this.faceVertexUvs[0].push([s,v,y])):Math.abs(this.vertices[f].y)===a?(v.x=(v.x+y.x)/2,this.faces.push(new THREE.Face3(d,e,f,[q,m,r])),this.faceVertexUvs[0].push([s,u,v])):(this.faces.push(new THREE.Face3(d,e,g,[q,m,t])),this.faceVertexUvs[0].push([s,u,y]),this.faces.push(new THREE.Face3(e,f,g,[m.clone(),r,t.clone()])),this.faceVertexUvs[0].push([u.clone(),v,y.clone()]))}this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)},THREE.SphereGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TextGeometry=function(a,b){b=b||{};var c=THREE.FontUtils.generateShapes(a,b);b.amount=void 0!==b.height?b.height:50,void 0===b.bevelThickness&&(b.bevelThickness=10),void 0===b.bevelSize&&(b.bevelSize=8),void 0===b.bevelEnabled&&(b.bevelEnabled=!1),THREE.ExtrudeGeometry.call(this,c,b),this.type="TextGeometry"},THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype),THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this),this.type="TorusGeometry",this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e},a=a||100,b=b||40,c=c||8,d=d||6,e=e||2*Math.PI;for(var f=new THREE.Vector3,g=[],h=[],k=0;k<=c;k++)for(var n=0;n<=d;n++){var p=n/d*e,q=k/c*Math.PI*2;f.x=a*Math.cos(p),f.y=a*Math.sin(p);var m=new THREE.Vector3;m.x=(a+b*Math.cos(q))*Math.cos(p),m.y=(a+b*Math.cos(q))*Math.sin(p),m.z=b*Math.sin(q),this.vertices.push(m),g.push(new THREE.Vector2(n/d,k/c)),h.push(m.clone().sub(f).normalize())}for(k=1;k<=c;k++)for(n=1;n<=d;n++)a=(d+1)*k+n-1,b=(d+1)*(k-1)+n-1,e=(d+1)*(k-1)+n,f=(d+1)*k+n,p=new THREE.Face3(a,b,f,[h[a].clone(),h[b].clone(),h[f].clone()]),this.faces.push(p),this.faceVertexUvs[0].push([g[a].clone(),g[b].clone(),g[f].clone()]),p=new THREE.Face3(b,e,f,[h[b].clone(),h[e].clone(),h[f].clone()]),this.faces.push(p),this.faceVertexUvs[0].push([g[b].clone(),g[e].clone(),g[f].clone()]);this.computeFaceNormals()},THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e){var f=Math.cos(a),g=Math.sin(a);return a*=b/c,b=Math.cos(a),f*=d*(2+b)*.5,g=d*(2+b)*g*.5,d=e*d*Math.sin(a)*.5,new THREE.Vector3(f,g,d)}THREE.Geometry.call(this),this.type="TorusKnotGeometry",this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,p:e,q:f,heightScale:g},a=a||100,b=b||40,c=c||64,d=d||8,e=e||2,f=f||3,g=g||1;for(var k=Array(c),n=new THREE.Vector3,p=new THREE.Vector3,q=new THREE.Vector3,m=0;m<c;++m){k[m]=Array(d);var r=m/c*2*e*Math.PI,t=h(r,f,e,a,g),r=h(r+.01,f,e,a,g);for(n.subVectors(r,t),p.addVectors(r,t),q.crossVectors(n,p),p.crossVectors(q,n),q.normalize(),p.normalize(),r=0;r<d;++r){var s=r/d*2*Math.PI,u=-b*Math.cos(s),s=b*Math.sin(s),v=new THREE.Vector3;v.x=t.x+u*p.x+s*q.x,v.y=t.y+u*p.y+s*q.y,v.z=t.z+u*p.z+s*q.z,k[m][r]=this.vertices.push(v)-1}}for(m=0;m<c;++m)for(r=0;r<d;++r)e=(m+1)%c,f=(r+1)%d,a=k[m][r],b=k[e][r],e=k[e][f],f=k[m][f],g=new THREE.Vector2(m/c,r/d),n=new THREE.Vector2((m+1)/c,r/d),p=new THREE.Vector2((m+1)/c,(r+1)/d),q=new THREE.Vector2(m/c,(r+1)/d),this.faces.push(new THREE.Face3(a,b,f)),this.faceVertexUvs[0].push([g,n,q]),this.faces.push(new THREE.Face3(b,e,f)),this.faceVertexUvs[0].push([n.clone(),p,q.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TubeGeometry=function(a,b,c,d,e){THREE.Geometry.call(this),this.type="TubeGeometry",this.parameters={path:a,segments:b,radius:c,radialSegments:d,closed:e},b=b||64,c=c||1,d=d||8,e=e||!1;var g,h,n,p,q,m,t,s,u,f=[],k=b+1,r=new THREE.Vector3;for(t=new THREE.TubeGeometry.FrenetFrames(a,b,e),s=t.normals,u=t.binormals,this.tangents=t.tangents,this.normals=s,this.binormals=u,t=0;t<k;t++)for(f[t]=[],n=t/(k-1),m=a.getPointAt(n),g=s[t],h=u[t],n=0;n<d;n++)p=n/d*2*Math.PI,q=-c*Math.cos(p),p=c*Math.sin(p),r.copy(m),r.x+=q*g.x+p*h.x,r.y+=q*g.y+p*h.y,r.z+=q*g.z+p*h.z,f[t][n]=this.vertices.push(new THREE.Vector3(r.x,r.y,r.z))-1;for(t=0;t<b;t++)for(n=0;n<d;n++)k=e?(t+1)%b:t+1,r=(n+1)%d,a=f[t][n],c=f[k][n],k=f[k][r],r=f[t][r],s=new THREE.Vector2(t/b,n/d),u=new THREE.Vector2((t+1)/b,n/d),g=new THREE.Vector2((t+1)/b,(n+1)/d),h=new THREE.Vector2(t/b,(n+1)/d),this.faces.push(new THREE.Face3(a,c,r)),this.faceVertexUvs[0].push([s,u,h]),this.faces.push(new THREE.Face3(c,k,r)),this.faceVertexUvs[0].push([u.clone(),g,h.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},THREE.TubeGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TubeGeometry.FrenetFrames=function(a,b,c){new THREE.Vector3;var d=new THREE.Vector3;new THREE.Vector3;var e=[],f=[],g=[],h=new THREE.Vector3,k=new THREE.Matrix4;b+=1;var n,p,q;for(this.tangents=e,this.normals=f,this.binormals=g,n=0;n<b;n++)p=n/(b-1),e[n]=a.getTangentAt(p),e[n].normalize();for(f[0]=new THREE.Vector3,g[0]=new THREE.Vector3,a=Number.MAX_VALUE,n=Math.abs(e[0].x),p=Math.abs(e[0].y),q=Math.abs(e[0].z),n<=a&&(a=n,d.set(1,0,0)),p<=a&&(a=p,d.set(0,1,0)),q<=a&&d.set(0,0,1),h.crossVectors(e[0],d).normalize(),f[0].crossVectors(e[0],h),g[0].crossVectors(e[0],f[0]),n=1;n<b;n++)f[n]=f[n-1].clone(),g[n]=g[n-1].clone(),h.crossVectors(e[n-1],e[n]),1e-4<h.length()&&(h.normalize(),d=Math.acos(THREE.Math.clamp(e[n-1].dot(e[n]),-1,1)),f[n].applyMatrix4(k.makeRotationAxis(h,d))),g[n].crossVectors(e[n],f[n]);if(c)for(d=Math.acos(THREE.Math.clamp(f[0].dot(f[b-1]),-1,1)),d/=b-1,0<e[0].dot(h.crossVectors(f[0],f[b-1]))&&(d=-d),n=1;n<b;n++)f[n].applyMatrix4(k.makeRotationAxis(e[n],d*n)),g[n].crossVectors(e[n],f[n])},THREE.PolyhedronGeometry=function(a,b,c,d){function e(a){var b=a.normalize().clone();b.index=k.vertices.push(b)-1;var c=Math.atan2(a.z,-a.x)/2/Math.PI+.5;return a=Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+.5,b.uv=new THREE.Vector2(c,1-a),b}function f(a,b,c){var d=new THREE.Face3(a.index,b.index,c.index,[a.clone(),b.clone(),c.clone()]);k.faces.push(d),u.copy(a).add(b).add(c).divideScalar(3),d=Math.atan2(u.z,-u.x),k.faceVertexUvs[0].push([h(a.uv,a,d),h(b.uv,b,d),h(c.uv,c,d)])}function g(a,b){var c=Math.pow(2,b);Math.pow(4,b);for(var d=e(k.vertices[a.a]),g=e(k.vertices[a.b]),h=e(k.vertices[a.c]),m=[],n=0;n<=c;n++){m[n]=[];for(var p=e(d.clone().lerp(h,n/c)),q=e(g.clone().lerp(h,n/c)),r=c-n,s=0;s<=r;s++)m[n][s]=0==s&&n==c?p:e(p.clone().lerp(q,s/r))}for(n=0;n<c;n++)for(s=0;s<2*(c-n)-1;s++)d=Math.floor(s/2),0==s%2?f(m[n][d+1],m[n+1][d],m[n][d]):f(m[n][d+1],m[n+1][d+1],m[n+1][d])}function h(a,b,c){return 0>c&&1===a.x&&(a=new THREE.Vector2(a.x-1,a.y)),0===b.x&&0===b.z&&(a=new THREE.Vector2(c/2/Math.PI+.5,a.y)),a.clone()}THREE.Geometry.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:a,indices:b,radius:c,detail:d},c=c||1,d=d||0;for(var k=this,n=0,p=a.length;n<p;n+=3)e(new THREE.Vector3(a[n],a[n+1],a[n+2]));a=this.vertices;for(var q=[],m=n=0,p=b.length;n<p;n+=3,m++){var r=a[b[n]],t=a[b[n+1]],s=a[b[n+2]];q[m]=new THREE.Face3(r.index,t.index,s.index,[r.clone(),t.clone(),s.clone()])}for(var u=new THREE.Vector3,n=0,p=q.length;n<p;n++)g(q[n],d);for(n=0,p=this.faceVertexUvs[0].length;n<p;n++)b=this.faceVertexUvs[0][n],d=b[0].x,a=b[1].x,q=b[2].x,m=Math.max(d,Math.max(a,q)),r=Math.min(d,Math.min(a,q)),.9<m&&.1>r&&(.2>d&&(b[0].x+=1),.2>a&&(b[1].x+=1),.2>q&&(b[2].x+=1));for(n=0,p=this.vertices.length;n<p;n++)this.vertices[n].multiplyScalar(c);this.mergeVertices(),this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,c)},THREE.PolyhedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.DodecahedronGeometry=function(a,b){this.parameters={radius:a,detail:b};var c=(1+Math.sqrt(5))/2,d=1/c;THREE.PolyhedronGeometry.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b)},THREE.DodecahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.IcosahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b),this.type="IcosahedronGeometry",this.parameters={radius:a,detail:b}},THREE.IcosahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.OctahedronGeometry=function(a,b){this.parameters={radius:a,detail:b},THREE.PolyhedronGeometry.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b),this.type="OctahedronGeometry",this.parameters={radius:a,detail:b}},THREE.OctahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TetrahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b),this.type="TetrahedronGeometry",this.parameters={radius:a,detail:b}},THREE.TetrahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.ParametricGeometry=function(a,b,c){THREE.Geometry.call(this),this.type="ParametricGeometry",this.parameters={func:a,slices:b,stacks:c};var g,h,k,n,d=this.vertices,e=this.faces,f=this.faceVertexUvs[0],p=b+1;for(g=0;g<=c;g++)for(n=g/c,h=0;h<=b;h++)k=h/b,k=a(k,n),d.push(k);var q,m,r,t;for(g=0;g<c;g++)for(h=0;h<b;h++)a=g*p+h,d=g*p+h+1,n=(g+1)*p+h+1,k=(g+1)*p+h,q=new THREE.Vector2(h/b,g/c),m=new THREE.Vector2((h+1)/b,g/c),r=new THREE.Vector2((h+1)/b,(g+1)/c),t=new THREE.Vector2(h/b,(g+1)/c),e.push(new THREE.Face3(a,d,k)),f.push([q,m,t]),e.push(new THREE.Face3(d,n,k)),f.push([m.clone(),r,t.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},THREE.ParametricGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.AxisHelper=function(a){a=a||1;var b=new Float32Array([0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a]),c=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);a=new THREE.BufferGeometry,a.addAttribute("position",new THREE.BufferAttribute(b,3)),a.addAttribute("color",new THREE.BufferAttribute(c,3)),b=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors}),THREE.Line.call(this,a,b,THREE.LinePieces)},THREE.AxisHelper.prototype=Object.create(THREE.Line.prototype),THREE.ArrowHelper=function(){var a=new THREE.Geometry;a.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0));var b=new THREE.CylinderGeometry(0,.5,1,5,1);return b.applyMatrix((new THREE.Matrix4).makeTranslation(0,-.5,0)),function(c,d,e,f,g,h){THREE.Object3D.call(this),void 0===f&&(f=16776960),void 0===e&&(e=1),void 0===g&&(g=.2*e),void 0===h&&(h=.2*g),this.position.copy(d),this.line=new THREE.Line(a,new THREE.LineBasicMaterial({color:f})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:f})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(c),this.setLength(e,g,h)}}(),THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype),THREE.ArrowHelper.prototype.setDirection=function(){var b,a=new THREE.Vector3;return function(c){.99999<c.y?this.quaternion.set(0,0,0,1):-.99999>c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}(),THREE.ArrowHelper.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a),void 0===c&&(c=.2*b),this.line.scale.set(1,a,1),this.line.updateMatrix(),this.cone.scale.set(c,b,c),this.cone.position.y=a,this.cone.updateMatrix()},THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.set(a),this.cone.material.color.set(a)},THREE.BoxHelper=function(a){var b=new THREE.BufferGeometry;b.addAttribute("position",new THREE.BufferAttribute(new Float32Array(72),3)),THREE.Line.call(this,b,new THREE.LineBasicMaterial({color:16776960}),THREE.LinePieces),void 0!==a&&this.update(a)},THREE.BoxHelper.prototype=Object.create(THREE.Line.prototype),THREE.BoxHelper.prototype.update=function(a){var b=a.geometry;null===b.boundingBox&&b.computeBoundingBox();var c=b.boundingBox.min,b=b.boundingBox.max,d=this.geometry.attributes.position.array;d[0]=b.x,d[1]=b.y,d[2]=b.z,d[3]=c.x,d[4]=b.y,d[5]=b.z,d[6]=c.x,d[7]=b.y,d[8]=b.z,d[9]=c.x,d[10]=c.y,d[11]=b.z,d[12]=c.x,d[13]=c.y,d[14]=b.z,d[15]=b.x,d[16]=c.y,d[17]=b.z,d[18]=b.x,d[19]=c.y,d[20]=b.z,d[21]=b.x,d[22]=b.y,d[23]=b.z,d[24]=b.x,d[25]=b.y,d[26]=c.z,d[27]=c.x,d[28]=b.y,d[29]=c.z,d[30]=c.x,d[31]=b.y,d[32]=c.z,d[33]=c.x,d[34]=c.y,d[35]=c.z,d[36]=c.x,d[37]=c.y,d[38]=c.z,d[39]=b.x,d[40]=c.y,d[41]=c.z,d[42]=b.x,d[43]=c.y,d[44]=c.z,d[45]=b.x,d[46]=b.y,d[47]=c.z,d[48]=b.x,d[49]=b.y,d[50]=b.z,d[51]=b.x,d[52]=b.y,d[53]=c.z,d[54]=c.x,d[55]=b.y,d[56]=b.z,d[57]=c.x,d[58]=b.y,d[59]=c.z,d[60]=c.x,d[61]=c.y,d[62]=b.z,d[63]=c.x,d[64]=c.y,d[65]=c.z,d[66]=b.x,d[67]=c.y,d[68]=b.z,d[69]=b.x,d[70]=c.y,d[71]=c.z,this.geometry.attributes.position.needsUpdate=!0,this.geometry.computeBoundingSphere(),this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1},THREE.BoundingBoxHelper=function(a,b){var c=void 0!==b?b:8947848;this.object=a,this.box=new THREE.Box3,THREE.Mesh.call(this,new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:c,wireframe:!0}))},THREE.BoundingBoxHelper.prototype=Object.create(THREE.Mesh.prototype),THREE.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object),this.box.size(this.scale),this.box.center(this.position)},THREE.CameraHelper=function(a){function b(a,b,d){c(a,d),c(b,d)}function c(a,b){d.vertices.push(new THREE.Vector3),d.colors.push(new THREE.Color(b)),void 0===f[a]&&(f[a]=[]),f[a].push(d.vertices.length-1)}var d=new THREE.Geometry,e=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),f={};b("n1","n2",16755200),b("n2","n4",16755200),b("n4","n3",16755200),b("n3","n1",16755200),b("f1","f2",16755200),b("f2","f4",16755200),b("f4","f3",16755200),b("f3","f1",16755200),b("n1","f1",16755200),b("n2","f2",16755200),b("n3","f3",16755200),b("n4","f4",16755200),b("p","n1",16711680),b("p","n2",16711680),b("p","n3",16711680),b("p","n4",16711680),b("u1","u2",43775),b("u2","u3",43775),b("u3","u1",43775),b("c","t",16777215),b("p","c",3355443),b("cn1","cn2",3355443),b("cn3","cn4",3355443),b("cf1","cf2",3355443),b("cf3","cf4",3355443),THREE.Line.call(this,d,e,THREE.LinePieces),this.camera=a,this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=f,this.update()},THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype),THREE.CameraHelper.prototype.update=function(){var a,b,c=new THREE.Vector3,d=new THREE.Camera,e=function(e,g,h,k){if(c.set(g,h,k).unproject(d),e=b[e],void 0!==e)for(g=0,h=e.length;g<h;g++)a.vertices[e[g]].copy(c)};return function(){a=this.geometry,b=this.pointMap,d.projectionMatrix.copy(this.camera.projectionMatrix),e("c",0,0,-1),e("t",0,0,1),e("n1",-1,-1,-1),e("n2",1,-1,-1),e("n3",-1,1,-1),e("n4",1,1,-1),e("f1",-1,-1,1),e("f2",1,-1,1),e("f3",-1,1,1),e("f4",1,1,1),e("u1",.7,1.1,-1),e("u2",-.7,1.1,-1),e("u3",0,2,-1),e("cf1",-1,0,1),e("cf2",1,0,1),e("cf3",0,-1,1),e("cf4",0,1,1),e("cn1",-1,0,-1),e("cn2",1,0,-1),e("cn3",0,-1,-1),e("cn4",0,1,-1),a.verticesNeedUpdate=!0}}(),THREE.DirectionalLightHelper=function(a,b){THREE.Object3D.call(this),this.light=a,this.light.updateMatrixWorld(),this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1,b=b||1;var c=new THREE.Geometry;c.vertices.push(new THREE.Vector3((-b),b,0),new THREE.Vector3(b,b,0),new THREE.Vector3(b,(-b),0),new THREE.Vector3((-b),(-b),0),new THREE.Vector3((-b),b,0));var d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.lightPlane=new THREE.Line(c,d),this.add(this.lightPlane),c=new THREE.Geometry,c.vertices.push(new THREE.Vector3,new THREE.Vector3),d=new THREE.LineBasicMaterial({fog:!1}),d.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine=new THREE.Line(c,d),this.add(this.targetLine),this.update()},THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype),THREE.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},THREE.DirectionalLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(){a.setFromMatrixPosition(this.light.matrixWorld),b.setFromMatrixPosition(this.light.target.matrixWorld),c.subVectors(b,a),this.lightPlane.lookAt(c),this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine.geometry.vertices[1].copy(c),this.targetLine.geometry.verticesNeedUpdate=!0,this.targetLine.material.color.copy(this.lightPlane.material.color)}}(),THREE.EdgesHelper=function(a,b){var c=void 0!==b?b:16777215,d=[0,0],e={},f=function(a,b){return a-b},g=["a","b","c"],h=new THREE.BufferGeometry,k=a.geometry.clone();k.mergeVertices(),k.computeFaceNormals();for(var n=k.vertices,k=k.faces,p=0,q=0,m=k.length;q<m;q++)for(var r=k[q],t=0;3>t;t++){d[0]=r[g[t]],d[1]=r[g[(t+1)%3]],d.sort(f);var s=d.toString();void 0===e[s]?(e[s]={vert1:d[0],vert2:d[1],face1:q,face2:void 0},p++):e[s].face2=q}d=new Float32Array(6*p),f=0;for(s in e)g=e[s],(void 0===g.face2||.9999>k[g.face1].normal.dot(k[g.face2].normal))&&(p=n[g.vert1],d[f++]=p.x,d[f++]=p.y,d[f++]=p.z,p=n[g.vert2],d[f++]=p.x,d[f++]=p.y,d[f++]=p.z);h.addAttribute("position",new THREE.BufferAttribute(d,3)),THREE.Line.call(this,h,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces),this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1},THREE.EdgesHelper.prototype=Object.create(THREE.Line.prototype),THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a,this.size=void 0!==b?b:1,a=void 0!==c?c:16776960,d=void 0!==d?d:1,b=new THREE.Geometry,c=0;for(var e=this.object.geometry.faces.length;c<e;c++)b.vertices.push(new THREE.Vector3,new THREE.Vector3);THREE.Line.call(this,b,new THREE.LineBasicMaterial({color:a,linewidth:d}),THREE.LinePieces),this.matrixAutoUpdate=!1,this.normalMatrix=new THREE.Matrix3,this.update()},THREE.FaceNormalsHelper.prototype=Object.create(THREE.Line.prototype),THREE.FaceNormalsHelper.prototype.update=function(){var a=this.geometry.vertices,b=this.object,c=b.geometry.vertices,d=b.geometry.faces,e=b.matrixWorld;b.updateMatrixWorld(!0),this.normalMatrix.getNormalMatrix(e);for(var f=b=0,g=d.length;b<g;b++,f+=2){var h=d[b];a[f].copy(c[h.a]).add(c[h.b]).add(c[h.c]).divideScalar(3).applyMatrix4(e),a[f+1].copy(h.normal).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size).add(a[f])}return this.geometry.verticesNeedUpdate=!0,this},THREE.GridHelper=function(a,b){var c=new THREE.Geometry,d=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});this.color1=new THREE.Color(4473924),this.color2=new THREE.Color(8947848);for(var e=-a;e<=a;e+=b){c.vertices.push(new THREE.Vector3((-a),0,e),new THREE.Vector3(a,0,e),new THREE.Vector3(e,0,(-a)),new THREE.Vector3(e,0,a));var f=0===e?this.color1:this.color2;c.colors.push(f,f,f,f)}THREE.Line.call(this,c,d,THREE.LinePieces)},THREE.GridHelper.prototype=Object.create(THREE.Line.prototype),THREE.GridHelper.prototype.setColors=function(a,b){this.color1.set(a),this.color2.set(b),this.geometry.colorsNeedUpdate=!0},THREE.HemisphereLightHelper=function(a,b,c,d){for(THREE.Object3D.call(this),this.light=a,this.light.updateMatrixWorld(),this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1,this.colors=[new THREE.Color,new THREE.Color],a=new THREE.SphereGeometry(b,4,2),a.applyMatrix((new THREE.Matrix4).makeRotationX(-Math.PI/2)),b=0;8>b;b++)a.faces[b].color=this.colors[4>b?0:1];b=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,wireframe:!0}),this.lightSphere=new THREE.Mesh(a,b),this.add(this.lightSphere),this.update()},THREE.HemisphereLightHelper.prototype=Object.create(THREE.Object3D.prototype),THREE.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose(),this.lightSphere.material.dispose()},THREE.HemisphereLightHelper.prototype.update=function(){var a=new THREE.Vector3;return function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity),this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity),this.lightSphere.lookAt(a.setFromMatrixPosition(this.light.matrixWorld).negate()),this.lightSphere.geometry.colorsNeedUpdate=!0}}(),THREE.PointLightHelper=function(a,b){this.light=a,this.light.updateMatrixWorld();var c=new THREE.SphereGeometry(b,4,2),d=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity),THREE.Mesh.call(this,c,d),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1},THREE.PointLightHelper.prototype=Object.create(THREE.Mesh.prototype),THREE.PointLightHelper.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},THREE.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)},THREE.SkeletonHelper=function(a){this.bones=this.getBoneList(a);for(var b=new THREE.Geometry,c=0;c<this.bones.length;c++)this.bones[c].parent instanceof THREE.Bone&&(b.vertices.push(new THREE.Vector3),b.vertices.push(new THREE.Vector3),b.colors.push(new THREE.Color(0,0,1)),b.colors.push(new THREE.Color(0,1,0)));c=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,depthTest:!1,depthWrite:!1,transparent:!0}),THREE.Line.call(this,b,c,THREE.LinePieces),this.root=a,this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1,this.update()},THREE.SkeletonHelper.prototype=Object.create(THREE.Line.prototype),THREE.SkeletonHelper.prototype.getBoneList=function(a){var b=[];a instanceof THREE.Bone&&b.push(a);for(var c=0;c<a.children.length;c++)b.push.apply(b,this.getBoneList(a.children[c]));return b},THREE.SkeletonHelper.prototype.update=function(){for(var a=this.geometry,b=(new THREE.Matrix4).getInverse(this.root.matrixWorld),c=new THREE.Matrix4,d=0,e=0;e<this.bones.length;e++){var f=this.bones[e];f.parent instanceof THREE.Bone&&(c.multiplyMatrices(b,f.matrixWorld),a.vertices[d].setFromMatrixPosition(c),c.multiplyMatrices(b,f.parent.matrixWorld),a.vertices[d+1].setFromMatrixPosition(c),d+=2)}a.verticesNeedUpdate=!0,a.computeBoundingSphere()},THREE.SpotLightHelper=function(a){THREE.Object3D.call(this),this.light=a,this.light.updateMatrixWorld(),this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1,a=new THREE.CylinderGeometry(0,1,1,8,1,(!0)),a.applyMatrix((new THREE.Matrix4).makeTranslation(0,-.5,0)),a.applyMatrix((new THREE.Matrix4).makeRotationX(-Math.PI/2));var b=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});this.cone=new THREE.Mesh(a,b),this.add(this.cone),this.update()},THREE.SpotLightHelper.prototype=Object.create(THREE.Object3D.prototype),THREE.SpotLightHelper.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},THREE.SpotLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){
var c=this.light.distance?this.light.distance:1e4,d=c*Math.tan(this.light.angle);this.cone.scale.set(d,d,c),a.setFromMatrixPosition(this.light.matrixWorld),b.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(b.sub(a)),this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)}}(),THREE.VertexNormalsHelper=function(a,b,c,d){this.object=a,this.size=void 0!==b?b:1,b=void 0!==c?c:16711680,d=void 0!==d?d:1,c=new THREE.Geometry,a=a.geometry.faces;for(var e=0,f=a.length;e<f;e++)for(var g=0,h=a[e].vertexNormals.length;g<h;g++)c.vertices.push(new THREE.Vector3,new THREE.Vector3);THREE.Line.call(this,c,new THREE.LineBasicMaterial({color:b,linewidth:d}),THREE.LinePieces),this.matrixAutoUpdate=!1,this.normalMatrix=new THREE.Matrix3,this.update()},THREE.VertexNormalsHelper.prototype=Object.create(THREE.Line.prototype),THREE.VertexNormalsHelper.prototype.update=function(a){var b=new THREE.Vector3;return function(a){a=["a","b","c","d"],this.object.updateMatrixWorld(!0),this.normalMatrix.getNormalMatrix(this.object.matrixWorld);for(var d=this.geometry.vertices,e=this.object.geometry.vertices,f=this.object.geometry.faces,g=this.object.matrixWorld,h=0,k=0,n=f.length;k<n;k++)for(var p=f[k],q=0,m=p.vertexNormals.length;q<m;q++){var r=p.vertexNormals[q];d[h].copy(e[p[a[q]]]).applyMatrix4(g),b.copy(r).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size),b.add(d[h]),h+=1,d[h].copy(b),h+=1}return this.geometry.verticesNeedUpdate=!0,this}}(),THREE.VertexTangentsHelper=function(a,b,c,d){this.object=a,this.size=void 0!==b?b:1,b=void 0!==c?c:255,d=void 0!==d?d:1,c=new THREE.Geometry,a=a.geometry.faces;for(var e=0,f=a.length;e<f;e++)for(var g=0,h=a[e].vertexTangents.length;g<h;g++)c.vertices.push(new THREE.Vector3),c.vertices.push(new THREE.Vector3);THREE.Line.call(this,c,new THREE.LineBasicMaterial({color:b,linewidth:d}),THREE.LinePieces),this.matrixAutoUpdate=!1,this.update()},THREE.VertexTangentsHelper.prototype=Object.create(THREE.Line.prototype),THREE.VertexTangentsHelper.prototype.update=function(a){var b=new THREE.Vector3;return function(a){a=["a","b","c","d"],this.object.updateMatrixWorld(!0);for(var d=this.geometry.vertices,e=this.object.geometry.vertices,f=this.object.geometry.faces,g=this.object.matrixWorld,h=0,k=0,n=f.length;k<n;k++)for(var p=f[k],q=0,m=p.vertexTangents.length;q<m;q++){var r=p.vertexTangents[q];d[h].copy(e[p[a[q]]]).applyMatrix4(g),b.copy(r).transformDirection(g).multiplyScalar(this.size),b.add(d[h]),h+=1,d[h].copy(b),h+=1}return this.geometry.verticesNeedUpdate=!0,this}}(),THREE.WireframeHelper=function(a,b){var c=void 0!==b?b:16777215,d=[0,0],e={},f=function(a,b){return a-b},g=["a","b","c"],h=new THREE.BufferGeometry;if(a.geometry instanceof THREE.Geometry){for(var k=a.geometry.vertices,n=a.geometry.faces,p=0,q=new Uint32Array(6*n.length),m=0,r=n.length;m<r;m++)for(var t=n[m],s=0;3>s;s++){d[0]=t[g[s]],d[1]=t[g[(s+1)%3]],d.sort(f);var u=d.toString();void 0===e[u]&&(q[2*p]=d[0],q[2*p+1]=d[1],e[u]=!0,p++)}for(d=new Float32Array(6*p),m=0,r=p;m<r;m++)for(s=0;2>s;s++)p=k[q[2*m+s]],g=6*m+3*s,d[g+0]=p.x,d[g+1]=p.y,d[g+2]=p.z;h.addAttribute("position",new THREE.BufferAttribute(d,3))}else if(a.geometry instanceof THREE.BufferGeometry){if(void 0!==a.geometry.attributes.index){k=a.geometry.attributes.position.array,r=a.geometry.attributes.index.array,n=a.geometry.drawcalls,p=0,0===n.length&&(n=[{count:r.length,index:0,start:0}]);for(var q=new Uint32Array(2*r.length),t=0,v=n.length;t<v;++t)for(var s=n[t].start,u=n[t].count,g=n[t].index,m=s,y=s+u;m<y;m+=3)for(s=0;3>s;s++)d[0]=g+r[m+s],d[1]=g+r[m+(s+1)%3],d.sort(f),u=d.toString(),void 0===e[u]&&(q[2*p]=d[0],q[2*p+1]=d[1],e[u]=!0,p++);for(d=new Float32Array(6*p),m=0,r=p;m<r;m++)for(s=0;2>s;s++)g=6*m+3*s,p=3*q[2*m+s],d[g+0]=k[p],d[g+1]=k[p+1],d[g+2]=k[p+2]}else for(k=a.geometry.attributes.position.array,p=k.length/3,q=p/3,d=new Float32Array(6*p),m=0,r=q;m<r;m++)for(s=0;3>s;s++)g=18*m+6*s,q=9*m+3*s,d[g+0]=k[q],d[g+1]=k[q+1],d[g+2]=k[q+2],p=9*m+(s+1)%3*3,d[g+3]=k[p],d[g+4]=k[p+1],d[g+5]=k[p+2];h.addAttribute("position",new THREE.BufferAttribute(d,3))}THREE.Line.call(this,h,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces),this.matrix=a.matrixWorld,this.matrixAutoUpdate=!1},THREE.WireframeHelper.prototype=Object.create(THREE.Line.prototype),THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this),this.render=function(a){}},THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype),THREE.MorphBlendMesh=function(a,b){THREE.Mesh.call(this,a,b),this.animationsMap={},this.animationsList=[];var c=this.geometry.morphTargets.length;this.createAnimation("__default",0,c-1,c/1),this.setAnimationWeight("__default",1)},THREE.MorphBlendMesh.prototype=Object.create(THREE.Mesh.prototype),THREE.MorphBlendMesh.prototype.createAnimation=function(a,b,c,d){b={startFrame:b,endFrame:c,length:c-b+1,fps:d,duration:(c-b)/d,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1},this.animationsMap[a]=b,this.animationsList.push(b)},THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var c,b=/([a-z]+)_?(\d+)/,d={},e=this.geometry,f=0,g=e.morphTargets.length;f<g;f++){var h=e.morphTargets[f].name.match(b);if(h&&1<h.length){var k=h[1];d[k]||(d[k]={start:1/0,end:-(1/0)}),h=d[k],f<h.start&&(h.start=f),f>h.end&&(h.end=f),c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c},THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){(a=this.animationsMap[a])&&(a.direction=1,a.directionBackwards=!1)},THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){(a=this.animationsMap[a])&&(a.direction=-1,a.directionBackwards=!0)},THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)},THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)},THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)},THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)},THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;return(a=this.animationsMap[a])&&(b=a.time),b},THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;return(a=this.animationsMap[a])&&(b=a.duration),b},THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("animation["+a+"] undefined")},THREE.MorphBlendMesh.prototype.stopAnimation=function(a){(a=this.animationsMap[a])&&(a.active=!1)},THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var e=d.duration/d.length;d.time+=d.direction*a,d.mirroredLoop?(d.time>d.duration||0>d.time)&&(d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)):(d.time%=d.duration,0>d.time&&(d.time+=d.duration));var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f),e=d.time%e/e,d.directionBackwards&&(e=1-e),this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}},THREE.OBJExporter=function(){},THREE.OBJExporter.prototype={constructor:THREE.OBJExporter,parse:function(geometry,materialName,faceIndexOffset){faceIndexOffset=faceIndexOffset||0;for(var output="",i=0,l=geometry.vertices.length;i<l;i++){var vertex=geometry.vertices[i];output+="v "+vertex.x+" "+vertex.y+" "+vertex.z+"\n"}for(var i=0,l=geometry.faceVertexUvs[0].length;i<l;i++)for(var vertexUvs=geometry.faceVertexUvs[0][i],j=0;j<vertexUvs.length;j++){var uv=vertexUvs[j];output+="vt "+uv.x+" "+uv.y+"\n"}for(var i=0,l=geometry.faces.length;i<l;i++)for(var normals=geometry.faces[i].vertexNormals,j=0;j<normals.length;j++){var normal=normals[j];output+="vn "+normal.x+" "+normal.y+" "+normal.z+"\n"}output+="usemtl "+materialName+"\n",output+="s off\n";for(var i=0,j=1,l=geometry.faces.length;i<l;i++,j+=3){var face=geometry.faces[i];output+="f ",output+=face.a+1+faceIndexOffset+"/"+(j+faceIndexOffset)+"/"+(j+faceIndexOffset)+" ",output+=face.b+1+faceIndexOffset+"/"+(j+1+faceIndexOffset)+"/"+(j+1+faceIndexOffset)+" ",output+=face.c+1+faceIndexOffset+"/"+(j+2+faceIndexOffset)+"/"+(j+2+faceIndexOffset)+"\n"}return output}},THREE.OBJLoader=function(manager){this.manager=void 0!==manager?manager:THREE.DefaultLoadingManager},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(url,onLoad,onProgress,onError){var scope=this,loader=new THREE.XHRLoader(scope.manager);loader.setCrossOrigin(this.crossOrigin),loader.load(url,function(text){onLoad(scope.parse(text))})},parse:function(text){function vector(x,y,z){return new THREE.Vector3(parseFloat(x),parseFloat(y),parseFloat(z))}function uv(u,v){return new THREE.Vector2(parseFloat(u),parseFloat(v))}function face3(a,b,c,normals){return new THREE.Face3(a,b,c,normals)}function parseVertexIndex(index){return index=parseInt(index),index>=0?index-1:index+vertices.length}function parseNormalIndex(index){return index=parseInt(index),index>=0?index-1:index+normals.length}function parseUVIndex(index){return index=parseInt(index),index>=0?index-1:index+uvs.length}function add_face(a,b,c,normals_inds){void 0===normals_inds?geometry.faces.push(face3(vertices[parseVertexIndex(a)]-1,vertices[parseVertexIndex(b)]-1,vertices[parseVertexIndex(c)]-1)):geometry.faces.push(face3(vertices[parseVertexIndex(a)]-1,vertices[parseVertexIndex(b)]-1,vertices[parseVertexIndex(c)]-1,[normals[parseNormalIndex(normals_inds[0])].clone(),normals[parseNormalIndex(normals_inds[1])].clone(),normals[parseNormalIndex(normals_inds[2])].clone()]))}function add_uvs(a,b,c){geometry.faceVertexUvs[0].push([uvs[parseUVIndex(a)].clone(),uvs[parseUVIndex(b)].clone(),uvs[parseUVIndex(c)].clone()])}function handle_face_line(faces,uvs,normals_inds){void 0===faces[3]?(add_face(faces[0],faces[1],faces[2],normals_inds),void 0!==uvs&&uvs.length>0&&add_uvs(uvs[0],uvs[1],uvs[2])):(void 0!==normals_inds&&normals_inds.length>0?(add_face(faces[0],faces[1],faces[3],[normals_inds[0],normals_inds[1],normals_inds[3]]),add_face(faces[1],faces[2],faces[3],[normals_inds[1],normals_inds[2],normals_inds[3]])):(add_face(faces[0],faces[1],faces[3]),add_face(faces[1],faces[2],faces[3])),void 0!==uvs&&uvs.length>0&&(add_uvs(uvs[0],uvs[1],uvs[3]),add_uvs(uvs[1],uvs[2],uvs[3])))}var geometry,material,mesh,object=new THREE.Object3D;/^o /gm.test(text)===!1&&(geometry=new THREE.Geometry,material=new THREE.MeshLambertMaterial,mesh=new THREE.Mesh(geometry,material),object.add(mesh));for(var vertices=[],normals=[],uvs=[],vertex_pattern=/v( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,normal_pattern=/vn( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,uv_pattern=/vt( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/,face_pattern1=/f( +-?\d+)( +-?\d+)( +-?\d+)( +-?\d+)?/,face_pattern2=/f( +(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+))?/,face_pattern3=/f( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_pattern4=/f( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))?/,lines=text.split("\n"),i=0;i<lines.length;i++){var line=lines[i];line=line.trim();var result;0!==line.length&&"#"!==line.charAt(0)&&(null!==(result=vertex_pattern.exec(line))?vertices.push(geometry.vertices.push(vector(result[1],result[2],result[3]))):null!==(result=normal_pattern.exec(line))?normals.push(vector(result[1],result[2],result[3])):null!==(result=uv_pattern.exec(line))?uvs.push(uv(result[1],result[2])):null!==(result=face_pattern1.exec(line))?handle_face_line([result[1],result[2],result[3],result[4]]):null!==(result=face_pattern2.exec(line))?handle_face_line([result[2],result[5],result[8],result[11]],[result[3],result[6],result[9],result[12]]):null!==(result=face_pattern3.exec(line))?handle_face_line([result[2],result[6],result[10],result[14]],[result[3],result[7],result[11],result[15]],[result[4],result[8],result[12],result[16]]):null!==(result=face_pattern4.exec(line))?handle_face_line([result[2],result[5],result[8],result[11]],[],[result[3],result[6],result[9],result[12]]):/^o /.test(line)?(geometry=new THREE.Geometry,material=new THREE.MeshLambertMaterial,mesh=new THREE.Mesh(geometry,material),mesh.name=line.substring(2).trim(),object.add(mesh)):/^g /.test(line)||(/^usemtl /.test(line)?material.name=line.substring(7).trim():/^mtllib /.test(line)||/^s /.test(line)))}for(var children=object.children,i=0,l=children.length;i<l;i++){var geometry=children[i].geometry;geometry.computeFaceNormals(),geometry.computeBoundingSphere()}return object}},THREE.BloomPass=function(strength,kernelSize,sigma,resolution){strength=void 0!==strength?strength:1,kernelSize=void 0!==kernelSize?kernelSize:25,sigma=void 0!==sigma?sigma:4,resolution=void 0!==resolution?resolution:256;var pars={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat};this.renderTargetX=new THREE.WebGLRenderTarget(resolution,resolution,pars),this.renderTargetY=new THREE.WebGLRenderTarget(resolution,resolution,pars),void 0===THREE.CopyShader&&console.error("THREE.BloomPass relies on THREE.CopyShader");var copyShader=THREE.CopyShader;this.copyUniforms=THREE.UniformsUtils.clone(copyShader.uniforms),this.copyUniforms.opacity.value=strength,this.materialCopy=new THREE.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:copyShader.vertexShader,fragmentShader:copyShader.fragmentShader,blending:THREE.AdditiveBlending,transparent:!0}),void 0===THREE.ConvolutionShader&&console.error("THREE.BloomPass relies on THREE.ConvolutionShader");var convolutionShader=THREE.ConvolutionShader;this.convolutionUniforms=THREE.UniformsUtils.clone(convolutionShader.uniforms),this.convolutionUniforms.uImageIncrement.value=THREE.BloomPass.blurx,this.convolutionUniforms.cKernel.value=THREE.ConvolutionShader.buildKernel(sigma),this.materialConvolution=new THREE.ShaderMaterial({uniforms:this.convolutionUniforms,vertexShader:convolutionShader.vertexShader,fragmentShader:convolutionShader.fragmentShader,defines:{KERNEL_SIZE_FLOAT:kernelSize.toFixed(1),KERNEL_SIZE_INT:kernelSize.toFixed(0)}}),this.enabled=!0,this.needsSwap=!1,this.clear=!1,this.camera=new THREE.OrthographicCamera((-1),1,1,(-1),0,1),this.scene=new THREE.Scene,this.quad=new THREE.Mesh(new THREE.PlaneGeometry(2,2),null),this.scene.add(this.quad)},THREE.BloomPass.prototype={render:function(renderer,writeBuffer,readBuffer,delta,maskActive){maskActive&&renderer.context.disable(renderer.context.STENCIL_TEST),this.quad.material=this.materialConvolution,this.convolutionUniforms.tDiffuse.value=readBuffer,this.convolutionUniforms.uImageIncrement.value=THREE.BloomPass.blurX,renderer.render(this.scene,this.camera,this.renderTargetX,!0),this.convolutionUniforms.tDiffuse.value=this.renderTargetX,this.convolutionUniforms.uImageIncrement.value=THREE.BloomPass.blurY,renderer.render(this.scene,this.camera,this.renderTargetY,!0)}},THREE.BloomPass.blurX=new THREE.Vector2(.001953125,0),THREE.BloomPass.blurY=new THREE.Vector2(0,.001953125),THREE.ConvolutionShader={defines:{KERNEL_SIZE_FLOAT:"25.0",KERNEL_SIZE_INT:"25"},uniforms:{tDiffuse:{type:"t",value:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:["uniform vec2 uImageIncrement;","varying vec2 vUv;","void main() {","vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float cKernel[ KERNEL_SIZE_INT ];","uniform sampler2D tDiffuse;","uniform vec2 uImageIncrement;","varying vec2 vUv;","void main() {","vec2 imageCoord = vUv;","vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );","for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {","sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];","imageCoord += uImageIncrement;","}","gl_FragColor = sum;","}"].join("\n"),buildKernel:function(sigma){function gauss(x,sigma){return Math.exp(-(x*x)/(2*sigma*sigma))}var i,values,sum,halfWidth,kMaxKernelSize=25,kernelSize=2*Math.ceil(3*sigma)+1;for(kernelSize>kMaxKernelSize&&(kernelSize=kMaxKernelSize),halfWidth=.5*(kernelSize-1),values=new Array(kernelSize),sum=0,i=0;i<kernelSize;++i)values[i]=gauss(i-halfWidth,sigma),sum+=values[i];for(i=0;i<kernelSize;++i)values[i]/=sum;return values}},THREE.CopyShader={uniforms:{tDiffuse:{type:"t",value:null},opacity:{type:"f",value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","gl_FragColor = opacity * texel;","}"].join("\n")},THREE.EffectComposer=function(renderer,renderTarget){if(this.renderer=renderer,void 0===renderTarget){var width=window.innerWidth||1,height=window.innerHeight||1,parameters={minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBFormat,stencilBuffer:!1};renderTarget=new THREE.WebGLRenderTarget(width,height,parameters)}this.renderTarget1=renderTarget,this.renderTarget2=renderTarget.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.passes=[],void 0===THREE.CopyShader&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),this.copyPass=new THREE.ShaderPass(THREE.CopyShader)},THREE.EffectComposer.prototype={swapBuffers:function(){var tmp=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=tmp},addPass:function(pass){this.passes.push(pass)},insertPass:function(pass,index){this.passes.splice(index,0,pass)},render:function(delta){this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2;var pass,i,maskActive=!1,il=this.passes.length;for(i=0;i<il;i++)if(pass=this.passes[i],pass.enabled){if(pass.render(this.renderer,this.writeBuffer,this.readBuffer,delta,maskActive),pass.needsSwap){if(maskActive){var context=this.renderer.context;context.stencilFunc(context.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,delta),context.stencilFunc(context.EQUAL,1,4294967295)}this.swapBuffers()}pass instanceof THREE.MaskPass?maskActive=!0:pass instanceof THREE.ClearMaskPass&&(maskActive=!1)}},reset:function(renderTarget){void 0===renderTarget&&(renderTarget=this.renderTarget1.clone(),renderTarget.width=window.innerWidth,renderTarget.height=window.innerHeight),this.renderTarget1=renderTarget,this.renderTarget2=renderTarget.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(width,height){var renderTarget=this.renderTarget1.clone();renderTarget.width=width,renderTarget.height=height,this.reset(renderTarget)}},THREE.FXAAShader={uniforms:{tDiffuse:{type:"t",value:null},resolution:{type:"v2",value:new THREE.Vector2(1/1024,1/512)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","varying vec2 vUv;","#define FXAA_REDUCE_MIN (1.0/128.0)","#define FXAA_REDUCE_MUL (1.0/8.0)","#define FXAA_SPAN_MAX 8.0","void main() {","vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;","vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;","vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );","vec3 rgbM = rgbaM.xyz;","float opacity = rgbaM.w;","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float lumaNW = dot( rgbNW, luma );","float lumaNE = dot( rgbNE, luma );","float lumaSW = dot( rgbSW, luma );","float lumaSE = dot( rgbSE, luma );","float lumaM = dot( rgbM, luma );","float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );","float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );","vec2 dir;","dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));","dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));","float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );","float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );","dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),","max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),","dir * rcpDirMin)) * resolution;","vec3 rgbA = texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ).xyz;","rgbA += texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ).xyz;","rgbA *= 0.5;","vec3 rgbB = texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * -0.5 ).xyz;","rgbB += texture2D( tDiffuse, gl_FragCoord.xy * resolution + dir * 0.5 ).xyz;","rgbB *= 0.25;","rgbB += rgbA * 0.5;","float lumaB = dot( rgbB, luma );","if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {","gl_FragColor = vec4( rgbA, opacity );","} else {","gl_FragColor = vec4( rgbB, opacity );","}","}"].join("\n")},THREE.LuminosityShader={uniforms:{tDiffuse:{type:"t",value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float v = dot( texel.xyz, luma );","gl_FragColor = vec4( v, v, v, texel.w );","}"].join("\n")},THREE.MaskPass=function(scene,camera){this.scene=scene,this.camera=camera,this.enabled=!0,this.clear=!0,this.needsSwap=!1,this.inverse=!1},THREE.MaskPass.prototype={render:function(renderer,writeBuffer,readBuffer,delta){var context=renderer.context;context.colorMask(!1,!1,!1,!1),context.depthMask(!1);var writeValue,clearValue;this.inverse?(writeValue=0,clearValue=1):(writeValue=1,clearValue=0),context.enable(context.STENCIL_TEST),context.stencilOp(context.REPLACE,context.REPLACE,context.REPLACE),context.stencilFunc(context.ALWAYS,writeValue,4294967295),context.clearStencil(clearValue),renderer.render(this.scene,this.camera,readBuffer,this.clear),renderer.render(this.scene,this.camera,writeBuffer,this.clear),context.colorMask(!0,!0,!0,!0),context.depthMask(!0),context.stencilFunc(context.EQUAL,1,4294967295),context.stencilOp(context.KEEP,context.KEEP,context.KEEP)}},THREE.ClearMaskPass=function(){this.enabled=!0},THREE.ClearMaskPass.prototype={render:function(renderer,writeBuffer,readBuffer,delta){var context=renderer.context;context.disable(context.STENCIL_TEST)}},THREE.RenderPass=function(scene,camera,overrideMaterial,clearColor,clearAlpha){this.scene=scene,this.camera=camera,this.overrideMaterial=overrideMaterial,this.clearColor=clearColor,this.clearAlpha=void 0!==clearAlpha?clearAlpha:1,this.oldClearColor=new THREE.Color,this.oldClearAlpha=1,this.enabled=!0,this.clear=!0,this.needsSwap=!1},THREE.RenderPass.prototype={render:function(renderer,writeBuffer,readBuffer,delta){this.scene.overrideMaterial=this.overrideMaterial,this.clearColor&&(this.oldClearColor.copy(renderer.getClearColor()),this.oldClearAlpha=renderer.getClearAlpha(),renderer.setClearColor(this.clearColor,this.clearAlpha)),renderer.render(this.scene,this.camera,readBuffer,this.clear),this.clearColor&&renderer.setClearColor(this.oldClearColor,this.oldClearAlpha),this.scene.overrideMaterial=null}},THREE.ShaderPass=function(shader,textureID){this.textureID=void 0!==textureID?textureID:"tDiffuse",this.uniforms=THREE.UniformsUtils.clone(shader.uniforms),this.material=new THREE.ShaderMaterial({uniforms:this.uniforms,vertexShader:shader.vertexShader,fragmentShader:shader.fragmentShader}),this.renderToScreen=!1,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.camera=new THREE.OrthographicCamera((-1),1,1,(-1),0,1),this.scene=new THREE.Scene,this.quad=new THREE.Mesh(new THREE.PlaneGeometry(2,2),null),this.scene.add(this.quad)},THREE.ShaderPass.prototype={render:function(renderer,writeBuffer,readBuffer,delta){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=readBuffer),this.quad.material=this.material,this.renderToScreen?renderer.render(this.scene,this.camera):renderer.render(this.scene,this.camera,writeBuffer,this.clear)}},THREE.SSAOShader={uniforms:{tDiffuse:{type:"t",value:null},tDepth:{type:"t",value:null},size:{type:"v2",value:new THREE.Vector2(512,512)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},onlyAO:{type:"i",value:0},aoClamp:{type:"f",value:.5},lumInfluence:{type:"f",value:.5}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float cameraNear;","uniform float cameraFar;","uniform bool onlyAO;","uniform vec2 size;","uniform float aoClamp;","uniform float lumInfluence;","uniform sampler2D tDiffuse;","uniform sampler2D tDepth;","varying vec2 vUv;","#define DL 2.399963229728653","#define EULER 2.718281828459045","float width = size.x;","float height = size.y;","float cameraFarPlusNear = cameraFar + cameraNear;","float cameraFarMinusNear = cameraFar - cameraNear;","float cameraCoef = 2.0 * cameraNear;","const int samples = 8;","const float radius = 5.0;","const bool useNoise = false;","const float noiseAmount = 0.0003;","const float diffArea = 0.4;","const float gDisplace = 0.4;","float unpackDepth( const in vec4 rgba_depth ) {","const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );","float depth = dot( rgba_depth, bit_shift );","return depth;","}","vec2 rand( const vec2 coord ) {","vec2 noise;","if ( useNoise ) {","float nx = dot ( coord, vec2( 12.9898, 78.233 ) );","float ny = dot ( coord, vec2( 12.9898, 78.233 ) * 2.0 );","noise = clamp( fract ( 43758.5453 * sin( vec2( nx, ny ) ) ), 0.0, 1.0 );","} else {","float ff = fract( 1.0 - coord.s * ( width / 2.0 ) );","float gg = fract( coord.t * ( height / 2.0 ) );","noise = vec2( 0.25, 0.75 ) * vec2( ff ) + vec2( 0.75, 0.25 ) * gg;","}","return ( noise * 2.0 - 1.0 ) * noiseAmount;","}","float readDepth( const in vec2 coord ) {","return cameraCoef / ( cameraFarPlusNear - unpackDepth( texture2D( tDepth, coord ) ) * cameraFarMinusNear );","}","float compareDepths( const in float depth1, const in float depth2, inout int far ) {","float garea = 2.0;","float diff = ( depth1 - depth2 ) * 100.0;","if ( diff < gDisplace ) {","garea = diffArea;","} else {","far = 1;","}","float dd = diff - gDisplace;","float gauss = pow( EULER, -2.0 * dd * dd / ( garea * garea ) );","return gauss;","}","float calcAO( float depth, float dw, float dh ) {","float dd = radius - depth * radius;","vec2 vv = vec2( dw, dh );","vec2 coord1 = vUv + dd * vv;","vec2 coord2 = vUv - dd * vv;","float temp1 = 0.0;","float temp2 = 0.0;","int far = 0;","temp1 = compareDepths( depth, readDepth( coord1 ), far );","if ( far > 0 ) {","temp2 = compareDepths( readDepth( coord2 ), depth, far );","temp1 += ( 1.0 - temp1 ) * temp2;","}","return temp1;","}","void main() {","vec2 noise = rand( vUv );","float depth = readDepth( vUv );","float tt = clamp( depth, aoClamp, 1.0 );","float w = ( 1.0 / width ) / tt + ( noise.x * ( 1.0 - noise.x ) );","float h = ( 1.0 / height ) / tt + ( noise.y * ( 1.0 - noise.y ) );","float ao = 0.0;","float dz = 1.0 / float( samples );","float z = 1.0 - dz / 2.0;","float l = 0.0;","for ( int i = 0; i <= samples; i ++ ) {","float r = sqrt( 1.0 - z );","float pw = cos( l ) * r;","float ph = sin( l ) * r;","ao += calcAO( depth, pw * w, ph * h );","z = z - dz;","l = l + DL;","}","ao /= float( samples );","ao = 1.0 - ao;","vec3 color = texture2D( tDiffuse, vUv ).rgb;","vec3 lumcoeff = vec3( 0.299, 0.587, 0.114 );","float lum = dot( color.rgb, lumcoeff );","vec3 luminance = vec3( lum );","vec3 final = vec3( color * mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","if ( onlyAO ) {","final = vec3( mix( vec3( ao ), vec3( 1.0 ), luminance * lumInfluence ) );","}","gl_FragColor = vec4( final, 1.0 );","}"].join("\n")},THREE.VignetteShader={uniforms:{tDiffuse:{type:"t",value:null},offset:{type:"f",value:1},darkness:{type:"f",value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float offset;","uniform float darkness;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );","gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );","}"].join("\n")};
/*! gorescript / http://gorescript.com */var GS=GS||{};GS.inherit=function(classObj,members){var base=Object.create(classObj.prototype);return Object.getOwnPropertyNames(members).forEach(function(prop){var desc=Object.getOwnPropertyDescriptor(members,prop);void 0!==desc.get?base.__defineGetter__(prop,desc.get):base[prop]=members[prop],void 0!==desc.set&&base.__defineSetter__(prop,desc.set)}),base},GS.pushArray=function(dst,src){src.forEach(function(x){this.push(x)},dst)},GS.msToFrames=function(ms){return Math.round(ms/16.66)},GS.pad=function(n,width,z){return z=z||"0",n+="",n.length>=width?n:new Array(width-n.length+1).join(z)+n},GS.logOnce=function(id,str){GS.logOnce[id.toString()]!==!0&&(GS.logOnce[id.toString()]=!0,console.log(str))},GS.isFirefox="undefined"!=typeof InstallTrigger,GS.isIFrame=function(){try{return window.self!==window.top}catch(e){return!0}}(),GS.Base=function(){this.clearColor=0,this.antialias=!0,this.cameraFov=90,this.cameraNear=.1,this.cameraFar=1e3,this.timeStep=.01666,this.fpsCounter={updateRate:0,frameRate:0,updates:0,frames:0,currentTime:this.getCurrentTime()},this.requestAnimationFrameId=null},GS.Base.prototype={constructor:GS.Base,init:function(){var that=this;this.renderer=new THREE.WebGLRenderer({antialias:this.antialias}),this.renderer.setClearColor(this.clearColor,1),this.renderer.setSize(window.innerWidth,window.innerHeight),this.renderer.domElement.id="game-canvas",this.camera=new THREE.PerspectiveCamera(this.cameraFov,window.innerWidth/window.innerHeight,this.cameraNear,this.cameraFar),this.scene=new THREE.Scene,window.addEventListener("resize",function(){that.onResize()},!1),this.onResize(),document.body.appendChild(this.renderer.domElement),this.load()},load:function(){null!==this.requestAnimationFrameId&&cancelAnimationFrame(this.requestAnimationFrameId),this.currentTime=this.getCurrentTime(),this.accumulator=0,this.gameLoop()},update:function(){},draw:function(){this.renderer.render(this.scene,this.camera)},gameLoop:function(){var that=this,newTime=this.getCurrentTime(),frameTime=(newTime-this.currentTime)/1e3;for(frameTime>.33&&(frameTime=.33),this.currentTime=newTime,this.accumulator+=frameTime;this.accumulator>=this.timeStep;)this.update(),this.fpsCounter.updates++,this.accumulator-=this.timeStep;this.draw(),this.fpsCounter.frames++,newTime-this.fpsCounter.currentTime>=1e3&&(this.fpsCounter.updateRate=this.fpsCounter.updates,this.fpsCounter.frameRate=this.fpsCounter.frames,this.fpsCounter.updates=0,this.fpsCounter.frames=0,this.fpsCounter.currentTime=newTime,GS.DebugUI.trackNumericValue("fps",this.fpsCounter.frameRate)),this.requestAnimationFrameId=requestAnimationFrame(function(){that.gameLoop()})},onResize:function(){this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(window.innerWidth,window.innerHeight)},getCurrentTime:function(){return void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now()},set showFPS(value){GS.DebugUI.setStaticLineVisibility("fps",value)},get showFPS(){return GS.DebugUI.getStaticLineVisibility("fps")}},GS.Canvas2d=function(hideOnStart){this.canvasId="canvas2d",this.hideOnStart=void 0!==hideOnStart&&hideOnStart,this.minWidth=1280,this.minHeight=720,this.alpha=1,this.redrawOnResize=!0},GS.Canvas2d.prototype={constructor:GS.Canvas2d,init:function(){var that=this,screenCanvas=document.createElement("canvas");screenCanvas.width=window.innerWidth,screenCanvas.height=window.innerHeight,screenCanvas.style.backgroundColor="rgba(0, 0, 0, "+this.alpha+")",screenCanvas.id=this.canvasId,this.screenCanvas=screenCanvas,this.hideOnStart&&this.hide(),document.body.appendChild(this.screenCanvas);var screenCtx=screenCanvas.getContext("2d");screenCtx.globalCompositeOperation="source-over",screenCtx.save(),this.screenCtx=screenCtx;var bufferCanvas=document.createElement("canvas");bufferCanvas.width=window.innerWidth,bufferCanvas.height=window.innerHeight,bufferCanvas.style.backgroundColor="rgba(0, 0, 0, 1)",this.bufferCanvas=bufferCanvas;var bufferCtx=bufferCanvas.getContext("2d");bufferCtx.globalCompositeOperation="source-over",bufferCtx.save(),this.bufferCtx=bufferCtx,$(window).on("resize."+this.canvasId,function(){that.onResize()}),this.onResize()},show:function(){this.screenCanvas.style.display=""},hide:function(){this.screenCanvas.style.display="none"},clear:function(){this.bufferCtx.clearRect(0,0,this.bufferCanvas.width,this.bufferCanvas.height)},flip:function(){this.screenCtx.clearRect(0,0,this.screenCanvas.width,this.screenCanvas.height),this.screenCtx.drawImage(this.bufferCanvas,0,0)},line:function(p0,p1,color,lineWidth){color=void 0!==color?color:"#fff",lineWidth=lineWidth||3,this.bufferCtx.save(),this.bufferCtx.strokeStyle=color,this.bufferCtx.lineWidth=lineWidth,this.bufferCtx.beginPath(),this.bufferCtx.moveTo(p0.x,p0.y),this.bufferCtx.lineTo(p1.x,p1.y),this.bufferCtx.closePath(),this.bufferCtx.stroke(),this.bufferCtx.restore()},box:function(p0,p1,color,lineWidth){color=void 0!==color?color:"#fff",lineWidth=lineWidth||3,this.bufferCtx.save(),this.bufferCtx.strokeStyle=color,this.bufferCtx.lineWidth=lineWidth,this.bufferCtx.beginPath(),this.bufferCtx.moveTo(p0.x,p0.y),this.bufferCtx.lineTo(p1.x,p0.y),this.bufferCtx.lineTo(p1.x,p1.y),this.bufferCtx.lineTo(p0.x,p1.y),this.bufferCtx.closePath(),this.bufferCtx.stroke(),this.bufferCtx.restore()},boxFill:function(p0,p1,color){color=void 0!==color?color:"#fff";var x0=Math.min(p0.x,p1.x),y0=Math.min(p0.y,p1.y),x1=Math.max(p0.x,p1.x),y1=Math.max(p0.y,p1.y),w=x1-x0,h=y1-y0;this.bufferCtx.save(),this.bufferCtx.fillStyle=color,this.bufferCtx.fillRect(x0,y0,w,h),this.bufferCtx.restore()},_roundedBox:function(p0,p1,radius,filled,color,lineWidth){color=void 0!==color?color:"#fff",lineWidth=lineWidth||3;var x0=Math.min(p0.x,p1.x),y0=Math.min(p0.y,p1.y),x1=Math.max(p0.x,p1.x),y1=Math.max(p0.y,p1.y);this.bufferCtx.save(),filled?this.bufferCtx.fillStyle=color:(this.bufferCtx.strokeStyle=color,this.bufferCtx.lineWidth=lineWidth),this.bufferCtx.beginPath(),this.bufferCtx.moveTo(x0,y0+radius),this.bufferCtx.lineTo(x0,y1-radius),this.bufferCtx.quadraticCurveTo(x0,y1,x0+radius,y1),this.bufferCtx.lineTo(x1-radius,y1),this.bufferCtx.quadraticCurveTo(x1,y1,x1,y1-radius),this.bufferCtx.lineTo(x1,y0+radius),this.bufferCtx.quadraticCurveTo(x1,y0,x1-radius,y0),this.bufferCtx.lineTo(x0+radius,y0),this.bufferCtx.quadraticCurveTo(x0,y0,x0,y0+radius),this.bufferCtx.closePath(),filled?this.bufferCtx.fill():this.bufferCtx.stroke(),this.bufferCtx.restore()},roundedBox:function(p0,p1,radius,color,lineWidth){this._roundedBox(p0,p1,radius,!1,color,lineWidth)},roundedBoxFill:function(p0,p1,radius,color){this._roundedBox(p0,p1,radius,!0,color)},polygon:function(points,color,lineWidth){color=void 0!==color?color:"#fff",lineWidth=lineWidth||3,this.bufferCtx.save(),this.bufferCtx.strokeStyle=color,this.bufferCtx.lineWidth=lineWidth,this.bufferCtx.beginPath(),this.bufferCtx.moveTo(points[0].x,points[0].y);for(var i=1;i<points.length;i++)this.bufferCtx.lineTo(points[i].x,points[i].y);this.bufferCtx.closePath(),this.bufferCtx.stroke(),this.bufferCtx.restore()},polygonFill:function(points,color){color=void 0!==color?color:"#fff",this.bufferCtx.save(),this.bufferCtx.fillStyle=color,this.bufferCtx.beginPath(),this.bufferCtx.moveTo(points[0].x,points[0].y);for(var i=1;i<points.length;i++)this.bufferCtx.lineTo(points[i].x,points[i].y);this.bufferCtx.closePath(),this.bufferCtx.fill(),this.bufferCtx.restore()},circle:function(pos,radius,color,lineWidth){color=void 0!==color?color:"#fff",lineWidth=lineWidth||3,this.bufferCtx.save(),this.bufferCtx.beginPath(),this.bufferCtx.arc(pos.x,pos.y,radius,0,2*Math.PI),this.bufferCtx.strokeStyle=color,this.bufferCtx.lineWidth=lineWidth,this.bufferCtx.stroke(),this.bufferCtx.restore()},circleFill:function(pos,radius,color){color=void 0!==color?color:"#fff",this.bufferCtx.save(),this.bufferCtx.beginPath(),this.bufferCtx.arc(pos.x,pos.y,radius,0,2*Math.PI),this.bufferCtx.fillStyle=color,this.bufferCtx.fill(),this.bufferCtx.restore()},text:function(pos,str,color,fontSize,textBaseline,textAlign,fontFamily){color=void 0!==color?color:"#fff",fontSize=void 0!==fontSize?fontSize:16,textBaseline=textBaseline||"top",textAlign=textAlign||"left",fontFamily=fontFamily||"'Lucida Console', Monaco, monospace",this.bufferCtx.save();var offset=GS.isFirefox?4:0;this.bufferCtx.textBaseline=textBaseline,this.bufferCtx.textAlign=textAlign,this.bufferCtx.font=fontSize+"px "+fontFamily,this.bufferCtx.fillStyle=color,this.bufferCtx.fillText(str,pos.x,pos.y+offset),this.bufferCtx.restore()},drawImage:function(pos,img,size){this.bufferCtx.drawImage(img,pos.x,pos.y,size.x,size.y)},drawImageFromAtlas:function(pos,img,atlasOffset,atlasSize){this.bufferCtx.drawImage(img,atlasOffset.x,atlasOffset.y,atlasSize.x,atlasSize.y,pos.x,pos.y,atlasSize.x,atlasSize.y)},getTextWidth:function(str,fontSize,fontFamily){fontSize=void 0!==fontSize?fontSize:16,fontFamily=fontFamily||"'Lucida Console', Monaco, monospace",this.bufferCtx.save(),this.bufferCtx.font=fontSize+"px '"+fontFamily+"'";var width=this.bufferCtx.measureText(str).width;return this.bufferCtx.restore(),width},onResize:function(){var canvas;this.redrawOnResize&&(canvas=this.clone()),this.screenCanvas.width=Math.max(window.innerWidth,this.minWidth),this.screenCanvas.height=Math.max(window.innerHeight,this.minHeight),this.bufferCanvas.width=Math.max(window.innerWidth,this.minWidth),this.bufferCanvas.height=Math.max(window.innerHeight,this.minHeight),$(this.screenCanvas).css("width",window.innerWidth+"px").css("height",window.innerHeight+"px"),this.redrawOnResize&&this.screenCtx.drawImage(canvas,0,0)},clone:function(){var canvas=document.createElement("canvas");canvas.width=this.screenCanvas.width,canvas.height=this.screenCanvas.height;var ctx=canvas.getContext("2d");return ctx.globalCompositeOperation="source-over",ctx.save(),ctx.drawImage(this.screenCanvas,0,0),canvas},dispose:function(){$(window).off("resize."+this.canvasId),$("#"+this.canvasId).remove()}},GS.Cube={getVertices:function(){var vertices=[new THREE.Vector3(1,1,(-1)),new THREE.Vector3(1,1,1),new THREE.Vector3(1,(-1),(-1)),new THREE.Vector3(1,1,1),new THREE.Vector3(1,(-1),1),new THREE.Vector3(1,(-1),(-1)),new THREE.Vector3((-1),1,1),new THREE.Vector3((-1),1,(-1)),new THREE.Vector3((-1),(-1),1),new THREE.Vector3((-1),1,(-1)),new THREE.Vector3((-1),(-1),(-1)),new THREE.Vector3((-1),(-1),1),new THREE.Vector3((-1),1,1),new THREE.Vector3(1,1,1),new THREE.Vector3((-1),1,(-1)),new THREE.Vector3(1,1,1),new THREE.Vector3(1,1,(-1)),new THREE.Vector3((-1),1,(-1)),new THREE.Vector3((-1),(-1),(-1)),new THREE.Vector3(1,(-1),(-1)),new THREE.Vector3((-1),(-1),1),new THREE.Vector3(1,(-1),(-1)),new THREE.Vector3(1,(-1),1),new THREE.Vector3((-1),(-1),1),new THREE.Vector3(1,1,1),new THREE.Vector3((-1),1,1),new THREE.Vector3(1,(-1),1),new THREE.Vector3((-1),1,1),new THREE.Vector3((-1),(-1),1),new THREE.Vector3(1,(-1),1),new THREE.Vector3((-1),1,(-1)),new THREE.Vector3(1,1,(-1)),new THREE.Vector3((-1),(-1),(-1)),new THREE.Vector3(1,1,(-1)),new THREE.Vector3(1,(-1),(-1)),new THREE.Vector3((-1),(-1),(-1))];return vertices}},GS.Detector={run:function(callback){var canvas=document.createElement("canvas");if(void 0===canvas.getContext)return void this.displayErrorMessage("HTML5 canvas");var webGL=function(){try{var canvas=document.createElement("canvas");return!!window.WebGLRenderingContext&&(canvas.getContext("webgl")||canvas.getContext("experimental-webgl"))}catch(e){return!1}}();if(!webGL)return void this.displayErrorMessage("WebGL, or WebGL failed to initialize");var webAudio="undefined"!=typeof AudioContext||"undefined"!=typeof webkitAudioContext;if(!webAudio)return void this.displayErrorMessage("the Web Audio API");var pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document;if(!pointerLock)return void this.displayErrorMessage("the Pointer Lock API");var localStorage;try{localStorage="localStorage"in window&&null!==window.localStorage}catch(e){localStorage=!1}return localStorage?void callback():void this.displayErrorMessage("HTML5 local storage")},displayErrorMessage:function(html){var div=document.createElement("div");div.style.width="450px",div.style.height="150px",div.style.marginLeft="-225px",div.style.marginTop="-75px",div.style.position="absolute",div.style.top="50%",div.style.left="50%",div.style.backgroundColor="#000",div.style.color="#fff",div.style.fontSize="20px",div.style.fontFamily="Arial, Helvetica, sans-serif",div.style.fontWeight="normal",div.style.textAlign="center",div.style.border="1px dashed #fff";var span=document.createElement("span");span.style.display="block",span.style.marginTop="50px",span.innerHTML="Your browser does not support<br/>"+html+".",div.appendChild(span),document.body.appendChild(div)}},function(){THREE.Vector3.prototype.toVector2=function(optionalTarget){var v=optionalTarget||new THREE.Vector2;return v.x=this.x,v.y=this.z,v},THREE.Vector3.prototype.toString=function(d){return d=d||0,["[",this.x.toFixed(d),this.y.toFixed(d),this.z.toFixed(d),"]"].join(" ")},THREE.Vector3.prototype.equalsEpsilon=function(v,e){return e=e||1e-4,Math.abs(v.x-this.x)<e&&Math.abs(v.y-this.y)<e&&Math.abs(v.z-this.z)<e},THREE.Vector3.prototype.minCoord=function(){return Math.min(Math.min(this.x,this.y),Math.min(this.y,this.z))},THREE.Vector3.prototype.maxCoord=function(){return Math.max(Math.max(this.x,this.y),Math.max(this.y,this.z))},THREE.Box3.prototype.isIntersectionBoxSwept=function(){var aux1=new THREE.Vector3,aux2=new THREE.Vector3,auxBox=new THREE.Box3,velocity=new THREE.Vector3,invEntry=new THREE.Vector3,invExit=new THREE.Vector3,entry=new THREE.Vector3,exit=new THREE.Vector3,size1=new THREE.Vector3,size2=new THREE.Vector3;return function(oldPos,newPos,box,boxPos,point){if(velocity.copy(newPos).sub(oldPos),aux1.copy(this.min).add(velocity),aux2.copy(this.max).add(velocity),auxBox.setFromPoints([this.min,this.max,aux1,aux2]),!auxBox.isIntersectionBox(box))return!1;if(this.isIntersectionBox(box))return point.copy(oldPos),!0;if(auxBox.min.copy(this.min).add(velocity),auxBox.max.copy(this.max).add(velocity),auxBox.isIntersectionBox(box))return point.copy(newPos),!0;size1.copy(this.max).sub(this.min),size2.copy(box.max).sub(box.min),velocity.x>0?(invEntry.x=box.min.x-(this.min.x+size1.x),invExit.x=box.min.x+size2.x-this.min.x):(invEntry.x=box.min.x+size2.x-this.min.x,invExit.x=box.min.x-(this.min.x+size1.x)),velocity.y>0?(invEntry.y=box.min.y-(this.min.y+size1.y),invExit.y=box.min.y+size2.y-this.min.y):(invEntry.y=box.min.y+size2.y-this.min.y,invExit.y=box.min.y-(this.min.y+size1.y)),velocity.z>0?(invEntry.z=box.min.z-(this.min.z+size1.z),invExit.z=box.min.z+size2.z-this.min.z):(invEntry.z=box.min.z+size2.z-this.min.z,invExit.z=box.min.z-(this.min.z+size1.z)),0===velocity.x?(entry.x=-(1/0),exit.x=1/0):(entry.x=invEntry.x/velocity.x,exit.x=invExit.x/velocity.x),0===velocity.y?(entry.y=-(1/0),exit.y=1/0):(entry.y=invEntry.y/velocity.y,exit.y=invExit.y/velocity.y),0===velocity.z?(entry.z=-(1/0),exit.z=1/0):(entry.z=invEntry.z/velocity.z,exit.z=invExit.z/velocity.z);var entryTime=entry.maxCoord(),exitTime=exit.minCoord();return!(entryTime>exitTime||entry.x<0&&entry.y<0&&entry.z<0||entry.x>1||entry.y>1||entry.z>1)&&(velocity.multiplyScalar(entryTime),point.copy(oldPos).add(velocity),!0)}}(),THREE.Ray.prototype.intersectsOrStartsInBox=function(box,optionalTarget){var result=optionalTarget||new THREE.Vector3;return box.containsPoint(this.origin)?result.copy(this.origin):this.intersectBox(box,result),result},THREE.Vector2.prototype.toString=function(d){return d=d||0,["[",this.x.toFixed(d),this.y.toFixed(d),"]"].join(" ")},THREE.Vector2.prototype.equalsEpsilon=function(v,e){return e=e||1e-4,Math.abs(v.x-this.x)<e&&Math.abs(v.y-this.y)<e},THREE.Vector2.prototype.minCoord=function(){return Math.min(this.x,this.y)},THREE.Vector2.prototype.maxCoord=function(){return Math.max(this.x,this.y)},THREE.Box2.prototype.isIntersectionBoxSwept=function(){var aux1=new THREE.Vector2,aux2=new THREE.Vector2,auxBox=new THREE.Box2,velocity=new THREE.Vector2,invEntry=new THREE.Vector2,invExit=new THREE.Vector2,entry=new THREE.Vector2,exit=new THREE.Vector2,size1=new THREE.Vector2,size2=new THREE.Vector2;return function(oldPos,newPos,box,boxPos,point){if(velocity.copy(newPos).sub(oldPos),aux1.copy(this.min).add(velocity),aux2.copy(this.max).add(velocity),auxBox.setFromPoints([this.min,this.max,aux1,aux2]),!auxBox.isIntersectionBox(box))return!1;if(this.isIntersectionBox(box))return point.copy(oldPos),!0;if(auxBox.min.copy(this.min).add(velocity),auxBox.max.copy(this.max).add(velocity),auxBox.isIntersectionBox(box))return point.copy(newPos),!0;size1.copy(this.max).sub(this.min),size2.copy(box.max).sub(box.min),velocity.x>0?(invEntry.x=box.min.x-(this.min.x+size1.x),invExit.x=box.min.x+size2.x-this.min.x):(invEntry.x=box.min.x+size2.x-this.min.x,invExit.x=box.min.x-(this.min.x+size1.x)),velocity.y>0?(invEntry.y=box.min.y-(this.min.y+size1.y),invExit.y=box.min.y+size2.y-this.min.y):(invEntry.y=box.min.y+size2.y-this.min.y,invExit.y=box.min.y-(this.min.y+size1.y)),0===velocity.x?(entry.x=-(1/0),exit.x=1/0):(entry.x=invEntry.x/velocity.x,exit.x=invExit.x/velocity.x),0===velocity.y?(entry.y=-(1/0),exit.y=1/0):(entry.y=invEntry.y/velocity.y,exit.y=invExit.y/velocity.y);var entryTime=entry.maxCoord(),exitTime=exit.minCoord();return!(entryTime>exitTime||entry.x<0&&entry.y<0||entry.x>1||entry.y>1)&&(velocity.multiplyScalar(entryTime),point.copy(oldPos).add(velocity),!0)}}(),THREE.Box2.prototype.isIntersectionLineSwept=function(){var velocity=new THREE.Vector2,boxExtent=new THREE.Vector2,boxCenter=new THREE.Vector2,lineNormal=new THREE.Vector2,lineDir=new THREE.Vector2,lineMin=new THREE.Vector2,lineMax=new THREE.Vector2,aux=new THREE.Vector2;return function(oldPos,newPos,line){var result={foundCollision:!1,pos:new THREE.Vector2,distance:0,normal:new THREE.Vector2};if(velocity.copy(newPos).sub(oldPos),boxExtent.copy(this.max).sub(this.min).multiplyScalar(.5),boxCenter.copy(this.max).add(this.min).multiplyScalar(.5),GS.MathHelper.vec2Normal(line.start,line.end,lineNormal),lineNormal.dot(velocity)>=0)return result;lineDir.copy(line.end).sub(line.start),lineDir.x>0?(lineMin.x=line.start.x,lineMax.x=line.end.x):(lineMin.x=line.end.x,lineMax.x=line.start.x),lineDir.y>0?(lineMin.y=line.start.y,lineMax.y=line.end.y):(lineMin.y=line.end.y,lineMax.y=line.start.y);var hitTime=0,outTime=1,r=boxExtent.x*Math.abs(lineNormal.x)+boxExtent.y*Math.abs(lineNormal.y);aux.copy(line.start).sub(boxCenter);var boxProj=aux.dot(lineNormal),velProj=velocity.dot(lineNormal);if(velProj<0&&(r*=-1),hitTime=Math.max((boxProj-r)/velProj,hitTime),outTime=Math.min((boxProj+r)/velProj,outTime),velocity.x<0){if(this.max.x<lineMin.x)return result;hitTime=Math.max((lineMax.x-this.min.x)/velocity.x,hitTime),outTime=Math.min((lineMin.x-this.max.x)/velocity.x,outTime)}else if(velocity.x>0){if(this.min.x>lineMax.x)return result;hitTime=Math.max((lineMin.x-this.max.x)/velocity.x,hitTime),outTime=Math.min((lineMax.x-this.min.x)/velocity.x,outTime)}else if(lineMin.x>this.max.x||lineMax.x<this.min.x)return result;if(hitTime>outTime)return result;if(velocity.y<0){if(this.max.y<lineMin.y)return result;hitTime=Math.max((lineMax.y-this.min.y)/velocity.y,hitTime),outTime=Math.min((lineMin.y-this.max.y)/velocity.y,outTime)}else if(velocity.y>0){if(this.min.y>lineMax.y)return result;hitTime=Math.max((lineMin.y-this.max.y)/velocity.y,hitTime),outTime=Math.min((lineMax.y-this.min.y)/velocity.y,outTime)}else if(lineMin.y>this.max.y||lineMax.y<this.min.y)return result;return hitTime>outTime?result:(result.foundCollision=!0,result.pos.copy(oldPos).add(velocity.multiplyScalar(hitTime)),result.distance=velocity.length()*hitTime,result.normal.copy(lineNormal),result)}}(),THREE.Geometry.prototype.merge=function(geometry,matrix,materialIndexOffset){if(geometry instanceof THREE.Geometry==!1)return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",geometry);var normalMatrix,vertexOffset=this.vertices.length,vertices1=this.vertices,vertices2=geometry.vertices,faces1=this.faces,faces2=geometry.faces,uvs1=this.faceVertexUvs[0],uvs2=geometry.faceVertexUvs[0];void 0===materialIndexOffset&&(materialIndexOffset=0),void 0!==matrix&&(normalMatrix=(new THREE.Matrix3).getNormalMatrix(matrix));for(var i=0,il=vertices2.length;i<il;i++){var vertex=vertices2[i],vertexCopy=vertex.clone();void 0!==matrix&&vertexCopy.applyMatrix4(matrix),vertices1.push(vertexCopy)}for(i=0,il=faces2.length;i<il;i++){var faceCopy,normal,color,face=faces2[i],faceVertexNormals=face.vertexNormals,faceVertexColors=face.vertexColors;faceCopy=new THREE.Face3(face.a+vertexOffset,face.b+vertexOffset,face.c+vertexOffset),faceCopy.normal.copy(face.normal),void 0!==normalMatrix&&faceCopy.normal.applyMatrix3(normalMatrix).normalize();for(var j=0,jl=faceVertexNormals.length;j<jl;j++)normal=faceVertexNormals[j].clone(),void 0!==normalMatrix&&normal.applyMatrix3(normalMatrix).normalize(),faceCopy.vertexNormals.push(normal);faceCopy.color.copy(face.color),faceCopy.emissive=face.emissive.clone();for(var j=0,jl=faceVertexColors.length;j<jl;j++)color=faceVertexColors[j],faceCopy.vertexColors.push(color.clone());faceCopy.materialIndex=face.materialIndex+materialIndexOffset,faces1.push(faceCopy)}for(i=0,il=uvs2.length;i<il;i++){var uv=uvs2[i],uvCopy=[];if(void 0!==uv){for(var j=0,jl=uv.length;j<jl;j++)uvCopy.push(new THREE.Vector2(uv[j].x,uv[j].y));uvs1.push(uvCopy)}}},THREE.BufferGeometry.prototype.fromGeometry=function(geometry,settings){settings=settings||{vertexColors:THREE.NoColors};var vertices=geometry.vertices,faces=geometry.faces,faceVertexUvs=geometry.faceVertexUvs,vertexColors=settings.vertexColors,hasFaceVertexUv=faceVertexUvs[0].length>0,hasFaceVertexNormals=3==faces[0].vertexNormals.length,positions=new Float32Array(3*faces.length*3);this.addAttribute("position",new THREE.BufferAttribute(positions,3));var normals=new Float32Array(3*faces.length*3);if(this.addAttribute("normal",new THREE.BufferAttribute(normals,3)),vertexColors!==THREE.NoColors){var colors=new Float32Array(3*faces.length*3);this.addAttribute("color",new THREE.BufferAttribute(colors,3));var emissives=new Float32Array(3*faces.length*3);this.addAttribute("emissive",new THREE.BufferAttribute(emissives,3))}if(hasFaceVertexUv===!0){var uvs=new Float32Array(3*faces.length*2);this.addAttribute("uv",new THREE.BufferAttribute(uvs,2))}for(var i=0,i2=0,i3=0;i<faces.length;i++,i2+=6,i3+=9){var face=faces[i],a=vertices[face.a],b=vertices[face.b],c=vertices[face.c];if(positions[i3]=a.x,positions[i3+1]=a.y,positions[i3+2]=a.z,positions[i3+3]=b.x,positions[i3+4]=b.y,positions[i3+5]=b.z,positions[i3+6]=c.x,positions[i3+7]=c.y,positions[i3+8]=c.z,hasFaceVertexNormals===!0){var na=face.vertexNormals[0],nb=face.vertexNormals[1],nc=face.vertexNormals[2];normals[i3]=na.x,normals[i3+1]=na.y,normals[i3+2]=na.z,normals[i3+3]=nb.x,normals[i3+4]=nb.y,normals[i3+5]=nb.z,normals[i3+6]=nc.x,normals[i3+7]=nc.y,normals[i3+8]=nc.z}else{var n=face.normal;normals[i3]=n.x,normals[i3+1]=n.y,normals[i3+2]=n.z,normals[i3+3]=n.x,normals[i3+4]=n.y,normals[i3+5]=n.z,normals[i3+6]=n.x,normals[i3+7]=n.y,normals[i3+8]=n.z}if(vertexColors===THREE.FaceColors){var fc=face.color;colors[i3]=fc.r,colors[i3+1]=fc.g,colors[i3+2]=fc.b,colors[i3+3]=fc.r,colors[i3+4]=fc.g,colors[i3+5]=fc.b,colors[i3+6]=fc.r,colors[i3+7]=fc.g,colors[i3+8]=fc.b;var em=face.emissive;emissives[i3]=em.r,emissives[i3+1]=em.g,emissives[i3+2]=em.b,emissives[i3+3]=em.r,emissives[i3+4]=em.g,emissives[i3+5]=em.b,emissives[i3+6]=em.r,emissives[i3+7]=em.g,emissives[i3+8]=em.b}else if(vertexColors===THREE.VertexColors){var vca=face.vertexColors[0],vcb=face.vertexColors[1],vcc=face.vertexColors[2];colors[i3]=vca.r,colors[i3+1]=vca.g,colors[i3+2]=vca.b,colors[i3+3]=vcb.r,colors[i3+4]=vcb.g,colors[i3+5]=vcb.b,colors[i3+6]=vcc.r,colors[i3+7]=vcc.g,colors[i3+8]=vcc.b}if(hasFaceVertexUv===!0){var uva=faceVertexUvs[0][i][0],uvb=faceVertexUvs[0][i][1],uvc=faceVertexUvs[0][i][2];uvs[i2]=uva.x,uvs[i2+1]=uva.y,uvs[i2+2]=uvb.x,uvs[i2+3]=uvb.y,uvs[i2+4]=uvc.x,uvs[i2+5]=uvc.y}}return this.computeBoundingSphere(),this}}(),GS.InputHelper={keyState:[],leftMouseDown:!1,middleMouseDown:!1,rightMouseDown:!1,mouseX:0,mouseY:0,screenRatioX:1,screenRatioY:1,mouseWheelEvents:[],ctrl:!1,shift:!1,alt:!1,pressedKeys:[],keysPressed:!1,init:function(){var that=this;$(document).on("contextmenu",function(){return!1}),$(document).keydown(function(e){if(that.keyState[e.keyCode]=!0,that.ctrl=e.ctrlKey,that.alt=e.altKey,that.shift=e.shiftKey,9==e.keyCode||65==e.keyCode&&e.ctrlKey||90==e.keyCode&&e.ctrlKey||71==e.keyCode&&e.ctrlKey||189==e.keyCode&&e.ctrlKey||187==e.keyCode&&e.ctrlKey||48==e.keyCode&&e.ctrlKey)return e.stopPropagation(),e.preventDefault(),!1}),$(document).keyup(function(e){that.keyState[e.keyCode]=!1,that.ctrl=e.ctrlKey,that.alt=e.altKey,that.shift=e.shiftKey}),$(document).mousedown(function(e){1==e.which&&(that.leftMouseDown=!0),2==e.which&&(that.middleMouseDown=!0),3==e.which&&(that.rightMouseDown=!0)}),$(document).mouseup(function(e){1==e.which&&(that.leftMouseDown=!1),2==e.which&&(that.middleMouseDown=!1),3==e.which&&(that.rightMouseDown=!1)}),$(document).mousemove(function(e){that.mouseX=e.pageX*that.screenRatioX,that.mouseY=e.pageY*that.screenRatioY}),document.addEventListener("mousewheel",function(e){that.mouseWheelEvents.push(e.wheelDelta)},!1),document.addEventListener("DOMMouseScroll",function(e){that.mouseWheelEvents.push(e.detail*-1)},!1)},isKeyUp:function(keyCode){return!this.keyState[keyCode]},isKeyDown:function(keyCode,dontModifyPressed){return dontModifyPressed||this.keyState[keyCode]&&(this.pressedKeys.indexOf(keyCode)==-1&&this.pressedKeys.push(keyCode),this.keysPressed=!0),this.keyState[keyCode]},checkPressedKeys:function(){if(this.pressedKeys.length>0){for(var n=0,i=0;i<this.pressedKeys.length;i++){if(!this.isKeyUp(this.pressedKeys[i]))return;n++}n==this.pressedKeys.length&&(this.keysPressed=!1)}}},GS.InputHelper.init(),GS.LineHelper={compare:function(p,q){return p.x==q.x?p.y-q.y:p.x-q.x},slope:function(s){return(s.end.y-s.start.y)/(s.end.x-s.start.x)},intersectionLineSegments:function(){var p0=new THREE.Vector2;return function(s1,s2,p){return p=p||p0,this.intersectionLines(s1,s2,p,!0)}}(),intersectionLines:function(s1,s2,p,compareLineSegments){var x1=s1.start.x,x2=s1.end.x,x3=s2.start.x,x4=s2.end.x,y1=s1.start.y,y2=s1.end.y,y3=s2.start.y,y4=s2.end.y,denom=(y4-y3)*(x2-x1)-(x4-x3)*(y2-y1);if(0===denom)return!1;var ua=((x4-x3)*(y1-y3)-(y4-y3)*(x1-x3))/denom,ub=((x2-x1)*(y1-y3)-(y2-y1)*(x1-x3))/denom;return(!compareLineSegments||ua>=0&&ua<=1&&ub>=0&&ub<=1)&&(p.x=x1+ua*(x2-x1),p.y=y1+ua*(y2-y1),!0)},intersectionLineSegmentBox:function(){var box0=new THREE.Box2,seg0={start:new THREE.Vector2,end:new THREE.Vector2},p=new THREE.Vector2;return function(seg,box){return box0.setFromPoints([seg.start,seg.end]),!!box.isIntersectionBox(box0)&&(!(!box.containsPoint(seg.start)||!box.containsPoint(seg.end))||(seg0.start.x=box.min.x,seg0.start.y=box.min.y,seg0.end.x=box.max.x,seg0.end.y=box.min.y,!!this.intersectionLineSegments(seg,seg0,p)||(seg0.start.x=box.max.x,seg0.start.y=box.min.y,seg0.end.x=box.max.x,seg0.end.y=box.max.y,!!this.intersectionLineSegments(seg,seg0,p)||(seg0.start.x=box.max.x,seg0.start.y=box.max.y,seg0.end.x=box.min.x,seg0.end.y=box.max.y,!!this.intersectionLineSegments(seg,seg0,p)||(seg0.start.x=box.min.x,seg0.start.y=box.max.y,seg0.end.x=box.min.x,seg0.end.y=box.min.y,!!this.intersectionLineSegments(seg,seg0,p))))))}}(),lineSegmentsToGraph:function(segments,gridCellSize){function sort(a,b){return that.compare(a,b)}for(var that=this,graph=new GS.PlanarGraph,p=new THREE.Vector2,i=0;i<segments.length;i++){var cuts=[];cuts.push(segments[i].start.clone()),cuts.push(segments[i].end.clone());for(var j=0;j<segments.length;j++)if(i!=j){var result=this.intersectionLineSegments(segments[i],segments[j],p);result&&cuts.push(p.clone())}cuts.sort(sort);for(var j=0;j<cuts.length-1;j++)graph.addEdge(cuts[j],cuts[j+1])}if(void 0!==gridCellSize)for(var i=0;i<graph.vertices.length;i++){var v=graph.vertices[i];v.x=Math.floor(v.x/gridCellSize)*gridCellSize,v.y=Math.floor(v.y/gridCellSize)*gridCellSize}return graph},pointOnLineSegment:function(seg,p){var offset=this.pointOffsetOnLineSegment(seg,p);return offset!=-1},pointOffsetOnLineSegment:function(seg,p){var epsilon=1e-4,cross=(p.y-seg.start.y)*(seg.end.x-seg.start.x)-(p.x-seg.start.x)*(seg.end.y-seg.start.y);if(Math.abs(cross)>epsilon)return-1;var dot=(p.x-seg.start.x)*(seg.end.x-seg.start.x)+(p.y-seg.start.y)*(seg.end.y-seg.start.y);if(dot<0)return-1;var lengthSq=(seg.end.x-seg.start.x)*(seg.end.x-seg.start.x)+(seg.end.y-seg.start.y)*(seg.end.y-seg.start.y);if(dot>lengthSq)return-1;var offset=0!==lengthSq?dot/lengthSq:1;return offset},arePointsCollinear:function(p1,p2,p3){return(p1.y-p2.y)*(p1.x-p3.x)==(p1.y-p3.y)*(p1.x-p2.x)}},GS.MapLayers={Segment:0,Sector:2,Entity:3,Zone:4},GS.SegmentTypes={User:0,InteriorFloor:1,InteriorCeiling:2,Exterior:3,TVScreen:4,Switch:5},GS.MapEntities={M:{name:"medkit",type:"Item"},A:{name:"ammo",type:"Item"},H:{name:"hyper_blaster",type:"Item"},D:{name:"double_shotgun",type:"Item"},N:{name:"nom",type:"Monster",animations:{walk:6,death:4}},E:{name:"eye",type:"Monster",animations:{walk:4,death:4,attack:2}}},GS.MathHelper={clamp:function(x,min,max){return x<min&&(x=min),x>max&&(x=max),x},getConvexHullPoints:function(P){var cross=function(O,A,B){return(A.x-O.x)*(B.y-O.y)-(A.y-O.y)*(B.x-O.x)},n=P.length,k=0,H=[];P.sort(function(a,b){return a.x==b.x?a.y-b.y:a.x-b.x});for(var i=0;i<n;i++){for(;k>=2&&cross(H[k-2],H[k-1],P[i])<=0;)k--;H[k++]=P[i]}for(var t=k+1,i=n-2;i>=0;i--){for(;k>=t&&cross(H[k-2],H[k-1],P[i])<=0;)k--;H[k++]=P[i]}return H.length=k-1,H},pointInTriangle:function(P,A,B,C){var result=this.getTriangleBarycentricCoordinates(P,A,B,C);return result.inTriangle},getTriangleBarycentricCoordinates:function(P,A,B,C){var v0=(new THREE.Vector2).subVectors(C,A),v1=(new THREE.Vector2).subVectors(B,A),v2=(new THREE.Vector2).subVectors(P,A),dot00=v0.dot(v0),dot01=v0.dot(v1),dot02=v0.dot(v2),dot11=v1.dot(v1),dot12=v1.dot(v2),invDenom=1/(dot00*dot11-dot01*dot01),u=(dot11*dot02-dot01*dot12)*invDenom,v=(dot00*dot12-dot01*dot02)*invDenom,inTriangle=u>=0&&v>=0&&u+v<1;return{u:u,v:v,inTriangle:inTriangle}},vec2Rotate:function(v,angle){var sn=Math.sin(Math.PI/180*angle),cs=Math.cos(Math.PI/180*angle),x=v.x*cs-v.y*sn,y=v.x*sn+v.y*cs;v.x=x,v.y=y},vec2RotateRadians:function(v,radians){var sn=Math.sin(radians),cs=Math.cos(radians),x=v.x*cs-v.y*sn,y=v.x*sn+v.y*cs;v.x=x,v.y=y},vec2Angle:function(v0,v1){return-Math.atan2(v1.y-v0.y,v1.x-v0.x)*(180/Math.PI)*2},vec2AngleRadians:function(v0,v1){return 2*-Math.atan2(v1.y-v0.y,v1.x-v0.x)},vec2AngleDirected:function(v0,v1){return Math.atan2(v0.y,v0.x)-Math.atan2(v1.y,v1.x)},vec2Normal:function(v0,v1,optionalTarget){var result=optionalTarget||new THREE.Vector2,dx=v1.x-v0.x,dy=v1.y-v0.y;return result.set(dy,-dx).normalize(),result},vec2PointSide:function(a,b,c){return(b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x)>0}},GS.SmoothNumber=function(initialValue,speed){this.value=initialValue,this.targetValue=initialValue,this.speed=speed},GS.SmoothNumber.prototype={setTargetValue:function(targetValue){this.targetValue=targetValue},update:function(){this.value<this.targetValue&&(this.value+=this.speed,this.value>this.targetValue&&(this.value=this.targetValue)),this.value>this.targetValue&&(this.value-=this.speed,this.value<this.targetValue&&(this.value=this.targetValue))}},GS.SmoothVector3=function(x,y,z,speed){THREE.Vector3.call(this,x,y,z),this.targetValue=this.clone(),this.speed=void 0!==speed?speed:.1,this.color=new THREE.Color},GS.SmoothVector3.prototype=GS.inherit(THREE.Vector3,{setTargetValue:function(targetValue){this.targetValue=targetValue.clone()},update:function(){this.updateProperty("x"),this.updateProperty("y"),
this.updateProperty("z"),this.updateColor()},updateColor:function(){this.color.r=this.x,this.color.g=this.y,this.color.b=this.z},updateProperty:function(name){this[name]<this.targetValue[name]&&(this[name]+=this.speed,this[name]>this.targetValue[name]&&(this[name]=this.targetValue[name])),this[name]>this.targetValue[name]&&(this[name]-=this.speed,this[name]<this.targetValue[name]&&(this[name]=this.targetValue[name]))}}),GS.PolygonHelper={getPolygonsFromLineSegments:function(segments,gridCellSize){var graph=GS.LineHelper.lineSegmentsToGraph(segments,gridCellSize);graph.computeShortestPaths(),graph.computeMinimumCycleBasis(),graph.removeNonCycleEdges();for(var vertices=graph.vertices,polygons=[],mcb=graph.minimumCycleBasis,i=0;i<mcb.length;i++){var cycle=graph.cycles[mcb[i]].elements;polygons[i]=[];for(var j=0;j<cycle.length;j++)polygons[i].push(vertices[cycle[j].start])}return{vertices:vertices,polygons:polygons,graph:graph}},getTriangulatedPolygonsFromLineSegments:function(segments,gridCellSize){for(var result=this.getPolygonsFromLineSegments(segments,gridCellSize),i=0;i<result.polygons.length;i++){var polygon=result.polygons[i],vertices=this.vector2ToVertexArray(polygon);this.areVerticesClockwise(vertices)&&this.reverseVertices(vertices),result.polygons[i]={vertices:this.vertexToVector2Array(vertices),indices:PolyK.Triangulate(vertices),area:PolyK.GetArea(vertices)}}return result.polygons.sort(function(a,b){return b.area-a.area}),result},vector2ToVertexArray:function(vectors){for(var vertices=[],j=0;j<vectors.length;j++)vertices.push(vectors[j].x),vertices.push(vectors[j].y);return vertices},vertexToVector2Array:function(vertices){for(var vectors=[],i=0;i<vertices.length;i+=2)vectors.push(new THREE.Vector2(vertices[i],vertices[i+1]));return vectors},reverseVertices:function(vertices){for(var i=0;i<vertices.length/2;i+=2){var j=vertices.length-i-2,x=vertices[i];vertices[i]=vertices[j],vertices[j]=x;var y=vertices[i+1];vertices[i+1]=vertices[j+1],vertices[j+1]=y}},areVerticesClockwise:function(vertices){for(var sum=0,i=0;i<vertices.length-2;i+=2){var x1=vertices[i],y1=vertices[i+1],x2=vertices[i+2],y2=vertices[i+3];sum+=(x2-x1)*(y2+y1)}var x1=vertices[vertices.length-2],y1=vertices[vertices.length-1],x2=vertices[0],y2=vertices[1];return sum+=(x2-x1)*(y2+y1),sum>=0},sectorContainsPoint:function(sector,p,useCollisionVertices){var i,v=useCollisionVertices?sector.collisionVertices:sector.vertices,n=v.length,c=!1,j=0;for(i=0,j=n-1;i<n;j=i++){var start=v[i],end=v[j];start.y>p.y!=end.y>p.y&&p.x<(end.x-start.x)*(p.y-start.y)/(end.y-start.y)+start.x&&(c=!c)}return c},intersectionSectorBox:function(){var box0=new THREE.Box2,seg0={start:new THREE.Vector2,end:new THREE.Vector2},boxPoints=(new THREE.Vector2,[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2]);return function(sector,box){if(box0.setFromPoints(sector.vertices),!box.isIntersectionBox(box0))return!1;if(box.containsBox(box0))return!0;boxPoints[0].x=box.min.x,boxPoints[0].y=box.min.y,boxPoints[1].x=box.max.x,boxPoints[1].y=box.min.y,boxPoints[2].x=box.max.x,boxPoints[2].y=box.max.y,boxPoints[3].x=box.min.x,boxPoints[3].y=box.max.y;for(var v0,v1,v2,i=0;i<sector.indices.length;i+=3){v0=sector.vertices[sector.indices[i]],v1=sector.vertices[sector.indices[i+1]],v2=sector.vertices[sector.indices[i+2]];for(var j=0;j<4;j++)if(GS.MathHelper.pointInTriangle(boxPoints[j],v0,v1,v2))return!0}for(var i=0;i<sector.vertices.length-1;i++)if(seg0.start.copy(sector.vertices[i]),seg0.end.copy(sector.vertices[i+1]),GS.LineHelper.intersectionLineSegmentBox(seg0,box))return!0;return seg0.start.copy(sector.vertices[sector.vertices.length-1]),seg0.end.copy(sector.vertices[0]),!!GS.LineHelper.intersectionLineSegmentBox(seg0,box)}}(),retriangulateSectors:function(sectors){function sectorEdgeContainsVertex(a,v){var i,offset,result={edgeIndex:0,offset:0};for(i=0;i<a.vertices.length-1;i++){if(a.vertices[i].equalsEpsilon(v)||a.vertices[i+1].equalsEpsilon(v))return;if(offset=GS.LineHelper.pointOffsetOnLineSegment({start:a.vertices[i],end:a.vertices[i+1]},v),offset!=-1)return result.edgeIndex=i,result.offset=offset,result}if(!a.vertices[i].equalsEpsilon(v)&&!a.vertices[0].equalsEpsilon(v))return offset=GS.LineHelper.pointOffsetOnLineSegment({start:a.vertices[i],end:a.vertices[0]},v),offset!=-1?(result.edgeIndex=i,result.offset=offset,result):void 0}function edgeSetEquals(a,b){return a.vertex.equalsEpsilon(b.vertex)}function sortCompare(a,b){return b.offset-a.offset}function getSectorEdgeIndex(a,start,end){for(var i=0;i<a.vertices.length-1;i++)if(a.vertices[i].equalsEpsilon(start)&&a.vertices[i+1].equalsEpsilon(end))return i;return a.vertices[i].equalsEpsilon(start)&&a.vertices[0].equalsEpsilon(end)?i:-1}function addVerticesToSector(a,v){var edgeIndex=getSectorEdgeIndex(a,v.edgeStart,v.edgeEnd);if(edgeIndex!=-1)for(var i=0;i<v.vertices.length;i++)a.vertices.splice(edgeIndex+1,0,v.vertices[i])}function addVertices(aIndex,bIndex){for(var a=sectors[aIndex],b=sectors[bIndex],i=0;i<b.vertices.length;i++){var result=sectorEdgeContainsVertex(a,b.vertices[i]);if(void 0!==result){var edges=sectorEdges[aIndex];edges[result.edgeIndex].add({vertex:b.vertices[i],offset:result.offset})}}}for(var sectorEdges=[],i=0;i<sectors.length;i++){for(var edges=[],j=0;j<sectors[i].vertices.length;j++)edges.push(new GS.Set([],edgeSetEquals));sectorEdges.push(edges)}for(var i=0;i<sectors.length-1;i++)for(var j=i+1;j<sectors.length;j++)i!=j&&(addVertices(i,j),addVertices(j,i));for(var i=0;i<sectors.length;i++){for(var toAdd=[],n=sectors[i].vertices.length,j=0;j<n;j++){var newPoints=sectorEdges[i][j].elements;if(newPoints.length>0){newPoints.sort(sortCompare);for(var item={vertices:[],edgeStart:sectors[i].vertices[j],edgeEnd:sectors[i].vertices[j==n-1?0:j+1]},k=0;k<newPoints.length;k++)item.vertices.push(newPoints[k].vertex);toAdd.push(item)}}for(var j=0;j<toAdd.length;j++)addVerticesToSector(sectors[i],toAdd[j]);var vertices=this.vector2ToVertexArray(sectors[i].vertices);this.areVerticesClockwise(vertices)&&this.reverseVertices(vertices),sectors[i].vertices=this.vertexToVector2Array(vertices),sectors[i].indices=PolyK.Triangulate(vertices)}},retriangulateSegments:function(segments){function rightSideCompare(a,b){return b-a}function leftSideCompare(a,b){return a-b}function addVertices(seg,endPoint,compare){for(var points=new GS.Set,i=0;i<segments.length;i++){var s=segments[i];s!==seg&&(s.start.equalsEpsilon(endPoint)||s.end.equalsEpsilon(endPoint))&&(s.topY<seg.topY&&s.topY>seg.bottomY&&points.add(s.topY),s.bottomY<seg.topY&&s.bottomY>seg.bottomY&&points.add(s.bottomY))}if(points.elements.length>0){points.elements.sort(compare);for(var i=0;i<points.elements.length;i++)seg.vertices.push(new THREE.Vector3(endPoint.x,points.elements[i],endPoint.y))}return points.elements.length}for(var i=0;i<segments.length;i++){var seg=segments[i];if(seg.type!==GS.SegmentTypes.TVScreen&&seg.type!==GS.SegmentTypes.Switch){seg.indices=[0,1,2],seg.vertices=[new THREE.Vector3(seg.start.x,seg.topY,seg.start.y),new THREE.Vector3(seg.end.x,seg.topY,seg.end.y)];var n=addVertices(seg,seg.end,rightSideCompare);if(n>0)for(var j=0;j<n;j++)seg.indices.push(0),seg.indices.push(j+2),seg.indices.push(j+3);seg.vertices.push(new THREE.Vector3(seg.end.x,seg.bottomY,seg.end.y)),seg.vertices.push(new THREE.Vector3(seg.start.x,seg.bottomY,seg.start.y));var m=seg.vertices.length-2;if(n=addVertices(seg,seg.start,leftSideCompare),n>0)for(var j=0;j<n;j++)seg.indices.push(m),seg.indices.push(m+j+1),seg.indices.push(m+j+2);seg.indices.push(m),seg.indices.push(m+n+1),seg.indices.push(0),seg.bottomRightIndex=m}}},detriangulateSectors:function(sectors){for(var i=0;i<sectors.length;i++){for(var sector=sectors[i],points=[sector.vertices[0]],n=sector.vertices.length,j=1;j<n;j++)j<n-1?GS.LineHelper.arePointsCollinear(sector.vertices[j-1],sector.vertices[j],sector.vertices[j+1])||points.push(sector.vertices[j]):points.push(sector.vertices[j]);var vertices=this.vector2ToVertexArray(points);this.areVerticesClockwise(vertices)&&this.reverseVertices(vertices),sector.collisionVertices=this.vertexToVector2Array(vertices),sector.collisionIndices=PolyK.Triangulate(vertices)}},getSectorCentroid:function(sector){function getPoint(n){return n===sector.vertices.length&&(n=0),sector.vertices[n]}for(var p1,p2,f,twicearea=0,x=0,y=0,nPts=sector.vertices.length,i=0,j=nPts-1;i<nPts;j=i++)p1=getPoint(i),p2=getPoint(j),f=p1.x*p2.y-p2.x*p1.y,twicearea+=f,x+=(p1.x+p2.x)*f,y+=(p1.y+p2.y)*f;return f=3*twicearea,new THREE.Vector2(x/f,y/f)}},GS.Graph=function(equalsFunc){this.equalsFunc=equalsFunc||function(a,b){return a==b},this.vertices=[],this.edges=[]},GS.Graph.prototype={addEdge:function(start,end){this.equalsFunc(start,end)||this.edges.push({start:this.addVertex(start),end:this.addVertex(end)})},removeEdge:function(start,end){function equals(a,b){return that.equalsFunc(a.start,b.start)&&that.equalsFunc(a.end,b.end)||that.equalsFunc(a.end,b.start)&&that.equalsFunc(a.start,b.end)}if(!this.equalsFunc(start,end))for(var that=this,edge={start:start,end:end},i=this.edges.length-1;i>=0;i--)equals(edge,this.edges[i])&&this.edges.splice(i,1)},addVertex:function(vertex){var result=this.vertexExists(vertex);return result>-1?result:(this.vertices.push(vertex),this.vertices.length-1)},vertexExists:function(vertex){for(var i=0;i<this.vertices.length;i++)if(this.equalsFunc(this.vertices[i],vertex))return i;return-1},computeShortestPaths:function(){for(var dist=[],i=0;i<this.vertices.length;i++){dist[i]=[];for(var j=0;j<this.vertices.length;j++)dist[i].push(1/0)}this.dist=dist;for(var next=[],i=0;i<this.vertices.length;i++){next[i]=[];for(var j=0;j<this.vertices.length;j++)next[i].push(null)}this.next=next;for(var i=0;i<this.vertices.length;i++)dist[i][i]=0;for(var i=0;i<this.edges.length;i++){var edge=this.edges[i];dist[edge.start][edge.end]=1,dist[edge.end][edge.start]=1}this.initNextArray();for(var k=0;k<this.vertices.length;k++)for(var i=0;i<this.vertices.length;i++)for(var j=0;j<this.vertices.length;j++)dist[i][k]+dist[k][j]<dist[i][j]&&(dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[k][j])},initNextArray:function(){for(var i=0;i<this.vertices.length;i++)for(var j=0;j<this.vertices.length;j++)i==j||this.dist[i][j]==1/0?this.next[i][j]=0:this.next[i][j]=i},getPath:function(i,j){if(i==j)return[];var path=this.constructPath(i,j);return void 0!==path&&(path.unshift(i),path.push(j)),path},constructPath:function(i,j){if(this.dist[i][j]!=1/0){var intermediate=this.next[i][j];if(intermediate==i)return[];var prev=this.constructPath(i,intermediate),path=[intermediate],next=this.constructPath(intermediate,j);if(void 0!==prev)for(var i=prev.length-1;i>=0;i--)path.unshift(prev[i]);if(void 0!==next)for(var i=0;i<next.length;i++)path.push(next[i]);return path}},computeVertexNeighborSets:function(){for(var neighborSets=[],i=0;i<this.vertices.length;i++){for(var v=this.vertices[i],neighbors=new GS.Set,j=0;j<this.edges.length;j++){var edge=this.edges[j];this.equalsFunc(v,this.vertices[edge.start])?neighbors.add(this.vertices[edge.end]):this.equalsFunc(v,this.vertices[edge.end])&&neighbors.add(this.vertices[edge.start])}neighborSets.push(neighbors)}this.neighborSets=neighborSets},computeMaximalCliques:function(){function bronKerbosch(R,P,X){0===P.elements.length&&0===X.elements.length&&that.maximalCliques.push(R);for(var i=0;i<P.elements.length;i++){var v=P.elements[i],N=that.neighborSets[v];bronKerbosch(R.clone().add(v),P.clone().intersection(N),X.clone().intersection(N)),P.remove(v),X.add(v)}}var that=this;this.maximalCliques=[],this.computeVertexNeighborSets();var R=new GS.Set((void 0),this.equalsFunc),P=new GS.Set(this.vertices,this.equalsFunc),X=new GS.Set((void 0),this.equalsFunc);bronKerbosch(R,P,X),this.maximalCliques.sort(function(a,b){return a.length-b.length})},getVertexIndex:function(vertex){for(var i=0;i<this.vertices.length;i++)if(this.equalsFunc(this.vertices[i],vertex))return i;return-1}},GS.PlanarGraph=function(){GS.Graph.call(this);var epsilon=1e-4;this.equalsFunc=function(a,b){return Math.abs(a.x-b.x)<epsilon&&Math.abs(a.y-b.y)<epsilon}},GS.PlanarGraph.prototype=GS.inherit(GS.Graph,{computeMinimumCycleBasis:function(){this.computeAllCycles(),this.cycles.length>100?(console.log("cycle count > 100; using horton"),this.selectCyclesHorton()):this.selectCyclesNonOverlapping()},computeAllCycles:function(){function inCycles(cycle){for(var i=0;i<cycles.length;i++)if(cycles[i].equals(cycle))return!0;return!1}function equals(a,b){return a.start==b.start&&a.end==b.end||a.end==b.start&&b.end==a.start}function fromPathSet(set){for(var a=new GS.Set((void 0),equals),e=set.elements,n=e.length,i=0;i<n-1;i++)a.add({start:e[i],end:e[i+1]});return a.add({start:e[n-1],end:e[0]}),a}for(var that=this,cycles=[],path0=new GS.Set,path1=new GS.Set,i=0;i<this.vertices.length;i++)for(var j=0;j<this.edges.length;j++){var edge=this.edges[j];path0.elements=this.getPath(edge.start,i)||[],path1.elements=this.getPath(i,edge.end)||[];var it=path0.intersection(path1);if(1==it.elements.length&&it.elements[0]==i){var cycle=fromPathSet(path0.union(path1));cycle.add(edge),inCycles(cycle)||cycles.push(cycle)}}cycles.sort(function(a,b){var weightA=that.getCycleWeight(a),weightB=that.getCycleWeight(b);return weightA-weightB}),this.cycles=cycles},getCycleWeight:function(cycle){return cycle.elements.length},pointInCycle:function(p,cycle){var i,v=this.vertices,idx=cycle.elements,n=idx.length-1,c=!1,j=0;for(i=0,j=n-1;i<n;j=i++){var start=v[idx[i].start],end=v[idx[j].start];start.y>p.y!=end.y>p.y&&p.x<(end.x-start.x)*(p.y-start.y)/(end.y-start.y)+start.x&&(c=!c)}return c},cyclesOverlap:function(a,b){for(var center=new THREE.Vector2,edgesA=a.difference(b).elements,v=this.vertices,i=0;i<edgesA.length;i++){var edge=edgesA[i];if(center.x=(v[edge.start].x+v[edge.end].x)/2,center.y=(v[edge.start].y+v[edge.end].y)/2,this.pointInCycle(center,b))return!0}for(var edgesB=b.difference(a).elements,i=0;i<edgesB.length;i++){var edge=edgesB[i];if(center.x=(v[edge.start].x+v[edge.end].x)/2,center.y=(v[edge.start].y+v[edge.end].y)/2,this.pointInCycle(center,a))return!0}return!1},selectCyclesNonOverlapping:function(){for(var n=this.cycles.length,graph=new GS.Graph,i=0;i<n;i++)graph.addVertex(i);for(var i=0;i<n-1;i++)for(var j=i+1;j<n;j++)graph.addEdge(i,j);for(var i=0;i<n-1;i++)for(var j=i+1;j<n;j++)this.cyclesOverlap(this.cycles[i],this.cycles[j])&&graph.removeEdge(i,j);graph.computeMaximalCliques(),graph.maximalCliques.length>0&&(this.minimumCycleBasis=graph.maximalCliques[0].elements)},selectCyclesHorton:function(){for(var m=this.cycles.length,n=this.edges.length,matrix=new GS.Matrix(m,n),i=0;i<m;i++)for(var j=0;j<n;j++)this.cycles[i].elemExists(this.edges[j])&&(matrix.matrix[i][j]=1);matrix.binaryGaussianElimination(),this.minimumCycleBasis=matrix.getNonZeroRowIndices()},removeNonCycleEdges:function(){this.nonCycleVertices=[];for(var i=this.vertices.length-1;i>=0;i--){for(var exists=!1,j=0;j<this.cycles.length;j++){var cycle=this.cycles[j];if(cycle.elemExists(i)){exists=!0;break}}if(!exists){this.nonCycleVertices.push(i);for(var j=this.edges.length-1;j>=0;j--){var edge=this.edges[j];edge.start!=i&&edge.end!=i||this.edges.splice(j,1)}}}}}),GS.Set=function(source,equalsFunc){this.equalsFunc=equalsFunc||function(a,b){return a==b},this.elements=void 0!==source?source:[]},GS.Set.prototype={add:function(elem){return this.elemExists(elem)||this.elements.push(elem),this},remove:function(elem){for(var i=0;i<this.elements.length;i++)if(this.equalsFunc(this.elements[i],elem)){this.elements.splice(i,1);break}return this},elemExists:function(elem){for(var i=0;i<this.elements.length;i++)if(this.equalsFunc(this.elements[i],elem))return!0;return!1},intersection:function(set){for(var elements=set.elements,it=[],i=0;i<this.elements.length;i++)for(var j=0;j<elements.length;j++)this.equalsFunc(this.elements[i],elements[j])&&it.push(this.elements[i]);return new GS.Set(it,this.equalsFunc)},union:function(set){for(var un=new GS.Set(this.elements.slice(),this.equalsFunc),elements=set.elements,i=0;i<elements.length;i++)un.add(elements[i]);return un},difference:function(set){for(var diff=[],i=0;i<this.elements.length;i++)set.elemExists(this.elements[i])||diff.push(this.elements[i]);return new GS.Set(diff,this.equalsFunc)},equals:function(set){var diff1=this.difference(set),diff2=set.difference(this);return 0===diff1.elements.length&&0===diff2.elements.length},clone:function(){return new GS.Set(this.elements.slice(),this.equalsFunc)}},GS.Matrix=function(m,n){for(var matrix=[],i=0;i<m;i++){matrix[i]=[];for(var j=0;j<n;j++)matrix[i].push(0)}this.matrix=matrix,this.rowCount=m,this.columnCount=n},GS.Matrix.prototype={binaryGaussianElimination:function(){for(var that=this,addRow=function(r0,r1){for(var i=0;i<that.columnCount;i++)that.matrix[r0][i]=that.matrix[r0][i]^that.matrix[r1][i]},i=0;i<this.rowCount;i++){for(var found=!1,j=0;j<this.columnCount;j++)if(1==this.matrix[i][j]){found=!0;break}if(found)for(var k=0;k<this.rowCount;k++)k!=i&&1==this.matrix[k][j]&&addRow(k,i)}},clear:function(value){value=value||0;for(var i=0;i<this.rowCount;i++)for(var j=0;j<this.columnCount;j++)this.matrix[i][j]=value},getNonZeroRowIndices:function(){for(var rowIndices=[],i=0;i<this.rowCount;i++){for(var nonZero=!1,j=0;j<this.columnCount;j++)if(this.matrix[i][j]>0){nonZero=!0;break}nonZero&&rowIndices.push(i)}return rowIndices},toString:function(){for(var str="",i=0;i<this.rowCount;i++){for(var j=0;j<this.columnCount;j++)str+=this.matrix[i][j]+" ";str+="\n"}return str}},GS.Rebound=function(keybinds){this.keybinds=keybinds,this.modifyingKeybind=!1,this.onModifyingKeybindStart=function(){},this.onModifyingKeybindStop=function(){}},GS.Rebound.prototype={init:function(){var that=this;$(document).on("keydown.keybindUse",function(e){if(!that.modifyingKeybind){var keybind=_.find(that.keybinds,{code:e.keyCode});keybind&&(keybind.inUse=!0,e.preventDefault())}}),$(document).on("keyup.keybindUse",function(e){if(!that.modifyingKeybind){var keybind=_.find(that.keybinds,{code:e.keyCode});keybind&&(keybind.inUse=!1,e.preventDefault())}}),$(document).on("mousedown.keybindUse",function(e){if(!that.modifyingKeybind){var keybind=_.find(that.keybinds,{mouse:!0,button:e.which});keybind&&(keybind.inUse=!0,e.preventDefault())}}),$(document).on("mouseup.keybindUse",function(e){if(!that.modifyingKeybind){var keybind=_.find(that.keybinds,{mouse:!0,button:e.which});keybind&&(keybind.inUse=!1,e.preventDefault())}})},getKeybindByActionName:function(actionName){return _.find(this.keybinds,{actionName:actionName})},modifyKeybind:function(keybind){var that=this;this.modifyingKeybind||(this.modifyingKeybind=!0,this.onModifyingKeybindStart({keybind:keybind}),$(document).on("keydown.modifyKeybind",function(e){e.keyCode||e.which;$(document).off("keydown.modifyKeybind"),$(document).off("mousedown.modifyKeybind");var ok=that.changeKey(keybind,e);that.modifyingKeybind=!1,that.onModifyingKeybindStop({keybind:keybind,success:ok}),e.preventDefault()}),$(document).on("mousedown.modifyKeybind",function(e){e.keyCode||e.which;$(document).off("keydown.modifyKeybind"),$(document).off("mousedown.modifyKeybind");var ok=that.changeMouse(keybind,e);that.modifyingKeybind=!1,that.onModifyingKeybindStop({keybind:keybind,success:ok}),e.preventDefault()}))},changeKey:function(keybind,e){var name=this.isKeyAllowed(e);if(!name)return!1;e.preventDefault();var code=e.keyCode,existing=_.find(this.keybinds,{code:code});return existing&&(existing.code=void 0,existing.mouse=void 0,existing.button=void 0,existing.controlName="NOT BOUND"),keybind.code=code,keybind.mouse=void 0,keybind.button=void 0,keybind.controlName=name,!0},changeMouse:function(keybind,e){var name;if(1===e.which?name="MOUSE LEFT":2===e.which&&(name="MOUSE MIDDLE"),!name)return!1;var existing=_.find(this.keybinds,{mouse:!0,button:e.which});return existing&&(existing.code=void 0,existing.mouse=void 0,existing.button=void 0,existing.controlName="NOT BOUND"),keybind.code=void 0,keybind.mouse=!0,keybind.button=e.which,keybind.controlName=name,!0},isKeyAllowed:function(e){if(e.keyCode>=65&&e.keyCode<=90)return String.fromCharCode(e.keyCode);if(e.keyCode>=48&&e.keyCode<=57)return String.fromCharCode(e.keyCode);if(e.keyCode>=37&&e.keyCode<=40)return e.originalEvent.keyIdentifier.toUpperCase();if(e.keyCode>=16&&e.keyCode<=18)return e.originalEvent.keyIdentifier.toUpperCase();switch(e.keyCode){case 32:return"SPACE";case 13:return"ENTER";case 8:return"BACKSPACE";case 91:case 93:return"COMMAND"}return!1}},GS.DebugUI={fontSize:24,maxTempLines:5,defaultTimeout:GS.msToFrames(5e3),overlayMargin:10,overlayPadding:5,overlayWidth:0,overlayHeight:0,overlayX:0,overlayY:0,visibleStaticLines:0,staticLines:{},tempLines:[],valueTracking:{},hasChanged:!1,_visible:!1,set visible(value){this._visible=value,!value&&this.ctx&&this.ctx.clearRect(0,0,this.width,this.height)},get visible(){return this._visible},init:function(){var that=this;this.minWidth=1280,this.minHeight=720,this.width=window.innerWidth,this.height=window.innerHeight,window.addEventListener("resize",function(){that.onResize()},!1);var canvas=document.createElement("canvas");canvas.id="debug-ui-canvas",canvas.width=this.width,canvas.height=this.height,canvas.style.backgroundColor="rgba(0, 0, 0, 0)",canvas.style.zIndex=100,this.canvas=canvas;var ctx=canvas.getContext("2d");ctx.globalCompositeOperation="source-over",ctx.save(),this.ctx=ctx,this.updateFont(),document.body.appendChild(this.canvas),this.onResize()},update:function(){for(var i=this.tempLines.length-1;i>=0;i--){var line=this.tempLines[i];line.timeout--,0===line.timeout&&(this.tempLines.splice(i,1),this.hasChanged=!0)}this.hasChanged&&(this.calculateOverlayCoords(),this.draw(),this.hasChanged=!1)},draw:function(){if(this._visible&&(this.ctx.clearRect(0,0,this.width,this.height),this.visibleStaticLines>0||this.tempLines.length>0)){this.ctx.save(),this.ctx.fillStyle="rgba(0, 0, 0, 0.5)",this.ctx.fillRect(this.overlayX,this.overlayY,this.overlayWidth,this.overlayHeight),this.ctx.fillStyle="#fff";var y=this.overlayY+this.overlayPadding;for(var i in this.staticLines)this.staticLines[i].visible&&(this.ctx.fillText(this.staticLines[i].text,this.overlayX+this.overlayPadding,y),y+=this.fontSize+this.overlayPadding);for(var i=0;i<this.tempLines.length;i++)this.ctx.fillText(this.tempLines[i].text,this.overlayX+this.overlayPadding,y),y+=this.fontSize+this.overlayPadding;this.ctx.restore()}},updateFont:function(){this.ctx.font=this.fontSize+"px 'Lucida Console', Monaco, monospace",this.ctx.textBaseline="top"},calculateOverlayCoords:function(){this.overlayWidth=0,this.visibleStaticLines=0;for(var i in this.staticLines)this.staticLines[i].visible&&this.visibleStaticLines++;this.overlayHeight=(this.visibleStaticLines+this.tempLines.length)*(this.fontSize+this.overlayPadding)+this.overlayPadding,this.overlayX=this.overlayMargin,this.overlayY=this.overlayMargin;for(var i in this.staticLines)this.staticLines[i].visible&&(this.overlayWidth=Math.max(this.overlayWidth,this.ctx.measureText(this.staticLines[i].text).width+2*this.overlayPadding));for(var i=0;i<this.tempLines.length;i++)this.overlayWidth=Math.max(this.overlayWidth,this.ctx.measureText(this.tempLines[i].text).width+2*this.overlayPadding)},trackNumericValue:function(id,numericValue){void 0===this.valueTracking[id]&&(this.valueTracking[id]={},this.valueTracking[id].min=1/0,this.valueTracking[id].max=-(1/0),this.valueTracking[id].avg=0,this.valueTracking[id].count=0);var v=this.valueTracking[id];v.min=Math.min(v.min,numericValue),v.max=Math.max(v.max,numericValue),v.count++,v.avg+=(numericValue-v.avg)/v.count,this.setStaticLine(id,numericValue+" (min: "+v.min+", max: "+v.max+", avg: "+v.avg.toFixed(0)+")")},setStaticLine:function(id,text){text=id+": "+text,id in this.staticLines?this.staticLines[id].text=text:this.staticLines[id]={text:text,visible:!0},this.hasChanged=!0},removeStaticLine:function(id){delete this.staticLines[id],this.hasChanged=!0},setStaticLineVisibility:function(id,value){id in this.staticLines?this.staticLines[id].visible=value===!0:this.staticLines[id]={text:"",visible:value}},getStaticLineVisibility:function(id){if(id in this.staticLines)return this.staticLines[id].visible},addTempLine:function(text,timeout){this.tempLines.length==this.maxTempLines&&this.tempLines.shift(),timeout=void 0!==timeout?timeout:this.defaultTimeout;var line={text:text,timeout:timeout};this.tempLines.push(line),this.hasChanged=!0},onResize:function(){this.width=Math.max(window.innerWidth,this.minWidth),this.height=Math.max(window.innerHeight,this.minHeight),this.canvas.width=this.width,this.canvas.height=this.height,$(this.canvas).css("width",window.innerWidth+"px").css("height",window.innerHeight+"px"),this.ctx.font=this.fontSize+"px 'Lucida Console', Monaco, monospace",this.ctx.textBaseline="top",this.draw()}},GS.LoadingUI=function(){this.redraw=!0,this.hidden=!0,this.spinnerOnly=!1,this.screenInfo={width:null,height:null,center:new THREE.Vector2},this.loadingBox={width:.5,height:.05,contentPadding:.005,topLeft:new THREE.Vector2,bottomRight:new THREE.Vector2,contentTopLeft:new THREE.Vector2,contentBottomRight:new THREE.Vector2,contentCurrentBottomRight:new THREE.Vector2},this.percentLoaded=0},GS.LoadingUI.prototype={init:function(){this.cvs=new GS.Canvas2d((!0)),this.cvs.canvasId="loading-canvas",this.cvs.init(),this.cvs.screenCanvas.style.zIndex=50,this.onResize()},draw:function(){!this.hidden&&this.redraw&&(this.redraw=!1,this.cvs.clear(),this.spinnerOnly?this.cvs.text(this.screenInfo.center,"Imagine it's 1994...","#fff",40,"middle","center",GS.UIFont):(this.cvs.box(this.loadingBox.topLeft,this.loadingBox.bottomRight,"#fff",3),this.cvs.boxFill(this.loadingBox.contentTopLeft,this.loadingBox.contentCurrentBottomRight,"#fff")),this.cvs.flip())},updateProgress:function(e){this.percentLoaded=e.percentLoaded},updateLoadingBoxContent:function(){var width=this.loadingBox.contentBottomRight.x-this.loadingBox.contentTopLeft.x;this.loadingBox.contentCurrentBottomRight.x=this.loadingBox.contentTopLeft.x+Math.floor(width*this.percentLoaded*.01),this.redraw=!0},show:function(){this.cvs.show(),this.hidden=!1},hide:function(){this.cvs.hide(),this.hidden=!0},onResize:function(){this.screenInfo.width=this.cvs.bufferCanvas.width,this.screenInfo.height=this.cvs.bufferCanvas.height,this.screenInfo.center.set(Math.floor(this.screenInfo.width/2),Math.floor(this.screenInfo.height/2)),this.loadingBox.topLeft.copy(this.screenInfo.center),this.loadingBox.topLeft.x-=Math.floor(.5*this.loadingBox.width*this.screenInfo.width),this.loadingBox.topLeft.y-=Math.floor(.5*this.loadingBox.height*this.screenInfo.height),this.loadingBox.bottomRight.copy(this.screenInfo.center),this.loadingBox.bottomRight.x+=Math.floor(.5*this.loadingBox.width*this.screenInfo.width),this.loadingBox.bottomRight.y+=Math.floor(.5*this.loadingBox.height*this.screenInfo.height),this.loadingBox.contentTopLeft.copy(this.loadingBox.topLeft),this.loadingBox.contentTopLeft.x+=Math.floor(this.loadingBox.contentPadding*this.screenInfo.width),this.loadingBox.contentTopLeft.y+=Math.floor(this.loadingBox.contentPadding*this.screenInfo.width),this.loadingBox.contentBottomRight.copy(this.loadingBox.bottomRight),this.loadingBox.contentBottomRight.x-=Math.floor(this.loadingBox.contentPadding*this.screenInfo.width),this.loadingBox.contentBottomRight.y-=Math.floor(this.loadingBox.contentPadding*this.screenInfo.width),this.loadingBox.contentCurrentBottomRight.y=this.loadingBox.contentBottomRight.y,this.updateLoadingBoxContent()},set percentLoaded(value){this._percentLoaded=value,this.updateLoadingBoxContent()},get percentLoaded(){return this._percentLoaded}},GS.UIColors={background:"rgba(0, 0, 0, 0.75)",menuBackground:"rgba(0, 0, 0, 0.9)",foreground:"rgba(255, 255, 255, 1)",foregroundDisabled:"rgba(64, 64, 64, 1)",buttonHover:"rgba(128, 0, 0, 0.5)",buttonActive:"rgba(255, 0, 0, 0.5)"},GS.UIFont="hudFont",GS.UIComponents=GS.UIComponents||{},GS.UIManager=function(){this.reset(),this.menuOnly=!0,this.menuActive=!1,this.menuBackOffset=new THREE.Vector2(0,0),this.menuBackPos=new THREE.Vector2(0,0),this.menuBackSize=new THREE.Vector2(1,1),this.showHUD=GS.Settings.showHUD},GS.UIManager.prototype={constructor:GS.UIManager,reset:function(){this.grid=void 0,this.hidden=!0},init:function(){this.cvs=new GS.Canvas2d((!0)),this.cvs.alpha=0,this.cvs.canvasId="ui-canvas",this.cvs.redrawOnResize=!1,this.cvs.init(),this.cvs.screenCanvas.style.zIndex=30,this.vectorCanvas=new GS.VectorCanvas(this.cvs),this.vectorCanvas.init()},initComponents:function(assets,grid){this.grid=grid,this.assets={images:assets[GS.AssetTypes.UIWidget]},this.components=[],void 0!==this.grid&&(this.powerBars=new GS.UIComponents.PowerBars(this.vectorCanvas,this.assets,this.grid.player),this.powerBars.init(),this.components.push(this.powerBars),this.crosshair=new GS.UIComponents.Crosshair(this.vectorCanvas,this.assets,this.grid.player),this.crosshair.init(),this.components.push(this.crosshair),this.notifications=new GS.UIComponents.Notifications(this.vectorCanvas,this.assets,this.grid.player),this.notifications.init(),this.components.push(this.notifications),this.winScreen=new GS.UIComponents.WinScreen(this.vectorCanvas,this.assets,this.grid.player),this.winScreen.init(),this.components.push(this.winScreen),this.automap=new GS.UIComponents.Automap(this.vectorCanvas,this.assets,this.grid.player),this.automap.init(),this.components.push(this.automap)),void 0===this.menu&&(this.menu=new GS.UIComponents.Menu(this.vectorCanvas,this.assets),this.menu.init()),this.overrideRedraw=!0},show:function(){this.overrideRedraw=!0,this.cvs.show(),this.hidden=!1},hide:function(){this.cvs.hide(),this.hidden=!0},update:function(){for(var i=0;i<this.components.length;i++)this.components[i].update();this.menuActive&&this.menu.update()},draw:function(){if(this.menuActive)this.cvs.clear(),this.menuOnly&&this.vectorCanvas.drawImage(this.menuBackOffset,this.menuBackPos,this.assets.images.menu_back,this.menuBackSize,!1),this.menu.draw(),this.cvs.flip();else if(this.winScreen.visible)this.cvs.clear(),this.winScreen.draw(),this.cvs.flip();else if(this.automap.visible)(this.overrideRedraw||this.automap.needsRedraw)&&(this.overrideRedraw&&(this.overrideRedraw=!1),this.cvs.clear(),this.automap.draw(),this.automap.needsRedraw=!1,this.cvs.flip());else if(!this.hidden&&this.checkIfRedraw()){if(this.cvs.clear(),this.showHUD)for(var i=0;i<this.components.length;i++)this.components[i].visible&&(this.components[i].draw(),this.components[i].needsRedraw=!1);this.cvs.flip()}},checkIfRedraw:function(){if(this.overrideRedraw)return this.overrideRedraw=!1,!0;for(var i=0;i<this.components.length;i++)if(this.components[i].visible&&this.components[i].needsRedraw)return!0;return!1},removeNewsBox:function(){this.menu.removeNewsBox()},useIngameMenu:function(){this.menuOnly=!1,this.menu.switchToIngame()},onResize:function(){this.overrideRedraw=!0,this.vectorCanvas.onResize(),GS.InputHelper.screenRatioX=this.cvs.bufferCanvas.width/window.innerWidth,GS.InputHelper.screenRatioY=this.cvs.bufferCanvas.height/window.innerHeight},dispose:function(){this.grid=void 0,this.powerBars=void 0,this.crosshair=void 0,this.notifications=void 0,this.winScreen=void 0,this.components=[]}},GS.VectorCanvas=function(canvas2d){this.cvs=canvas2d,this.ratio=new THREE.Vector2},GS.VectorCanvas.prototype={constructor:GS.VectorCanvas,init:function(){this.onResize()},onResize:function(){this.ratio.set(this.cvs.bufferCanvas.width,this.cvs.bufferCanvas.height)},convertToScreenCoords:function(v0,v,fixedOffset){v.x=Math.floor(v0.x*this.ratio.x),v.y=Math.floor(v0.y*this.ratio.y),void 0!==fixedOffset&&(v.x+=fixedOffset.x,v.y+=fixedOffset.y)},fixedLine:function(){var v0=new THREE.Vector2,v1=new THREE.Vector2;return function(pos,p0,p1,color,lineWidth){this.convertToScreenCoords(pos,v0,p0),this.convertToScreenCoords(pos,v1,p1),this.cvs.line(v0,v1,color,lineWidth)}}(),line:function(){var v0=new THREE.Vector2,v1=new THREE.Vector2;return function(fixedOffset,pos,lineOffset,isFixedLineOffset,color,lineWidth){
this.convertToScreenCoords(pos,v0,fixedOffset),isFixedLineOffset?v1.copy(v0).add(lineOffset):(this.convertToScreenCoords(lineOffset,v1),v1.add(v0)),this.cvs.line(v0,v1,color,lineWidth)}}(),box:function(){var v0=new THREE.Vector2,v1=new THREE.Vector2;return function(fixedOffset,pos,size,isFixedSize,color,lineWidth){this.convertToScreenCoords(pos,v0,fixedOffset),isFixedSize?v1.copy(v0).add(size):(this.convertToScreenCoords(size,v1),v1.add(v0)),this.cvs.box(v0,v1,color,lineWidth)}}(),boxFill:function(){var v0=new THREE.Vector2,v1=new THREE.Vector2;return function(fixedOffset,pos,size,isFixedSize,color){this.convertToScreenCoords(pos,v0,fixedOffset),isFixedSize?v1.copy(v0).add(size):(this.convertToScreenCoords(size,v1),v1.add(v0)),this.cvs.boxFill(v0,v1,color)}}(),circle:function(){var v=new THREE.Vector2;return function(fixedOffset,pos,radius,color,lineWidth){this.convertToScreenCoords(pos,v,fixedOffset),this.cvs.circle(v,radius,color,lineWidth)}}(),circleFill:function(){var v=new THREE.Vector2;return function(fixedOffset,pos,radius,color){this.convertToScreenCoords(pos,v,fixedOffset),this.cvs.circleFill(v,radius,color)}}(),text:function(){var v=new THREE.Vector2;return function(fixedOffset,pos,str,color,fontSize,textBaseline,textAlign,fontFamily){this.convertToScreenCoords(pos,v,fixedOffset),this.cvs.text(v,str,color,fontSize,textBaseline,textAlign,fontFamily)}}(),drawImage:function(){var v0=new THREE.Vector2,v1=new THREE.Vector2;return function(fixedOffset,pos,img,size,isFixedSize){this.convertToScreenCoords(pos,v0,fixedOffset),isFixedSize?v1.copy(size):this.convertToScreenCoords(size,v1),this.cvs.drawImage(v0,img,v1)}}(),drawImageFromAtlas:function(){var v=new THREE.Vector2;return function(fixedOffset,pos,img,atlasOffset,atlasSize){this.convertToScreenCoords(pos,v,fixedOffset),this.cvs.drawImageFromAtlas(v,img,atlasOffset,atlasSize)}}(),getTextWidth:function(str,fontSize,fontFamily){return this.cvs.getTextWidth(str,fontSize,fontFamily)},roundedBox:function(){var v0=new THREE.Vector2,v1=new THREE.Vector2;return function(fixedOffset,pos,size,isFixedSize,radius,color,lineWidth){this.convertToScreenCoords(pos,v0,fixedOffset),isFixedSize?v1.copy(v0).add(size):(this.convertToScreenCoords(size,v1),v1.add(v0)),this.cvs.roundedBox(v0,v1,radius,color,lineWidth)}}(),roundedBoxFill:function(){var v0=new THREE.Vector2,v1=new THREE.Vector2;return function(fixedOffset,pos,size,isFixedSize,radius,color){this.convertToScreenCoords(pos,v0,fixedOffset),isFixedSize?v1.copy(v0).add(size):(this.convertToScreenCoords(size,v1),v1.add(v0)),this.cvs.roundedBoxFill(v0,v1,radius,color)}}()},GS.UIComponents.Automap=function(vectorCanvas,assets,player){this.cvs=vectorCanvas,this.assets=assets,this.player=player,this.aiManager=player.grid.aiManager,this.background={offset:new THREE.Vector2(0,0),pos:new THREE.Vector2(0,0),size:new THREE.Vector2(1,1)},this.playerDraw={offset:new THREE.Vector2(0,0),pos:new THREE.Vector2(.5,.5)},this.mapDraw={offset:new THREE.Vector2(0,0),pos:new THREE.Vector2(.5,.5)},this.backgroundColor=GS.UIColors.menuBackground,this.oldRegionsDiscovered=Object.keys(this.aiManager.regionsDiscovered).length,this.oldPlayerPosition=this.player.position.toVector2(),this.currentPlayerPosition=this.player.position.toVector2(),this.oldPlayerDirection=this.player.direction.toVector2(),this.currentPlayerDirection=this.player.direction.toVector2(),this.zoomSpeed=.25,this.minZoom=.5,this.maxZoom=4,this.zoom=2,this.visible=!1},GS.UIComponents.Automap.prototype={constructor:GS.UIComponents.Automap,init:function(){},update:function(){var regionsDiscovered=Object.keys(this.aiManager.regionsDiscovered).length;for(regionsDiscovered>this.oldRegionsDiscovered&&(this.needsRedraw=!0,this.oldRegionsDiscovered=regionsDiscovered),this.player.position.toVector2(this.currentPlayerPosition),this.currentPlayerPosition.equalsEpsilon(this.oldPlayerPosition)||(this.needsRedraw=!0,this.oldPlayerPosition.copy(this.currentPlayerPosition)),this.player.direction.toVector2(this.currentPlayerDirection),this.currentPlayerDirection.equalsEpsilon(this.oldPlayerDirection)||(this.needsRedraw=!0,this.oldPlayerDirection.copy(this.currentPlayerDirection));GS.InputHelper.mouseWheelEvents.length>0;){var delta=GS.InputHelper.mouseWheelEvents.shift();delta<0&&(this.zoom-=this.zoomSpeed),delta>0&&(this.zoom+=this.zoomSpeed),this.zoom=GS.MathHelper.clamp(this.zoom,this.minZoom,this.maxZoom),this.needsRedraw=!0}},draw:function(){this.cvs.boxFill(this.background.offset,this.background.pos,this.background.size,!1,this.backgroundColor);var regionsDiscovered=this.aiManager.regionsDiscovered;for(var i in regionsDiscovered)this.drawRegion(regionsDiscovered[i]);this.drawPlayer()},drawPlayer:function(){var p0=new THREE.Vector2,p1=new THREE.Vector2,p2=new THREE.Vector2,color=(new THREE.Vector2,"rgba(192, 192, 192, 1)");return function(){var size=this.player.size.x*this.zoom,xAngle=this.player.xAngle;p0.x=size*Math.sin(Math.PI/180*(450-xAngle)),p0.y=size*Math.cos(Math.PI/180*(450-xAngle)),p1.x=size*Math.sin(Math.PI/180*(300-xAngle)),p1.y=size*Math.cos(Math.PI/180*(300-xAngle)),p2.x=size*Math.sin(Math.PI/180*(240-xAngle)),p2.y=size*Math.cos(Math.PI/180*(240-xAngle)),this.cvs.fixedLine(this.mapDraw.pos,p0,p1,color,3),this.cvs.fixedLine(this.mapDraw.pos,p1,p2,color,3),this.cvs.fixedLine(this.mapDraw.pos,p2,p0,color,3)}}(),drawRegion:function(){var p0=new THREE.Vector2,p1=new THREE.Vector2,wallColor="rgba(64, 64, 64, 1)",doorColor="rgba(128, 0, 0, 1)";return function(region){function drawSectorLine(sector,x0,x1,color,lineWidth){p0.copy(sector.collisionVertices[x0]),p1.copy(sector.collisionVertices[x1]),p0.sub(that.currentPlayerPosition).multiplyScalar(that.zoom),p1.sub(that.currentPlayerPosition).multiplyScalar(that.zoom),p1.sub(p0),that.cvs.line(p0,that.mapDraw.pos,p1,!0,color,lineWidth)}var that=this,sectorDict=this.aiManager.sectorDict;for(var i in region.sectorIds){var sector=sectorDict[i].sector;if(!sector.door){for(var j=0;j<sector.collisionVertices.length-1;j++)drawSectorLine(sector,j,j+1,wallColor,1);drawSectorLine(sector,j,0,wallColor,1)}}for(var i in region.sectorIds){var sector=sectorDict[i].sector;if(sector.door&§or.doorOpenedEver){for(var j=0;j<sector.collisionVertices.length-1;j++)drawSectorLine(sector,j,j+1,doorColor,3);drawSectorLine(sector,j,0,doorColor,3)}}}}()},GS.UIComponents.Crosshair=function(vectorCanvas,assets,player){this.cvs=vectorCanvas,this.assets=assets,this.player=player,this.size=10,this.lineWidth=3,this.pos=new THREE.Vector2(.5,.5),this.hOffset=new THREE.Vector2((-this.size),0),this.hLineOffset=new THREE.Vector2(2*this.size,0),this.vOffset=new THREE.Vector2(0,(-this.size)),this.vLineOffset=new THREE.Vector2(0,2*this.size),this.visible=!0},GS.UIComponents.Crosshair.prototype={constructor:GS.UIComponents.Crosshair,init:function(){},update:function(){},draw:function(){this.cvs.line(this.hOffset,this.pos,this.hLineOffset,!0,GS.UIColors.foreground,this.lineWidth),this.cvs.line(this.vOffset,this.pos,this.vLineOffset,!0,GS.UIColors.foreground,this.lineWidth)}},GS.UIComponents.Menu=function(vectorCanvas,assets){this.cvs=vectorCanvas,this.assets=assets,this.fontSize=60,this.boxCornerRadius=10,this.background={offset:new THREE.Vector2(0,0),pos:new THREE.Vector2(0,0),size:new THREE.Vector2(1,1)},this.text={offset:new THREE.Vector2(0,0),pos:new THREE.Vector2(.5,.5)},this.logo={offset:new THREE.Vector2((-300),(-384)),pos:new THREE.Vector2(.5,.5),size:new THREE.Vector2(600,200),image:this.assets.images.logo},this.children=[],this.activePanel=null,this.backgroundColor=GS.UIColors.menuBackground,this.ingame=!1,this.visible=!0},GS.UIComponents.Menu.prototype={constructor:GS.UIComponents.Menu,init:function(){this.initTopPanel(),this.initOptionsPanel(),this.initGraphicsPanel(),this.initSoundPanel(),this.initGameplayPanel(),this.initControlsPanel(),this.initCreditsPanel(),this.initCheatsPanel(),this.initLevelSelectPanel(),this.initFooter(),this.initNewsBox(),this.activePanel=this.topPanel},initTopPanel:function(){var that=this;this.topPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),72,80),this.btnNewGame=this.topPanel.addButton("new game"),this.btnNewGame.onClick=function(){GAME.newGame()},this.btnSteamPage=this.topPanel.addButton("steam page"),this.btnSteamPage.onClick=function(){var a=document.createElement("a");a.href="https://goo.gl/akICRV",document.body.appendChild(a),a.click(),document.body.removeChild(a)},this.btnLevelSelect=this.topPanel.addButton("level select"),this.btnLevelSelect.onClick=function(){that.activePanel=that.levelSelectPanel},this.btnOptions=this.topPanel.addButton("options"),this.btnOptions.onClick=function(){that.activePanel=that.optionsPanel},this.btnCredits=this.topPanel.addButton("credits"),this.btnCredits.onClick=function(){that.activePanel=that.creditsPanel},this.btnSubscribe=this.topPanel.addButton("subscribe"),this.btnSubscribe.onClick=function(){var a=document.createElement("a");a.href="http://eepurl.com/cEkb3T",document.body.appendChild(a),a.click(),document.body.removeChild(a)}},initOptionsPanel:function(){var that=this;this.optionsPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),60,65),this.btnGraphics=this.optionsPanel.addButton("graphics"),this.btnGraphics.onClick=function(){that.activePanel=that.graphicsPanel},this.btnSound=this.optionsPanel.addButton("sound"),this.btnSound.onClick=function(){that.activePanel=that.soundPanel},this.btnGameplay=this.optionsPanel.addButton("gameplay"),this.btnGameplay.onClick=function(){that.activePanel=that.gameplayPanel},this.btnControls=this.optionsPanel.addButton("controls"),this.btnControls.onClick=function(){that.activePanel=that.controlsPanel},this.btnCheats=this.optionsPanel.addButton("cheats"),this.btnCheats.disabled=!0,this.btnCheats.onClick=function(){that.activePanel=that.cheatsPanel},this.optionsPanel.addEmptyRow(),this.btnOptionsBack=this.optionsPanel.addButton("back"),this.btnOptionsBack.onClick=function(){that.activePanel=that.topPanel}},initGraphicsPanel:function(){var that=this;this.graphicsPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),40,43),this.btnToggleHalfSize=this.graphicsPanel.addToggleButton("half-size rendering"),this.btnToggleHalfSize.button.currentStateIndex=GS.Settings.halfSize===!0?0:1,this.btnToggleHalfSize.button.onClick=function(e){GS.Settings.halfSize="on"===e.state},this.graphicsPanel.addEmptyRow(),this.btnToggleSSAO=this.graphicsPanel.addToggleButton("SSAO"),this.btnToggleSSAO.button.currentStateIndex=GS.Settings.ssao===!0?0:1,this.btnToggleSSAO.button.onClick=function(e){GS.Settings.ssao="on"===e.state},this.btnToggleBloom=this.graphicsPanel.addToggleButton("bloom"),this.btnToggleBloom.button.currentStateIndex=GS.Settings.bloom===!0?0:1,this.btnToggleBloom.button.onClick=function(e){GS.Settings.bloom="on"===e.state},this.btnToggleNoise=this.graphicsPanel.addToggleButton("noise filter"),this.btnToggleNoise.button.currentStateIndex=GS.Settings.noise===!0?0:1,this.btnToggleNoise.button.onClick=function(e){GS.Settings.noise="on"===e.state},this.btnToggleVignette=this.graphicsPanel.addToggleButton("vignette"),this.btnToggleVignette.button.currentStateIndex=GS.Settings.vignette===!0?0:1,this.btnToggleVignette.button.onClick=function(e){GS.Settings.vignette="on"===e.state},this.btnToggleFXAA=this.graphicsPanel.addToggleButton("FXAA"),this.btnToggleFXAA.button.currentStateIndex=GS.Settings.fxaa===!0?0:1,this.btnToggleFXAA.button.onClick=function(e){GS.Settings.fxaa="on"===e.state},this.graphicsPanel.addEmptyRow(),this.numberPickerFOV=this.graphicsPanel.addNumberPicker("field of view",GS.Settings.fov,GS.Settings.fovMin,GS.Settings.fovMax,5),this.numberPickerFOV.numberPicker.onChange=function(e){GS.Settings.fov=e.value},this.btnToggleShowFPS=this.graphicsPanel.addToggleButton("show FPS"),this.btnToggleShowFPS.button.currentStateIndex=GS.Settings.showFPS===!0?0:1,this.btnToggleShowFPS.button.onClick=function(e){GS.Settings.showFPS="on"===e.state},this.graphicsPanel.addEmptyRow(),this.btnGraphicsBack=this.graphicsPanel.addButton("back"),this.btnGraphicsBack.onClick=function(){that.activePanel=that.optionsPanel}},initSoundPanel:function(){var that=this;this.soundPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),40,43),this.numberPickerSound=this.soundPanel.addNumberPicker("sound volume",GS.Settings.sound,GS.Settings.soundMin,GS.Settings.soundMax,1),this.numberPickerSound.numberPicker.onChange=function(e){GS.Settings.sound=e.value},this.numberPickerMusic=this.soundPanel.addNumberPicker("music volume",GS.Settings.music,GS.Settings.musicMin,GS.Settings.musicMax,1),this.numberPickerMusic.numberPicker.onChange=function(e){GS.Settings.music=e.value},this.soundPanel.addEmptyRow(),this.btnSoundBack=this.soundPanel.addButton("back"),this.btnSoundBack.onClick=function(){that.activePanel=that.optionsPanel}},initGameplayPanel:function(){var that=this;this.gameplayPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),40,43),this.btnToggleViewBob=this.gameplayPanel.addToggleButton("view bobbing"),this.btnToggleViewBob.button.currentStateIndex=GS.Settings.viewBob===!0?0:1,this.btnToggleViewBob.button.onClick=function(e){GS.Settings.viewBob="on"===e.state},this.btnToggleWeaponBob=this.gameplayPanel.addToggleButton("weapon bobbing"),this.btnToggleWeaponBob.button.currentStateIndex=GS.Settings.weaponBob===!0?0:1,this.btnToggleWeaponBob.button.onClick=function(e){GS.Settings.weaponBob="on"===e.state},this.gameplayPanel.addEmptyRow(),this.btnToggleShowHUD=this.gameplayPanel.addToggleButton("show HUD"),this.btnToggleShowHUD.button.currentStateIndex=GS.Settings.showHUD===!0?0:1,this.btnToggleShowHUD.button.onClick=function(e){GS.Settings.showHUD="on"===e.state},this.btnToggleShowWeapon=this.gameplayPanel.addToggleButton("show weapon"),this.btnToggleShowWeapon.button.currentStateIndex=GS.Settings.showWeapon===!0?0:1,this.btnToggleShowWeapon.button.onClick=function(e){GS.Settings.showWeapon="on"===e.state},this.gameplayPanel.addEmptyRow(),this.btnGameplayBack=this.gameplayPanel.addButton("back"),this.btnGameplayBack.onClick=function(){that.activePanel=that.optionsPanel}},initCheatsPanel:function(){var that=this;this.cheatsPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),40,43),this.btnToggleGod=this.cheatsPanel.addToggleButton("god mode"),this.btnToggleGod.button.currentStateIndex=1,this.btnToggleGod.button.onClick=function(e){GAME.grid.player.god(),GS.DebugUI.addTempLine("god mode "+e.state)},this.btnToggleFly=this.cheatsPanel.addToggleButton("fly mode"),this.btnToggleFly.button.currentStateIndex=1,this.btnToggleFly.button.onClick=function(e){GAME.grid.player.fly(),GS.DebugUI.addTempLine("fly mode "+e.state)},this.btnToggleNoclip=this.cheatsPanel.addToggleButton("noclip mode"),this.btnToggleNoclip.button.currentStateIndex=1,this.btnToggleNoclip.button.onClick=function(e){GAME.grid.player.noClip(),GS.DebugUI.addTempLine("noclip mode "+e.state)},this.cheatsPanel.addEmptyRow(),this.btnCheatsGiveAll=this.cheatsPanel.addButton("give ammo and all weapons"),this.btnCheatsGiveAll.onClick=function(){GAME.grid.player.giveAll(),GS.DebugUI.addTempLine("all weapons and max ammo given")},this.cheatsPanel.addEmptyRow(),this.btnCheatsBack=this.cheatsPanel.addButton("back"),this.btnCheatsBack.onClick=function(){that.activePanel=that.optionsPanel}},initLevelSelectPanel:function(){var that=this;this.levelSelectPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),60,140),this.btnLevel1=this.levelSelectPanel.addImageButton("airstrip one",this.assets.images.thumb_airstrip1),this.btnLevel1.onClick=function(){GAME.loadLevel("airstrip1")},this.btnLevel1=this.levelSelectPanel.addImageButton("drencrom",this.assets.images.thumb_drencrom),this.btnLevel1.onClick=function(){GAME.loadLevel("drencrom")},this.btnLevel2=this.levelSelectPanel.addImageButton("sacrosanct",this.assets.images.thumb_sacrosanct),this.btnLevel2.onClick=function(){GAME.loadLevel("sacrosanct")},this.levelSelectPanel.fontSize=40,this.levelSelectPanel.rowHeight=43,this.levelSelectPanel.addEmptyRow(),this.btnLevelSelectBack=this.levelSelectPanel.addButton("back"),this.btnLevelSelectBack.onClick=function(){that.activePanel=that.topPanel}},initControlsPanel:function(){var that=this;this.controlsPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),28,31),this.btnToggleMouseInvertY=this.controlsPanel.addToggleButton("invert mouse y axis"),this.btnToggleMouseInvertY.button.currentStateIndex=GS.Settings.mouseInvertY===!0?0:1,this.btnToggleMouseInvertY.button.onClick=function(e){GS.Settings.mouseInvertY="on"===e.state},this.numberPickerMouse=this.controlsPanel.addNumberPicker("mouse sensitivity",GS.Settings.mouse,GS.Settings.mouseMin,GS.Settings.mouseMax,1),this.numberPickerMouse.numberPicker.onChange=function(e){GS.Settings.mouse=e.value},this.controlsPanel.addEmptyRow(),this.btnToggleMoveForward=this.controlsPanel.addToggleButton("move forward",["W"]),this.btnToggleMoveBackward=this.controlsPanel.addToggleButton("move backward",["S"]),this.btnToggleStrafeLeft=this.controlsPanel.addToggleButton("strafe left",["A"]),this.btnToggleStrafeRight=this.controlsPanel.addToggleButton("strafe right",["D"]),this.btnToggleUse=this.controlsPanel.addToggleButton("use",["E"]),this.btnToggleShoot=this.controlsPanel.addToggleButton("shoot",["mouse left"]),this.btnTogglePistol=this.controlsPanel.addToggleButton("pistol",["2"]),this.btnToggleShotgun=this.controlsPanel.addToggleButton("shotgun",["3"]),this.btnToggleHyperBlaster=this.controlsPanel.addToggleButton("hyperblaster",["4"]),this.btnToggleAutomap=this.controlsPanel.addToggleButton("automap",["TAB"]),this.btnToggleAutomap.button.disabled=!0,this.btnToggleMenu=this.controlsPanel.addToggleButton("menu",["ESC"]),this.btnToggleMenu.button.disabled=!0,this.controlsPanel.addEmptyRow(),this.btnControlsBack=this.controlsPanel.addButton("back"),this.btnControlsBack.onClick=function(){that.activePanel=that.optionsPanel},this.attachReboundEventHandlers()},attachReboundEventHandlers:function(){function getOnClickEventHandler(actionName){return function(){GS.KeybindSettings.rebound.modifyKeybind(GS.Keybinds[actionName])}}var keyButtonMap={moveForward:this.btnToggleMoveForward,moveBackward:this.btnToggleMoveBackward,strafeLeft:this.btnToggleStrafeLeft,strafeRight:this.btnToggleStrafeRight,use:this.btnToggleUse,shoot:this.btnToggleShoot,pistol:this.btnTogglePistol,shotgun:this.btnToggleShotgun,hyperblaster:this.btnToggleHyperBlaster};for(var i in keyButtonMap){var button=keyButtonMap[i].button;button.onClick=getOnClickEventHandler(i),button.states=[GS.Keybinds[i].controlName],button.currentStateIndex=0}GS.KeybindSettings.rebound.onModifyingKeybindStart=function(e){var button=keyButtonMap[e.keybind.actionName].button;button.states=["press new key"],button.currentStateIndex=0},GS.KeybindSettings.rebound.onModifyingKeybindStop=function(e){for(var i in keyButtonMap){var button=keyButtonMap[i].button;button.states=[GS.Keybinds[i].controlName],button.currentStateIndex=0}if(e.success){var button2=keyButtonMap[e.keybind.actionName].button,onClickEventHandler=button2.onClick;button2.onClick=function(){},setTimeout(function(){button2.onClick=onClickEventHandler},100),GS.Settings.saveSettings();var notifications=GAME.uiManager.notifications;notifications&&(notifications.useText="["+GS.Keybinds.use.controlName+"] to use",notifications.calculateSizes())}}},initCreditsPanel:function(){var that=this;this.creditsPanel=new GS.UIComponents.MenuPanel(this.cvs,new THREE.Vector2((-400),(-160)),new THREE.Vector2(.5,.5),new THREE.Vector2(800,520),30,33),this.dblLabelCredits1=this.creditsPanel.addDoubleLabel('code, "art"',"sergiu valentin bucur"),this.creditsPanel.addEmptyRow(),this.dblLabelCredits23=this.creditsPanel.addDoubleLabel("music","DST"),this.dblLabelCredits24=this.creditsPanel.addDoubleLabel("","3uhox"),this.creditsPanel.addEmptyRow(),this.dblLabelCredits3=this.creditsPanel.addDoubleLabel("sound effects","freesound.org"),this.dblLabelCredits4=this.creditsPanel.addDoubleLabel("","opengameart.org"),this.creditsPanel.addEmptyRow(),this.dblLabelCredits5=this.creditsPanel.addDoubleLabel("skybox texture","alexcpeterson.com/spacescape"),this.creditsPanel.addEmptyRow(),this.dblLabelCredits6=this.creditsPanel.addDoubleLabel("frameworks","three.js"),this.dblLabelCredits7=this.creditsPanel.addDoubleLabel("","tween.js"),this.dblLabelCredits8=this.creditsPanel.addDoubleLabel("","jszip"),this.creditsPanel.addEmptyRow(),this.btnCreditsBack=this.creditsPanel.addButton("back"),this.btnCreditsBack.onClick=function(){that.activePanel=that.topPanel}},initFooter:function(){this.label1=new GS.UIComponents.MenuLabel(this.cvs,GS.GameVersion,new THREE.Vector2((-20),(-70)),new THREE.Vector2(1,1)),this.label1.textAlign="right",this.label1.fontSize=30,this.children.push(this.label1),this.label2=new GS.UIComponents.MenuLabel(this.cvs,GS.ReleaseDate,new THREE.Vector2((-20),(-35)),new THREE.Vector2(1,1)),this.label2.textAlign="right",this.label2.fontSize=30,this.children.push(this.label2)},initNewsBox:function(){this.newsBox=$(".news-box"),this.newsBox.show()},switchToIngame:function(){this.ingame=!0,this.btnCheats.disabled=!1,this.btnToggleGod.button.currentStateIndex=1,this.btnToggleFly.button.currentStateIndex=1,this.btnToggleNoclip.button.currentStateIndex=1},update:function(){this.activePanel.update();for(var i=0;i<this.children.length;i++)this.children[i].update()},draw:function(){this.ingame&&this.cvs.boxFill(this.background.offset,this.background.pos,this.background.size,!1,this.backgroundColor),this.cvs.drawImage(this.logo.offset,this.logo.pos,this.logo.image,this.logo.size,!0),this.activePanel.draw();for(var i=0;i<this.children.length;i++)this.children[i].draw()},removeNewsBox:function(){this.newsBox.remove(),this.newsBox=void 0}},GS.UIComponents.MenuButton=function(vectorCanvas,text,offset,pos,size,onClick,states){this.cvs=vectorCanvas,this.fontSize=40,this.text=text,this.textBaseline="middle",this.textAlign="center",this.offset=offset,this.pos=pos,this.size=size,this.borderRadius=10,this.onClick=onClick||function(){},this.states=states,this._currentStateIndex=0,this.min=new THREE.Vector2,this.max=new THREE.Vector2,this.textOffset=this.offset.clone().add(this.size.clone().multiplyScalar(.5)),this.hover=!1,this.active=!1,this.disabled=!1,this.backgroundColor=GS.UIColors.buttonHover,this.foregroundColor=GS.UIColors.foregroundDisabled},GS.UIComponents.MenuButton.prototype={constructor:GS.UIComponents.MenuButton,init:function(){},update:function(){var mx=GS.InputHelper.mouseX,my=GS.InputHelper.mouseY;this.cvs.convertToScreenCoords(this.pos,this.min,this.offset),this.max.copy(this.min).add(this.size),this.disabled?this.foregroundColor=GS.UIColors.foregroundDisabled:(this.foregroundColor=GS.UIColors.foreground,mx>=this.min.x&&my>=this.min.y&&mx<this.max.x&&my<this.max.y?(this.hover=!0,this.backgroundColor=GS.UIColors.buttonHover):this.hover=!1,this.hover&&(GS.InputHelper.leftMouseDown?(this.active=!0,this.backgroundColor=GS.UIColors.buttonActive):this.active&&(void 0!==this.states?(this._currentStateIndex++,this._currentStateIndex>=this.states.length&&(this._currentStateIndex=0),this.text=this.states[this._currentStateIndex],this.onClick({state:this.text,stateIndex:this._currentStateIndex})):this.onClick(),this.active=!1,this.backgroundColor=GS.UIColors.buttonHover)))},draw:function(){!this.disabled&&this.hover&&this.cvs.roundedBoxFill(this.offset,this.pos,this.size,!0,this.borderRadius,this.backgroundColor),this.cvs.text(this.textOffset,this.pos,this.text,this.foregroundColor,this.fontSize,this.textBaseline,this.textAlign,GS.UIFont)},set currentStateIndex(value){void 0!==this.states&&value>=0&&value<this.states.length&&(this._currentStateIndex=value,this.text=this.states[this._currentStateIndex])},get currentStateIndex(){return this._currentStateIndex}},GS.UIComponents.MenuImageButton=function(vectorCanvas,offset,pos,size,fontSize,text,image,onClick){this.cvs=vectorCanvas,this.fontSize=fontSize||40,this.offset=offset,this.pos=pos,this.size=size,this.text=text,this.image=image,this.onClick=onClick||function(){},this.init()},GS.UIComponents.MenuImageButton.prototype={constructor:GS.UIComponents.MenuImageButton,init:function(){var that=this,buttonOffset=this.offset.clone(),buttonSize=new THREE.Vector2(this.size.x,this.size.y),button=new GS.UIComponents.MenuButton(this.cvs,this.text,buttonOffset,this.pos,buttonSize,function(){that.onClick()});button.textOffset.x-=.1*this.size.x,button.textAlign="left",button.fontSize=this.fontSize,this.button=button,this.imageSize=new THREE.Vector2(231,130),this.imageOffset=this.offset.clone(),this.imageOffset.x+=.2*this.size.x-this.imageSize.x/2,this.imageOffset.y+=.5*this.size.y-this.imageSize.y/2},update:function(){this.button.update()},draw:function(){this.button.draw(),this.cvs.drawImage(this.imageOffset,this.pos,this.image,this.imageSize,!0)}},GS.UIComponents.MenuLabel=function(vectorCanvas,text,offset,pos){this.cvs=vectorCanvas,this.fontSize=40,this.text=text,this.textBaseline="middle",this.textAlign="center",this.offset=offset,this.pos=pos,this.foregroundColor=GS.UIColors.foreground},GS.UIComponents.MenuLabel.prototype={constructor:GS.UIComponents.MenuLabel,init:function(){},update:function(){},draw:function(){this.cvs.text(this.offset,this.pos,this.text,this.foregroundColor,this.fontSize,this.textBaseline,this.textAlign,GS.UIFont)}},GS.UIComponents.MenuNumberPicker=function(vectorCanvas,offset,pos,size,fontSize,value,min,max,step,onChange){this.cvs=vectorCanvas,this.fontSize=fontSize||40,this.offset=offset,this.pos=pos,this.size=size,this.value=void 0!==value?value:5,this.min=void 0!==min?min:1,this.max=void 0!==max?max:10,this.step=void 0!==step?step:1,this.onChange=onChange||function(){},this.init()},GS.UIComponents.MenuNumberPicker.prototype={constructor:GS.UIComponents.MenuNumberPicker,init:function(){var that=this,size=new THREE.Vector2(.2*this.size.x,this.size.y),leftOffset=this.offset.clone();this.leftButton=new GS.UIComponents.MenuButton(this.cvs,"<",leftOffset,this.pos,size),this.leftButton.fontSize=this.fontSize,this.leftButton.onClick=function(){that.value-=that.step,that.value=Math.max(that.min,that.value),that.label.text=that.value,that.onChange({value:that.value})};var rightOffset=this.offset.clone();rightOffset.x+=.8*this.size.x,this.rightButton=new GS.UIComponents.MenuButton(this.cvs,">",rightOffset,this.pos,size),this.rightButton.fontSize=this.fontSize,this.rightButton.onClick=function(){that.value+=that.step,that.value=Math.min(that.max,that.value),that.label.text=that.value,that.onChange({value:that.value})};var labelOffset=this.offset.clone();labelOffset.x+=.5*this.size.x,labelOffset.y+=.5*this.size.y,this.label=new GS.UIComponents.MenuLabel(this.cvs,this.value,labelOffset,this.pos),this.label.fontSize=this.fontSize},update:function(){this.leftButton.update(),this.rightButton.update()},draw:function(){this.leftButton.draw(),this.rightButton.draw(),this.label.draw()}},GS.UIComponents.MenuPanel=function(vectorCanvas,offset,pos,size,fontSize,rowHeight){this.cvs=vectorCanvas,this.children=[],this.fontSize=fontSize||40,this.offset=offset,this.pos=pos,this.size=size,this.rowHeight=rowHeight||40,this.rowOffset=0},GS.UIComponents.MenuPanel.prototype={constructor:GS.UIComponents.MenuPanel,init:function(){},addButton:function(text,onClick){var offset=this.getRowOffset(),size=new THREE.Vector2(this.size.x,this.rowHeight),button=new GS.UIComponents.MenuButton(this.cvs,text,offset,this.pos,size,onClick);return button.fontSize=this.fontSize,this.children.push(button),this.rowOffset+=this.rowHeight,button},addToggleButton:function(text,states,buttonSize,onClick){buttonSize=buttonSize||.2;var offset=this.getRowOffset(),labelOffset=offset.clone();labelOffset.x+=.5*this.size.x-10,labelOffset.y+=.5*this.rowHeight;var label=new GS.UIComponents.MenuLabel(this.cvs,text,labelOffset,this.pos);label.fontSize=this.fontSize,label.textAlign="right",this.children.push(label);var buttonOffset=offset.clone(),buttonSize=new THREE.Vector2(this.size.x*buttonSize,this.rowHeight);buttonOffset.x+=.5*this.size.x+10,states=states||["on","off"];var button=new GS.UIComponents.MenuButton(this.cvs,states[0],buttonOffset,this.pos,buttonSize,onClick,states);return button.fontSize=this.fontSize,this.children.push(button),this.rowOffset+=this.rowHeight,{label:label,button:button}},addDoubleLabel:function(text1,text2){var offset=this.getRowOffset(),label1Offset=offset.clone();label1Offset.x+=.5*this.size.x-30,label1Offset.y+=.5*this.rowHeight;var label1=new GS.UIComponents.MenuLabel(this.cvs,text1,label1Offset,this.pos);label1.fontSize=this.fontSize,label1.textAlign="right",this.children.push(label1);var label2Offset=offset.clone();label2Offset.x+=.5*this.size.x+30,label2Offset.y+=.5*this.rowHeight;var label2=new GS.UIComponents.MenuLabel(this.cvs,text2,label2Offset,this.pos);return label2.fontSize=this.fontSize,label2.textAlign="left",this.children.push(label2),this.rowOffset+=this.rowHeight,{label1:label1,label2:label2}},addNumberPicker:function(text,value,min,max,step,onChange){var offset=this.getRowOffset(),labelOffset=offset.clone();labelOffset.x+=.5*this.size.x-10,labelOffset.y+=.5*this.rowHeight;var label=new GS.UIComponents.MenuLabel(this.cvs,text,labelOffset,this.pos);label.fontSize=this.fontSize,label.textAlign="right",this.children.push(label);var numberPickerOffset=offset.clone(),numberPickerSize=new THREE.Vector2(.2*this.size.x,this.rowHeight);numberPickerOffset.x+=.5*this.size.x+10;var numberPicker=new GS.UIComponents.MenuNumberPicker(this.cvs,numberPickerOffset,this.pos,numberPickerSize,this.fontSize,value,min,max,step,onChange);return this.children.push(numberPicker),this.rowOffset+=this.rowHeight,{label:label,numberPicker:numberPicker}},addImageButton:function(text,image,onClick){var offset=this.getRowOffset(),imageButtonOffset=offset.clone(),imageButtonSize=new THREE.Vector2(this.size.x,this.rowHeight),imageButton=new GS.UIComponents.MenuImageButton(this.cvs,imageButtonOffset,this.pos,imageButtonSize,this.fontSize,text,image,onClick);return this.children.push(imageButton),this.rowOffset+=this.rowHeight,imageButton},addEmptyRow:function(){this.rowOffset+=this.rowHeight},getRowOffset:function(){var offset=this.offset.clone();return offset.y+=this.rowOffset,Math.abs(offset.y-this.offset.y)>this.size.y?void GAME.handleFatalError("menu panel exceeds height"):offset},update:function(){for(var i=0;i<this.children.length;i++)this.children[i].update()},draw:function(){for(var i=0;i<this.children.length;i++)this.children[i].draw()},add:function(menuComponent){this.children.push(menuComponent)}},GS.UIComponents.Notifications=function(vectorCanvas,assets,player){this.cvs=vectorCanvas,this.assets=assets,this.player=player,this.fontSize=40,this.boxCornerRadius=10,this.useText="["+GS.Keybinds.use.controlName+"] to use",this.pointerLockText="right-click to enable pointer lock",this.restartText="[ENTER] to restart level",this.usePopup={originalOffset:new THREE.Vector2(0,100),offset:new THREE.Vector2,pos:new THREE.Vector2(.5,.5),size:new THREE.Vector2(0,60),textOffset:new THREE.Vector2(0,0)},this.pointerLockPopup={originalOffset:new THREE.Vector2(0,100),offset:new THREE.Vector2,pos:new THREE.Vector2(.5,.5),size:new THREE.Vector2(0,60),textOffset:new THREE.Vector2(0,0)},this.restartPopup={originalOffset:new THREE.Vector2(0,100),offset:new THREE.Vector2,pos:new THREE.Vector2(.5,.5),size:new THREE.Vector2(0,60),textOffset:new THREE.Vector2(0,0)
},this.calculateSizes(),this.visible=!0,this.oldShowUsePopup=!1,this.showUsePopup=!1,this.oldShowPointerLockPopup=!1,this.showPointerLockPopup=!1,this.oldShowRestartPopup=!1,this.showRestartPopup=!1},GS.UIComponents.Notifications.prototype={constructor:GS.UIComponents.Notifications,init:function(){},update:function(){this.showUsePopup=this.player.canUse,this.showUsePopup!=this.oldShowUsePopup&&(this.needsRedraw=!0,this.oldShowUsePopup=this.showUsePopup),this.showPointerLockPopup=!this.player.controls.pointerLockEnabled,this.showPointerLockPopup!=this.oldShowPointerLockPopup&&(this.needsRedraw=!0,this.oldShowPointerLockPopup=this.showPointerLockPopup),this.showRestartPopup=this.player.dead,this.showRestartPopup!=this.oldShowRestartPopup&&(this.needsRedraw=!0,this.oldShowRestartPopup=this.showRestartPopup)},draw:function(){this.showRestartPopup?this.drawPopup(this.restartText,this.restartPopup):this.showPointerLockPopup?this.drawPopup(this.pointerLockText,this.pointerLockPopup):this.showUsePopup&&this.drawPopup(this.useText,this.usePopup)},drawPopup:function(text,popup){this.cvs.roundedBoxFill(popup.offset,popup.pos,popup.size,!0,this.boxCornerRadius,GS.UIColors.background),this.cvs.text(popup.textOffset,popup.pos,text,GS.UIColors.foreground,this.fontSize,"middle","center",GS.UIFont)},calculateSizes:function(){this.calculatePopupSize(this.useText,this.usePopup),this.calculatePopupSize(this.pointerLockText,this.pointerLockPopup),this.calculatePopupSize(this.restartText,this.restartPopup)},calculatePopupSize:function(text,popup,textWidth){void 0===textWidth&&(textWidth=this.cvs.getTextWidth(text,this.fontSize,GS.UIFont));var padding=15,width=textWidth+2*padding;popup.size.x=width,popup.offset.x=-width/2,popup.offset.y=popup.originalOffset.y-popup.size.y,popup.textOffset.copy(popup.offset).add(popup.size.clone().multiplyScalar(.5))}},GS.UIComponents.PowerBars=function(vectorCanvas,assets,player){this.cvs=vectorCanvas,this.assets=assets,this.player=player,this.fontSize=60,this.boxCornerRadius=10,this.healthBar={offset:new THREE.Vector2(20,(-20)),pos:new THREE.Vector2(0,1),size:new THREE.Vector2(220,90),textOffset:new THREE.Vector2(95,4),imageOffset:new THREE.Vector2(20,20),imageAtlasOffset:new THREE.Vector2(0,0),imageAtlasSize:new THREE.Vector2(64,64)},this.healthBar.offset.y-=this.healthBar.size.y,this.healthBar.imageOffset.add(this.healthBar.offset),this.healthBar.textOffset.add(this.healthBar.offset).add(this.healthBar.size.clone().multiplyScalar(.5)),this.ammoBar={offset:new THREE.Vector2((-20),(-20)),pos:new THREE.Vector2(1,1),size:new THREE.Vector2(220,90),textOffset:new THREE.Vector2(95,4),imageOffset:new THREE.Vector2(20,20),imageAtlasOffset:new THREE.Vector2(64,0),imageAtlasSize:new THREE.Vector2(64,64)},this.ammoBar.offset.sub(this.ammoBar.size),this.ammoBar.imageOffset.add(this.ammoBar.offset),this.ammoBar.textOffset.add(this.ammoBar.offset).add(this.ammoBar.size.clone().multiplyScalar(.5)),this.tex=this.assets.images.hud,this.visible=!0,this.ammo=void 0,this.health="",this.oldHealth=-1,this.oldAmmo=-1},GS.UIComponents.PowerBars.prototype={constructor:GS.UIComponents.PowerBars,init:function(){},update:function(){this.health=Math.floor(this.player.health),void 0===this.player.weapon||this.player.weapon.infiniteAmmo?this.ammo=void 0:this.ammo=this.player.weapon.ammo,this.health==this.oldHealth&&this.ammo==this.oldAmmo||(this.needsRedraw=!0,this.oldHealth=this.health,this.oldAmmo=this.ammo)},draw:function(){this.cvs.roundedBoxFill(this.healthBar.offset,this.healthBar.pos,this.healthBar.size,!0,this.boxCornerRadius,GS.UIColors.background),this.cvs.text(this.healthBar.textOffset,this.healthBar.pos,this.health,GS.UIColors.foreground,this.fontSize,"middle","right",GS.UIFont),this.cvs.drawImageFromAtlas(this.healthBar.imageOffset,this.healthBar.pos,this.tex,this.healthBar.imageAtlasOffset,this.healthBar.imageAtlasSize),void 0!==this.ammo&&(this.cvs.roundedBoxFill(this.ammoBar.offset,this.ammoBar.pos,this.ammoBar.size,!0,this.boxCornerRadius,GS.UIColors.background),this.cvs.text(this.ammoBar.textOffset,this.ammoBar.pos,this.ammo,GS.UIColors.foreground,this.fontSize,"middle","right",GS.UIFont),this.cvs.drawImageFromAtlas(this.ammoBar.imageOffset,this.ammoBar.pos,this.tex,this.ammoBar.imageAtlasOffset,this.ammoBar.imageAtlasSize))}},GS.UIComponents.WinScreen=function(vectorCanvas,assets,player){this.cvs=vectorCanvas,this.assets=assets,this.player=player,this.fontSize=40,this.rowHeight=45,this.boxCornerRadius=10,this.aiManager=player.grid.aiManager,this.mapName="map name",this.hasNextMap=!1,this.monstersKilled=0,this.maxMonsters=0,this.itemsPickedUp=0,this.maxItems=0,this.secretsFound=0,this.maxSecrets=0,this.minutes="00",this.seconds="00",this.popup={offset:new THREE.Vector2((-480),(-315)),pos:new THREE.Vector2(.5,.5),size:new THREE.Vector2(960,630)},this.textOffsetLeft=new THREE.Vector2((-30),(-247)),this.textOffsetRight=new THREE.Vector2(30,(-247)),this.textOffsetCenter=new THREE.Vector2(0,(-247)),this.visible=!1},GS.UIComponents.WinScreen.prototype={constructor:GS.UIComponents.WinScreen,init:function(){},update:function(){!this.visible&&void 0!==this.aiManager.script&&this.aiManager.script.mapWon&&(this.collectData(),this.visible=!0)},collectData:function(){var script=this.aiManager.script;this.mapName=script.mapName,this.hasNextMap=void 0!==script.nextMap,this.monstersKilled=this.aiManager.monstersKilled,this.maxMonsters=this.aiManager.maxMonsters,this.itemsPickedUp=this.aiManager.itemsPickedUp,this.maxItems=this.aiManager.maxItems,this.secretsFound=script.secretsFound,this.maxSecrets=script.maxSecrets,this.minutes=GS.pad(this.aiManager.minutes,2),this.seconds=GS.pad(this.aiManager.seconds,2)},draw:function(){this.cvs.roundedBoxFill(this.popup.offset,this.popup.pos,this.popup.size,!0,this.boxCornerRadius,GS.UIColors.menuBackground),this.drawMessage('"'+this.mapName+'" complete',0),this.drawField("monsters killed",this.monstersKilled+" / "+this.maxMonsters,2),this.drawField("items picked up",this.itemsPickedUp+" / "+this.maxItems,3),this.drawField("secrets found",this.secretsFound+" / "+this.maxSecrets,4),this.drawField("time spent",this.minutes+":"+this.seconds,6),this.hasNextMap?this.drawMessage("[ENTER] to continue to the next level",11):(this.drawMessage("congrats!",10),this.drawMessage("this concludes the current release",11))},drawField:function(){var left=new THREE.Vector2,right=new THREE.Vector2;return function(name,value,row){left.copy(this.textOffsetLeft),left.y+=row*this.rowHeight,right.copy(this.textOffsetRight),right.y+=row*this.rowHeight,this.cvs.text(left,this.popup.pos,name,GS.UIColors.foreground,this.fontSize,"middle","right",GS.UIFont),this.cvs.text(right,this.popup.pos,value,GS.UIColors.foreground,this.fontSize,"middle","left",GS.UIFont)}}(),drawMessage:function(){var center=new THREE.Vector2;return function(message,row){center.copy(this.textOffsetCenter),center.y+=row*this.rowHeight,this.cvs.text(center,this.popup.pos,message,GS.UIColors.foreground,this.fontSize,"middle","center",GS.UIFont)}}()},GS.CollisionHelper={gravity:new THREE.Vector3(0,(-1.5),0),unitsPerMeter:100,handleCollisionsSliding:function(oldPos,newPos,gravityFactor,ellipsoid,triangleIterator){return this.handleCollisions(oldPos,newPos,gravityFactor,ellipsoid,triangleIterator,!1,!1)},handleCollisionsFirstHit:function(oldPos,newPos,gravityFactor,ellipsoid,triangleIterator){return this.handleCollisions(oldPos,newPos,gravityFactor,ellipsoid,triangleIterator,!0,!1)},handleCollisions:function(){var p={ellipsoidSpace:new THREE.Vector3,worldPosition:new THREE.Vector3,worldVelocity:new THREE.Vector3,lspPosition:new THREE.Vector3,lspVelocity:new THREE.Vector3,lspNormalizedVelocity:new THREE.Vector3,normal:new THREE.Vector3,foundCollision:!1,nearestDistance:0,intersectionPoint:new THREE.Vector3,collisionRecursionDepth:0,stopOnFirstHit:!1,gravityFactor:0};return function(oldPos,newPos,gravityFactor,ellipsoid,triangleIterator,stopOnFirstHit,horizontalOnly){p.ellipsoidSpace.copy(ellipsoid),p.worldPosition.copy(oldPos),p.worldVelocity.subVectors(newPos,oldPos),p.foundCollision=!1,p.nearestDistance=0,p.collisionRecursionDepth=0,p.stopOnFirstHit=stopOnFirstHit,p.gravityFactor=gravityFactor;var result=this.collisionSlide(p,triangleIterator);return newPos.copy(result.pos),result}}(),collisionSlide:function(p,triangleIterator){p.lspVelocity.copy(p.worldVelocity).divide(p.ellipsoidSpace),p.lspPosition.copy(p.worldPosition).divide(p.ellipsoidSpace);var oldY=p.lspPosition.y;p.collisionRecursionDepth=0;var finalPosition=this.collideWithWorld(p,triangleIterator),climbing=oldY<finalPosition.y;0===p.gravityFactor||climbing||p.horizontalOnly||(p.lspVelocity.copy(this.gravity),p.lspVelocity.y*=p.gravityFactor,p.lspVelocity.divide(p.ellipsoidSpace),p.lspPosition.copy(finalPosition),p.collisionRecursionDepth=0,finalPosition=this.collideWithWorld(p,triangleIterator)),finalPosition.multiply(p.ellipsoidSpace),p.horizontalOnly&&(finalPosition.y=p.originalHeight);var result={pos:finalPosition,climbing:climbing,foundCollision:p.foundCollision,gridObject:p.gridObject,normal:p.normal};return result},collideWithWorld:function(){var normal=new THREE.Vector3,aux=new THREE.Vector3,result=new THREE.Vector3,destinationPoint=new THREE.Vector3,newPosition=new THREE.Vector3,slidePlaneOrigin=new THREE.Vector3,slidePlaneNormal=new THREE.Vector3,newDestinationPoint=new THREE.Vector3,newVelocityVector=new THREE.Vector3,v0=new THREE.Vector3,v1=new THREE.Vector3,v2=new THREE.Vector3;return function(p,triangleIterator){var that=this,unitScale=this.unitsPerMeter/100,veryCloseDistance=.005*unitScale;if(p.collisionRecursionDepth>5)return p.lspPosition;if(p.lspNormalizedVelocity.copy(p.lspVelocity).normalize(),p.foundCollision=!1,p.nearestDistance=0,triangleIterator(function(gridObject,t0,t1,t2,triangleOffset){GAME.grid.totalSphereTriangleChecks++,v0.copy(t0).divide(p.ellipsoidSpace),v1.copy(t1).divide(p.ellipsoidSpace),v2.copy(t2).divide(p.ellipsoidSpace),aux.subVectors(v2,v0),normal.copy(v1).sub(v0).cross(aux).normalize(),that.sphereCollidingWithTriangle(gridObject,p,v0,v1,v2,normal)}),!p.foundCollision)return result.copy(p.lspPosition).add(p.lspVelocity),result;if(destinationPoint.copy(p.lspPosition).add(p.lspVelocity),newPosition.copy(p.lspPosition),p.nearestDistance>=veryCloseDistance&&(aux.copy(p.lspVelocity).normalize(),aux.multiplyScalar(p.nearestDistance-veryCloseDistance),newPosition.copy(p.lspPosition).add(aux),aux.normalize().multiplyScalar(veryCloseDistance),p.intersectionPoint.sub(aux)),p.stopOnFirstHit)return p.lspPosition.copy(newPosition),p.lspPosition;slidePlaneOrigin.copy(p.intersectionPoint),slidePlaneNormal.copy(newPosition).sub(p.intersectionPoint).normalize();var x=slidePlaneOrigin.x,y=slidePlaneOrigin.y,z=slidePlaneOrigin.z,A=slidePlaneNormal.x,B=slidePlaneNormal.y,C=slidePlaneNormal.z,D=-(A*x+B*y+C*z),planeConstant=D,signedDistFromDestPointToSlidingPlane=slidePlaneNormal.dot(destinationPoint)+planeConstant;return aux.copy(slidePlaneNormal).multiplyScalar(signedDistFromDestPointToSlidingPlane),newDestinationPoint.copy(destinationPoint).sub(aux),newVelocityVector.copy(newDestinationPoint).sub(p.intersectionPoint),newVelocityVector.length()<veryCloseDistance?newPosition:(p.collisionRecursionDepth++,p.lspPosition.copy(newPosition),p.lspVelocity.copy(newVelocityVector),this.collideWithWorld(p,triangleIterator))}}(),sphereCollidingWithTriangle:function(){var velocity=new THREE.Vector3,position=new THREE.Vector3,aux=new THREE.Vector3,planeIntersectionPoint=new THREE.Vector3,collisionPoint=new THREE.Vector3,edge=new THREE.Vector3,spherePositionToVertex=new THREE.Vector3;return function(gridObject,p,v0,v1,v2,normal){var facing=normal.dot(p.lspNormalizedVelocity);if(facing<=0){velocity.copy(p.lspVelocity),position.copy(p.lspPosition);var t0,t1,sphereInPlane=!1,A=normal.x,B=normal.y,C=normal.z,D=-(A*v0.x+B*v0.y+C*v0.z),planeConstant=D,signedDistFromPositionToTriPlane=position.dot(normal)+planeConstant,planeNormalDotVelocity=normal.dot(velocity);if(0===planeNormalDotVelocity){if(Math.abs(signedDistFromPositionToTriPlane)>=1)return!1;sphereInPlane=!0}else{if(t0=(1-signedDistFromPositionToTriPlane)/planeNormalDotVelocity,t1=(-1-signedDistFromPositionToTriPlane)/planeNormalDotVelocity,t0>t1){var temp=t0;t0=t1,t1=temp}if(t0>1||t1<0)return!1;t0<0&&(t0=0),t1>1&&(t1=1)}var collidingWithTri=!1,t=1;if(sphereInPlane||(aux.copy(velocity).multiplyScalar(t0),planeIntersectionPoint.copy(position).add(aux).sub(normal),this.checkPointInTriangle(planeIntersectionPoint,v0,v1,v2)&&(collidingWithTri=!0,t=t0,collisionPoint.copy(planeIntersectionPoint))),!collidingWithTri){var a,b,c,velocityLengthSquared=velocity.lengthSq();a=velocityLengthSquared;var result={};aux.copy(position).sub(v0),b=2*velocity.dot(aux),aux.copy(v0).sub(position),c=aux.length(),c=c*c-1,this.getLowestRoot(a,b,c,t,result)&&(t=result.root,collidingWithTri=!0,collisionPoint.copy(v0)),aux.copy(position).sub(v1),b=2*velocity.dot(aux),aux.copy(v1).sub(position),c=aux.length(),c=c*c-1,this.getLowestRoot(a,b,c,t,result)&&(t=result.root,collidingWithTri=!0,collisionPoint.copy(v1)),aux.copy(position).sub(v2),b=2*velocity.dot(aux),aux.copy(v2).sub(position),c=aux.length(),c=c*c-1,this.getLowestRoot(a,b,c,t,result)&&(t=result.root,collidingWithTri=!0,collisionPoint.copy(v2)),edge.copy(v1).sub(v0),spherePositionToVertex.copy(v0).sub(position);var edgeLengthSquared=edge.lengthSq(),edgeDotVelocity=edge.dot(velocity),edgeDotSpherePositionToVertex=edge.dot(spherePositionToVertex),spherePositionToVertexLengthSquared=spherePositionToVertex.lengthSq();if(a=edgeLengthSquared*-velocityLengthSquared+edgeDotVelocity*edgeDotVelocity,b=2*edgeLengthSquared*velocity.dot(spherePositionToVertex)-2*edgeDotVelocity*edgeDotSpherePositionToVertex,c=edgeLengthSquared*(1-spherePositionToVertexLengthSquared)+edgeDotSpherePositionToVertex*edgeDotSpherePositionToVertex,this.getLowestRoot(a,b,c,t,result)){var f=(edgeDotVelocity*result.root-edgeDotSpherePositionToVertex)/edgeLengthSquared;f>=0&&f<=1&&(t=result.root,collidingWithTri=!0,edge.multiplyScalar(f),collisionPoint.copy(v0).add(edge))}if(edge.copy(v2).sub(v1),spherePositionToVertex.copy(v1).sub(position),edgeLengthSquared=edge.lengthSq(),edgeDotVelocity=edge.dot(velocity),edgeDotSpherePositionToVertex=edge.dot(spherePositionToVertex),spherePositionToVertexLengthSquared=spherePositionToVertex.lengthSq(),a=edgeLengthSquared*-velocityLengthSquared+edgeDotVelocity*edgeDotVelocity,b=2*edgeLengthSquared*velocity.dot(spherePositionToVertex)-2*edgeDotVelocity*edgeDotSpherePositionToVertex,c=edgeLengthSquared*(1-spherePositionToVertexLengthSquared)+edgeDotSpherePositionToVertex*edgeDotSpherePositionToVertex,this.getLowestRoot(a,b,c,t,result)){var f=(edgeDotVelocity*result.root-edgeDotSpherePositionToVertex)/edgeLengthSquared;f>=0&&f<=1&&(t=result.root,collidingWithTri=!0,edge.multiplyScalar(f),collisionPoint.copy(v1).add(edge))}if(edge.copy(v0).sub(v2),spherePositionToVertex.copy(v2).sub(position),edgeLengthSquared=edge.lengthSq(),edgeDotVelocity=edge.dot(velocity),edgeDotSpherePositionToVertex=edge.dot(spherePositionToVertex),spherePositionToVertexLengthSquared=spherePositionToVertex.lengthSq(),a=edgeLengthSquared*-velocityLengthSquared+edgeDotVelocity*edgeDotVelocity,b=2*edgeLengthSquared*velocity.dot(spherePositionToVertex)-2*edgeDotVelocity*edgeDotSpherePositionToVertex,c=edgeLengthSquared*(1-spherePositionToVertexLengthSquared)+edgeDotSpherePositionToVertex*edgeDotSpherePositionToVertex,this.getLowestRoot(a,b,c,t,result)){var f=(edgeDotVelocity*result.root-edgeDotSpherePositionToVertex)/edgeLengthSquared;f>=0&&f<=1&&(t=result.root,collidingWithTri=!0,edge.multiplyScalar(f),collisionPoint.copy(v2).add(edge))}}if(collidingWithTri){var distToCollision=t*velocity.length();if(!p.foundCollision||distToCollision<p.nearestDistance)return p.nearestDistance=distToCollision,p.intersectionPoint.copy(collisionPoint),p.foundCollision=!0,p.normal.copy(normal),p.gridObject=gridObject,!0}}return!1}}(),checkPointInTriangle:function(){var cp1=new THREE.Vector3,cp2=new THREE.Vector3,aux=new THREE.Vector3,aux2=new THREE.Vector3;return function(point,v1,v2,v3){if(aux.copy(v3).sub(v2),aux2.copy(point).sub(v2),cp1.crossVectors(aux,aux2),aux.copy(v3).sub(v2),aux2.copy(v1).sub(v2),cp2.crossVectors(aux,aux2),cp1.dot(cp2)>=0&&(aux.copy(v3).sub(v1),aux2.copy(point).sub(v1),cp1.crossVectors(aux,aux2),aux.copy(v3).sub(v1),aux2.copy(v2).sub(v1),cp2.crossVectors(aux,aux2),cp1.dot(cp2)>=0&&(aux.copy(v2).sub(v1),aux2.copy(point).sub(v1),cp1.crossVectors(aux,aux2),aux.copy(v2).sub(v1),aux2.copy(v3).sub(v1),cp2.crossVectors(aux,aux2),cp1.dot(cp2)>=0)))return!0}}(),getLowestRoot:function(a,b,c,maxR,result){var determinant=b*b-4*a*c;if(determinant<0)return!1;var sqrtD=Math.sqrt(determinant),r1=(-b-sqrtD)/(2*a),r2=(-b+sqrtD)/(2*a);if(r1>r2){var temp=r2;r2=r1,r1=temp}return r1>0&&r1<maxR?(result.root=r1,!0):r2>0&&r2<maxR&&(result.root=r2,!0)}},GS.HitscanHelper={unitLength:64,steps:5,spread:function(weapon,xAngle,yAngle,callback){for(var angleForX=weapon.spread.angleOffset+20*(Math.abs(yAngle-90)/90)*(Math.abs(yAngle-90)/90),angleForY=weapon.spread.angleOffset,i=0;i<weapon.spread.shots;i++){var xAngleOffset=xAngle+Math.random()*angleForX*2-angleForX,yAngleOffset=yAngle+Math.random()*angleForY*2-angleForY,x=Math.sin(Math.PI/180*yAngleOffset)*Math.cos(Math.PI/180*xAngleOffset),y=Math.cos(Math.PI/180*yAngleOffset),z=Math.sin(Math.PI/180*yAngleOffset)*Math.sin(Math.PI/180*xAngleOffset),dir=new THREE.Vector3(x,y,z);dir.normalize(),callback(dir)}},getIntersection:function(){var newPos=new THREE.Vector3,step=new THREE.Vector3,endPoint=new THREE.Vector3,points=[new THREE.Vector2,new THREE.Vector2],ray=new THREE.Ray;new THREE.Vector3;return function(pos,dir,grid,typesEnvironment,typesEntity,steps,except){steps=steps||this.steps,newPos.copy(pos),step.copy(dir).multiplyScalar(this.unitLength);var result={type:GS.CollisionTypes.None,pos:new THREE.Vector3,gridObject:null,distance:1/0,normal:new THREE.Vector3};ray.set(pos,dir);for(var i=0;i<steps;i++){endPoint.copy(newPos).add(step),newPos.toVector2(points[0]),endPoint.toVector2(points[1]);var gridLocation=grid.getGridLocationFromPoints(points);if(void 0===gridLocation)break;if(this.checkEnvironmentIntersection(ray,grid,gridLocation,typesEnvironment,result,except),this.checkEntityIntersection(ray,grid,gridLocation,typesEntity,result,except),result.type!==GS.CollisionTypes.None)break;newPos.add(step)}return result}}(),checkEnvironmentIntersection:function(){var aux=new THREE.Vector3,point=new THREE.Vector3;return function(ray,grid,gridLocation,types,result,except){var triangleIterator=grid.getTriangleIterator(gridLocation,types);triangleIterator(function(gridObject,v0,v1,v2){if(gridObject!==except&&null!==ray.intersectTriangle(v0,v1,v2,!0,point)){var dist=point.distanceToSquared(ray.origin);dist<result.distance&&(result.type=GS.CollisionTypes.Environment,aux.subVectors(v2,v0),result.normal.copy(v1).sub(v0).cross(aux).normalize(),result.pos.copy(point).add(result.normal),result.distance=dist,result.gridObject=gridObject)}})}}(),checkEntityIntersection:function(){var point=new THREE.Vector3;return function(ray,grid,gridLocation,types,result,except){var cells=grid.getCellsFromGridLocation(gridLocation);grid.forEachUniqueGridObjectInCells(cells,types,function(gridObject){if(!gridObject.dead&&gridObject!==except&&null!==ray.intersectBox(gridObject.view.collisionData.boundingBox,point)){var dist=point.distanceToSquared(ray.origin);dist<result.distance&&(result.type=GS.CollisionTypes.Entity,result.pos.copy(point),result.distance=dist,result.gridObject=gridObject)}})}}()},GS.RegionHelper=function(){this.material=new GS.MeshVertexColorMaterial},GS.RegionHelper.prototype={constructor:GS.RegionHelper,getRegions:function(sectors,sectorLinks){var result=this.getSectorGraph(sectors,sectorLinks);return result.regions=this.constructRegions(result.sectorDict,result.sectorGraph),result},getSectorGraph:function(sectors,sectorLinks){for(var sectorGraph=new GS.Graph(function(a,b){return a.id==b.id}),sectorDict={},i=0;i<sectorLinks.length;i+=2){var s1=this.getSectorById(sectors,sectorLinks[i]),s2=this.getSectorById(sectors,sectorLinks[i+1]);sectorDict[s1.id]={index:-1,sector:s1,center:GS.PolygonHelper.getSectorCentroid(s1)},sectorDict[s2.id]={index:-1,sector:s2,center:GS.PolygonHelper.getSectorCentroid(s2)},sectorGraph.addEdge(s1,s2)}for(var keys=Object.keys(sectorDict),i=0;i<keys.length;i++){var obj=sectorDict[keys[i]];obj.index=sectorGraph.getVertexIndex(obj.sector)}return sectorGraph.computeVertexNeighborSets(),{sectorGraph:sectorGraph,sectorDict:sectorDict}},constructRegions:function(sectorDict,sectorGraph){this.regionIdCount=0;var toVisit=[],doorCount=0,seeds={};for(var i in sectorDict)if(sectorDict[i].sector.door){for(var neighbors=sectorGraph.neighborSets[sectorDict[i].index].elements,j=0;j<neighbors.length;j++){var id=neighbors[j].id;toVisit.push({id:id,seed:id}),seeds[id]={doorIds:{},sectorIds:{}}}doorCount++}var regions=[];if(doorCount>0){for(var visited={};toVisit.length>0;){var current=toVisit.pop(),id=current.id,seedId=current.seed;if(sectorDict[id].sector.door&&(seeds[seedId].doorIds[id]=!0),!visited[id]&&(visited[id]=!0,seeds[seedId].sectorIds[id]=!0,!sectorDict[id].sector.door))for(var neighbors=sectorGraph.neighborSets[sectorDict[id].index].elements,i=0;i<neighbors.length;i++){var info=sectorDict[neighbors[i].id],id=info.sector.id;toVisit.push({id:id,seed:seedId})}}for(var i in seeds){var sectorIds=seeds[i].sectorIds;Object.keys(sectorIds).length>0&®ions.push(this.getNewRegion(seeds[i].doorIds,sectorIds))}for(var i=0;i<regions.length;i++){var region=regions[i];region.linkedRegions=[];for(var j in region.doorIds)for(var k=0;k<regions.length;k++)if(k!==i){var region2=regions[k];for(var e in region2.doorIds)if(e===j){region.linkedRegions.push({doorId:e,region:region2});break}}}}else{var region=this.getNewRegion();for(var i in this.sectorDict)region.sectorIds[i]=!0;regions.push(region)}return regions},getNewRegion:function(doorIds,sectorIds){var region={id:this.regionIdCount,doorIds:doorIds||{},sectorIds:sectorIds||{},monsters:[]},mesh=new THREE.Mesh(new THREE.Geometry,this.material);return mesh.matrixAutoUpdate=!1,region.mesh=mesh,this.regionIdCount++,region},getSectorById:function(sectors,id){for(var i=0;i<sectors.length;i++)if(sectors[i].id==id)return sectors[i];GAME.handleFatalError("sector "+id+" not found")}},GS.BrightnessFilterShader={uniforms:{tDiffuse:{type:"t",value:null}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D(tDiffuse, vUv);","float lum = dot(texel, vec4(0.299, 0.587, 0.114, 0.0));","lum = step(0.9999, lum);","gl_FragColor = vec4(texel.xyz * lum, 1.0);","}"].join("\n")},GS.ColorShader={uniforms:{tDiffuse:{type:"t",value:null},color:{type:"c",value:new THREE.Color(16777215)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D(tDiffuse, vUv);","gl_FragColor = vec4(texel.xyz + color.xyz * 0.75, 1.0);","}"].join("\n")},GS.GlowShader={uniforms:{tDiffuse:{type:"t",value:null},tGlow:{type:"t",value:null},intensity:{type:"f",value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform float intensity;","uniform sampler2D tDiffuse;","uniform sampler2D tGlow;","varying vec2 vUv;","void main() {","vec4 texel = texture2D(tDiffuse, vUv);","vec4 glow = texture2D(tGlow, vUv);","gl_FragColor = vec4(texel.xyz + glow.xyz * intensity, 1.0);","}"].join("\n")},GS.MeshPhongGlowMaterial=function(map,glow,normal,emissive,glowIntensity){this.shader=GS.PhongGlowShader,this.uniforms=THREE.UniformsUtils.clone(this.shader.uniforms),this.uniforms.map.value=map,this.uniforms.glowMap.value=glow,this.uniforms.normalMap.value=normal,this.uniforms.emissive.value=new THREE.Color(emissive||0),this.uniforms.glowIntensity.value=void 0!==glowIntensity?glowIntensity:1,THREE.ShaderMaterial.call(this,{uniforms:this.uniforms,fragmentShader:this.shader.fragmentShader,vertexShader:this.shader.vertexShader,lights:!0}),this.map=!0,this.normalMap=void 0!==normal&&null!==normal},GS.MeshPhongGlowMaterial.prototype=GS.inherit(THREE.ShaderMaterial,{constructor:GS.MeshPhongGlowMaterial,clone:function(){var material=new GS.MeshPhongGlowMaterial(this.uniforms.map.value,this.uniforms.glowMap.value,this.uniforms.normalMap.value,this.uniforms.emissive.value,this.uniforms.glowIntensity.value);return material},get emissive(){return this.uniforms.emissive.value},set glowIntensity(value){this.uniforms.glowIntensity.value=value},get glowIntensity(){return this.uniforms.glowIntensity.value}}),GS.MeshVertexColorMaterial=function(){this.shader=GS.VertexColorShader,this.uniforms=THREE.UniformsUtils.clone(this.shader.uniforms),THREE.ShaderMaterial.call(this,{uniforms:this.uniforms,attributes:{emissive:{type:"c",value:[]}},fragmentShader:this.shader.fragmentShader,vertexShader:this.shader.vertexShader,vertexColors:THREE.FaceColors,lights:!0})},GS.MeshVertexColorMaterial.prototype=GS.inherit(THREE.ShaderMaterial,{constructor:GS.MeshVertexColorMaterial,clone:function(){var material=new GS.MeshVertexColorMaterial;return material}}),GS.NoiseShader={uniforms:{tDiffuse:{type:"t",value:null},tNoise:{type:"t",value:null},ratio:{type:"v2",value:new THREE.Vector2(1,1)},intensity:{type:"f",value:.05}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform sampler2D tNoise;","uniform vec2 ratio;","uniform float intensity;","varying vec2 vUv;","void main() {","vec4 cDiffuse = texture2D(tDiffuse, vUv);","vec4 cNoise = texture2D(tNoise, vUv * ratio);","gl_FragColor = vec4(cDiffuse.xyz + cNoise.xyz * intensity - intensity * 0.5, 1.0);","}"].join("\n")},GS.PhongGlowShader={uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.normalmap,THREE.UniformsLib.fog,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(16777215)},emissive:{type:"c",value:new THREE.Color(0)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)},glowMap:{type:"t",value:null},glowIntensity:{type:"f",value:1}}]),vertexShader:["#define PHONG","varying vec3 vViewPosition;","varying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.defaultnormal_vertex,"\tvNormal = normalize( transformedNormal );",THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"\tvViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_phong_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform float opacity;","uniform vec3 ambient;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;","uniform sampler2D glowMap;","uniform float glowIntensity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tgl_FragColor = vec4( vec3( 1.0 ), opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.lights_phong_fragment,"\tfloat glow = texture2D(glowMap, vUv).x * glowIntensity * 2.0;","\tgl_FragColor.xyz = texelColor.xyz * clamp(emissive + totalDiffuse + ambientLightColor * ambient + glow, 0.0, 2.0) + totalSpecular;",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},GS.RandomNoiseShader={uniforms:{tDiffuse:{type:"t",value:null},intensity:{type:"f",value:.05},seed:{type:"v2",value:new THREE.Vector2(Math.random(),Math.random())}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float intensity;","uniform vec2 seed;","varying vec2 vUv;","highp float rand(vec2 co)","{","highp float a = 12.9898;","highp float b = 78.233;","highp float c = 43758.5453;","highp float dt = dot(co.xy, vec2(a,b));","highp float sn = mod(dt, 3.14);","return fract(sin(sn) * c);","}","void main() {","vec4 cDiffuse = texture2D(tDiffuse, vUv);","gl_FragColor = vec4(cDiffuse.xyz - rand(vUv + seed) * intensity, 1.0);","}"].join("\n")},GS.VertexColorShader={uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.normalmap,THREE.UniformsLib.fog,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(16777215)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["#define PHONG","varying vec3 vViewPosition;","varying vec3 vNormal;",THREE.ShaderChunk.lights_phong_pars_vertex,"#ifdef USE_COLOR","attribute vec3 emissive;","varying vec3 vColor;","varying vec3 vEmissive;","#endif","void main() {","#ifdef USE_COLOR","#ifdef GAMMA_INPUT","vColor = color * color;","#else","vColor = color;","#endif","vEmissive = emissive;","#endif",THREE.ShaderChunk.defaultnormal_vertex,"vNormal = normalize( transformedNormal );",THREE.ShaderChunk.default_vertex,"vViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.lights_phong_vertex,"}"].join("\n"),fragmentShader:["#define PHONG","uniform vec3 diffuse;","uniform float opacity;","uniform vec3 ambient;","uniform vec3 specular;","uniform float shininess;","#ifdef USE_COLOR","varying vec3 vColor;","varying vec3 vEmissive;","#endif",THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,"void main() {","gl_FragColor = vec4( vec3( 1.0 ), opacity );",THREE.ShaderChunk.specularmap_fragment,"vec3 emissive = vEmissive;",THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},GS.AssetTypes={Texture:0,Mesh:1,Sound:2,CubeTexture:3,UIWidget:4,Map:5,Script:6,MusicTrack:7},GS.TextureTypes={Map:0,TVScreen:1,Entity:2},GS.CubeTextureExtension=".jpg",GS.CubeTextureNames=["left","right","top","bottom","front","back"],GS.CustomFontFile="capsuula.woff",GS.Assets={},GS.Assets[GS.AssetTypes.Texture]={cyan_wall:{filename:"cyan_wall.png",type:GS.TextureTypes.Map},red_wall:{filename:"red_wall.png",type:GS.TextureTypes.Map},blue_metal:{filename:"blue_metal.png",type:GS.TextureTypes.Map},white:{filename:"white.png",type:GS.TextureTypes.Map},wall:{filename:"wall.png",type:GS.TextureTypes.Map},metal:{filename:"metal.png",type:GS.TextureTypes.Map},light:{filename:"light.png",type:GS.TextureTypes.Map},red:{filename:"red.png",type:GS.TextureTypes.Map},blue:{filename:"blue.png",type:GS.TextureTypes.Map},cyan:{
filename:"cyan.png",type:GS.TextureTypes.Map},brown:{filename:"brown.png",type:GS.TextureTypes.Map},exit:{filename:"exit.png",type:GS.TextureTypes.TVScreen,showInMapEditor:!0},switch_off:{filename:"switch_off.png",type:GS.TextureTypes.TVScreen},switch_on:{filename:"switch_on.png",type:GS.TextureTypes.TVScreen},ammo:{filename:"ammo.png",type:GS.TextureTypes.Entity},ammo_glow:{filename:"ammo_glow.png",type:GS.TextureTypes.Entity},medkit:{filename:"medkit.png",type:GS.TextureTypes.Entity},medkit_glow:{filename:"medkit_glow.png",type:GS.TextureTypes.Entity},pistol:{filename:"pistol.png",type:GS.TextureTypes.Entity},pistol_glow:{filename:"pistol_glow.png",type:GS.TextureTypes.Entity},double_shotgun:{filename:"double_shotgun.png",type:GS.TextureTypes.Entity},double_shotgun_glow:{filename:"double_shotgun_glow.png",type:GS.TextureTypes.Entity},hyper_blaster:{filename:"hyper_blaster.png",type:GS.TextureTypes.Entity},hyper_blaster_glow:{filename:"hyper_blaster_glow.png",type:GS.TextureTypes.Entity},nom:{filename:"nom.png",type:GS.TextureTypes.Entity},nom_glow:{filename:"nom_glow.png",type:GS.TextureTypes.Entity},eye:{filename:"eye.png",type:GS.TextureTypes.Entity},eye_glow:{filename:"eye_glow.png",type:GS.TextureTypes.Entity}},GS.Assets[GS.AssetTypes.CubeTexture]={skybox1:{filename:"skybox1"}},GS.Assets[GS.AssetTypes.UIWidget]={hud:{filename:"hud.png"},logo:{filename:"logo.png"},menu_back:{filename:"menu_back.png"},thumb_airstrip1:{filename:"thumb_airstrip1.png"},thumb_drencrom:{filename:"thumb_drencrom.png"},thumb_sacrosanct:{filename:"thumb_sacrosanct.png"}},GS.Assets[GS.AssetTypes.Mesh]={ammo:{filename:"ammo.js"},medkit:{filename:"medkit.js"},pistol:{filename:"pistol.js"},double_shotgun:{filename:"double_shotgun.js"},hyper_blaster:{filename:"hyper_blaster.js"},nom_walk0:{filename:"nom_walk0.js"},nom_walk1:{filename:"nom_walk1.js"},nom_walk2:{filename:"nom_walk2.js"},nom_walk3:{filename:"nom_walk3.js"},nom_walk4:{filename:"nom_walk4.js"},nom_walk5:{filename:"nom_walk5.js"},nom_death0:{filename:"nom_death0.js"},nom_death1:{filename:"nom_death1.js"},nom_death2:{filename:"nom_death2.js"},nom_death3:{filename:"nom_death3.js"},eye_walk0:{filename:"eye_walk0.js"},eye_walk1:{filename:"eye_walk1.js"},eye_walk2:{filename:"eye_walk2.js"},eye_walk3:{filename:"eye_walk3.js"},eye_death0:{filename:"eye_death0.js"},eye_death1:{filename:"eye_death1.js"},eye_death2:{filename:"eye_death2.js"},eye_death3:{filename:"eye_death3.js"},eye_attack0:{filename:"eye_attack0.js"},eye_attack1:{filename:"eye_attack1.js"}},GS.Assets[GS.AssetTypes.Sound]={door_close:{filename:"door_close.ogg",allowMultipleAtOnce:!0},door_open:{filename:"door_open.ogg",allowMultipleAtOnce:!0},elevator_move:{filename:"elevator_move.ogg",allowMultipleAtOnce:!0},elevator_stop:{filename:"elevator_stop.ogg",allowMultipleAtOnce:!0},hyper_blaster_fire:{filename:"hyper_blaster_fire.ogg",allowMultipleAtOnce:!0},hyper_blaster_hit:{filename:"hyper_blaster_hit.ogg",allowMultipleAtOnce:!0},monster_pain:{filename:"monster_pain.ogg",allowMultipleAtOnce:!1},monster_roar:{filename:"monster_roar.ogg",allowMultipleAtOnce:!0},monster_bite:{filename:"monster_bite.ogg",allowMultipleAtOnce:!0},monster_death:{filename:"monster_death.ogg",allowMultipleAtOnce:!0},eye_charging:{filename:"eye_charging.ogg",allowMultipleAtOnce:!0},pickup_ammo:{filename:"pickup_ammo.ogg",allowMultipleAtOnce:!0},pickup_item:{filename:"pickup_item.ogg",allowMultipleAtOnce:!0},pickup_weapon:{filename:"pickup_weapon.ogg",allowMultipleAtOnce:!0},shotgun_fire:{filename:"shotgun_fire.ogg",allowMultipleAtOnce:!0},player_death:{filename:"player_death.ogg",allowMultipleAtOnce:!0},switch_on:{filename:"switch_on.ogg",allowMultipleAtOnce:!0},none:{filename:"none.ogg",allowMultipleAtOnce:!0}},GS.Assets[GS.AssetTypes.MusicTrack]={simple_action_beat:{filename:"simple_action_beat.ogg"},tower_defense_theme:{filename:"tower_defense_theme.ogg"},angry_robot_3:{filename:"angry_robot_3.ogg"}},GS.Assets[GS.AssetTypes.Map]={testMap:{filename:""},airstrip1:{filename:"airstrip1.js"},drencrom:{filename:"drencrom.js"},sacrosanct:{filename:"sacrosanct.js"}},GS.Assets[GS.AssetTypes.Script]={airstrip1:{filename:"airstrip1.js"},drencrom:{filename:"drencrom.js"},sacrosanct:{filename:"sacrosanct.js"}},GS.MonsterAttackTypes={Melee:0,Ranged:1},GS.Monsters={nom:{size:new THREE.Vector3(7.2,8,7.2),scale:new THREE.Vector3(.9,.9,.9),offset:new THREE.Vector3(3.6,8.03,3.6),speed:.75,rotationOffset:Math.PI,painChance:.25,attackType:GS.MonsterAttackTypes.Melee,maxHealth:160,meleeDamage:10,meleeAttackMaxCooldown:GS.msToFrames(500),meleeRange:15,walkDelay:5,bloodColor:(new THREE.Color).setRGB(1,0,0).getHex(),roarSound:"monster_roar",meleeAttackSound:"monster_bite",painSound:"monster_pain",deathSound:"monster_death"},eye:{size:new THREE.Vector3(5.6,8,5.6),scale:new THREE.Vector3(.5,.5,.5),offset:new THREE.Vector3(2.8,8.03,2.8),speed:.25,rotationOffset:Math.PI,painChance:.75,attackType:GS.MonsterAttackTypes.Ranged,maxHealth:50,meleeRange:15,rangedAttackMaxCooldown:GS.msToFrames(1500),rangedAttackCooldownRandomModifier:GS.msToFrames(1e3),rangedAttackRange:200,rangedAttackProjectile:"eye_bolt",rangedAttackChargeMaxCooldown:GS.msToFrames(500),preferredMaxDistance:100,walkDelay:15,bloodColor:(new THREE.Color).setRGB(0,1,1).getHex(),roarSound:"monster_roar",rangedAttackChargeUpSound:"eye_charging",painSound:"monster_pain",deathSound:"monster_death"}},GS.Projectiles={pistol_bolt:{hitSound:"hyper_blaster_hit",size:new THREE.Vector3(1,1,1),visualSize:new THREE.Vector3(1,1,3),rotating:!1,speed:5,maxDistance:500,color:(new THREE.Color).setRGB(1,1,1).getHex(),damage:10},hyper_blaster_bolt:{hitSound:"hyper_blaster_hit",size:new THREE.Vector3(1,1,1),visualSize:new THREE.Vector3(1,1,3),rotating:!1,speed:5,maxDistance:500,color:(new THREE.Color).setRGB(1,1,1).getHex(),damage:10},eye_bolt:{hitSound:"hyper_blaster_hit",size:new THREE.Vector3(2,2,2),visualSize:new THREE.Vector3(3,3,3),rotating:!0,speed:2,maxDistance:500,color:(new THREE.Color).setRGB(1,1,1).getHex(),damage:20}},GS.Weapons={pistol:{name:"pistol",powerLevel:2,ammo:0,infiniteAmmo:!0,cooldown:400,hitscan:!1},double_shotgun:{name:"shotgun",powerLevel:3,ammo:0,ammoMax:50,ammoClip:8,bulletsPerShot:2,cooldown:1e3,hitscan:!0,spread:{shots:8,angleOffset:5},damage:10,impactParticleColor:(new THREE.Color).setRGB(1,1,1).getHex(),impactParticleCount:1},hyper_blaster:{name:"hyperblaster",powerLevel:4,ammo:0,ammoMax:200,ammoClip:20,bulletsPerShot:1,cooldown:80,hitscan:!1}},GS.GridObject=function(grid,layer,sourceObj){this.id=GS.gridObjectIdCount,this.grid=grid,this.type=layer,this.sourceObj=sourceObj,this.linkedGridCells=[],this.view=null,this.removed=!1,this.usable=!1,this.lightLevelFactor=.1,this.minLightLevel=.1,this.maxLightLevel=.75,GS.gridObjectIdCount++},GS.GridObject.prototype={constructor:GS.GridObject,init:function(){},update:function(){},updateCollisionData:function(newPos){},updateBoundingBox:function(){var min=new THREE.Vector3,max=new THREE.Vector3,points=[new THREE.Vector2,new THREE.Vector2],aux=new THREE.Vector2;return function(){var data=this.view.collisionData;min.copy(this.position).sub(this.size),max.copy(this.position).add(this.size),data.boundingBox.set(min,max);var debugMesh=this.view.debugMesh;void 0!==debugMesh&&(debugMesh.userData.isTriangleMesh!==!0?(debugMesh.scale.subVectors(max,min),debugMesh.position.copy(this.position)):(debugMesh.geometry.vertices.length=0,GS.pushArray(debugMesh.geometry.vertices,data.triangles),debugMesh.geometry.verticesNeedUpdate=!0)),void 0!==data.boundingSquare&&(this.size.toVector2(aux),this.position.toVector2(points[0]),points[0].sub(aux),this.size.toVector2(aux),this.position.toVector2(points[1]),points[1].add(aux),data.boundingSquare.setFromPoints(points))}}(),updateTriangles:function(velocity){for(var triangles=this.view.collisionData.triangles,i=0;i<triangles.length;i++)triangles[i].add(velocity)},updateSegments:function(yVelocity){for(var segs=this.view.collisionData.segments,i=0;i<segs.length;i++)segs[i].bottomY+=yVelocity,segs[i].topY+=yVelocity},assignToCells:function(gridLocation){void 0!==gridLocation?void 0!==this.gridLocation?gridLocation.gridMin.equals(this.gridLocation.gridMin)&&gridLocation.gridMax.equals(this.gridLocation.gridMax)||(this.unlinkFromCells(),this.linkToCells(gridLocation)):this.linkToCells(gridLocation):this.unlinkFromCells()},linkToCells:function(gridLocation){for(var min=gridLocation.gridMin,max=gridLocation.gridMax,i=min.y;i<=max.y;i++)for(var j=min.x;j<=max.x;j++)this.grid.cells[i][j].children.push(this),this.linkedGridCells.push(this.grid.cells[i][j]);this.gridLocation=gridLocation},unlinkFromCells:function(){for(var i=0;i<this.linkedGridCells.length;i++){var cell=this.linkedGridCells[i],idx=cell.children.indexOf(this);idx!=-1&&cell.children.splice(idx,1)}this.linkedGridCells.length=0,this.gridLocation=void 0},getLightColorFromSector:function(optionalTarget,optionalSector){var sector=optionalSector||this.getSector();if(void 0!==sector){var color=optionalTarget||new THREE.Color,x=sector.lightLevel*this.lightLevelFactor;x*=x,x=GS.MathHelper.clamp(x,this.minLightLevel,this.maxLightLevel),color.setHex(16777215).multiplyScalar(x)}},computeYFromSector:function(){var sector=this.getSector();void 0!==sector&&(this.position.y=sector.floorTopY+this.size.y+.03)},getSector:function(){var position2d=new THREE.Vector2;return function(){var sector,currentSector;return this.position.toVector2(position2d),this.grid.forEachUniqueGridObjectInCells(this.linkedGridCells,[GS.Concrete,GS.Elevator],function(gridObject){if(void 0===sector){if(gridObject instanceof GS.Concrete){if(gridObject.type!==GS.MapLayers.Sector)return;currentSector=gridObject.sourceObj}else currentSector=gridObject.sector;GS.PolygonHelper.sectorContainsPoint(currentSector,position2d,!0)&&(sector=currentSector)}}),sector}}(),onHit:function(){},remove:function(){this.removed=!0,this.unlinkFromCells()}},GS.gridObjectIdCount=0,GS.Concrete=function(grid,layer,sourceObj){GS.GridObject.apply(this,arguments),layer===GS.MapLayers.Sector&&(this.sector=this.sourceObj),this.view={collisionData:{triangles:null}}},GS.Concrete.prototype=GS.inherit(GS.GridObject,{constructor:GS.Concrete}),GS.DoorStates={Open:0,Closed:1,Opening:2,Closing:3},GS.Door=function(grid,sector){GS.GridObject.call(this,grid),this.sector=sector,this.sector.doorGridObject=this,this.lightColor=new THREE.Color,this.speed=.5,this.state=GS.DoorStates.Closed,this.automatic=!0,this.view={collisionData:{boundingBox:new THREE.Box3,triangles:null,segments:null}},this.maxCooldown=GS.msToFrames(5e3),this.cooldown=this.maxCooldown},GS.Door.prototype=GS.inherit(GS.GridObject,{constructor:GS.Door,init:function(){this.closedY=this.position.y,this.openY=this.closedY+this.sector.doorMaxHeight,this.usable=!0,this.updateBoundingBox()},update:function(){var velocity=new THREE.Vector3;switch(this.state){case GS.DoorStates.Open:this.automatic?(this.cooldown--,this.cooldown<=0&&(this.cooldown=this.maxCooldown,this.state=GS.DoorStates.Closing,this.grid.soundManager.playSound("door_close"))):this.cooldown=this.maxCooldown;break;case GS.DoorStates.Closed:break;case GS.DoorStates.Opening:this.position.y+=this.speed,velocity.y=this.speed,this.position.y>=this.openY&&(this.position.y=this.openY,this.state=GS.DoorStates.Open);break;case GS.DoorStates.Closing:this.grid.collisionManager.isEntityNearDoor(this)?(this.sector.doorOpenedEver=!0,this.state=GS.DoorStates.Opening):(this.position.y-=this.speed,velocity.y=-this.speed,this.position.y<=this.closedY&&(this.position.y=this.closedY,this.state=GS.DoorStates.Closed))}if(this.usable=this.state===GS.DoorStates.Closed&&this._automatic===!0,0!==velocity.y&&(this.updateBoundingBox(),this.updateTriangles(velocity),this.updateSegments(velocity.y),this.updateMesh()),!this.sector.useVertexColors){this.getLightColorFromSector(this.lightColor,this.sector);for(var i=0;i<this.view.mesh.children.length;i++){var material=this.view.mesh.children[i].material;void 0!==material.emissive&&material.emissive.copy(this.lightColor)}}},updateMesh:function(){for(var i=0;i<this.view.mesh.children.length;i++)this.view.mesh.children[i].position.copy(this.position)},onUse:function(){this.state==GS.DoorStates.Closed&&(this.sector.doorOpenedEver=!0,this.state=GS.DoorStates.Opening,this.grid.soundManager.playSound("door_open"),this.grid.aiManager.onPlayerOpenDoor(this))},open:function(){return this.sector.doorOpenedEver=!0,this.state=GS.DoorStates.Opening,this.grid.soundManager.playSound("door_open"),this},openSilent:function(){return this.sector.doorOpenedEver=!0,this.state=GS.DoorStates.Opening,this},close:function(){return this.state=GS.DoorStates.Closing,this.grid.soundManager.playSound("door_close"),this},set automatic(value){this._automatic=value,this.usable=this._automatic===!0},get automatic(){return this._automatic}}),GS.ElevatorStates={Down:0,Up:1,GoindDown:2,GoingUp:3},GS.Elevator=function(grid,sector){GS.GridObject.call(this,grid),this.sector=sector,this.speed=.25,this.state=GS.ElevatorStates.Down,this.automatic=!0,this.lightColor=new THREE.Color,this.view={collisionData:{boundingBox:new THREE.Box3,triangles:null,segments:null}},this.maxCooldown=GS.msToFrames(0),this.cooldown=this.maxCooldown,this.velocity=new THREE.Vector3},GS.Elevator.prototype=GS.inherit(GS.GridObject,{constructor:GS.Elevator,init:function(){this.downY=this.position.y,this.upY=this.downY+this.sector.elevatorMaxHeight,this.updateBoundingBox()},update:function(){this.velocity.set(0,0,0);var oldY=0;switch(this.state){case GS.ElevatorStates.Down:this.automatic&&(this.cooldown--,this.cooldown<=0&&(this.cooldown=this.maxCooldown,this.state=GS.ElevatorStates.GoingUp));break;case GS.ElevatorStates.Up:this.automatic&&(this.cooldown--,this.cooldown<=0&&(this.cooldown=this.maxCooldown,this.state=GS.ElevatorStates.GoingDown));break;case GS.ElevatorStates.GoingDown:oldY=this.position.y,this.position.y-=this.speed,this.position.y<=this.downY?(this.position.y=this.downY,this.velocity.y=this.downY-oldY,this.state=GS.ElevatorStates.Down,this.grid.soundManager.playSound("elevator_stop")):this.velocity.y=-this.speed;break;case GS.ElevatorStates.GoingUp:oldY=this.position.y,this.position.y+=this.speed,this.position.y>=this.upY?(this.position.y=this.upY,this.velocity.y=this.upY-oldY,this.state=GS.ElevatorStates.Up,this.grid.soundManager.playSound("elevator_stop")):this.velocity.y=this.speed}this.updateChange()},updateChange:function(){if(0!==this.velocity.y&&(this.updateBoundingBox(),this.updateTriangles(this.velocity),this.updateSegments(this.velocity.y),this.updateSector(this.velocity.y),this.updateMesh(),this.grid.collisionManager.elevatorMove(this,this.velocity.y)),!this.sector.useVertexColors){this.getLightColorFromSector(this.lightColor,this.sector);for(var i=0;i<this.view.mesh.children.length;i++){var material=this.view.mesh.children[i].material;void 0!==material.emissive&&material.emissive.copy(this.lightColor)}}},updateSector:function(yVelocity){this.sector.floorTopY+=yVelocity,this.sector.ceilBottomY+=yVelocity},setPositionUp:function(){return this.velocity.y=this.upY-this.position.y,this.position.y=this.upY,this.state=GS.ElevatorStates.Up,this.updateChange(),this},setPositionDown:function(){return this.velocity.y=this.downY-this.position.y,this.position.y=this.downY,this.state=GS.ElevatorStates.Down,this.updateChange(),this},goDown:function(){return this.state=GS.ElevatorStates.GoingDown,this.grid.soundManager.playSound("elevator_move"),this},goUp:function(){return this.state=GS.ElevatorStates.GoingUp,this.grid.soundManager.playSound("elevator_move"),this},updateMesh:function(){for(var i=0;i<this.view.mesh.children.length;i++)this.view.mesh.children[i].position.copy(this.position)},onUse:function(){this.state==GS.ElevatorStates.Closed&&(this.state=GS.ElevatorStates.Opening)}}),GS.Item=function(grid,layer,sourceObj){GS.GridObject.apply(this,arguments),this.size=new THREE.Vector3(5,5,5),this.scale=new THREE.Vector3(.4,.4,.4),this.offset=new THREE.Vector3(4,3,4),this.animation={rotationSpeed:.01,floatYDelta:.25,floatAngle:0,floatSpeed:2},this.view={collisionData:{boundingBox:new THREE.Box3}}},GS.Item.prototype=GS.inherit(GS.GridObject,{constructor:GS.Item,init:function(){this.updateBoundingBox(),this.sector=this.getSector(),this.getLightColorFromSector(this.view.mesh.material.emissive,this.sector)},update:function(){this.updateLightLevel(),this.view.mesh.rotation.y+=this.animation.rotationSpeed,this.animation.floatAngle+=this.animation.floatSpeed;var pos=this.view.mesh.position;pos.y=this.position.y+this.animation.floatYDelta*Math.sin(Math.PI/180*this.animation.floatAngle)},updateLightLevel:function(){this.getLightColorFromSector(this.view.mesh.material.emissive,this.sector)},updateCollisionData:function(newPos){this.position.copy(newPos),this.view.mesh.position.copy(this.position),this.updateBoundingBox()},remove:function(){this.grid.removeEntityMesh(this.view.mesh),GS.GridObject.prototype.remove.call(this)}}),GS.MonsterStates={Scripted:0,Inactive:1,Awake:2,Active:3},GS.Monster=function(grid,layer,sourceObj){GS.GridObject.apply(this,arguments),this.monsterType=GS.MapEntities[sourceObj.type].name,$.extend(!0,this,GS.Monsters[this.monsterType]),this.xAngle=THREE.Math.degToRad(360-sourceObj.rotation),this.direction=new THREE.Vector3,this.view={collisionData:{boundingBox:new THREE.Box3,boundingSquare:new THREE.Box2,ellipsoid:this.size,triangles:null}},this.dead=!1,this.health=this.maxHealth,this.scatterCooldown=0,this.state=GS.MonsterStates.Inactive,this.moving=!1,this.inPain=!1,this.changeTargetMaxCooldown=GS.msToFrames(500),this.changeTargetCooldown=1,this.meleeAttackCooldown=0,this.rangedAttackCooldown=Math.floor(Math.random()*this.rangedAttackCooldownRandomModifier),this.rangedAttackChargeCooldown=0,this.chargingUpRangedAttack=!1},GS.Monster.prototype=GS.inherit(GS.GridObject,{constructor:GS.Monster,init:function(){this.animationView=new GS.AnimationView(this),this.animationView.init(),this.animationView.setLoop("inactive"),this.updateBoundingBox(),this.updateMesh(),this.sector=this.getSector()},update:function(){this.animationView.update(),this.dead||(this.state===GS.MonsterStates.Awake?this.updateScan():this.state===GS.MonsterStates.Active&&(this.updateMove(),this.attackType===GS.MonsterAttackTypes.Melee?this.updateAttackMelee():this.attackType===GS.MonsterAttackTypes.Ranged&&this.updateAttackRanged())),this.updateLightLevel()},updateLightLevel:function(){this.getLightColorFromSector(this.animationView.currentMesh.material.emissive,this.sector)},updateMesh:function(){this.view.mesh.position.copy(this.position),this.view.mesh.position.y+=this.animationView.positionYOffset,this.view.mesh.rotation.y=this.xAngle+this.rotationOffset+this.animationView.rotationYOffset},updateScan:function(){var target=this.grid.player;return this.inMeleeRange(target.position)?void this.activate():this.isFacing(target.position)?void this.activate():void this.updateMesh()},updateMove:function(){var target=this.grid.player;this.chargingUpRangedAttack?(this.calculateDirection(target.position),this.calculateRotation(),this.updateMesh()):(this.scatterCooldown>0?this.scatterCooldown--:target.dead?this.scatter():this.attackType===GS.MonsterAttackTypes.Melee?this.updateMoveMelee():this.attackType===GS.MonsterAttackTypes.Ranged&&this.updateMoveRanged(),this.inPain?this.updateMesh():this.move())},updateMoveMelee:function(){var aux=new THREE.Vector3,targetPos=new THREE.Vector3;return function(){var target=this.grid.player;if(this.changeTargetCooldown>0&&(this.changeTargetCooldown--,0===this.changeTargetCooldown)){this.changeTargetCooldown=this.changeTargetMaxCooldown,targetPos.copy(target.position);var distanceToTarget=this.position.distanceTo(targetPos);distanceToTarget>20&&(aux.set(Math.random()-.5,0,Math.random()-.5).normalize().multiplyScalar(20),targetPos.add(aux)),this.calculateDirection(targetPos),this.calculateRotation()}}}(),updateMoveRanged:function(){var aux=new THREE.Vector3,targetPos=new THREE.Vector3;return function(){var target=this.grid.player;if(this.changeTargetCooldown>0&&(this.changeTargetCooldown--,0===this.changeTargetCooldown)){this.changeTargetCooldown=this.changeTargetMaxCooldown,targetPos.copy(target.position);var distanceToTarget=this.position.distanceTo(targetPos);distanceToTarget>30&&distanceToTarget<this.preferredMaxDistance&&(targetPos.copy(this.position),aux.set(Math.random()-.5,0,Math.random()-.5).normalize().multiplyScalar(20),targetPos.add(aux)),this.calculateDirection(targetPos),this.calculateRotation()}}}(),move:function(){var newPos=new THREE.Vector3;return function(){this.moving=!0,newPos.copy(this.direction).multiplyScalar(this.speed).add(this.position),this.grid.collisionManager.collideMonster(this,this.position,newPos)}}(),updateAttackMelee:function(){var target=this.grid.player;this.meleeAttackCooldown>0?this.meleeAttackCooldown--:target.dead||this.inPain||this.inMeleeRange(target.position)&&this.isFacing(target.position)&&this.grid.collisionManager.checkMonsterLineOfSight(this,target,this.meleeRange)&&this.meleeAttack()},meleeAttack:function(){var target=this.grid.player;this.grid.soundManager.playSound("monster_bite"),this.meleeAttackCooldown=this.meleeAttackMaxCooldown,target.onHit(this.meleeDamage),this.grid.addEntityImpactParticles(target.position,target.bloodColor)},updateAttackRanged:function(){var target=this.grid.player;this.rangedAttackCooldown>0?this.rangedAttackCooldown--:target.dead||this.inPain||(this.rangedAttackChargeCooldown>0?(this.rangedAttackChargeCooldown--,0===this.rangedAttackChargeCooldown&&this.rangedAttack()):this.isFacing(target.position)&&this.grid.collisionManager.checkMonsterLineOfSight(this,target,this.rangedAttackRange)&&this.chargeUpRangedAttack())},chargeUpRangedAttack:function(){this.grid.soundManager.playSound(this.rangedAttackChargeUpSound),this.moving=!1,this.chargingUpRangedAttack=!0,this.rangedAttackChargeCooldown=this.rangedAttackChargeMaxCooldown,this.animationView.setLoop("attack")},cancelRangedAttack:function(){this.chargingUpRangedAttack=!1,this.rangedAttackChargeCooldown=0,this.animationView.setLoop("walk")},rangedAttack:function(){var direction=new THREE.Vector3;return function(){this.moving=!1;var target=this.grid.player;this.chargingUpRangedAttack=!1,this.animationView.setLoop("walk"),this.rangedAttackCooldown=this.rangedAttackMaxCooldown+Math.floor(Math.random()*this.rangedAttackCooldownRandomModifier),direction.copy(target.position).sub(this.position).normalize(),this.grid.addProjectile(this,this.rangedAttackProjectile,this.position.clone(),direction.clone())}}(),inMeleeRange:function(pos){return this.position.distanceTo(pos)<this.meleeRange},inRangedAttackRange:function(pos){return this.position.distanceTo(pos)<this.rangedAttackRange},isFacing:function(){var p=new THREE.Vector2,t=new THREE.Vector2,a=new THREE.Vector2,b=new THREE.Vector2;return function(pos){this.position.toVector2(p),pos.toVector2(t);var x=this.xAngle+this.rotationOffset;return a.set(Math.sin(x-Math.PI/2),Math.cos(x-Math.PI/2)).add(p),b.set(Math.sin(x+Math.PI/2),Math.cos(x+Math.PI/2)).add(p),GS.MathHelper.vec2PointSide(a,b,t)}}(),scatter:function(){var target=this.grid.player;if(!(this.scatterCooldown>20)){var distance=target.position.distanceTo(this.position);(target.dead||distance>10*(1+this.scale.x))&&(this.direction=new THREE.Vector3(2*Math.random()-1,0,2*Math.random()-1),this.direction.normalize(),this.calculateRotation(),this.scatterCooldown=30)}},calculateDirection:function(targetPos){this.direction.copy(targetPos).sub(this.position),this.direction.y=0,this.direction.normalize()},calculateRotation:function(){this.xAngle=Math.atan2(this.direction.x,this.direction.z)+Math.PI},updateCollisionData:function(){var velocity=new THREE.Vector3;return function(newPos){velocity.copy(newPos).sub(this.position);var currentSpeed=newPos.distanceTo(this.position);this.position.copy(newPos),this.updateTriangles(velocity),this.updateBoundingBox(),this.updateMesh(),currentSpeed/this.speed<.1&&this.scatter(),this.sector=this.getSector()}}(),wakeUp:function(script){this.state!==GS.MonsterStates.Awake&&(script!==!0&&this.state===GS.MonsterStates.Scripted||(this.state=GS.MonsterStates.Awake,this.animationView.setLoop("inactive")))},activate:function(script){this.state!==GS.MonsterStates.Active&&(script!==!0&&this.state===GS.MonsterStates.Scripted||(this.state=GS.MonsterStates.Active,this.animationView.setLoop("walk"),this.grid.soundManager.playSound(this.roarSound)))},onHit:function(damage){this.state!==GS.MonsterStates.Active&&this.activate(!0),Math.random()<=this.painChance&&(this.inPain=!0,this.moving=!1,this.attackType===GS.MonsterAttackTypes.Ranged&&this.cancelRangedAttack(),this.animationView.pain(),this.grid.soundManager.playSound(this.painSound)),this.health-=damage,this.health<0&&(this.health=0,this.onDeath())},onDeath:function(){this.moving=!1;var target=this.grid.player;this.calculateDirection(target.position),this.calculateRotation(),this.dead=!0,this.grid.soundManager.playSound(this.deathSound),this.grid.aiManager.onMonsterDeath(),this.animationView.setLoop("death"),this.updateMesh()}}),GS.Player=function(grid,camera,playerView){GS.GridObject.call(this,grid),this.camera=camera,this.playerView=playerView,this.playerView.player=this,this.moveSpeed=1.5,this.godEnabled=!1,this.flyEnabled=!1,this.noClipEnabled=!1,this.inMenu=!1,this.health=100,this.dead=!1,this.size=new THREE.Vector3(3,7,3),this.useRange=this.size.x+15,this.bloodColor=(new THREE.Color).setRGB(1,0,0).getHex(),this.direction=new THREE.Vector3,this.view={collisionData:{boundingBox:new THREE.Box3,boundingSquare:new THREE.Box2,ellipsoid:this.size,triangles:null}},this.moving=!1,this.shooting=!1,this.canUse=!0,this.ySmoothingMaxCooldown=GS.msToFrames(500),this.ySmoothingCooldown=0,this.swapWeaponsOnPickup=!0},GS.Player.prototype=GS.inherit(GS.GridObject,{constructor:GS.Player,init:function(){var that=this;this.availableWeapons=$.extend(!0,{},GS.Weapons),Object.keys(this.availableWeapons).forEach(function(key){that.availableWeapons[key].pickedUp=!1,that.availableWeapons[key].cooldownRemaining=0}),this.computeYFromSector(),this.initTriangles(),this.updateBoundingBox(),this.controls=new GS.FPSControls(this.camera),this.controls.eye.copy(this.position),this.controls.followingEye.copy(this.position),this.controls.moveSpeed=this.moveSpeed,this.controls.init(),this.controls.onHandleCollisions=function(oldPos,newPos){that.noClipEnabled?that.updateCollisionData(newPos):that.grid.collisionManager.collidePlayer(that,oldPos,newPos)},that.availableWeapons.pistol.pickedUp=!0,that.availableWeapons.pistol.cooldownRemaining=0,this.weapon=this.availableWeapons.pistol,this.weaponName="pistol",this.playerView.changeToWeaponInstant("pistol")},getPersistencePackage:function(){var pkg={health:this.health,weapons:{},currentWeapon:this.weaponName};for(var i in this.availableWeapons)pkg.weapons[i]={},pkg.weapons[i].pickedUp=this.availableWeapons[i].pickedUp,pkg.weapons[i].ammo=this.availableWeapons[i].ammo;return pkg},applyPersistencePackage:function(pkg){this.health=pkg.health;for(var i in this.availableWeapons)this.availableWeapons[i].pickedUp=pkg.weapons[i].pickedUp,this.availableWeapons[i].ammo=pkg.weapons[i].ammo;this.weapon=this.availableWeapons[pkg.currentWeapon],this.weaponName=pkg.currentWeapon,this.playerView.changeToWeaponInstant(pkg.currentWeapon)},giveAll:function(){var that=this;Object.keys(this.availableWeapons).forEach(function(key){var weapon=that.availableWeapons[key];weapon.pickedUp=!0,weapon.cooldownRemaining=0,weapon.infiniteAmmo||(weapon.ammo=weapon.ammoMax)})},fly:function(value){void 0===value?this.flyEnabled=!this.flyEnabled:this.flyEnabled=value,this.controls.fly=this.flyEnabled,this.flyEnabled?(this.playerView.viewBob.enabled=!1,this.playerView.weaponBob.enabled=!1):(this.playerView.viewBob.enabled=!0,this.playerView.weaponBob.enabled=!0)},noClip:function(value){void 0===value?this.noClipEnabled=!this.noClipEnabled:this.noClipEnabled=value},god:function(value){void 0===value?this.godEnabled=!this.godEnabled:this.godEnabled=value},initTriangles:function(){for(var triangles=GS.Cube.getVertices(),i=0;i<triangles.length;i++)triangles[i].multiply(this.size).add(this.position);this.view.collisionData.triangles=triangles},update:function(){this.dead||(this.updateControls(),this.updateUse(),this.updateShoot(),this.updateChangeWeapon())},afterCollision:function(result){!result.climbing||result.gridObject instanceof GS.Elevator||(this.ySmoothingCooldown=this.ySmoothingMaxCooldown)},onHit:function(damage){this.godEnabled||(this.health-=damage,this.health<=0&&(this.health=0,this.onDeath()),this.playerView.onDamage())},onDeath:function(){this.dead=!0,this.grid.soundManager.playSound("player_death"),void 0!==this.weapon&&this.playerView.onDeath()},onItemCollision:function(item){var name=GS.MapEntities[item.sourceObj.type].name;(this.pickupWeapon(name)||this.pickupAmmo(name)||this.pickupMedkit(name))&&(this.grid.aiManager.onPlayerItemPickup(this,item),item.remove(),this.playerView.onItemPickup())},pickupWeapon:function(name){if(void 0!==this.availableWeapons[name]){var weapon=this.availableWeapons[name];return weapon.pickedUp||(weapon.pickedUp=!0,GS.DebugUI.addTempLine("picked up "+weapon.name),(void 0===this.weapon||this.swapWeaponsOnPickup&&weapon.powerLevel>this.weapon.powerLevel)&&(this.weapon=weapon,this.weaponName=name,this.playerView.changeToWeapon(name))),weapon.ammo+=weapon.ammoClip,this.grid.soundManager.playSound("pickup_weapon"),weapon.ammo>weapon.ammoMax&&(weapon.ammo=weapon.ammoMax),GS.DebugUI.addTempLine("picked up "+weapon.ammoClip+" "+weapon.name+" ammo"),!0}return!1},pickupAmmo:function(name){var that=this,once=!1;return!("ammo"!=name||(Object.keys(this.availableWeapons).forEach(function(key){var weapon=that.availableWeapons[key];!weapon.infiniteAmmo&&weapon.ammo<weapon.ammoMax&&(weapon.ammo+=weapon.ammoClip,weapon.ammo>weapon.ammoMax&&(weapon.ammo=weapon.ammoMax),GS.DebugUI.addTempLine("picked up "+weapon.ammoClip+" "+weapon.name+" ammo"),once=!0)}),!once))&&(this.grid.soundManager.playSound("pickup_ammo"),!0)},pickupMedkit:function(name){return"medkit"==name&&this.health<100&&(GS.DebugUI.addTempLine("picked up medkit"),this.health+=25,this.health>100&&(this.health=100),this.grid.soundManager.playSound("pickup_item"),!0)},updateUse:function(){this.canUse&&GS.Keybinds.use.inUse&&this.useTarget.onUse()},updateShoot:function(){if(void 0!==this.weapon){if(this.weapon.cooldownRemaining>0)return void(this.weapon.cooldownRemaining-=1);var oldShooting=this.shooting;if(GS.Keybinds.shoot.inUse&&this.playerView.weaponReady){if(this.weapon.infiniteAmmo||this.weapon.ammo>0){this.shooting=!0,this.shooting&&!oldShooting&&this.shootStart(),this.weapon.infiniteAmmo||(this.weapon.ammo-=this.weapon.bulletsPerShot),this.playerView.shoot(),this.playShootSound(),this.weapon.cooldownRemaining=GS.msToFrames(this.weapon.cooldown);var projectileStart=this.getProjectileStart();this.weapon.hitscan?this.grid.collisionManager.hitscan(this,projectileStart,this.weapon,this.xAngle,this.yAngle):"hyper_blaster"==this.weaponName?this.grid.addProjectile(this,"hyper_blaster_bolt",projectileStart,this.direction.clone()):"pistol"==this.weaponName&&this.grid.addProjectile(this,"pistol_bolt",projectileStart,this.direction.clone())}this.weapon.infiniteAmmo||0!==this.weapon.ammo||this.trySwapToWeaponWithAmmo()}else this.shooting=!1,!this.shooting&&oldShooting&&this.shootEnd()}},playShootSound:function(){var name;"double_shotgun"==this.weaponName?name="shotgun_fire":"hyper_blaster"==this.weaponName?name="hyper_blaster_fire":"pistol"==this.weaponName&&(name="hyper_blaster_fire"),this.grid.soundManager.playSound(name)},shootStart:function(){this.grid.aiManager.onPlayerShoot(this)},shootEnd:function(){},trySwapToWeaponWithAmmo:function(){for(var keys=Object.keys(this.availableWeapons),i=keys.length-1;i>=0;i--){var name=keys[i],weapon=this.availableWeapons[name];if(weapon.pickedUp&&(weapon.infiniteAmmo||weapon.ammo>0)){
this.changeToWeapon(name);break}}},getProjectileStart:function(){var projectileStart=this.position.clone();return projectileStart.y+=this.controls.eyeOffsetY,projectileStart},updateChangeWeapon:function(){var that=this;Object.keys(this.availableWeapons).forEach(function(key){var weapon=that.availableWeapons[key];weapon.pickedUp&&weapon!==that.weapon&&void 0!==that.weapon&&that.playerView.weaponReady&&GS.Keybinds[weapon.name].inUse&&that.changeToWeapon(key)})},changeToWeapon:function(name){this.weapon=this.availableWeapons[name],this.weaponName=name,this.playerView.changeToWeapon(name)},updateControls:function(e){this.ySmoothingCooldown>0?(this.ySmoothingCooldown--,this.controls.ySmoothing=!0):this.controls.ySmoothing=!1,this.controls.update(),this.direction.copy(this.controls.lookNoOffset).sub(this.controls.followingEye).normalize(),this.xAngle=this.controls.xAngle,this.yAngle=this.controls.yAngle,this.playerView.update()},moveStart:function(){},moveEnd:function(){},updateCollisionData:function(newPos){this.playerView.updateThrottle(this.position,newPos);var velocity=newPos.clone().sub(this.position);this.updateTriangles(velocity);var oldMoving=this.moving;this.moving=!this.position.equals(newPos),this.position.copy(newPos),this.controls.eye.copy(newPos),this.moving&&!oldMoving?this.moveStart():!this.moving&&oldMoving&&this.moveEnd(),this.updateBoundingBox()}}),GS.Projectile=function(grid,sourceGridObject,type,position,direction){GS.GridObject.call(this,grid),$.extend(!0,this,GS.Projectiles[type]),this.sourceGridObject=sourceGridObject,this.type=type,this.position=position,this.direction=direction,this.steps=0,this.maxSteps=Math.floor(this.maxDistance/this.speed),this.view={collisionData:{boundingBox:new THREE.Box3,ellipsoid:this.size}}},GS.Projectile.prototype=GS.inherit(GS.GridObject,{constructor:GS.Projectile,init:function(){this.updateBoundingBox(),this.particle=this.grid.particleView.addParticle(this.visualSize.x,this.visualSize.y,this.visualSize.z,this.color),this.view.mesh=this.particle.mesh,this.view.mesh.lookAt(this.direction),this.view.mesh.visible=!1;var points=[new THREE.Vector2(this.position.x-this.size.x,this.position.z-this.size.z),new THREE.Vector2(this.position.x+this.size.x,this.position.z+this.size.z)],gridLocation=this.grid.getGridLocationFromPoints(points);this.assignToCells(gridLocation)},update:function(){this.steps++;var newPos=this.position.clone().add(this.direction.clone().multiplyScalar(this.speed));this.grid.collisionManager.collideProjectile(this,this.position,newPos),this.view.mesh.position.copy(this.position),this.rotating&&(this.view.mesh.rotation.x+=.1,this.view.mesh.rotation.y+=.1),(this.steps>this.maxSteps||0===this.linkedGridCells.length)&&this.remove()},updateCollisionData:function(newPos){this.distanceTravelled+=newPos.distanceTo(this.position),this.steps>1&&(this.view.mesh.visible=!0),this.position.copy(newPos),this.updateBoundingBox()},onHit:function(){this.grid.soundManager.playSound(this.hitSound),this.remove()},remove:function(){this.particle.toBeRemoved=!0,GS.GridObject.prototype.remove.call(this)}}),GS.Switch=function(grid,seg){GS.GridObject.call(this,grid),this.segment=seg,this.on=!1,this.usable=!0,this.view={collisionData:{boundingBox:new THREE.Box3}}},GS.Switch.prototype=GS.inherit(GS.GridObject,{constructor:GS.Switch,init:function(){},onUse:function(){this.on=!0,this.view.mesh.material.map=this.view.textureOn,this.usable=!1,this.grid.aiManager.onSwitchStateChange(this),this.grid.soundManager.playSound("switch_on")},block:function(){this.on=!0,this.view.mesh.material.map=this.view.textureOn,this.usable=!1}}),GS.TVScreen=function(grid,seg){GS.GridObject.call(this,grid),this.segment=seg,this.view={}},GS.TVScreen.prototype=GS.inherit(GS.GridObject,{constructor:GS.TVScreen,init:function(){}}),GS.FontLoader=function(){this.fontPath=""},GS.FontLoader.prototype={constructor:GS.FontLoader,load:function(name,filename,callback){var path=this.fontPath+filename;$("head").prepend(["<style type='text/css'>","@font-face {","font-family: '"+name+"';","src: url('"+path+"') format('woff');","font-weight: normal;","font-style: normal;","}","</style>"].join("\n"));var node=document.createElement("span");node.innerHTML="giItT1WQy@!-/#",node.style.position="absolute",node.style.left="-10000px",node.style.top="-10000px",node.style.fontSize="300px",node.style.fontFamily="sans-serif",node.style.fontVariant="normal",node.style.fontStyle="normal",node.style.fontWeight="normal",node.style.letterSpacing="0",document.body.appendChild(node);var width=node.offsetWidth;node.style.fontFamily=name;var intervalId=setInterval(function(){node.offsetWidth!=width&&(node.parentNode.removeChild(node),clearInterval(intervalId),callback())},50)}},GS.MapScripts={},GS.MapLoader=function(){this.mapPath="assets/maps/"},GS.MapLoader.prototype={constructor:GS.MapLoader,loadTestMap:function(){var testMap=window.localStorage.testMap;return testMap||alert("testMap not found in localStorage"),testMap},load:function(name,filename,callback){var path=this.mapPath+filename;$.ajax({url:path,dataType:"text",success:function(jsonStr){callback(jsonStr)},error:function(jqXHR,textStatus,errorThrown){throw errorThrown}})},parse:function(text){var map;try{map=JSON.parse(text,function(k,v){if(v instanceof Object){if(void 0!==v.x&&void 0!==v.y&&void 0!==v.z)return new THREE.Vector3(v.x,v.y,v.z);if(void 0!==v.x&&void 0!==v.y)return new THREE.Vector2(v.x,v.y)}return v})}catch(ex){GAME.handleFatalError("invalid map - parse error")}return map.bounds=this.getMapBounds(map),map},getMapBounds:function(map){var points=[];map.layerObjects||GAME.handleFatalError("invalid map - no layer objects");for(var segs=map.layerObjects[GS.MapLayers.Segment],i=0;i<segs.length;i++){var seg=segs[i];points.push((new THREE.Vector2).copy(seg.start)),points.push((new THREE.Vector2).copy(seg.end))}for(var sectors=map.layerObjects[GS.MapLayers.Sector],i=0;i<sectors.length;i++)for(var sector=sectors[i],j=0;j<sector.vertices.length;j++){var vertex=sector.vertices[j];points.push((new THREE.Vector2).copy(vertex))}var bounds=new THREE.Box2;return bounds.setFromPoints(points),bounds}},GS.ZipAssetLoader=function(audioContext){this.audioContext=audioContext,this.objLoader=new THREE.OBJLoader,this.mapLoader=new GS.MapLoader,this.fontLoader=new GS.FontLoader,this.fontLoader.fontPath="",this.zipPath="assets.zip",this.path={},this.path[GS.AssetTypes.Texture]="textures/",this.path[GS.AssetTypes.CubeTexture]="textures/",this.path[GS.AssetTypes.UIWidget]="textures/widgets/",this.path[GS.AssetTypes.Mesh]="meshes/",this.path[GS.AssetTypes.Sound]="sounds/",this.path[GS.AssetTypes.Map]="maps/",this.path[GS.AssetTypes.Script]="scripts/",this.path[GS.AssetTypes.MusicTrack]="music/",this.reset()},GS.ZipAssetLoader.prototype={reset:function(){this.loaded=!1,this.assetsToLoad=0,this.queue=[],this.assets={},this.assets[GS.AssetTypes.Texture]={},this.assets[GS.AssetTypes.CubeTexture]={},this.assets[GS.AssetTypes.UIWidget]={},this.assets[GS.AssetTypes.Mesh]={},this.assets[GS.AssetTypes.Sound]={},this.assets[GS.AssetTypes.Map]={},this.assets[GS.AssetTypes.Script]={},this.assets[GS.AssetTypes.MusicTrack]={}},init:function(){for(var j in GS.AssetTypes){var assetDict=GS.Assets[GS.AssetTypes[j]];for(var i in assetDict)this.add(i,assetDict[i].filename,GS.AssetTypes[j])}},add:function(name,filename,type){this.queue.push({name:name,filename:filename,type:type}),this.assetsToLoad++},loadZip:function(){var that=this,xhr=new XMLHttpRequest;xhr.open("GET",this.zipPath,!0),xhr.responseType="arraybuffer",xhr.onreadystatechange=function(e){4==this.readyState&&200==this.status&&(that.zip=new JSZip(this.response),setTimeout(function(){that._load()},0))},xhr.onprogress=function(e){that.zipOnProgress(e)},xhr.send()},_load:function(){var that=this;this.totalAssets=this.queue.length+1,this.assetsToLoad++,this.fontLoader.load("hudFont",GS.CustomFontFile,function(){that.checkIfFullyLoaded()});for(var asset;this.queue.length>0;)asset=this.queue.pop(),asset.name in this.assets[asset.type]?this.assetsToLoad--:this.loadAsset(asset)},load:function(){this.loadZip()},loadAsset:function(asset){switch(asset.type){case GS.AssetTypes.Texture:this.loadTexture(asset.name,asset.filename);break;case GS.AssetTypes.CubeTexture:this.loadCubeTexture(asset.name,asset.filename);break;case GS.AssetTypes.UIWidget:this.loadUIWidget(asset.name,asset.filename);break;case GS.AssetTypes.Mesh:this.loadMesh(asset.name,asset.filename);break;case GS.AssetTypes.Sound:this.loadSound(asset.name,asset.filename,GS.AssetTypes.Sound);break;case GS.AssetTypes.Map:this.loadMap(asset.name,asset.filename);break;case GS.AssetTypes.Script:this.loadScript(asset.name,asset.filename);break;case GS.AssetTypes.MusicTrack:this.loadSound(asset.name,asset.filename,GS.AssetTypes.MusicTrack)}},getImageFromZip:function(path){var buffer=this.zip.file(path).asArrayBuffer(),blob=new Blob([buffer],{type:"image/png"}),urlCreator=window.URL||window.webkitURL,imageUrl=urlCreator.createObjectURL(blob),img=new Image;return img.src=imageUrl,img},getTextureFromZip:function(path){var img=this.getImageFromZip(path),tex=new THREE.Texture(img);return tex.needsUpdate=!0,tex},loadTexture:function(name,filename){var path=this.path[GS.AssetTypes.Texture]+filename;this.assets[GS.AssetTypes.Texture][name]=this.getTextureFromZip(path),this.checkIfFullyLoaded()},loadCubeTexture:function(name,folder){var path=this.path[GS.AssetTypes.CubeTexture]+folder+"/",tex=new THREE.Texture;tex.image=[],tex.flipY=!1;for(var i=0;i<GS.CubeTextureNames.length;i++)tex.image[i]=this.getImageFromZip(path+GS.CubeTextureNames[i]+GS.CubeTextureExtension);tex.needsUpdate=!0,this.assets[GS.AssetTypes.CubeTexture][name]=tex,this.checkIfFullyLoaded()},loadUIWidget:function(name,filename){var path=this.path[GS.AssetTypes.UIWidget]+filename;this.assets[GS.AssetTypes.UIWidget][name]=this.getImageFromZip(path),this.checkIfFullyLoaded()},loadMesh:function(name,filename){var path=this.path[GS.AssetTypes.Mesh]+filename,text=this.zip.file(path).asText();this.assets[GS.AssetTypes.Mesh][name]=this.objLoader.parse(text).children[0],this.checkIfFullyLoaded()},loadSound:function(name,filename,assetType){var that=this,path=this.path[assetType]+filename,encodedBuffer=this.zip.file(path).asArrayBuffer();this.audioContext.decodeAudioData(encodedBuffer,function(buffer){that.assets[assetType][name]=buffer,that.checkIfFullyLoaded()})},loadMap:function(name,filename){var path=this.path[GS.AssetTypes.Map]+filename;"testMap"!==name?this.assets[GS.AssetTypes.Map][name]=this.zip.file(path).asText():GAME.isTestMap()&&(this.assets[GS.AssetTypes.Map][name]=this.mapLoader.loadTestMap()),this.checkIfFullyLoaded()},loadScript:function(name,filename){var path=this.path[GS.AssetTypes.Script]+filename,scriptTag=document.createElement("script");scriptTag.text=this.zip.file(path).asText(),document.body.appendChild(scriptTag),this.checkIfFullyLoaded()},zipOnProgress:function(e){var percentLoaded=e.loaded/e.total*50;this.dispatchEvent({type:"progress",percentLoaded:percentLoaded.toFixed(0)})},checkIfFullyLoaded:function(){this.assetsToLoad--;var percentLoaded=100*(.5+(this.totalAssets-this.assetsToLoad)/this.totalAssets*.5);this.dispatchEvent({type:"progress",percentLoaded:percentLoaded.toFixed(0)}),0===this.assetsToLoad&&(this.loaded=!0,this.dispatchEvent({type:"load",percentLoaded:100,assets:this.assets}))}},THREE.EventDispatcher.prototype.apply(GS.ZipAssetLoader.prototype),GS.GridFactory=function(viewFactory,soundManager,renderer,scene,camera){this.viewFactory=viewFactory,this.soundManager=soundManager,this.renderer=renderer,this.scene=scene,this.camera=camera,this.gridCellSize=8},GS.GridFactory.prototype={constructor:GS.GridFactory,getGrid:function(map){for(var hCells=Math.ceil((map.bounds.max.x-map.bounds.min.x)/this.gridCellSize),vCells=Math.ceil((map.bounds.max.y-map.bounds.min.y)/this.gridCellSize),cells=[],i=0;i<vCells;i++){cells[i]=[];for(var j=0;j<hCells;j++){var min=new THREE.Vector2(j*this.gridCellSize,i*this.gridCellSize).add(map.bounds.min),max=new THREE.Vector2((j+1)*this.gridCellSize,(i+1)*this.gridCellSize).add(map.bounds.min),box2=new THREE.Box2(min,max);cells[i][j]={box2:box2,children:[],x:j,y:i}}}var grid=new GS.Grid(this.renderer,this.scene);return grid.clearScene(),grid.cellSize=this.gridCellSize,grid.cells=cells,grid.width=hCells,grid.height=vCells,grid.map=map,grid.regionInfo=this.getRegions(map),grid.soundManager=this.soundManager,this.assignMapEntitiesToGrid(grid),this.addPlayerToGrid(grid),grid.initSkybox(this.viewFactory.getSkyboxMesh()),grid.init(),grid},getRegions:function(map){var sectors=map.layerObjects[GS.MapLayers.Sector],sectorLinks=map.sectorLinks;if(void 0===sectorLinks)return void GAME.handleFatalError("invalid map - sector links not found");var regionHelper=new GS.RegionHelper;return regionHelper.getRegions(sectors,sectorLinks)},addPlayerToGrid:function(grid){var playerView=this.viewFactory.getPlayerView();grid.player=new GS.Player(grid,this.camera,playerView);var position=new THREE.Vector3;position.x=grid.map.playerStartPosition.x,position.y=0,position.z=grid.map.playerStartPosition.y-1e-4,grid.player.position=position;var gridLocation=grid.getGridLocationFromPoints([grid.map.playerStartPosition]);grid.player.assignToCells(gridLocation),grid.player.view.debugMesh=this.viewFactory.getDebugMesh(position,grid.player.size)},assignMapEntitiesToGrid:function(grid){for(var sectorDict={},sectors=grid.map.layerObjects[GS.MapLayers.Sector],i=0;i<sectors.length;i++){var sector=sectors[i];sectorDict[sector.id]=sector;var hasFloor=sector.elevator!==!0,hasCeiling=sector.ceiling===!0&§or.door!==!0,gridLocation=grid.getGridLocationFromPoints(sector.collisionVertices);if(hasFloor||hasCeiling){if(hasFloor){var floor=new GS.Concrete(grid,GS.MapLayers.Sector,sector);floor.region=this.getRegionBySectorId(grid,sector.id),this.viewFactory.applySectorView(floor,!1),floor.assignToCells(gridLocation)}if(hasCeiling){var ceiling=new GS.Concrete(grid,GS.MapLayers.Sector,sector);ceiling.region=this.getRegionBySectorId(grid,sector.id),this.viewFactory.applySectorView(ceiling,!0),ceiling.assignToCells(gridLocation)}}sector.door===!0?this.addDoor(grid,gridLocation,sector):sector.elevator===!0&&this.addElevator(grid,gridLocation,sector)}for(var segs=grid.map.layerObjects[GS.MapLayers.Segment],i=0;i<segs.length;i++){var seg=segs[i],points=[];points.push((new THREE.Vector2).copy(seg.start)),points.push((new THREE.Vector2).copy(seg.end));var gridLocation=grid.getGridLocationFromPoints(points);if(seg.type!==GS.SegmentTypes.TVScreen&&seg.type!==GS.SegmentTypes.Switch){var gridObject=new GS.Concrete(grid,GS.MapLayers.Segment,seg);gridObject.sector=sectorDict[seg.sectorId],gridObject.region=this.getRegionBySectorId(grid,seg.sectorId),this.viewFactory.applySegmentView(gridObject),gridObject.assignToCells(gridLocation)}else seg.type===GS.SegmentTypes.TVScreen?this.addTVScreen(grid,gridLocation,seg):seg.type===GS.SegmentTypes.Switch&&this.addSwitch(grid,gridLocation,seg)}for(var entities=grid.map.layerObjects[GS.MapLayers.Entity],i=0;i<entities.length;i++){var ntt=entities[i],type=GS.MapEntities[ntt.type].type,gridObject=new GS[type](grid,GS.MapLayers.Entity,ntt),offset=gridObject.offset,size=gridObject.size;gridObject.position=offset.clone(),gridObject.position.x+=ntt.pos.x,gridObject.position.y+=ntt.y||0,gridObject.position.z+=ntt.pos.y,gridObject.isStatic=ntt.isStatic;var points=[ntt.pos.clone().add(new THREE.Vector2(offset.x,offset.z)).sub(new THREE.Vector2(size.x,size.z)),ntt.pos.clone().add(new THREE.Vector2(offset.x,offset.z)).add(new THREE.Vector2(size.x,size.z))],gridLocation=grid.getGridLocationFromPoints(points);this.viewFactory.applyEntityView(gridObject),gridObject.assignToCells(gridLocation),gridObject.startingSector=gridObject.getSector()}},addDoor:function(grid,gridLocation,sector){var door=new GS.Door(grid,sector);this.viewFactory.applyDoorView(door),door.assignToCells(gridLocation),sector.doorOpenedEver=!1},addElevator:function(grid,gridLocation,sector){var elevator=new GS.Elevator(grid,sector);this.viewFactory.applyElevatorView(elevator),elevator.assignToCells(gridLocation)},addTVScreen:function(grid,gridLocation,seg){var tvScreen=new GS.TVScreen(grid,seg);this.viewFactory.applyTVScreenView(tvScreen),tvScreen.assignToCells(gridLocation)},addSwitch:function(grid,gridLocation,seg){var switchObj=new GS.Switch(grid,seg);this.viewFactory.applySwitchView(switchObj),switchObj.assignToCells(gridLocation)},getRegionBySectorId:function(grid,sectorId){for(var regions=grid.regionInfo.regions,i=0;i<regions.length;i++)if(sectorId in regions[i].sectorIds)return regions[i];GAME.handleFatalError("sector has no corresponding region")}},GS.ViewFactory=function(renderer,map,assets){this.renderer=renderer,this.map=map,this.textures=assets[GS.AssetTypes.Texture],this.cubeTextures=assets[GS.AssetTypes.CubeTexture],this.meshes=assets[GS.AssetTypes.Mesh],this.anisotropy=renderer.getMaxAnisotropy(),this.debugBoundingBoxMaterial=new THREE.MeshBasicMaterial({color:16777215,wireframe:!0}),this.debugTriangleMaterial=new THREE.MeshBasicMaterial({color:49407,wireframe:!0}),this.texScale=16,this.triangleCount=0},GS.ViewFactory.prototype={constructor:GS.ViewFactory,init:function(){var that=this;Object.keys(this.textures).forEach(function(key){that.textures[key].anisotropy=that.anisotropy}),this.materials={};var textureAssets=GS.Assets[GS.AssetTypes.Texture];for(var i in textureAssets){var tex=textureAssets[i];tex.type===GS.TextureTypes.Map?(this.wrap(this.textures[i]),this.materials[i]=new THREE.MeshPhongMaterial({map:this.textures[i]})):tex.type===GS.TextureTypes.TVScreen&&(this.textures[i].flipY=!1)}for(var entities=this.map.layerObjects[GS.MapLayers.Entity],entityMaterials={},i=0;i<entities.length;i++){var ntt=entities[i],desc=GS.MapEntities[ntt.type],name=desc.name;void 0===entityMaterials[name]&&(entityMaterials[name]=!0,this.materials[name]=new GS.MeshPhongGlowMaterial(this.textures[name],this.textures[name+"_glow"]))}this.vertexColorMaterial=new GS.MeshVertexColorMaterial;for(var i in GS.Weapons)this.wrap(this.textures[i]),this.materials[i]=new GS.MeshPhongGlowMaterial(this.textures[i],this.textures[i+"_glow"])},getSkyboxMesh:function(){var name="skybox1",tex=this.cubeTextures[name];tex.format=THREE.RGBFormat;var shader=THREE.ShaderLib.cube,uniforms=THREE.UniformsUtils.clone(shader.uniforms);uniforms.tCube.value=tex;var material=new THREE.ShaderMaterial({fragmentShader:shader.fragmentShader,vertexShader:shader.vertexShader,uniforms:uniforms,depthWrite:!1,side:THREE.BackSide}),geometry=new THREE.BoxGeometry(1e3,1e3,1e3),mesh=new THREE.Mesh(geometry,material);return mesh},wrap:function(tex){tex.wrapS=tex.wrapT=THREE.RepeatWrapping},applySegmentView:function(gridObject){var seg=gridObject.sourceObj,geometry=new THREE.Geometry,triangles=this.getSegmentDefinedTriangles(seg);GS.pushArray(geometry.vertices,triangles);var length,distance=seg.start.distanceTo(seg.end);length=distance>this.texScale?Math.round(distance/(this.texScale*this.texScale)*this.texScale):distance/this.texScale;for(var color=new THREE.Color(seg.lightColor),emissive=this.getEmissiveColor(gridObject.sector.lightLevel),i=0;i<triangles.length;i+=3){var face=new THREE.Face3(i,i+1,i+2,null,color);face.emissive=emissive,geometry.faces.push(face)}geometry.computeFaceNormals(),geometry.computeVertexNormals(),gridObject.region.mesh.geometry.merge(geometry),gridObject.view.collisionData.triangles=this.getSegmentTriangles(seg),this.applyConcreteBoundingBox(gridObject,triangles),this.triangleCount+=gridObject.view.collisionData.triangles.length/3},getEmissiveColor:function(lightLevel){var lightLevelFactor=.1,minLightLevel=.1,maxLightLevel=.75,x=lightLevel*lightLevelFactor;return x*=x,x=GS.MathHelper.clamp(x,minLightLevel,maxLightLevel),new THREE.Color(16777215).multiplyScalar(x)},applySectorView:function(gridObject,ceiling){var geometry,sector=gridObject.sourceObj,triangles=[];if(ceiling){var hasCeiling=void 0===sector.ceiling||sector.ceiling;hasCeiling&&(geometry=this.getSectorGeometry(sector,triangles,!0),gridObject.region.mesh.geometry.merge(geometry))}else sector.elevator!==!0&&(geometry=this.getSectorGeometry(sector,triangles,!1),gridObject.region.mesh.geometry.merge(geometry));gridObject.view.collisionData.triangles=triangles,this.applyConcreteBoundingBox(gridObject,triangles),this.triangleCount+=triangles.length/3},applyConcreteBoundingBox:function(gridObject,triangles){var boundingBox=(new THREE.Box3).setFromPoints(triangles),center=boundingBox.min.clone().add(boundingBox.max).divideScalar(2),debugMesh=this.getDebugMesh(center);debugMesh.scale.copy(boundingBox.max).sub(boundingBox.min).addScalar(.01),gridObject.view.collisionData.boundingBox=boundingBox,gridObject.view.debugMesh=debugMesh},getSectorGeometry:function(sector,sectorTriangles,ceiling){var geometry=new THREE.Geometry,triangles=this.getSectorTriangles(sector,ceiling);GS.pushArray(geometry.vertices,triangles),GS.pushArray(sectorTriangles,this.getSectorTriangles(sector,ceiling,!0));for(var emissive=this.getEmissiveColor(sector.lightLevel),color=new THREE.Color(ceiling?sector.ceilingCatColor:sector.lightColor),j=0;j<triangles.length;j+=3){var face=new THREE.Face3(j,j+1,j+2,null,color);face.emissive=emissive,geometry.faces.push(face)}return geometry.computeFaceNormals(),geometry.computeVertexNormals(),geometry},getSegmentDefinedTriangles:function(seg){for(var triangles=[],bottomRightIndex=0,i=0;i<seg.indices.length;i+=3)triangles.push(seg.vertices[seg.indices[i]]),triangles.push(seg.vertices[seg.indices[i+1]]),triangles.push(seg.vertices[seg.indices[i+2]]),seg.indices[i+2]==seg.bottomRightIndex&&(bottomRightIndex=i+3);return seg.bottomRightIndex=bottomRightIndex,triangles},getSegmentTriangles:function(seg){var triangles=[];return triangles.push(new THREE.Vector3(seg.start.x,seg.topY,seg.start.y)),triangles.push(new THREE.Vector3(seg.end.x,seg.topY,seg.end.y)),triangles.push(new THREE.Vector3(seg.start.x,seg.bottomY,seg.start.y)),triangles.push(new THREE.Vector3(seg.end.x,seg.topY,seg.end.y)),triangles.push(new THREE.Vector3(seg.end.x,seg.bottomY,seg.end.y)),triangles.push(new THREE.Vector3(seg.start.x,seg.bottomY,seg.start.y)),triangles},getSectorTriangles:function(sector,ceiling,getCollisionTriangles){var triangles=[],v=sector.vertices,idx=sector.indices;if(getCollisionTriangles&&(v=sector.collisionVertices,idx=sector.collisionIndices),ceiling)for(var i=0;i<idx.length;i+=3)triangles.push(new THREE.Vector3(v[idx[i]].x,sector.ceilBottomY,v[idx[i]].y)),triangles.push(new THREE.Vector3(v[idx[i+1]].x,sector.ceilBottomY,v[idx[i+1]].y)),triangles.push(new THREE.Vector3(v[idx[i+2]].x,sector.ceilBottomY,v[idx[i+2]].y));else for(var i=0;i<idx.length;i+=3)triangles.push(new THREE.Vector3(v[idx[i+2]].x,sector.floorTopY,v[idx[i+2]].y)),triangles.push(new THREE.Vector3(v[idx[i+1]].x,sector.floorTopY,v[idx[i+1]].y)),triangles.push(new THREE.Vector3(v[idx[i]].x,sector.floorTopY,v[idx[i]].y));return triangles},applyEntityView:function(gridObject){var vertices=GS.Cube.getVertices();return function(gridObject){var mesh,that=this,ntt=gridObject.sourceObj,desc=GS.MapEntities[ntt.type],name=GS.MapEntities[ntt.type].name,offset=gridObject.offset,scale=gridObject.scale,size=gridObject.size,material=this.materials[name].clone();if(void 0===desc.animations)mesh=this.meshes[name].clone(),mesh.material=material;else{mesh=new THREE.Object3D;var data=mesh.userData;data.animations={},Object.keys(desc.animations).forEach(function(key){var count=desc.animations[key];data.animations[key]=[];for(var i=0;i<count;i++){var animationName=name+"_"+key+i,animMesh=that.meshes[animationName].clone();animMesh.visible=!1,animMesh.material=material,data.animations[key].push(animMesh),mesh.add(animMesh)}})}if(mesh.position.copy(offset),mesh.position.copy(gridObject.position),mesh.scale.copy(scale),gridObject.view.mesh=mesh,gridObject.view.debugMesh=this.getDebugMesh(gridObject.position),gridObject instanceof GS.Monster){gridObject.view.collisionData.triangles=[];for(var i=0;i<vertices.length;i++){var v=vertices[i].clone();v.multiply(size).add(gridObject.view.mesh.position),gridObject.view.collisionData.triangles.push(v)}gridObject.view.collisionData.boundingSquare.setFromPoints([gridObject.position.toVector2().sub(gridObject.size.toVector2()),gridObject.position.toVector2().add(gridObject.size.toVector2())])}}}(),getSegmentsForMovingSector:function(gridObject,elevator){for(var sector=gridObject.sector,segs=[],i=0;i<sector.collisionVertices.length-1;i++)segs.push({start:sector.collisionVertices[i].clone(),end:sector.collisionVertices[i+1].clone()});if(segs.push({start:sector.collisionVertices[i].clone(),end:sector.collisionVertices[0].clone()}),elevator!==!0)for(var i=0;i<segs.length;i++)segs[i].bottomY=sector.floorTopY,segs[i].topY=sector.ceilBottomY;else for(var i=0;i<segs.length;i++)segs[i].bottomY=sector.floorTopY-sector.elevatorMaxHeight,segs[i].topY=sector.floorTopY;return segs},applyDoorView:function(door){var triangles=[];door.position=this.getMovingSectorPosition(door),door.view.collisionData.segments=this.getSegmentsForMovingSector(door,!1);var centerMaterial=this.vertexColorMaterial,sideMaterial=this.vertexColorMaterial;door.sector.useVertexColors||(centerMaterial=this.materials[door.sector.ceilTexId].clone(),sideMaterial=this.materials[door.sector.sideTexId].clone());var mesh=new THREE.Object3D;mesh.children.push(this.getMovingSectorCenterMesh(door,triangles,centerMaterial)),mesh.children.push(this.getMovingSectorSideMesh(door,triangles,sideMaterial)),mesh.children[0].position.copy(door.position),mesh.children[1].position.copy(door.position),door.view.mesh=mesh,door.view.collisionData.triangles=triangles,door.view.debugMesh=this.getDebugMesh(door.position);var box=door.view.collisionData.boundingBox;box.setFromPoints(triangles),door.size=box.max.clone().sub(box.min).divideScalar(2),this.triangleCount+=triangles.length/3},applyElevatorView:function(elevator){var triangles=[];elevator.position=this.getMovingSectorPosition(elevator,!0),elevator.view.collisionData.segments=this.getSegmentsForMovingSector(elevator,!0);var centerMaterial=this.vertexColorMaterial,sideMaterial=this.vertexColorMaterial;elevator.sector.useVertexColors||(centerMaterial=this.materials[elevator.sector.floorTexId].clone(),sideMaterial=this.materials[elevator.sector.sideTexId].clone());var mesh=new THREE.Object3D;mesh.children.push(this.getMovingSectorCenterMesh(elevator,triangles,centerMaterial,!0)),mesh.children.push(this.getMovingSectorSideMesh(elevator,triangles,sideMaterial,!0)),mesh.children[0].position.copy(elevator.position),mesh.children[1].position.copy(elevator.position),elevator.view.mesh=mesh,elevator.view.collisionData.triangles=triangles,elevator.view.debugMesh=this.getDebugMesh(elevator.position);var box=elevator.view.collisionData.boundingBox;box.setFromPoints(triangles),elevator.size=box.max.clone().sub(box.min).divideScalar(2),this.triangleCount+=triangles.length/3},getMovingSectorPosition:function(movingSector,elevator){var box=(new THREE.Box2).setFromPoints(movingSector.sector.vertices),center=box.min.clone().add(box.max).divideScalar(2),pos=new THREE.Vector3(center.x,0,center.y);return elevator!==!0?pos.y=(movingSector.sector.floorTopY+movingSector.sector.ceilBottomY)/2:pos.y=movingSector.sector.floorTopY-movingSector.sector.elevatorMaxHeight/2,pos},getMovingSectorSideMesh:function(movingSector,movingSectorTriangles,material,elevator){var bottomY,topY;elevator!==!0?(bottomY=movingSector.sector.floorTopY,topY=movingSector.sector.ceilBottomY):(bottomY=movingSector.sector.floorTopY-movingSector.sector.elevatorMaxHeight,topY=movingSector.sector.floorTopY);for(var geometry=new THREE.Geometry,color=new THREE.Color(movingSector.sector.lightColor),emissive=this.getEmissiveColor(movingSector.sector.lightLevel),triangles=[],k=0,i=0;i<movingSector.sector.vertices.length;i++){var length,next=i<movingSector.sector.vertices.length-1?i+1:0,start=movingSector.sector.vertices[i],end=movingSector.sector.vertices[next],distance=start.distanceTo(end);length=distance>this.texScale?Math.round(distance/(this.texScale*this.texScale)*this.texScale):distance/this.texScale;for(var vertices=[new THREE.Vector3(start.x,topY,start.y),new THREE.Vector3(end.x,topY,end.y),new THREE.Vector3(start.x,bottomY,start.y),new THREE.Vector3(end.x,topY,end.y),new THREE.Vector3(end.x,bottomY,end.y),new THREE.Vector3(start.x,bottomY,start.y)],j=0;j<vertices.length;j++)triangles.push(vertices[j].clone());for(var j=0;j<vertices.length;j++)vertices[j].sub(movingSector.position);if(GS.pushArray(geometry.vertices,vertices),movingSector.sector.useVertexColors){var face1=new THREE.Face3(k,k+1,k+2,null,color);face1.emissive=emissive,geometry.faces.push(face1);var face2=new THREE.Face3(k+3,k+4,k+5,null,color);face2.emissive=emissive,geometry.faces.push(face2)}else geometry.faces.push(new THREE.Face3(k,k+1,k+2)),geometry.faces.push(new THREE.Face3(k+3,k+4,k+5)),geometry.faceVertexUvs[0].push([new THREE.Vector2(0,topY/this.texScale),new THREE.Vector2(length,topY/this.texScale),new THREE.Vector2(0,bottomY/this.texScale)]),geometry.faceVertexUvs[0].push([new THREE.Vector2(length,topY/this.texScale),new THREE.Vector2(length,bottomY/this.texScale),new THREE.Vector2(0,bottomY/this.texScale)]);k+=6}if(GS.pushArray(movingSectorTriangles,triangles),geometry.computeFaceNormals(),geometry.computeVertexNormals(),movingSector.sector.useVertexColors){var bufferGeo=(new THREE.BufferGeometry).fromGeometry(geometry,{vertexColors:THREE.FaceColors});return new THREE.Mesh(bufferGeo,material)}return new THREE.Mesh(geometry,material)},getMovingSectorCenterMesh:function(movingSector,movingSectorTriangles,material,elevator){for(var v0,v1,v2,minHeight=movingSector.sector.floorTopY,geometry=new THREE.Geometry,color=new THREE.Color(movingSector.sector.lightColor),emissive=this.getEmissiveColor(movingSector.sector.lightLevel),v=movingSector.sector.vertices,idx=movingSector.sector.indices,i=0;i<idx.length;i+=3){if(elevator===!0?(v0=new THREE.Vector3(v[idx[i+2]].x,minHeight,v[idx[i+2]].y),v1=new THREE.Vector3(v[idx[i+1]].x,minHeight,v[idx[i+1]].y),v2=new THREE.Vector3(v[idx[i]].x,minHeight,v[idx[i]].y)):(v0=new THREE.Vector3(v[idx[i]].x,minHeight,v[idx[i]].y),v1=new THREE.Vector3(v[idx[i+1]].x,minHeight,v[idx[i+1]].y),v2=new THREE.Vector3(v[idx[i+2]].x,minHeight,v[idx[i+2]].y)),movingSector.sector.useVertexColors){var face=new THREE.Face3(i,i+1,i+2,null,color);face.emissive=emissive,geometry.faces.push(face)}else geometry.faces.push(new THREE.Face3(i,i+1,i+2)),geometry.faceVertexUvs[0].push([new THREE.Vector2(v0.x/this.texScale,v0.z/this.texScale),new THREE.Vector2(v1.x/this.texScale,v1.z/this.texScale),new THREE.Vector2(v2.x/this.texScale,v2.z/this.texScale)]);v0.sub(movingSector.position),v1.sub(movingSector.position),v2.sub(movingSector.position),geometry.vertices.push(v0),geometry.vertices.push(v1),geometry.vertices.push(v2)}v=movingSector.sector.collisionVertices,idx=movingSector.sector.collisionIndices;for(var i=0;i<idx.length;i+=3)elevator===!0?(v0=new THREE.Vector3(v[idx[i+2]].x,minHeight,v[idx[i+2]].y),v1=new THREE.Vector3(v[idx[i+1]].x,minHeight,v[idx[i+1]].y),v2=new THREE.Vector3(v[idx[i]].x,minHeight,v[idx[i]].y)):(v0=new THREE.Vector3(v[idx[i]].x,minHeight,v[idx[i]].y),v1=new THREE.Vector3(v[idx[i+1]].x,minHeight,v[idx[i+1]].y),v2=new THREE.Vector3(v[idx[i+2]].x,minHeight,v[idx[i+2]].y)),movingSectorTriangles.push(v0),movingSectorTriangles.push(v1),movingSectorTriangles.push(v2);if(geometry.computeFaceNormals(),geometry.computeVertexNormals(),movingSector.sector.useVertexColors){var bufferGeo=(new THREE.BufferGeometry).fromGeometry(geometry,{vertexColors:THREE.FaceColors});return new THREE.Mesh(bufferGeo,material)}return new THREE.Mesh(geometry,material)},applyTVScreenView:function(tvScreen){tvScreen.view.mesh=this.getTVScreenMesh(tvScreen),tvScreen.view.mesh.material=new THREE.MeshBasicMaterial({map:this.textures[tvScreen.segment.texId],
depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-4,transparent:!0})},applySwitchView:function(switchObj){switchObj.segment.bottomY+=8,switchObj.segment.topY=switchObj.segment.bottomY+8,switchObj.view.mesh=this.getTVScreenMesh(switchObj),switchObj.view.collisionData.boundingBox.setFromPoints([new THREE.Vector3(switchObj.segment.start.x,switchObj.segment.bottomY,switchObj.segment.start.y),new THREE.Vector3(switchObj.segment.end.x,switchObj.segment.topY,switchObj.segment.end.y)]),switchObj.view.textureOn=this.textures.switch_on,switchObj.view.textureOff=this.textures.switch_off,switchObj.view.mesh.material=new THREE.MeshBasicMaterial({map:switchObj.view.textureOff,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-4,transparent:!0})},getTVScreenMesh:function(tvScreen){var seg=tvScreen.segment,geometry=new THREE.Geometry,triangles=this.getSegmentTriangles(seg);GS.pushArray(geometry.vertices,triangles),geometry.faces.push(new THREE.Face3(0,1,2)),geometry.faces.push(new THREE.Face3(3,4,5)),geometry.faceVertexUvs[0].push([new THREE.Vector2(1,0),new THREE.Vector2(0,0),new THREE.Vector2(1,1)]),geometry.faceVertexUvs[0].push([new THREE.Vector2(0,0),new THREE.Vector2(0,1),new THREE.Vector2(1,1)]),geometry.computeFaceNormals(),geometry.computeVertexNormals();var mesh=new THREE.Mesh(geometry,(void 0));return mesh.matrixAutoUpdate=!1,mesh.renderDepth=1e3,mesh},getPlayerView:function(){for(var playerView=new GS.PlayerView,weapons=Object.keys(GS.Weapons),i=0;i<weapons.length;i++){var name=weapons[i];if(void 0!==this.meshes[name]){var material=this.materials[name].clone(),mesh=this.meshes[name].clone();mesh.material=material,playerView.addWeaponMesh(name,mesh)}}return playerView.init(),playerView},getDebugMesh:function(position){var debugGeometry=new THREE.BoxGeometry(1,1,1),debugMesh=new THREE.Mesh(debugGeometry,this.debugBoundingBoxMaterial);return debugMesh.position.copy(position),debugMesh},getDebugTriangleMesh:function(triangles){var debugGeometry=new THREE.Geometry;GS.pushArray(debugGeometry.vertices,triangles);for(var i=0;i<triangles.length;i+=3)debugGeometry.faces.push(new THREE.Face3(i,i+1,i+2));var debugMesh=new THREE.Mesh(debugGeometry,this.debugTriangleMaterial);return debugMesh.userData.isTriangleMesh=!0,debugMesh.matrixAutoUpdate=!1,debugMesh}},THREE.EventDispatcher.prototype.apply(GS.ViewFactory.prototype),GS.AIManager=function(grid){this.grid=grid,this.map=grid.map,this.mapWon=!1,this.monstersKilled=0,this.maxMonsters=0,this.itemsPickedUp=0,this.maxItems=0,this.lastFrameTime=performance.now(),this.timeSpent=0,this.minutes=0,this.seconds=0,this.regionsDiscovered={}},GS.AIManager.prototype={init:function(){this.initZones(),this.sectorDict=this.grid.regionInfo.sectorDict,this.regions=this.grid.regionInfo.regions;for(var i=0;i<this.regions.length;i++)this.regions[i].mesh.visible=!1;this.assignMonstersToRegions(),this.initGridObjectLibrary(),this.initScripts()},initZones:function(){this.zones=this.map.layerObjects[GS.MapLayers.Zone];for(var i=0;i<this.zones.length;i++){var zone=this.zones[i];zone.boundingSquare=(new THREE.Box2).setFromPoints([zone.start,zone.end])}},assignMonstersToRegions:function(){var that=this;this.grid.forEachUniqueGridObject([GS.Monster],function(monster){if(void 0===monster.startingSector)return void GAME.handleFatalError("monster "+monster.id+" has no starting sector");var region=that.getRegionBySectorId(monster.startingSector.id);return void 0===region?void GAME.handleFatalError("sector not in region"):void region.monsters.push(monster)})},initGridObjectLibrary:function(){var library={items:{},doors:{},elevators:{},monsters:{},sectors:{},switches:{}};this.grid.forEachUniqueGridObject([GS.Item,GS.Door,GS.Elevator,GS.Monster,GS.Concrete,GS.Switch],function(gridObject){gridObject instanceof GS.Item?library.items[gridObject.sourceObj.id]=gridObject:gridObject instanceof GS.Door?library.doors[gridObject.sector.id]=gridObject:gridObject instanceof GS.Elevator?library.elevators[gridObject.sector.id]=gridObject:gridObject instanceof GS.Monster?library.monsters[gridObject.sourceObj.id]=gridObject:gridObject instanceof GS.Concrete&&gridObject.type==GS.MapLayers.Sector?library.sectors[gridObject.sourceObj.id]=gridObject:gridObject instanceof GS.Switch&&(library.switches[gridObject.segment.id]=gridObject)}),this.gridObjectLibrary=library},initScripts:function(){if(this.map.hasScript===!0){this.script=new GS.MapScripts[this.map.name](this.gridObjectLibrary),this.script.init();for(var entities=this.grid.map.layerObjects[GS.MapLayers.Entity],i=0;i<entities.length;i++){var entity=entities[i],type=GS.MapEntities[entity.type].type;"Monster"===type?this.maxMonsters++:"Item"===type&&this.maxItems++}}},update:function(){void 0!==this.script&&(this.script.update(),this.script.mapWon&&!this.mapWon&&(this.mapWon=!0)),this.mapWon||this.updateTime()},updateTime:function(){this.grid.player.inMenu||(this.timeSpent+=performance.now()-this.lastFrameTime,this.minutes=Math.floor(Math.floor(this.timeSpent)/6e4),this.seconds=Math.floor(Math.floor(this.timeSpent)/1e3-60*this.minutes)),this.lastFrameTime=performance.now()},resume:function(){this.lastFrameTime=performance.now()},onMonsterDeath:function(){this.monstersKilled++},onPlayerMove:function(player,oldPos,newPos){void 0!==this.script&&this.checkZones(player,oldPos,newPos),this.wakeUpNearbyMonsters(player),this.applyRegionVisibility(player)},onPlayerShoot:function(player){this.activateNearbyMonsters(player)},onPlayerOpenDoor:function(door){void 0!==this.script&&this.script.onPlayerOpenDoor(door)},onPlayerItemPickup:function(player,item){this.itemsPickedUp++,void 0!==this.script&&this.script.onItemPickup(item)},onSwitchStateChange:function(switchObj){void 0!==this.script&&this.script.onSwitchStateChange(switchObj)},applyRegionVisibility:function(player){for(var i=0;i<this.regions.length;i++)this.regions[i].reachedThisFrame=!1;var visibleRegions=0;this.propagateRegions(player,function(region){region.reachedThisFrame=!0,region.mesh.visible=!0,visibleRegions++});for(var i=0;i<this.regions.length;i++){var region=this.regions[i];region.mesh.visible&&!region.reachedThisFrame&&(region.mesh.visible=!1)}},checkZones:function(){var oldPos2d=new THREE.Vector2,newPos2d=new THREE.Vector2;return function(player,oldPos,newPos){oldPos.toVector2(oldPos2d),newPos.toVector2(newPos2d);for(var i=0;i<this.zones.length;i++){var zone=this.zones[i],c1=zone.boundingSquare.containsPoint(oldPos2d),c2=zone.boundingSquare.containsPoint(newPos2d);c1&&!c2?this.script.onZoneLeave(zone):!c1&&c2&&this.script.onZoneEnter(zone)}}}(),wakeUpNearbyMonsters:function(player){var that=this;this.propagateRegions(player,function(region){that.wakeUpMonsters(region)})},activateNearbyMonsters:function(player){var that=this;this.propagateRegions(player,function(region){that.activateMonsters(region)})},propagateRegions:function(player,callback){var sector=player.getSector();if(void 0!==sector)for(var toVisit=[this.getRegionBySectorId(sector.id)],visited={};toVisit.length>0;){var region=toVisit.pop();if(!(region.id in visited)&&(visited[region.id]=!0,this.regionsDiscovered[region.id]=region,callback(region),void 0!==region.linkedRegions))for(var i=0;i<region.linkedRegions.length;i++){var linked=region.linkedRegions[i],sector=this.sectorDict[linked.doorId].sector;sector.doorGridObject.state!==GS.DoorStates.Closed&&toVisit.push(linked.region)}}},wakeUpMonsters:function(region){if(!region.awake){for(var i=0;i<region.monsters.length;i++)region.monsters[i].wakeUp();region.awake=!0}},activateMonsters:function(region){if(!region.active){for(var i=0;i<region.monsters.length;i++)region.monsters[i].activate();region.active=!0}},getRegionBySectorId:function(sectorId){for(var i=0;i<this.regions.length;i++){var region=this.regions[i];if(sectorId in region.sectorIds)return region}GAME.handleFatalError("sector has no corresponding region")}},GS.ChromeAppFPSControls=function(camera){this.camera=camera,this.eye=new THREE.Vector3,this.followingEye=new THREE.Vector3,this.look=new THREE.Vector3(0,0,(-10)).add(this.eye),this.lookNoOffset=this.look.clone(),this.moveSpeed=1,this.lookSpeed=.066*(GS.Settings.mouse/5),this.mouseInvertY=GS.Settings.mouseInvertY,this.forwardLookVector=new THREE.Vector3(0,0,(-1)),this.forwardMoveVector=new THREE.Vector3(0,0,(-1)),this.rightLookVector=new THREE.Vector3(1,0,0),this.rightMoveVector=new THREE.Vector3(1,0,0),this.xAngle=270,this.yAngle=90,this.viewOffsetY=0,this.eyeOffsetY=3.5,this.pointerLockEnabled=!1,this.onHandleCollisions=function(oldPos,newPos){},this.enabled=!0,this.fly=!1,this.ySmoothing=!1,this.ySmoothingFactor=.1},GS.ChromeAppFPSControls.prototype={constructor:GS.ChromeAppFPSControls,init:function(){var pointerLock="pointerLockElement"in document;return pointerLock?(this.canvas=$("#game-canvas")[0],this.debugCanvas=$("#debug-ui-canvas")[0],void this.setViewAngles(this.xAngle,this.yAngle)):void GAME.handleFatalError("Pointer Lock API not supported")},enable:function(){var that=this;this.canvas.requestPointerLock(),$(document).off("mousemove.fpsControls"),$(document).on("mousemove.fpsControls",function(e){that.onMouseMove(e.originalEvent)})},disable:function(){document.exitPointerLock(),$(document).off("mousemove.fpsControls")},onMouseMove:function(e){if(this.enabled){var mx=e.movementX||e.mozMovementX||e.webkitMovementX||0,my=e.movementY||e.mozMovementY||e.webkitMovementY||0,invertY=this.mouseInvertY?-1:1;this.setViewAngles(this.xAngle+mx*this.lookSpeed,this.yAngle+invertY*my*this.lookSpeed)}},setViewOffsetY:function(y){this.viewOffsetY=y},update:function(){if(this.enabled){var x=0,z=0;GS.Keybinds.moveForward.inUse&&z++,GS.Keybinds.moveBackward.inUse&&z--,GS.Keybinds.strafeLeft.inUse&&x--,GS.Keybinds.strafeRight.inUse&&x++,this.move(x,z),this.dispatchEvent({type:"update",pos:this.eye,xAngle:this.xAngle,yAngle:this.yAngle,look:this.lookNoOffset})}},moveTo:function(pos){this.eye.copy(pos),this.updateCamera()},move:function(){var newPos=new THREE.Vector3,aux=new THREE.Vector3;return function(x,z){newPos.copy(this.eye),0===x&&0===z||(aux.copy(this.rightMoveVector).multiplyScalar(this.moveSpeed*x),newPos.add(aux),aux.copy(this.forwardMoveVector).multiplyScalar(this.moveSpeed*z),newPos.add(aux)),this.onHandleCollisions(this.eye,newPos),this.eye.copy(newPos),this.updateCamera()}}(),updateCamera:function(){this.followingEye.x=this.eye.x,this.followingEye.z=this.eye.z,this.ySmoothing?this.followingEye.y!=this.eye.y&&(this.followingEye.y=this.followingEye.y+this.ySmoothingFactor*(this.eye.y-this.followingEye.y)):this.followingEye.y=this.eye.y,this.camera.position.copy(this.followingEye),this.camera.position.y+=this.viewOffsetY+this.eyeOffsetY,this.lookNoOffset.addVectors(this.followingEye,this.forwardLookVector),this.look.addVectors(this.camera.position,this.forwardLookVector),this.camera.lookAt(this.look)},setViewAngles:function(){var right=new THREE.Vector3,forward=new THREE.Vector3;return function(x,y){this.xAngle=x,this.yAngle=GS.MathHelper.clamp(y,10,170);var x=Math.sin(Math.PI/180*this.yAngle)*Math.cos(Math.PI/180*this.xAngle),y=Math.cos(Math.PI/180*this.yAngle),z=Math.sin(Math.PI/180*this.yAngle)*Math.sin(Math.PI/180*this.xAngle);forward.set(x,y,z),x=Math.sin(Math.PI/180*this.yAngle)*Math.cos(Math.PI/180*(this.xAngle+90)),z=Math.sin(Math.PI/180*this.yAngle)*Math.sin(Math.PI/180*(this.xAngle+90)),right.set(x,0,z),this.forwardLookVector.copy(forward),this.fly?this.forwardMoveVector.copy(forward).normalize():this.forwardMoveVector.set(forward.x,0,forward.z).normalize(),this.rightLookVector.copy(right).normalize(),this.rightMoveVector.copy(right).normalize(),this.updateCamera()}}(),dispose:function(callback){this.onHandleCollisions=void 0,this.disable()}},THREE.EventDispatcher.prototype.apply(GS.ChromeAppFPSControls.prototype),GS.CollisionTypes={None:0,Environment:1,Entity:2},GS.CollisionManager=function(grid){this.grid=grid,this.gravity=1.33},GS.CollisionManager.prototype={init:function(){},collidePlayer:function(){var oldPosBeforeMove=new THREE.Vector3;return function(player,oldPos,newPos){oldPosBeforeMove.copy(oldPos),this.collidePlayerEnvironment(player,oldPos,newPos),this.updateGridLocationEllipsoid(player,newPos),this.collidePlayerItems(player),this.updatePlayerUseTarget(player),this.grid.aiManager.onPlayerMove(player,oldPosBeforeMove,newPos)}}(),collidePlayerEnvironment:function(){var points=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],points3d=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],velocityBoundingBox=new THREE.Box3,types=[GS.Monster,GS.Concrete,GS.Door,GS.Elevator];return function(player,oldPos,newPos){var lsp=player.view.collisionData.ellipsoid;points[0].set(oldPos.x+lsp.x,oldPos.z+lsp.z),points[1].set(oldPos.x-lsp.x,oldPos.z-lsp.z),points[2].set(newPos.x+lsp.x,newPos.z+lsp.z),points[3].set(newPos.x-lsp.x,newPos.z-lsp.z);var gridLocation=this.grid.getGridLocationFromPoints(points);if(points3d[0].copy(oldPos).sub(player.size),points3d[1].copy(oldPos).add(player.size),points3d[2].copy(newPos).sub(player.size),points3d[3].copy(newPos).add(player.size),velocityBoundingBox.setFromPoints(points3d),velocityBoundingBox.expandByScalar(2*this.gravity),void 0!==gridLocation){var triangleIterator=this.grid.getTriangleIterator(gridLocation,types,function(gridObject){return!(gridObject instanceof GS.Monster&&gridObject.dead)&&gridObject.view.collisionData.boundingBox.isIntersectionBox(velocityBoundingBox)}),gravity=player.flyEnabled?0:this.gravity,result=GS.CollisionHelper.handleCollisionsSliding(oldPos,newPos,gravity,lsp,triangleIterator);player.afterCollision(result)}}}(),slidingBoxLineCollision:function(){var newPos0=new THREE.Vector2,aux=new THREE.Vector2,slideVelocity=new THREE.Vector2,epsilon=.005;return function(oldPos,newPos,box,lineSegmentIterator){function iterator(seg){GAME.grid.totalBoxSegmentChecks++;var result=box.isIntersectionLineSwept(oldPos,newPos0,seg);if(result.foundCollision){foundCollision=!0,aux.copy(newPos0).sub(result.pos);var m=-aux.dot(result.normal);slideVelocity.copy(aux),aux.copy(result.normal).multiplyScalar(m),slideVelocity.add(aux),aux.copy(result.pos).sub(newPos0).normalize().multiplyScalar(epsilon),result.pos.add(aux),newPos0.copy(result.pos).add(slideVelocity)}}newPos0.copy(newPos);for(var foundCollision,k=0;k<5&&(foundCollision=!1,lineSegmentIterator(iterator),foundCollision);)k++;newPos.copy(newPos0)}}(),collidePlayerItems:function(player){this.grid.forEachUniqueGridObjectInCells(player.linkedGridCells,[GS.Item],function(item){player.view.collisionData.boundingBox.isIntersectionBox(item.view.collisionData.boundingBox)&&player.onItemCollision(item)})},updatePlayerUseTarget:function(player){var ray=new THREE.Ray,position=new THREE.Vector3,endPoint=new THREE.Vector3,aux=new THREE.Vector3,points=[new THREE.Vector2,new THREE.Vector2],usableTypes=[GS.Door,GS.Switch];return function(player){player.useTarget=null,position.copy(player.position),position.y+=player.controls.eyeOffsetY,ray.set(position,player.direction),aux.copy(player.direction).multiplyScalar(player.useRange),endPoint.copy(position).add(aux),position.toVector2(points[0]),endPoint.toVector2(points[1]);var gridLocation=this.grid.getGridLocationFromPoints(points);if(void 0!==gridLocation){var cells=this.grid.getCellsFromGridLocation(gridLocation),minDist=1/0,minObject=null;this.grid.forEachUniqueGridObjectInCells(cells,usableTypes,function(gridObject){if(null!==ray.intersectsOrStartsInBox(gridObject.view.collisionData.boundingBox,aux)){var dist=aux.distanceTo(position);dist<=player.useRange&&dist<minDist&&(minDist=dist,minObject=gridObject)}}),player.useTarget=minObject,player.canUse=null!==minObject&&minObject.usable}}}(),checkMonsterLineOfSight:function(){var direction=new THREE.Vector3,position=new THREE.Vector3,typesEnvironment=[GS.Elevator,GS.Door,GS.Concrete],typesEntity=[GS.Player];return function(monster,target,range){position.copy(monster.position),direction.copy(target.position).sub(monster.position).normalize();var steps=Math.ceil(range/GS.HitscanHelper.unitLength),result=GS.HitscanHelper.getIntersection(position,direction,this.grid,typesEnvironment,typesEntity,steps,monster);return result.type===GS.CollisionTypes.Entity&&result.gridObject===target}}(),collideMonster:function(monster,oldPos,newPos){this.collideMonsterPlayerEnvironment(monster,oldPos,newPos),this.updateGridLocationEllipsoid(monster,newPos)},collideMonsterPlayerEnvironment:function(){var points=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],types=[GS.Player,GS.Monster],aux=new THREE.Vector3,velocity=new THREE.Vector2,velocityBox=new THREE.Box2;return function(monster,oldPos,newPos){var lsp=monster.view.collisionData.ellipsoid;points[0].set(oldPos.x+lsp.x,oldPos.z+lsp.z),points[1].set(oldPos.x-lsp.x,oldPos.z-lsp.z),points[2].set(newPos.x+lsp.x,newPos.z+lsp.z),points[3].set(newPos.x-lsp.x,newPos.z-lsp.z);var gridLocation=this.grid.getGridLocationFromPoints(points);if(void 0!==gridLocation&&(this.handleConcreteCollisions(gridLocation,oldPos,newPos,monster.size),points[0].set(oldPos.x+lsp.x,oldPos.z+lsp.z),points[1].set(oldPos.x-lsp.x,oldPos.z-lsp.z),points[2].set(newPos.x+lsp.x,newPos.z+lsp.z),points[3].set(newPos.x-lsp.x,newPos.z-lsp.z),gridLocation=this.grid.getGridLocationFromPoints(points),void 0!==gridLocation)){var cells=this.grid.getCellsFromGridLocation(gridLocation);aux.subVectors(newPos,oldPos).toVector2(velocity),velocityBox.copy(monster.view.collisionData.boundingSquare),velocityBox.min.add(velocity),velocityBox.max.add(velocity);var foundCollision=!1,collisionGridObject=null;if(this.grid.forEachUniqueGridObjectInCells(cells,types,function(gridObject){foundCollision||gridObject===monster||gridObject instanceof GS.Monster&&gridObject.dead||velocityBox.isIntersectionBox(gridObject.view.collisionData.boundingSquare)&&(foundCollision=!0,collisionGridObject=gridObject)}),foundCollision){var y=newPos.y;newPos.copy(oldPos),newPos.y=y,collisionGridObject instanceof GS.Monster&&monster.scatter()}else;}}}(),handleConcreteCollisions:function(){var oldPos2d=new THREE.Vector2,newPos2d=new THREE.Vector2,size2d=new THREE.Vector2,box=new THREE.Box2,boxNew=new THREE.Box2;return function(gridLocation,oldPos,newPos,size){oldPos.toVector2(oldPos2d),newPos.toVector2(newPos2d),size.toVector2(size2d),box.min.copy(oldPos2d).sub(size2d),box.max.copy(oldPos2d).add(size2d),boxNew.min.copy(newPos2d).sub(size2d),boxNew.max.copy(newPos2d).add(size2d);var cells=this.grid.getCellsFromGridLocation(gridLocation),newSector=this.getSectorHeights(cells,boxNew),condition=function(){return!0};if(void 0!==newSector){var newHeight=(newPos.y-size.y,newSector.floorHeight);if(Math.abs(newSector.ceilHeight-newSector.floorHeight)>=2*size.y){newPos.y=newHeight+size.y;var minHeight=newPos.y-size.y+.03,maxHeight=newPos.y+size.y+.03;condition=function(seg){return seg.bottomY>=minHeight&&seg.bottomY<=maxHeight||seg.topY>=minHeight&&seg.topY<=maxHeight||seg.bottomY<minHeight&&seg.topY>maxHeight}}var segmentIterator=this.grid.getSegmentIterator(gridLocation,condition);this.slidingBoxLineCollision(oldPos2d,newPos2d,box,segmentIterator),newPos.x=newPos2d.x,newPos.z=newPos2d.y}else newPos.copy(oldPos)}}(),getSectorHeights:function(cells,box){var sector,heights=[],result={floorHeight:-(1/0),ceilHeight:1/0};if(this.grid.forEachUniqueGridObjectInCells(cells,[GS.Concrete,GS.Elevator],function(gridObject){if(gridObject instanceof GS.Concrete){if(gridObject.type!==GS.MapLayers.Sector)return;sector=gridObject.sourceObj}else sector=gridObject.sector;if(GAME.grid.totalBoxSectorChecks++,GS.PolygonHelper.intersectionSectorBox(sector,box)){var floorHeight=sector.floorTopY;floorHeight>result.floorHeight&&(result.floorHeight=floorHeight,result.ceilHeight=sector.ceiling===!0?sector.ceilBottomY:1/0),heights.push(floorHeight)}}),heights.length>0){heights.sort();for(var distance,maxDistance=0,i=0;i<heights.length-1;i++)distance=Math.abs(heights[i+1]-heights[i]),distance>maxDistance&&(maxDistance=distance);if(maxDistance<=6)return result}},isEntityNearDoor:function(door,types){types=types||[GS.Monster,GS.Player];var collided=!1,doorBoundingBox=door.view.collisionData.boundingBox;return this.grid.forEachUniqueGridObjectInCells(door.linkedGridCells,types,function(gridObject){collided||!gridObject.dead&&doorBoundingBox.isIntersectionBox(gridObject.view.collisionData.boundingBox)&&(collided=!0)}),collided},elevatorMove:function(){var newPos=new THREE.Vector3,pos2d=new THREE.Vector2;return function(elevator,velocity){var types=[GS.Item];velocity>0&&(types.push(GS.Monster),types.push(GS.Player));var boundingBox,elevatorBoundingBox=elevator.view.collisionData.boundingBox;this.grid.forEachUniqueGridObjectInCells(elevator.linkedGridCells,types,function(gridObject){if(!(gridObject instanceof GS.Item&&gridObject.isStatic===!0)&&(boundingBox=gridObject.view.collisionData.boundingBox,boundingBox.isIntersectionBox(elevatorBoundingBox))){if(gridObject instanceof GS.Item)if(void 0!==gridObject.elevatorId){if(gridObject.elevatorId!=elevator.id)return}else{if(gridObject.position.toVector2(pos2d),!GS.PolygonHelper.sectorContainsPoint(elevator.sector,pos2d,!0))return;gridObject.elevatorId=elevator.id}newPos.copy(gridObject.position),newPos.y+=velocity,gridObject.updateCollisionData(newPos)}})}}(),collideProjectile:function(){var points=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],normal=new THREE.Vector3;return function(projectile,oldPos,newPos){var lsp=projectile.view.collisionData.ellipsoid;points[0].set(oldPos.x+lsp.x,oldPos.z+lsp.z),points[1].set(oldPos.x-lsp.x,oldPos.z-lsp.z),points[2].set(newPos.x+lsp.x,newPos.z+lsp.z),points[3].set(newPos.x-lsp.x,newPos.z-lsp.z);var gridLocation=this.grid.getGridLocationFromPoints(points);if(void 0!==gridLocation){var result={type:GS.CollisionTypes.None,pos:new THREE.Vector3,gridObject:null,distance:1/0,normal:new THREE.Vector3};this.collideProjectileEnvironment(projectile,gridLocation,oldPos,newPos,result),this.collideProjectileEntities(projectile,gridLocation,oldPos,newPos,result),result.type!==GS.CollisionTypes.None?(result.type===GS.CollisionTypes.Environment?(this.grid.addEnvironmentImpactParticles(result.pos,result.normal,projectile.color),result.gridObject.onHit()):result.type===GS.CollisionTypes.Entity&&(result.gridObject.constructor===projectile.sourceGridObject.constructor?(normal.copy(result.pos).sub(projectile.position).normalize(),this.grid.addEnvironmentImpactParticles(result.pos,normal,projectile.color)):(this.grid.addEntityImpactParticles(result.pos,result.gridObject.bloodColor),result.gridObject.onHit(projectile.damage))),projectile.updateCollisionData(result.pos),projectile.onHit()):projectile.updateCollisionData(newPos),projectile.removed||this.updateGridLocationEllipsoid(projectile,newPos)}}}(),collideProjectileEnvironment:function(){var points3d=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],velocityBoundingBox=new THREE.Box3,types=[GS.Concrete,GS.Door,GS.Elevator];return function(projectile,gridLocation,oldPos,newPos,result){var lsp=projectile.view.collisionData.ellipsoid;points3d[0].copy(oldPos).sub(projectile.size),points3d[1].copy(oldPos).add(projectile.size),points3d[2].copy(newPos).sub(projectile.size),points3d[3].copy(newPos).add(projectile.size),velocityBoundingBox.setFromPoints(points3d);var triangleIterator=this.grid.getTriangleIterator(gridLocation,types,function(gridObject){return gridObject.view.collisionData.boundingBox.isIntersectionBox(velocityBoundingBox)}),triangleResult=GS.CollisionHelper.handleCollisionsFirstHit(oldPos,newPos,0,lsp,triangleIterator);if(triangleResult.foundCollision){var dist=oldPos.distanceToSquared(triangleResult.pos);dist<result.distance&&(result.type=GS.CollisionTypes.Environment,result.pos.copy(triangleResult.pos),result.normal.copy(triangleResult.normal),result.distance=dist,result.gridObject=triangleResult.gridObject)}}}(),collideProjectileEntities:function(){var collisionPoint=(new THREE.Vector3,new THREE.Vector3),types=[GS.Monster,GS.Player];return function(projectile,gridLocation,oldPos,newPos,result){var gridObjectBox,projectileBox=projectile.view.collisionData.boundingBox,cells=this.grid.getCellsFromGridLocation(gridLocation);this.grid.forEachUniqueGridObjectInCells(cells,types,function(gridObject){if(!gridObject.dead&&projectile.sourceGridObject!==gridObject&&(gridObjectBox=gridObject.view.collisionData.boundingBox,projectileBox.isIntersectionBoxSwept(oldPos,newPos,gridObjectBox,gridObject.position,collisionPoint))){var dist=oldPos.distanceToSquared(collisionPoint);dist<result.distance&&(result.type=GS.CollisionTypes.Entity,result.pos.copy(collisionPoint),result.distance=dist,result.gridObject=gridObject)}})}}(),updateGridLocationEllipsoid:function(){var points=[new THREE.Vector2,new THREE.Vector2];return function(gridObject,newPos){var lsp=gridObject.view.collisionData.ellipsoid;points[0].set(newPos.x+lsp.x,newPos.z+lsp.z),points[1].set(newPos.x-lsp.x,newPos.z-lsp.z);var gridLocation=this.grid.getGridLocationFromPoints(points);gridObject.assignToCells(gridLocation),gridObject.updateCollisionData(newPos)}}(),hitscan:function(sourceGridObject,projectileStart,weapon,xAngle,yAngle){var that=this,typesEnvironment=[GS.Concrete,GS.Door,GS.Elevator],typesEntity=[];sourceGridObject instanceof GS.Player&&typesEntity.push(GS.Monster),GS.HitscanHelper.spread(weapon,xAngle,yAngle,function(dir){var result=GS.HitscanHelper.getIntersection(projectileStart,dir,that.grid,typesEnvironment,typesEntity);result.type===GS.CollisionTypes.Environment?(that.grid.addEnvironmentImpactParticles(result.pos,result.normal,weapon.impactParticleColor,weapon.impactParticleCount),result.gridObject.onHit()):result.type===GS.CollisionTypes.Entity&&(that.grid.addEntityImpactParticles(result.pos,result.gridObject.bloodColor),result.gridObject.onHit(weapon.damage))})}},GS.FPSControls=function(camera){this.camera=camera,this.eye=new THREE.Vector3,this.followingEye=new THREE.Vector3,this.look=new THREE.Vector3(0,0,(-10)).add(this.eye),this.lookNoOffset=this.look.clone(),this.moveSpeed=1,this.lookSpeed=.066*(GS.Settings.mouse/5),this.mouseInvertY=GS.Settings.mouseInvertY,this.forwardLookVector=new THREE.Vector3(0,0,(-1)),this.forwardMoveVector=new THREE.Vector3(0,0,(-1)),this.rightLookVector=new THREE.Vector3(1,0,0),this.rightMoveVector=new THREE.Vector3(1,0,0),this.xAngle=270,this.yAngle=90,this.viewOffsetY=0,this.eyeOffsetY=3.5,this.pointerLockEnabled=!1,this.onHandleCollisions=function(oldPos,newPos){},this.enabled=!0,this.fly=!1,this.ySmoothing=!1,this.ySmoothingFactor=.1},GS.FPSControls.prototype={constructor:GS.FPSControls,init:function(){var pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document;if(!pointerLock)throw"Pointer Lock API not supported";this.attachEvents(),this.setViewAngles(this.xAngle,this.yAngle)},attachEvents:function(){var that=this;$(document).on("pointerlockchange.fpsControls",function(e){that.onPointerLockChange(e)}),$(document).on("mozpointerlockchange.fpsControls",function(e){that.onPointerLockChange(e)}),$(document).on("webkitpointerlockchange.fpsControls",function(e){that.onPointerLockChange(e)}),$(document).on("pointerlockerror.fpsControls",function(e){that.onPointerLockError(e)}),$(document).on("mozpointerlockerror.fpsControls",function(e){that.onPointerLockError(e)}),$(document).on("webkitpointerlockerror.fpsControls",function(e){that.onPointerLockError(e)}),this.canvas=$("#game-canvas")[0],this.debugCanvas=$("#debug-ui-canvas")[0];var rightMouseDown=!1;$(this.debugCanvas).on("mousedown.fpsControls",function(e){3==e.which&&(rightMouseDown=!0)}),$(this.debugCanvas).on("mouseup.fpsControls",function(e){3==e.which&&rightMouseDown&&(rightMouseDown=!1,that.enable())})},detachEvents:function(){$(this.debugCanvas).off("mousedown.fpsControls"),$(this.debugCanvas).off("mouseup.fpsControls"),$(document).off("pointerlockchange.fpsControls"),$(document).off("mozpointerlockchange.fpsControls"),$(document).off("webkitpointerlockchange.fpsControls"),$(document).off("pointerlockerror.fpsControls"),$(document).off("mozpointerlockerror.fpsControls"),$(document).off("webkitpointerlockerror.fpsControls")},enable:function(){this.pointerLockEnabled||(this.canvas.requestPointerLock=this.canvas.requestPointerLock||this.canvas.mozRequestPointerLock||this.canvas.webkitRequestPointerLock,this.canvas.requestPointerLock())},disable:function(){this.pointerLockEnabled&&(document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock())},onPointerLockChange:function(e){var that=this,isCanvas=document.pointerLockElement===this.canvas||document.mozPointerLockElement===this.canvas||document.webkitPointerLockElement===this.canvas;isCanvas?(this.pointerLockEnabled=!0,$(document).on("mousemove.fpsControls",function(e){that.onMouseMove(e.originalEvent)}),this.dispatchEvent({type:"pointerLockEnabled"})):(this.pointerLockEnabled=!1,$(document).off("mousemove.fpsControls"),void 0!==this.disposeCallback?(this.detachEvents(),this.disposeCallback()):this.dispatchEvent({type:"pointerLockDisabled"}))},onPointerLockError:function(){},onMouseMove:function(e){if(this.enabled){var mx=e.movementX||e.mozMovementX||e.webkitMovementX||0,my=e.movementY||e.mozMovementY||e.webkitMovementY||0,invertY=this.mouseInvertY?-1:1;this.setViewAngles(this.xAngle+mx*this.lookSpeed,this.yAngle+invertY*my*this.lookSpeed)}},setViewOffsetY:function(y){this.viewOffsetY=y},update:function(){if(this.enabled){var x=0,z=0;GS.Keybinds.moveForward.inUse&&z++,GS.Keybinds.moveBackward.inUse&&z--,GS.Keybinds.strafeLeft.inUse&&x--,GS.Keybinds.strafeRight.inUse&&x++,this.move(x,z),this.dispatchEvent({type:"update",pos:this.eye,xAngle:this.xAngle,yAngle:this.yAngle,look:this.lookNoOffset})}},moveTo:function(pos){this.eye.copy(pos),this.updateCamera()},move:function(){var newPos=new THREE.Vector3,aux=new THREE.Vector3;return function(x,z){newPos.copy(this.eye),0===x&&0===z||(aux.copy(this.rightMoveVector).multiplyScalar(this.moveSpeed*x),newPos.add(aux),aux.copy(this.forwardMoveVector).multiplyScalar(this.moveSpeed*z),newPos.add(aux)),this.onHandleCollisions(this.eye,newPos),this.eye.copy(newPos),this.updateCamera()}}(),updateCamera:function(){this.followingEye.x=this.eye.x,this.followingEye.z=this.eye.z,this.ySmoothing?this.followingEye.y!=this.eye.y&&(this.followingEye.y=this.followingEye.y+this.ySmoothingFactor*(this.eye.y-this.followingEye.y)):this.followingEye.y=this.eye.y,this.camera.position.copy(this.followingEye),this.camera.position.y+=this.viewOffsetY+this.eyeOffsetY,this.lookNoOffset.addVectors(this.followingEye,this.forwardLookVector),this.look.addVectors(this.camera.position,this.forwardLookVector),this.camera.lookAt(this.look)},setViewAngles:function(){var right=new THREE.Vector3,forward=new THREE.Vector3;return function(x,y){this.xAngle=x,this.yAngle=GS.MathHelper.clamp(y,10,170);var x=Math.sin(Math.PI/180*this.yAngle)*Math.cos(Math.PI/180*this.xAngle),y=Math.cos(Math.PI/180*this.yAngle),z=Math.sin(Math.PI/180*this.yAngle)*Math.sin(Math.PI/180*this.xAngle);forward.set(x,y,z),x=Math.sin(Math.PI/180*this.yAngle)*Math.cos(Math.PI/180*(this.xAngle+90)),z=Math.sin(Math.PI/180*this.yAngle)*Math.sin(Math.PI/180*(this.xAngle+90)),right.set(x,0,z),this.forwardLookVector.copy(forward),this.fly?this.forwardMoveVector.copy(forward).normalize():this.forwardMoveVector.set(forward.x,0,forward.z).normalize(),this.rightLookVector.copy(right).normalize(),this.rightMoveVector.copy(right).normalize(),this.updateCamera()}}(),dispose:function(callback){this.pointerLockEnabled&&(this.disposeCallback=callback),this.onHandleCollisions=void 0,this.disable(),this.pointerLockEnabled||(this.detachEvents(),callback())}},THREE.EventDispatcher.prototype.apply(GS.FPSControls.prototype),GS.GraphicsManager=function(renderer,camera){this.renderer=renderer,this.camera=camera,this.noPostProcessing=!1,this.noiseTextureSize=256,
this.showWeapon=GS.Settings.showWeapon},GS.GraphicsManager.prototype={init:function(){this.initEffectComposer(),this.bloomEnabled=GS.Settings.bloom,this.fxaaEnabled=GS.Settings.fxaa,this.ssaoEnabled=GS.Settings.ssao,this.noiseEnabled=GS.Settings.noise,this.vignetteEnabled=GS.Settings.vignette,this.halfSizeEnabled=GS.Settings.halfSize,this.monochromeEnabled=!1},setGrid:function(grid){var that=this;this.grid=grid,this.scene=grid.scene,that.effectColor.uniforms.color.value.setRGB(0,0,0),grid.player.playerView.addEventListener("screenOverlayColorChange",function(e){that.effectColor.uniforms.color.value.copy(e.color)})},initEffectComposer:function(){this.composer=new THREE.EffectComposer(this.renderer);var depthShader=THREE.ShaderLib.depthRGBA,depthUniforms=THREE.UniformsUtils.clone(depthShader.uniforms);this.depthMaterial=new THREE.ShaderMaterial({fragmentShader:depthShader.fragmentShader,vertexShader:depthShader.vertexShader,uniforms:depthUniforms}),this.depthMaterial.blending=THREE.NoBlending,this.depthTarget=new THREE.WebGLRenderTarget(window.innerWidth,window.innerHeight,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat}),this.effectSSAO=new THREE.ShaderPass(THREE.SSAOShader),this.effectSSAO.uniforms.tDepth.value=this.depthTarget,this.effectSSAO.uniforms.size.value.set(window.innerWidth,window.innerHeight),this.effectSSAO.uniforms.cameraNear.value=this.camera.near,this.effectSSAO.uniforms.cameraFar.value=this.camera.far,this.effectFilter=new THREE.ShaderPass(GS.BrightnessFilterShader),this.effectBloom=new THREE.BloomPass(1,25,4,512),this.effectBloom.needsSwap=!0,this.effectGlow=new THREE.ShaderPass(GS.GlowShader),this.effectGlow.uniforms.tGlow.value=this.effectBloom.renderTargetY,this.effectGlow.uniforms.intensity.value=1,this.effectColor=new THREE.ShaderPass(GS.ColorShader),this.effectColor.uniforms.color.value=new THREE.Color(0),this.effectFXAA=new THREE.ShaderPass(THREE.FXAAShader),this.effectFXAA.uniforms.resolution.value.set(1/window.innerWidth,1/window.innerHeight),this.effectVignette=new THREE.ShaderPass(THREE.VignetteShader),this.effectNoise=new THREE.ShaderPass(GS.NoiseShader),this.effectNoise.uniforms.tNoise.value=this.getNoiseTexture(this.noiseTextureSize),this.effectNoise.uniforms.ratio.value.set(window.innerWidth/this.noiseTextureSize,window.innerHeight/this.noiseTextureSize),this.effectMonochrome=new THREE.ShaderPass(THREE.LuminosityShader);var effectCopy=new THREE.ShaderPass(THREE.CopyShader);effectCopy.renderToScreen=!0,this.composer.addPass(this.effectFilter),this.composer.addPass(this.effectBloom),this.composer.addPass(this.effectNoise),this.composer.addPass(this.effectGlow),this.composer.addPass(this.effectSSAO),this.composer.addPass(this.effectColor),this.composer.addPass(this.effectFXAA),this.composer.addPass(this.effectVignette),this.composer.addPass(this.effectMonochrome),this.composer.addPass(effectCopy)},renderToScreen:function(){this.renderer.autoClear=!1,this.renderer.clear(!0,!0,!1),this.renderer.render(this.grid.skybox.scene,this.grid.skybox.camera),this.renderer.render(this.scene,this.camera),this.renderer.clear(!1,!0,!1);var playerView=this.grid.player.playerView;this.renderer.render(playerView.scene,playerView.camera)},render:function(){var renderTarget=this.composer.renderTarget2;if(this.renderer.autoClear=!1,this.renderer.clearTarget(renderTarget,!0,!0,!1),this.renderer.render(this.grid.skybox.scene,this.grid.skybox.camera,renderTarget),this.renderer.render(this.scene,this.camera,renderTarget),this.renderer.clearTarget(renderTarget,!1,!0,!1),this.showWeapon){var playerView=this.grid.player.playerView;this.renderer.render(playerView.scene,playerView.camera,renderTarget)}},renderDepthTarget:function(){var renderTarget=this.depthTarget;if(this.renderer.autoClear=!1,this.renderer.clearTarget(renderTarget,!0,!0,!1),this.scene.overrideMaterial=this.depthMaterial,this.renderer.render(this.scene,this.camera,renderTarget),this.scene.overrideMaterial=null,this.renderer.clearTarget(renderTarget,!1,!0,!1),this.showWeapon){var playerView=this.grid.player.playerView;playerView.scene.overrideMaterial=this.depthMaterial,this.renderer.render(playerView.scene,playerView.camera,renderTarget),playerView.scene.overrideMaterial=null}},draw:function(){this.noPostProcessing?this.renderToScreen():(this.render(),this.ssaoEnabled&&this.renderDepthTarget(),this.composer.render())},onResize:function(){var width=window.innerWidth,height=window.innerHeight;this._halfSizeEnabled&&(width*=.5,height*=.5);var depthTarget=this.depthTarget.clone();depthTarget.width=width,depthTarget.height=height,this.depthTarget=depthTarget,this.effectSSAO.uniforms.tDepth.value=this.depthTarget,this.effectSSAO.uniforms.size.value.set(width,height),this.effectFXAA.uniforms.resolution.value.set(1/width,1/height),this.effectNoise.uniforms.ratio.value.set(width/this.noiseTextureSize,height/this.noiseTextureSize),this.composer.setSize(width,height),$(this.renderer.domElement).css("width",window.innerWidth+"px").css("height",window.innerHeight+"px")},getNoiseTexture:function(size){size=size||256;var canvas=document.createElement("canvas");canvas.width=size,canvas.height=size,canvas.style.backgroundColor="rgba(255, 255, 255, 1)";var ctx=canvas.getContext("2d");ctx.globalCompositeOperation="source-over",ctx.save();for(var imageData=ctx.getImageData(0,0,size,size),i=0,n=size*size*4;i<n;i+=4){var x=Math.floor(255*Math.random());imageData.data[i]=x,imageData.data[i+1]=x,imageData.data[i+2]=x,imageData.data[i+3]=255}ctx.putImageData(imageData,0,0);var tex=new THREE.Texture(canvas);return tex.wrapS=tex.wrapT=THREE.RepeatWrapping,tex.needsUpdate=!0,tex},reset:function(){this.grid=void 0,this.scene=void 0},set ssaoEnabled(value){void 0!==this.effectSSAO&&(this.effectSSAO.enabled=value)},get ssaoEnabled(){return this.effectSSAO.enabled},set bloomEnabled(value){void 0!==this.effectBloom&&(this.effectFilter.enabled=value,this.effectBloom.enabled=value,this.effectGlow.enabled=value)},get bloomEnabled(){return this.effectBloom.enabled},set fxaaEnabled(value){void 0!==this.effectFXAA&&(this.effectFXAA.enabled=value)},get fxaaEnabled(){return this.effectFXAA.enabled},set vignetteEnabled(value){void 0!==this.effectVignette&&(this.effectVignette.enabled=value)},get vignetteEnabled(){return this.effectVignette.enabled},set monochromeEnabled(value){void 0!==this.effectMonochrome&&(this.effectMonochrome.enabled=value)},get monochromeEnabled(){return this.effectMonochrome.enabled},set noiseEnabled(value){void 0!==this.effectNoise&&(this.effectNoise.enabled=value)},get noiseEnabled(){return this.effectNoise.enabled},set halfSizeEnabled(value){this._halfSizeEnabled=value,this.onResize()},get halfSizeEnabled(){return this._halfSizeEnabled}},GS.Grid=function(renderer,scene){this.renderer=renderer,this.scene=scene,this.concreteMeshes=new THREE.Object3D,this.entityMeshes=new THREE.Object3D,this.stopMonsters=!1,this.debugEntityMeshes=!1,this.debugConcreteMeshes=!1,this.debugCellLines=!1},GS.Grid.prototype={constructor:GS.Grid,init:function(){this.particleView=new GS.ParticleView(this),this.particleView.init(),this.collisionManager=new GS.CollisionManager(this),this.collisionManager.init(),this.lightingView=new GS.LightingView(this),this.lightingView.init(),this.forEachUniqueGridObject(void 0,function(gridObject){gridObject.init()}),this.aiManager=new GS.AIManager(this),this.aiManager.init(),this.addConcreteMeshesToScene(),this.addEntityMeshesToScene(),this.debugCellLines&&this.addDebugCellLines()},initSkybox:function(skyboxMesh){this.skybox={mesh:skyboxMesh,scene:new THREE.Scene,camera:new THREE.PerspectiveCamera(GS.Settings.fov,window.innerWidth/window.innerHeight,1,2e3)},this.skybox.scene.add(skyboxMesh)},update:function(){var that=this;this.particleView.update(),this.lightingView.update(),this.aiManager.update(),this.totalSphereTriangleChecks=0,this.totalBoxSectorChecks=0,this.totalBoxSegmentChecks=0;this.forEachUniqueGridObject(void 0,function(gridObject){gridObject instanceof GS.Monster?that.stopMonsters||gridObject.update():gridObject.update()}),0===this.player.linkedGridCells.length&&this.player.update();var rotationMatrix=(new THREE.Matrix4).extractRotation(this.player.camera.matrixWorld);this.skybox.camera.rotation.setFromRotationMatrix(rotationMatrix,this.skybox.camera.rotation.order)},addConcreteMeshesToScene:function(){var that=this;this.forEachUniqueGridObject([GS.Concrete],function(gridObject){that.debugConcreteMeshes&&that.concreteMeshes.children.push(gridObject.view.debugMesh)});for(var regions=this.regionInfo.regions,i=0;i<regions.length;i++){var mesh=regions[i].mesh,bufferGeo=new THREE.BufferGeometry;bufferGeo.fromGeometry(mesh.geometry,{vertexColors:THREE.FaceColors}),mesh.geometry=bufferGeo,this.concreteMeshes.children.push(mesh)}this.scene.add(this.concreteMeshes)},addEntityMeshesToScene:function(){var that=this;this.forEachUniqueGridObject([GS.Item,GS.Monster,GS.Door,GS.Elevator,GS.TVScreen,GS.Switch],function(gridObject){that.debugEntityMeshes&&void 0!==gridObject.view.debugMesh&&gridObject.view.mesh.children.push(gridObject.view.debugMesh),that.entityMeshes.children.push(gridObject.view.mesh)}),this.scene.add(this.entityMeshes)},addDebugLine:function(pos0,pos1,color){color=void 0!==color?color:16777215;var geometry=new THREE.Geometry;geometry.vertices.push(pos0),geometry.vertices.push(pos1);var material=new THREE.LineBasicMaterial({color:color}),line=new THREE.Line(geometry,material);this.scene.add(line)},addDebugCellLines:function(){var height=2,color=(new THREE.Color).setRGB(0,0,.5).getHex(),geometry=new THREE.PlaneGeometry(this.width*this.cellSize,this.height*this.cellSize,this.width,this.height),material=new THREE.MeshBasicMaterial({color:color,wireframe:!0}),mesh=new THREE.Mesh(geometry,material);mesh.rotation.x=-Math.PI/2;var v=this.map.bounds.min.clone().multiplyScalar(-1);v.sub(this.map.bounds.max.clone().sub(this.map.bounds.min).divideScalar(2)),mesh.position.x=-v.x,mesh.position.y=height,mesh.position.z=-v.y,this.scene.add(mesh)},addProjectile:function(sourceGridObject,type,position,direction){var projectile=new GS.Projectile(this,sourceGridObject,type,position,direction);projectile.init(),this.debugEntityMeshes&&(projectile.view.debugMesh=new THREE.Mesh(new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:16777215,wireframe:!0})),this.scene.add(projectile.view.debugMesh)),this.lightingView.addProjectileLight(projectile)},addEnvironmentImpactParticles:function(position,normal,color,n){n=n||5;for(var i=0;i<n;i++){var particle=this.particleView.addParticle(1,1,1,color,GS.ParticleMovementTypes.Falling,position);this.particleView.alignParticleTrajectoryToNormal(particle,normal),particle.mesh.position.copy(position)}},addEntityImpactParticles:function(position,color,n){n=n||3;for(var i=0;i<n;i++){var particle=this.particleView.addParticle(1,1,1,color,GS.ParticleMovementTypes.Gushing,position);particle.mesh.position.copy(position)}},getMeshFromBox2:function(box2,material){var geometry=new THREE.Geometry;geometry.vertices.push(new THREE.Vector3(box2.min.x,0,box2.min.y)),geometry.vertices.push(new THREE.Vector3(box2.max.x,0,box2.min.y)),geometry.vertices.push(new THREE.Vector3(box2.min.x,0,box2.max.y)),geometry.vertices.push(new THREE.Vector3(box2.max.x,0,box2.max.y)),geometry.faces.push(new THREE.Face3(0,1,2)),geometry.faces.push(new THREE.Face3(1,3,2));var mesh=new THREE.Mesh(geometry,material);return mesh},addDebugGridLocation:function(gridLocation){var material=new THREE.MeshBasicMaterial({color:16711935,wireframe:!0}),mesh=this.getMeshFromBox2(gridLocation.box2,material);this.scene.add(mesh)},forEachUniqueGridObjectInCells:function(cells,types,callback){var gridObjects={};if(void 0!==types&&types.length>0)for(var i=0;i<cells.length;i++)for(var cell=cells[i],k=0;k<cell.children.length;k++)for(var gridObject=cell.children[k],e=0;e<types.length;e++)gridObject instanceof types[e]&&(gridObjects[gridObject.id]=gridObject);else for(var i=0;i<cells.length;i++)for(var cell=cells[i],k=0;k<cell.children.length;k++){var gridObject=cell.children[k];gridObjects[gridObject.id]=gridObject}Object.keys(gridObjects).forEach(function(key){callback(gridObjects[key])})},forEachUniqueGridObject:function(types,callback){var gridObjects={};if(void 0!==types&&types.length>0)for(var i=0;i<this.height;i++)for(var j=0;j<this.width;j++)for(var cell=this.cells[i][j],k=0;k<cell.children.length;k++)for(var gridObject=cell.children[k],e=0;e<types.length;e++)gridObject instanceof types[e]&&(gridObjects[gridObject.id]=gridObject);else for(var i=0;i<this.height;i++)for(var j=0;j<this.width;j++)for(var cell=this.cells[i][j],k=0;k<cell.children.length;k++){var gridObject=cell.children[k];gridObjects[gridObject.id]=gridObject}Object.keys(gridObjects).forEach(function(key){callback(gridObjects[key])})},removeEntityMesh:function(mesh){this.entityMeshes.remove(mesh)},isPointInMapBounds:function(point){return this.map.bounds.containsPoint(point)},getGridLocationFromPoints:function(points){var box2=(new THREE.Box2).setFromPoints(points);if(this.map.bounds.isIntersectionBox(box2)){var gridMin=this.getGridCoords(box2.min),gridMax=this.getGridCoords(box2.max);return gridMin.x=GS.MathHelper.clamp(gridMin.x,0,this.width-1),gridMin.y=GS.MathHelper.clamp(gridMin.y,0,this.height-1),gridMax.x=GS.MathHelper.clamp(gridMax.x,0,this.width-1),gridMax.y=GS.MathHelper.clamp(gridMax.y,0,this.height-1),{box2:box2,gridMin:gridMin,gridMax:gridMax}}},getGridCoords:function(point){var p=point.clone().sub(this.map.bounds.min);return p.x=Math.floor(p.x/this.cellSize),p.y=Math.floor(p.y/this.cellSize),p},getCellsFromGridLocation:function(gridLocation){for(var cells=[],min=gridLocation.gridMin,max=gridLocation.gridMax,i=min.y;i<=max.y;i++)for(var j=min.x;j<=max.x;j++)cells.push(this.cells[i][j]);return cells},getTriangleIterator:function(gridLocation,types,condition){var that=this,cells=that.getCellsFromGridLocation(gridLocation);return void 0===condition?function(callback){that.forEachUniqueGridObjectInCells(cells,types,function(gridObject){for(var triangles=gridObject.view.collisionData.triangles,i=0;i<triangles.length;i+=3)callback(gridObject,triangles[i],triangles[i+1],triangles[i+2],i)})}:function(callback){that.forEachUniqueGridObjectInCells(cells,types,function(gridObject){if(condition(gridObject))for(var triangles=gridObject.view.collisionData.triangles,i=0;i<triangles.length;i+=3)callback(gridObject,triangles[i],triangles[i+1],triangles[i+2],i)})}},getSegmentIterator:function(gridLocation,condition){var that=this,cells=that.getCellsFromGridLocation(gridLocation);return void 0===condition?function(callback){that.forEachUniqueGridObjectInCells(cells,[GS.Concrete,GS.Elevator,GS.Door],function(gridObject){if(gridObject instanceof GS.Concrete&&gridObject.type===GS.MapLayers.Segment)callback(gridObject.sourceObj);else if(gridObject instanceof GS.Elevator||gridObject instanceof GS.Door)for(var segs=gridObject.view.collisionData.segments,i=0;i<segs.length;i++)callback(segs[i])})}:function(callback){that.forEachUniqueGridObjectInCells(cells,[GS.Concrete,GS.Elevator,GS.Door],function(gridObject){if(gridObject instanceof GS.Concrete&&gridObject.type===GS.MapLayers.Segment)condition(gridObject.sourceObj)&&callback(gridObject.sourceObj);else if(gridObject instanceof GS.Elevator||gridObject instanceof GS.Door)for(var segs=gridObject.view.collisionData.segments,i=0;i<segs.length;i++)condition(segs[i])&&callback(segs[i])})}},clearScene:function(){for(var i=this.scene.children.length-1;i>=0;i--){var obj=this.scene.children[i];this.scene.remove(obj)}},onResize:function(){this.skybox.camera.aspect=window.innerWidth/window.innerHeight,this.skybox.camera.updateProjectionMatrix()},updateFov:function(){this.skybox.camera.fov=GS.Settings.fov,this.skybox.camera.updateProjectionMatrix()}},GS.MapScript=function(gridObjectLibrary){this.lib=gridObjectLibrary,this.mapName="map name",this.mapWon=!1,this.nextMap=void 0,this.secretsFound=0,this.maxSecrets=0,this.musicTrack="simple_action_beat"},GS.MapScript.prototype={constructor:GS.MapScript,init:function(){},update:function(){},onZoneEnter:function(zone){},onZoneLeave:function(zone){},onItemPickup:function(item){},onPlayerOpenDoor:function(door){},onSwitchStateChange:function(switchObj){},foundSecret:function(){this.secretsFound++,GS.DebugUI.addTempLine("secret found")},getGridObjectsById:function(type,idArray){var list=[],source=this.lib[type];for(var i in source)idArray.indexOf(parseInt(i,10))!=-1&&list.push(source[i]);return list}},GS.MusicManager=function(){this.volume=GS.Settings.music/10},GS.MusicManager.prototype={init:function(){var ctx;if("undefined"!=typeof AudioContext)ctx=new AudioContext;else{if("undefined"==typeof webkitAudioContext)return void GAME.handleFatalError("No AudioContext support");ctx=new webkitAudioContext}this.ctx=ctx,this.ctx.createGain||(this.ctx.createGain=ctx.createGainNode),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=this._volume,this.gainNode.connect(this.ctx.destination),this.initTracks()},playTrack:function(name){this.currentTrack=this.tracks[name],void 0!==this.source&&this.source.stop(0),this.source=this.ctx.createBufferSource(),this.source.buffer=this.currentTrack.buffer,this.source.loop=!0,this.source.connect(this.gainNode),this.source.start||(this.source.start=source.noteOn),this.source.start(0)},initTracks:function(soundBuffers){this.tracks={};for(var i in soundBuffers)this.tracks[i]={buffer:soundBuffers[i],duration:Math.ceil(soundBuffers[i].length/this.ctx.sampleRate*1e3)}},set volume(value){this._volume=value,void 0!==this.gainNode&&(this.gainNode.gain.value=this._volume)},get volume(){return this._volume}},GS.SoundManager=function(){this.volume=GS.Settings.sound/10},GS.SoundManager.prototype={init:function(){var ctx;if("undefined"!=typeof AudioContext)ctx=new AudioContext;else{if("undefined"==typeof webkitAudioContext)return void GAME.handleFatalError("No AudioContext support");ctx=new webkitAudioContext}this.ctx=ctx,this.ctx.createGain||(this.ctx.createGain=ctx.createGainNode),this.gainNode=this.ctx.createGain(),this.gainNode.gain.value=this._volume,this.compressor=this.ctx.createDynamicsCompressor(),this.gainNode.connect(this.compressor),this.compressor.connect(this.ctx.destination),this.initSounds()},playSound:function(name){var sound=this.sounds[name];if(!sound.isPlaying||sound.allowMultipleAtOnce){var source=this.ctx.createBufferSource();source.buffer=this.sounds[name].buffer,source.connect(this.gainNode),source.start||(source.start=source.noteOn),source.start(0),setTimeout(function(){sound.isPlaying=!1},sound.duration),sound.isPlaying=!0}},initSounds:function(soundBuffers){this.sounds={};for(var i in soundBuffers)this.sounds[i]={buffer:soundBuffers[i],duration:Math.ceil(soundBuffers[i].length/this.ctx.sampleRate*1e3),isPlaying:!1,allowMultipleAtOnce:GS.Assets[GS.AssetTypes.Sound][i].allowMultipleAtOnce}},set volume(value){this._volume=value,void 0!==this.gainNode&&(this.gainNode.gain.value=this._volume)},get volume(){return this._volume}},GS.AnimationView=function(gridObject){this.gridObject=gridObject,this.loops={attack:{delay:10},inactive:{delay:30},walk:{delay:gridObject.walkDelay},death:{delay:30,runOnce:!0}},this.floatYDelta=.5,this.floatAngle=0,this.floatSpeed=.175,this.inactiveFloatSpeed=.0875,this.painMaxAngle=Math.PI/2,this.painAngle=0,this.painSpeed=.05,this.painSgn=1,this.rotationYOffset=0,this.positionYOffset=0,this.currentMesh=new THREE.Object3D},GS.AnimationView.prototype={init:function(){var that=this;$.extend(!0,this,this.gridObject.view.mesh.userData),Object.keys(this.animations).forEach(function(key){var loop=that.loops[key];return void 0===that.loops[key]?void GAME.handleFatalError("animation loop not found"):(loop.index=0,loop.frames=that.animations[key],loop.max=loop.frames.length,void(loop.cooldown=Math.floor(Math.random()*(loop.delay-1))+1))}),this.initInactiveLoop()},update:function(){var loop=this.currentLoop;loop.runOnce&&loop.index===loop.max-1||loop.cooldown>0&&(loop.cooldown--,0===loop.cooldown&&(loop.cooldown=loop.delay,loop.index++,loop.index===loop.max&&(loop.index=0),this.switchMesh())),this.gridObject.dead||(this.gridObject.moving?this.floatAngle+=this.floatSpeed:loop===this.loops.inactive&&(this.floatAngle+=this.inactiveFloatSpeed),this.positionYOffset=this.floatYDelta*Math.sin(this.floatAngle),Math.abs(this.painAngle)>0&&(this.painAngle-=this.painSgn*this.painSpeed,1==this.painSgn&&this.painAngle<0?(this.gridObject.inPain=!1,this.painAngle=0):this.painSgn==-1&&this.painAngle>0&&(this.gridObject.inPain=!1,this.painAngle=0)),this.rotationYOffset=this.painAngle)},initInactiveLoop:function(){var walk=this.loops.walk,loop=this.loops.inactive;loop.index=0,loop.frames=[],loop.cooldown=loop.delay,loop.frames.push(walk.frames[0]),loop.frames.push(walk.frames[2]),loop.max=loop.frames.length},pain:function(){0===Math.floor(2*Math.random())?(this.painAngle=this.painMaxAngle,this.painSgn=1):(this.painAngle=-this.painMaxAngle,this.painSgn=-1)},death:function(){this.setLoop("death"),this.rotationYOffset=0,this.positionYOffset=0},setLoop:function(name){this.currentLoop=this.loops[name],this.switchMesh()},switchMesh:function(){var loop=this.currentLoop;this.currentMesh.visible=!1,this.currentMesh=loop.frames[loop.index],this.currentMesh.visible=!0}},GS.LightingView=function(grid){this.grid=grid,this.player=grid.player,this.worldScene=grid.scene,this.playerScene=grid.player.playerView.scene,this.ambientColor=(new THREE.Color).setRGB(0,0,0),this.directionalColor=(new THREE.Color).setRGB(1,1,1).getHex(),this.directionalPosition=new THREE.Vector3(1,1,1),this.directionalIntensity=0,this.muzzleFlashPosition=new THREE.Vector3(0,(-3),(-12)),this.muzzleFlashDistance=256,this.muzzleFlashMaxIntensity=1,this.muzzleFlashIntensity=new GS.SmoothNumber(0,.1),this.projectileIntensity=1,this.projectileDistance=32,this.maxProjectilePointLights=10,this.playerTorchDistance=256,this.playerTorchIntensity=.5,this.playerTorchColor=(new THREE.Color).setRGB(1,1,1),this.worldLights={},this.playerLights={},this.projectileLights=[]},GS.LightingView.prototype={init:function(){this.initWorldLights(),this.initPlayerLights()},initWorldLights:function(){var ambientLight=new THREE.AmbientLight(this.ambientColor);this.worldScene.add(ambientLight),this.worldLights.ambient=ambientLight;var pointLight=new THREE.PointLight;pointLight.intensity=this.muzzleFlashIntensity.value,pointLight.distance=this.muzzleFlashDistance,this.worldScene.add(pointLight),this.worldLights.muzzleFlash=pointLight;var dirLight=new THREE.DirectionalLight(this.directionalColor,this.directionalIntensity);dirLight.position.copy(this.directionalPosition),this.worldScene.add(dirLight),this.worldLights.directional=dirLight;for(var i=0;i<this.maxProjectilePointLights;i++){var pointLight=new THREE.PointLight;pointLight.intensity=0,pointLight.distance=this.projectileDistance;var light={active:!1,pointLight:pointLight,intensity:new GS.SmoothNumber(this.projectileIntensity,.1)};this.worldScene.add(pointLight),this.projectileLights.push(light)}var playerTorch=new THREE.PointLight;playerTorch.color.copy(this.playerTorchColor),playerTorch.intensity=this.playerTorchIntensity,playerTorch.distance=this.playerTorchDistance,this.worldScene.add(playerTorch),this.worldLights.playerTorch=playerTorch;var playerSceneTorch=new THREE.PointLight;playerSceneTorch.color.copy(this.playerTorchColor),playerSceneTorch.intensity=this.playerTorchIntensity,playerSceneTorch.distance=this.playerTorchDistance,this.playerScene.add(playerSceneTorch),this.playerLights.playerTorch=playerSceneTorch},initPlayerLights:function(){var ambientLight=new THREE.AmbientLight(this.ambientColor);this.playerScene.add(ambientLight),this.playerLights.ambient=ambientLight;var pointLight=new THREE.PointLight;pointLight.position.copy(this.muzzleFlashPosition),pointLight.intensity=this.muzzleFlashIntensity.value,pointLight.distance=this.muzzleFlashDistance,this.playerScene.add(pointLight),this.playerLights.muzzleFlash=pointLight;var dirLight=new THREE.DirectionalLight(this.directionalColor,this.directionalIntensity);dirLight.position.copy(this.directionalPosition),this.playerScene.add(dirLight),this.playerLights.directional=dirLight,this.player.playerView.lightingView=this},updatePlayerLights:function(){var xAngle=Math.PI/180*(this.player.yAngle-90),yAngle=Math.PI/180*(this.player.xAngle+90),matrix=(new THREE.Matrix4).makeRotationX(xAngle).multiply((new THREE.Matrix4).makeRotationY(yAngle)),dirPos=this.worldLights.directional.position;this.playerLights.directional.position.copy(dirPos).applyMatrix4(matrix),this.muzzleFlashIntensity.update(),this.worldLights.muzzleFlash.position.copy(this.player.position),this.worldLights.muzzleFlash.position.y+=.5*this.player.size.y,this.worldLights.muzzleFlash.intensity=this.muzzleFlashIntensity.value,this.playerLights.muzzleFlash.intensity=this.muzzleFlashIntensity.value,this.worldLights.playerTorch.position.copy(this.player.position)},beginMuzzleFlash:function(color){this.muzzleFlashIntensity.value=this.muzzleFlashMaxIntensity,this.worldLights.muzzleFlash.color.copy(color),this.playerLights.muzzleFlash.color.copy(color)},endMuzzleFlash:function(){this.muzzleFlashIntensity.setTargetValue(0)},addProjectileLight:function(projectile){var light;light=this.projectileLights.shift(),light.active=!0,light.projectile=projectile,light.intensity.value=this.projectileIntensity,light.intensity.setTargetValue(this.projectileIntensity),light.pointLight.color.setHex(projectile.color),light.pointLight.position.copy(projectile.position),light.pointLight.intensity=light.intensity.value,this.projectileLights.push(light)},update:function(){for(var i=0;i<this.projectileLights.length;i++){var light=this.projectileLights[i];light.active&&(light.projectile.removed&&light.intensity.setTargetValue(0),light.intensity.update(),light.pointLight.intensity=light.intensity.value,light.pointLight.position.copy(light.projectile.position),0===light.intensity.value&&(light.active=!1))}}},GS.ParticleMovementTypes={Static:0,Falling:1,Gushing:2},GS.ParticleView=function(grid){this.grid=grid,this.scene=grid.scene,this.particles=[],this.geometries={},this.materials={},this.particleSpeed=75e-5,this.particleGravity=new THREE.Vector3(0,(-.003),0)},GS.ParticleView.prototype={constructor:GS.ParticleView,init:function(){this.root=new THREE.Object3D,this.root.userData="particle root",this.scene.add(this.root)},update:function(){for(var i=0;i<this.particles.length;i++){var particle=this.particles[i];particle.movementType!=GS.ParticleMovementTypes.Static&&(particle.landed!==!0?(particle.acceleration.add(particle.gravity),particle.velocity.add(particle.acceleration),particle.mesh.position.add(particle.velocity),particle.mesh.rotation.y+=particle.rotationSpeed,particle.life++,void 0!==particle.floorImpactY&&particle.mesh.position.y<particle.floorImpactY&&(particle.mesh.position.y=particle.floorImpactY+.5,particle.landed=!0)):(particle.decayTime-=.01,particle.mesh.scale.set(particle.decayTime,particle.decayTime,particle.decayTime),particle.decayTime<=0&&(particle.toBeRemoved=!0)))}for(var i=this.particles.length-1;i>=0;i--)this.particles[i].toBeRemoved&&this.removeParticle(this.particles[i],i)},addParticle:function(width,height,depth,color,movementType,position){var geometry=this.getGeometry(width,height,depth),material=this.getMaterial(color),mesh=new THREE.Mesh(geometry,material);movementType=void 0!==movementType?movementType:GS.ParticleMovementTypes.Static;var particle={mesh:mesh,position:position,rotationSpeed:.25*Math.random(),movementType:movementType,color:color,decayTime:1};return movementType!=GS.ParticleMovementTypes.Static&&(particle.gravity=this.particleGravity.clone(),movementType==GS.ParticleMovementTypes.Falling?(particle.horizontalSpeed=15,particle.verticalSpeed=10*Math.random()):movementType==GS.ParticleMovementTypes.Gushing&&(particle.horizontalSpeed=20,particle.verticalSpeed=10*Math.random()+60),this.calculateAcceleration(particle),particle.velocity=new THREE.Vector3,this.calculateFloorImpactY(particle)),this.root.add(mesh),this.particles.push(particle),particle},removeParticle:function(particle,index){var i=void 0!==index?index:this.particles.indexOf(particle);i>-1&&(this.root.remove(particle.mesh),this.particles.splice(i,1))},calculateFloorImpactY:function(){var fauxGridObject={grid:null,position:new THREE.Vector3,linkedGridCells:null},position2d=new THREE.Vector2;return function(particle){particle.position.toVector2(position2d);var gridLocation=this.grid.getGridLocationFromPoints([position2d]);if(void 0!==gridLocation){fauxGridObject.grid=this.grid,fauxGridObject.position.copy(particle.position),fauxGridObject.linkedGridCells=this.grid.getCellsFromGridLocation(gridLocation);var sector=GS.GridObject.prototype.getSector.call(fauxGridObject);void 0!==sector&&(particle.floorImpactY=sector.floorTopY),fauxGridObject.grid=null,fauxGridObject.linkedGridCells=null}}}(),calculateAcceleration:function(particle){particle.acceleration=new THREE.Vector3(2*Math.random()-1,0,2*Math.random()-1),particle.acceleration.normalize(),particle.acceleration.multiplyScalar(particle.horizontalSpeed),particle.acceleration.y=particle.verticalSpeed,particle.acceleration.multiplyScalar(this.particleSpeed)},alignParticleTrajectoryToNormal:function(){var normal2d=new THREE.Vector2,axis=new THREE.Vector2(1,0);return function(particle,normal){if(0===normal.x&&0===normal.z){if(normal.y==-1)return;return particle.horizontalSpeed=20,particle.verticalSpeed=10*Math.random()+30,void this.calculateAcceleration(particle)}normal.toVector2(normal2d);var angle=GS.MathHelper.vec2AngleDirected(axis,normal2d)+Math.PI,k=angle-Math.random()*Math.PI;normal2d.set(Math.sin(k),Math.cos(k)),particle.acceleration.x=normal2d.x,particle.acceleration.z=normal2d.y,particle.acceleration.multiplyScalar(particle.horizontalSpeed*this.particleSpeed),particle.acceleration.y=particle.verticalSpeed*this.particleSpeed,particle.mesh.rotation.y+=angle,this.calculateFloorImpactY(particle)}}(),getGeometry:function(width,height,depth){var id=width.toFixed(2)+height.toFixed(2)+depth.toFixed(2);return id in this.geometries||(this.geometries[id]=new THREE.BoxGeometry(width,height,depth)),this.geometries[id]},getMaterial:function(color){var id=color.toString();return id in this.materials||(this.materials[id]=new THREE.MeshBasicMaterial({color:color})),this.materials[id]}},GS.PlayerView=function(){this.weapons={pistol:{position:new THREE.Vector3(2.75,(-2.5),(-4)),startPosition:new THREE.Vector3(2.5,(-6.5),1),scale:new THREE.Vector3(.4,.4,.4),rotation:new THREE.Vector3(0,THREE.Math.degToRad(-90),0),pushback:1,shootBackwardFactor:.5,shootForwardFactor:.5,muzzleDuration:GS.msToFrames(250),muzzleFlashColor:(new THREE.Color).setRGB(1,1,1)},double_shotgun:{position:new THREE.Vector3(2.25,(-3.5),(-3)),startPosition:new THREE.Vector3(2.5,(-6.5),1),scale:new THREE.Vector3(.4,.4,.4),rotation:new THREE.Vector3(0,THREE.Math.degToRad(180),0),pushback:2,shootBackwardFactor:.1,shootForwardFactor:.9,muzzleDuration:GS.msToFrames(250),muzzleFlashColor:(new THREE.Color).setRGB(1,1,1)},hyper_blaster:{position:new THREE.Vector3(2.75,(-2.5),(-3)),startPosition:new THREE.Vector3(2.5,(-6.5),1),scale:new THREE.Vector3(.4,.4,.4),rotation:new THREE.Vector3(0,THREE.Math.degToRad(-90),0),pushback:1,shootBackwardFactor:.5,shootForwardFactor:.5,muzzleDuration:GS.msToFrames(125),muzzleFlashColor:(new THREE.Color).setRGB(1,1,1)}},$.extend(!0,this.weapons,GS.Weapons),this.scene=new THREE.Scene,this.camera=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,.1,100),this.screenOverlayColor=new THREE.Color(0),this.screenOverlayColorFadeSpeed=.02,this.muzzleCooldown=0,this.weaponReady=!1,this.weaponBob={enabled:GS.Settings.weaponBob,magnitudeX:.5,magnitudeY:.5,offset:new THREE.Vector3,radian:0,speed:.1},this.viewBob={enabled:GS.Settings.viewBob,magnitude:1.5,offset:0,radian:0,speed:.2},this.viewThrottle=new GS.SmoothNumber(0,.1),this.weaponThrottle=new GS.SmoothNumber(0,.1),
this.tweens={shoot:{easing:TWEEN.Easing.Sinusoidal.InOut},show:{easing:TWEEN.Easing.Back.Out,duration:500},hide:{easing:TWEEN.Easing.Back.InOut,duration:250}}},GS.PlayerView.prototype={init:function(){var that=this;Object.keys(this.weapons).forEach(function(key){that.initWeaponMesh(key)})},addWeaponMesh:function(name,mesh){this.weapons[name].mesh=mesh},getWeaponMeshes:function(){var that=this,meshes=[];return Object.keys(this.weapons).forEach(function(key){var weapon=that.weapons[key];meshes.push(weapon.mesh)}),meshes},initWeaponMesh:function(name){var weapon=this.weapons[name];void 0!==weapon.mesh&&(weapon.mesh.visible=!1,weapon.mesh.position.copy(weapon.position),weapon.mesh.rotation.x=weapon.rotation.x,weapon.mesh.rotation.y=weapon.rotation.y,weapon.mesh.rotation.z=weapon.rotation.z,weapon.mesh.scale.copy(weapon.scale),this.scene.add(weapon.mesh))},update:function(){this.lightingView.updatePlayerLights(),this.updateMuzzleFlash(),this.updateLightLevel(),this.updateViewBob(),this.updateWeaponBob(),this.updateScreenOverlay()},updateMuzzleFlash:function(){this.muzzleCooldown>0&&(this.muzzleCooldown--,0===this.muzzleCooldown&&this.lightingView.endMuzzleFlash())},updateLightLevel:function(){void 0!==this.weapon&&this.player.getLightColorFromSector(this.weapon.mesh.material.emissive)},updateThrottle:function(oldPos,newPos){var velocity=oldPos.toVector2().distanceTo(newPos.toVector2());this.viewThrottle.setTargetValue(velocity/this.player.moveSpeed),this.viewThrottle.update(),!this.player.shooting&&this.weaponReady&&(this.weaponThrottle.setTargetValue(velocity/this.player.moveSpeed),this.weaponThrottle.update())},resetWeaponThrottle:function(){this.weaponThrottle.value=0,this.weaponBob.radian=0},updateViewBob:function(){this.viewBob.enabled&&(this.player.controls.setViewOffsetY(this.viewBob.offset),this.viewBob.radian+=this.viewBob.speed,this.viewBob.offset=this.viewThrottle.value*this.viewBob.magnitude*Math.sin(this.viewBob.radian))},updateWeaponBob:function(){if(this.weaponBob.enabled&&!this.player.shooting){this.weaponBob.radian+=this.weaponBob.speed;var x=this.weaponThrottle.value*this.weaponBob.magnitudeX*Math.sin(this.weaponBob.radian),y=-Math.abs(this.weaponThrottle.value*this.weaponBob.magnitudeY*Math.sin(this.weaponBob.radian));this.weaponBob.offset.set(x,y,0),void 0!==this.weapon&&this.weapon.mesh.position.copy(this.weapon.position.clone().add(this.weaponBob.offset))}},shoot:function(){this.resetWeaponThrottle(),this.weapon.mesh.position.copy(this.weapon.position);var backward=this.weapon.position.clone();backward.z+=this.weapon.pushback;var tweenShootBackward=new TWEEN.Tween(this.weapon.mesh.position).to(backward,this.weapon.cooldown*this.weapon.shootBackwardFactor);tweenShootBackward.easing(this.tweens.shoot.easing);var tweenShootForward=new TWEEN.Tween(this.weapon.mesh.position).to(this.weapon.position,this.weapon.cooldown*this.weapon.shootForwardFactor);tweenShootForward.easing(this.tweens.shoot.easing),tweenShootBackward.chain(tweenShootForward),tweenShootBackward.start(),this.showMuzzleFlash()},showMuzzleFlash:function(){this.lightingView.beginMuzzleFlash(this.weapon.muzzleFlashColor),this.muzzleCooldown=this.weapon.muzzleDuration},changeToWeaponInstant:function(name){this.resetWeaponThrottle(),void 0!==this.weapon&&(this.weapon.mesh.visible=!1),this.weaponReady=!0,this.weapon=this.weapons[name],this.weapon.mesh.visible=!0,this.weapon.mesh.position.copy(this.weapon.startPosition)},changeToWeapon:function(name){var that=this;this.resetWeaponThrottle(),this.weaponReady=!1,void 0!==this.weapon?this.hideWeapon(function(){that.showWeapon(name)}):this.showWeapon(name)},showWeapon:function(name,callback){var that=this;this.weapon=this.weapons[name],this.weapon.mesh.visible=!0,this.weapon.mesh.position.copy(this.weapon.startPosition);var tween=new TWEEN.Tween(this.weapon.mesh.position).to(this.weapon.position,this.tweens.show.duration);tween.easing(this.tweens.show.easing),tween.onComplete(function(){tween.onComplete(null),that.weaponReady=!0,void 0!==callback&&callback()}),tween.start()},hideWeapon:function(callback){var that=this;this.weaponReady=!1;var tween=new TWEEN.Tween(this.weapon.mesh.position).to(this.weapon.startPosition,this.tweens.hide.duration);tween.easing(this.tweens.hide.easing),tween.onComplete(function(){tween.onComplete(null),that.weapon.mesh.visible=!1,void 0!==callback&&callback()}),tween.start()},onResize:function(){this.camera.aspect=window.innerWidth/window.innerHeight,this.camera.updateProjectionMatrix()},onItemPickup:function(){this.screenOverlayColor.setRGB(.3,.3,0),this.dispatchEvent({type:"screenOverlayColorChange",color:this.screenOverlayColor})},onDamage:function(){this.screenOverlayColor.setRGB(.6,0,0),this.dispatchEvent({type:"screenOverlayColorChange",color:this.screenOverlayColor})},onDeath:function(){this.player.controls.eye.y-=this.player.size.y,this.player.controls.updateCamera(),void 0!==this.weapon&&this.hideWeapon()},updateScreenOverlay:function(){(this.screenOverlayColor.r>0||this.screenOverlayColor.g>0||this.screenOverlayColor.b>0)&&(this.screenOverlayColor.addScalar(-this.screenOverlayColorFadeSpeed),this.screenOverlayColor.r<0&&(this.screenOverlayColor.r=0),this.screenOverlayColor.g<0&&(this.screenOverlayColor.g=0),this.screenOverlayColor.b<0&&(this.screenOverlayColor.b=0),this.dispatchEvent({type:"screenOverlayColorChange",color:this.screenOverlayColor}))}},THREE.EventDispatcher.prototype.apply(GS.PlayerView.prototype),GS.GameVersion="v1.2.2",GS.ReleaseDate="april 2017",GS.GameStates={Dispose:0,PreLoad:1,Loading:2,PostLoad:3,Play:4,Menu:5},GS.Game=function(){GS.Base.call(this)},GS.Game.prototype=GS.inherit(GS.Base,{constructor:GS.Game,preInit:function(){GS.Settings.loadSettings(),this.state=GS.GameStates.PreLoad,this.nextState=null,this.updated=!1,this.firstLoad=!0,this.firstPlay=!0,this.mapWon=!1,this.restartedLevel=!1,this.antialias=!1,this.clearColor=3368601,this.cameraFov=GS.Settings.fov,this.cameraFar=1500,this.isTestMap()?this.noMenu=!0:this.noMenu=!1,this.firstTimeInMenu=!0,this.showFPS=GS.Settings.showFPS,this.showPerformanceDebugMeters=!1},init:function(){GS.DebugUI.init(),GS.DebugUI.visible=!1,this.loadingUI=new GS.LoadingUI,this.loadingUI.init(),this.uiManager=new GS.UIManager,this.uiManager.init(),this.soundManager=new GS.SoundManager,this.soundManager.init(),this.musicManager=new GS.MusicManager,this.musicManager.init(),this.initAssetLoader(),this.keys={Enter:13,Escape:27,Tab:9},GS.Base.prototype.init.call(this),this.graphicsManager=new GS.GraphicsManager(this.renderer,this.camera),this.graphicsManager.init()},preLoad:function(){this.uiManager.reset(),this.loadingUI.percentLoaded=0,this.loadingUI.show(),this.scene=new THREE.Scene,this.scene.fog=new THREE.Fog((new THREE.Color).setRGB(0,0,0).getHex(),500,900),this.assetLoader.loaded?this.nextState=GS.GameStates.PostLoad:(this.assetLoader.load(),this.nextState=GS.GameStates.Loading)},initAssetLoader:function(){var that=this;this.assetLoader=new GS.ZipAssetLoader(this.soundManager.ctx),this.assetLoader.init(),this.assetLoader.addEventListener("progress",function(e){that.loadingUI.updateProgress(e)}),this.assetLoader.addEventListener("load",function(e){that.loadingUI.updateProgress(e),that.nextState=GS.GameStates.PostLoad})},postLoad:function(){this.firstLoad?(this.loadingUI.spinnerOnly=!0,this.uiManager.initComponents(this.assetLoader.assets),this.openMenu(),this.firstLoad=!1,this.noMenu&&this.newGame()):(this.initComponents(this.assetLoader.assets),this.uiManager.initComponents(this.assetLoader.assets,this.grid),this.uiManager.useIngameMenu(),this.nextState=GS.GameStates.Play,this.graphicsManager.monochromeEnabled=!1,void 0===this.grid.aiManager.script||this.restartedLevel||this.musicManager.playTrack(this.grid.aiManager.script.musicTrack),this.restartedLevel=!1,this.firstPlay&&(this.firstPlay=!1))},play:function(){GS.InputHelper.checkPressedKeys(),!GS.InputHelper.keysPressed&&GS.InputHelper.isKeyDown(this.keys.Escape)&&this.openMenu(),this.grid.aiManager.mapWon||GS.InputHelper.keysPressed||!GS.InputHelper.isKeyDown(this.keys.Tab)||(this.uiManager.automap.visible=!this.uiManager.automap.visible,this.uiManager.overrideRedraw=!0,this.graphicsManager.monochromeEnabled=this.uiManager.automap.visible),this.grid.player.dead&&!GS.InputHelper.keysPressed&&GS.InputHelper.isKeyDown(this.keys.Enter)&&this.restartLevel(),this.grid.aiManager.mapWon&&!GS.InputHelper.keysPressed&&GS.InputHelper.isKeyDown(this.keys.Enter)&&void 0!==this.grid.aiManager.script.nextMap&&(this.playerPersistencePackage=this.grid.player.getPersistencePackage(),this.loadLevel(this.grid.aiManager.script.nextMap)),!this.mapWon&&this.grid.aiManager.mapWon&&(this.mapWon=!0,this.onMapWon()),this.grid.aiManager.mapWon||(this.grid.update(),TWEEN.update()),GS.DebugUI.update(),this.uiManager.update()},onMapWon:function(){this.graphicsManager.monochromeEnabled=!1},menu:function(){GS.InputHelper.checkPressedKeys(),!GS.InputHelper.keysPressed&&GS.InputHelper.isKeyDown(this.keys.Escape)&&void 0!==this.grid&&this.closeMenu(),this.uiManager.update()},openMenu:function(){this.nextState=GS.GameStates.Menu,void 0!==this.grid&&(this.grid.player.inMenu=!0,this.grid.player.controls.disable(),this.grid.player.controls.detachEvents()),this.graphicsManager.monochromeEnabled=!0,this.uiManager.menuActive=!0,GS.DebugUI.visible=!1},closeMenu:function(){this.nextState=GS.GameStates.Play,void 0!==this.grid?(this.grid.player.inMenu=!1,this.grid.player.controls.attachEvents(),this.grid.player.controls.enable(),this.grid.aiManager.resume(),!this.mapWon&&this.uiManager.automap.visible||(this.graphicsManager.monochromeEnabled=!1)):this.graphicsManager.monochromeEnabled=!1,this.firstTimeInMenu&&(this.uiManager.removeNewsBox(),this.firstTimeInMenu=!1),this.uiManager.menuActive=!1,GS.DebugUI.visible=GS.Settings.showHUD},restartLevel:function(){this.nextState=GS.GameStates.Dispose,this.restartedLevel=!0},loadLevel:function(name){this.uiManager.menuActive&&this.closeMenu(),this.mapName=name,this.nextState=GS.GameStates.Dispose},newGame:function(){this.uiManager.menuActive&&this.closeMenu(),this.isTestMap()?this.mapName="testMap":this.mapName="airstrip1",this.nextState=GS.GameStates.Dispose},isTestMap:function(){return window.location.search.toLowerCase().indexOf("testmap")>-1},initComponents:function(assets){var that=this,map=this.assetLoader.mapLoader.parse(assets[GS.AssetTypes.Map][this.mapName]);this.mapWon=!1;var viewFactory=new GS.ViewFactory(this.renderer,map,assets);viewFactory.init();var gridFactory=new GS.GridFactory(viewFactory,this.soundManager,this.renderer,this.scene,this.camera);this.grid=gridFactory.getGrid(map),this.soundManager.initSounds(assets[GS.AssetTypes.Sound]),this.musicManager.initTracks(assets[GS.AssetTypes.MusicTrack]),void 0!==this.playerPersistencePackage&&(this.grid.player.applyPersistencePackage(this.playerPersistencePackage),this.playerPersistencePackage=void 0),this.grid.update(),this.graphicsManager.setGrid(this.grid),this.grid.player.controls.addEventListener("pointerLockDisabled",function(){that.openMenu()})},update:function(){var time;this.showPerformanceDebugMeters&&(time=window.performance.now()),this.state==GS.GameStates.Dispose?this.updated||(this.updated=!0,this.dispose()):this.state==GS.GameStates.PreLoad?this.updated||(this.updated=!0,this.preLoad()):this.state==GS.GameStates.Loading?this.updated=!0:this.state==GS.GameStates.PostLoad?this.updated||(this.updated=!0,this.postLoad()):this.state==GS.GameStates.Play?(this.updated=!0,this.play()):this.state==GS.GameStates.Menu&&(this.updated=!0,this.menu()),null!==this.nextState&&this.updated&&(this.nextState!=GS.GameStates.Play&&this.nextState!=GS.GameStates.Menu||(this.loadingUI.hide(),this.uiManager.show()),this.state=this.nextState,this.nextState=null,this.updated=!1),this.showPerformanceDebugMeters&&(this.updateTime=(window.performance.now()-time).toFixed(2),GS.DebugUI.trackNumericValue("updateTime",this.updateTime))},draw:function(){var time;this.showPerformanceDebugMeters&&(time=window.performance.now()),this.state==GS.GameStates.PreLoad?this.loadingUI.draw():this.state==GS.GameStates.Loading?this.loadingUI.draw():this.state==GS.GameStates.PostLoad?this.loadingUI.draw():this.state!=GS.GameStates.Play&&this.state!=GS.GameStates.Menu||(void 0!==this.grid&&this.graphicsManager.draw(),this.uiManager.draw()),this.showPerformanceDebugMeters&&(this.drawTime=(window.performance.now()-time).toFixed(2),GS.DebugUI.trackNumericValue("drawTime",this.drawTime))},onResize:function(){GS.Base.prototype.onResize.call(this),this.uiManager.onResize(),this.loadingUI.onResize(),void 0!==this.graphicsManager&&this.graphicsManager.onResize(),void 0!==this.grid&&(this.grid.onResize(),this.grid.player.playerView.onResize())},customMap:function(){var that=this,customMapInput=$("#customMapInput"),files=customMapInput[0].files;if(void 0===files||0===files.length)return void customMapInput.trigger("click");var file=files[0],fileReader=new FileReader;fileReader.onload=function(e){that.assetLoader.assets[GS.AssetTypes.Map].customMap=e.target.result,that.loadLevel("customMap")},fileReader.onerror=function(e){GAME.handleFatalError("file read error - "+e.target.error.code)},fileReader.readAsText(file),customMapInput.val("")},handleFatalError:function(message){document.body.innerHTML="<span class='fatal-error'> fatal error: '"+message+"'</span><br/>",document.body.style.padding="20px";var a=document.createElement("a");a.innerHTML="click here or refresh page to restart",a.className="fatal-error-link",a.onclick=function(){window.location.reload()},document.body.appendChild(a),this.nextState=GS.GameStates.Dispose},updateFov:function(){this.cameraFov=GS.Settings.fov,this.camera.fov=GS.Settings.fov,this.camera.updateProjectionMatrix(),this.state==GS.GameStates.Play&&this.grid.updateFov()},disposeEnd:function(){TWEEN.removeAll(),this.grid=void 0,this.graphicsManager.reset(),this.scene=void 0,this.uiManager.dispose(),this.nextState=GS.GameStates.PreLoad},dispose:function(){var that=this;void 0!==this.grid?this.grid.player.controls.dispose(function(){that.disposeEnd()}):this.disposeEnd()}});var GAME;window.addEventListener("load",function(){GS.Detector.run(function(){GAME=new GS.Game,GAME.preInit(),GAME.init()})},!1),GS.KeybindSettings={keybinds:[{actionName:"moveForward",controlName:"W",code:87},{actionName:"moveBackward",controlName:"S",code:83},{actionName:"strafeLeft",controlName:"A",code:65},{actionName:"strafeRight",controlName:"D",code:68},{actionName:"use",controlName:"E",code:69},{actionName:"shoot",controlName:"MOUSE LEFT",mouse:!0,button:1},{actionName:"pistol",controlName:"2",code:50},{actionName:"shotgun",controlName:"3",code:51},{actionName:"hyperblaster",controlName:"4",code:52}],init:function(){this.rebound=new GS.Rebound(GS.KeybindSettings.keybinds),this.rebound.init(),GS.Keybinds={};for(var i=0;i<this.keybinds.length;i++){var keybind=this.keybinds[i];GS.Keybinds[keybind.actionName]=keybind}}},GS.Settings=function(){var settings={fovMin:60,fovMax:120,fov:75,ssao:!0,bloom:!0,noise:!0,vignette:!0,fxaa:!0,halfSize:!0,showFPS:!0,viewBob:!0,weaponBob:!0,showHUD:!0,showWeapon:!0,soundMin:0,soundMax:10,sound:5,musicMin:0,musicMax:10,music:5,mouseMin:1,mouseMax:10,mouse:5,mouseInvertY:!1,keybinds:null};return{loadSettings:function(){var jsonStr=localStorage["gs-settings"];if(void 0!==jsonStr){var loadedSettings=JSON.parse(jsonStr);for(var i in loadedSettings)i in settings&&(settings[i]=loadedSettings[i]);loadedSettings.keybinds&&(GS.KeybindSettings.keybinds=loadedSettings.keybinds)}GS.KeybindSettings.init(),settings.keybinds=GS.KeybindSettings.keybinds},saveSettings:function(){var jsonStr=JSON.stringify(settings);localStorage["gs-settings"]=jsonStr},get fovMin(){return settings.fovMin},get fovMax(){return settings.fovMax},set fov(value){var n=parseInt(value);isNaN(n)||(n=Math.floor(GS.MathHelper.clamp(n,settings.fovMin,settings.fovMax)),settings.fov=n,GAME.updateFov(),this.saveSettings())},get fov(){return settings.fov},set ssao(value){settings.ssao=value===!0,GAME.graphicsManager.ssaoEnabled=settings.ssao,this.saveSettings()},get ssao(){return settings.ssao},set bloom(value){settings.bloom=value===!0,GAME.graphicsManager.bloomEnabled=settings.bloom,this.saveSettings()},get bloom(){return settings.bloom},set noise(value){settings.noise=value===!0,GAME.graphicsManager.noiseEnabled=settings.noise,this.saveSettings()},get noise(){return settings.noise},set vignette(value){settings.vignette=value===!0,GAME.graphicsManager.vignetteEnabled=settings.vignette,this.saveSettings()},get vignette(){return settings.vignette},set fxaa(value){settings.fxaa=value===!0,GAME.graphicsManager.fxaaEnabled=settings.fxaa,this.saveSettings()},get fxaa(){return settings.fxaa},set viewBob(value){settings.viewBob=value===!0,this.saveSettings(),void 0!==GAME.grid&&(GAME.grid.player.playerView.viewBob.enabled=settings.viewBob)},get viewBob(){return settings.viewBob},set weaponBob(value){settings.weaponBob=value===!0,this.saveSettings(),void 0!==GAME.grid&&(GAME.grid.player.playerView.weaponBob.enabled=settings.weaponBob)},get weaponBob(){return settings.weaponBob},set halfSize(value){settings.halfSize=value===!0,this.saveSettings(),GAME.graphicsManager.halfSizeEnabled=settings.halfSize},get halfSize(){return settings.halfSize},set showFPS(value){settings.showFPS=value===!0,this.saveSettings(),GAME.showFPS=settings.showFPS},get showFPS(){return settings.showFPS},get soundMin(){return settings.soundMin},get soundMax(){return settings.soundMax},set sound(value){var n=parseInt(value);isNaN(n)||(n=Math.floor(GS.MathHelper.clamp(n,settings.soundMin,settings.soundMax)),settings.sound=n,GAME.soundManager.volume=settings.sound/10,this.saveSettings())},get sound(){return settings.sound},get musicMin(){return settings.musicMin},get musicMax(){return settings.musicMax},set music(value){var n=parseInt(value);isNaN(n)||(n=Math.floor(GS.MathHelper.clamp(n,settings.musicMin,settings.musicMax)),settings.music=n,GAME.musicManager.volume=settings.music/10,this.saveSettings())},get music(){return settings.music},get mouseMin(){return settings.mouseMin},get mouseMax(){return settings.mouseMax},set mouse(value){var n=parseInt(value);isNaN(n)||(n=Math.floor(GS.MathHelper.clamp(n,settings.mouseMin,settings.mouseMax)),settings.mouse=n,void 0!==GAME.grid&&(GAME.grid.player.controls.lookSpeed=.066*(settings.mouse/5)),this.saveSettings())},get mouse(){return settings.mouse},set showHUD(value){settings.showHUD=value===!0,this.saveSettings(),GAME.uiManager.showHUD=settings.showHUD,GAME.uiManager.overrideRedraw=!0},get showHUD(){return settings.showHUD},set showWeapon(value){settings.showWeapon=value===!0,this.saveSettings(),GAME.graphicsManager.showWeapon=settings.showWeapon},get showWeapon(){return settings.showWeapon},set mouseInvertY(value){settings.mouseInvertY=value===!0,this.saveSettings(),void 0!==GAME.grid&&(GAME.grid.player.controls.mouseInvertY=settings.mouseInvertY)},get mouseInvertY(){return settings.mouseInvertY}}}();