!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.AFRAME=e()}}(function(){var t;return function i(e,t,r){function n(a,s){if(!t[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var l=t[a]={exports:{}};e[a][0].call(l.exports,function(t){var i=e[a][1][t];return n(i?i:t)},l,l.exports,i,e,t,r)}return t[a].exports}for(var o="function"==typeof require&&require,a=0;a1)for(var i=1;i=31}function n(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+i.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var n=0,o=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(o=n))}),e.splice(o,0,r),e}function o(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?i.storage.removeItem("debug"):i.storage.debug=e}catch(t){}}function s(){var e;try{e=i.storage.debug}catch(t){}return e}function c(){try{return window.localStorage}catch(e){}}i=t.exports=e("./debug"),i.log=o,i.formatArgs=n,i.save=a,i.load=s,i.useColors=r,i.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),i.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],i.formatters.j=function(e){return JSON.stringify(e)},i.enable(s())},{"./debug":4}],4:[function(e,t,i){function r(){return i.colors[l++%i.colors.length]}function n(e){function t(){}function n(){var e=n,t=+new Date,o=t-(h||t);e.diff=o,e.prev=h,e.curr=t,h=t,null==e.useColors&&(e.useColors=i.useColors()),null==e.color&&e.useColors&&(e.color=r());var a=Array.prototype.slice.call(arguments);a[0]=i.coerce(a[0]),"string"!=typeof a[0]&&(a=["%o"].concat(a));var s=0;a[0]=a[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;s++;var n=i.formatters[r];if("function"==typeof n){var o=a[s];t=n.call(e,o),a.splice(s,1),s--}return t}),"function"==typeof i.formatArgs&&(a=i.formatArgs.apply(e,a));var c=n.log||i.log||console.log.bind(console);c.apply(e,a)}t.enabled=!1,n.enabled=!0;var o=i.enabled(e)?n:t;return o.namespace=e,o}function o(e){i.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,n=0;r>n;n++)t[n]&&(e=t[n].replace(/\*/g,".*?"),"-"===e[0]?i.skips.push(new RegExp("^"+e.substr(1)+"$")):i.names.push(new RegExp("^"+e+"$")))}function a(){i.enable("")}function s(e){var t,r;for(t=0,r=i.skips.length;r>t;t++)if(i.skips[t].test(e))return!1;for(t=0,r=i.names.length;r>t;t++)if(i.names[t].test(e))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}i=t.exports=n,i.coerce=c,i.disable=a,i.enable=o,i.enabled=s,i.humanize=e("ms"),i.names=[],i.skips=[],i.formatters={};var h,l=0},{ms:5}],5:[function(e,t){function i(e){if(e=""+e,!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var i=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return i*l;case"days":case"day":case"d":return i*h;case"hours":case"hour":case"hrs":case"hr":case"h":return i*c;case"minutes":case"minute":case"mins":case"min":case"m":return i*s;case"seconds":case"second":case"secs":case"sec":case"s":return i*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i}}}}function r(e){return e>=h?Math.round(e/h)+"d":e>=c?Math.round(e/c)+"h":e>=s?Math.round(e/s)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function n(e){return o(e,h,"day")||o(e,c,"hour")||o(e,s,"minute")||o(e,a,"second")||e+" ms"}function o(e,t,i){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+i:Math.ceil(e/t)+" "+i+"s"}var a=1e3,s=60*a,c=60*s,h=24*c,l=365.25*h;t.exports=function(e,t){return t=t||{},"string"==typeof e?i(e):t["long"]?n(e):r(e)}},{}],6:[function(e,t){"use strict";function i(e){if(null===e||void 0===e)throw new TypeError("Sources cannot be null or undefined");return Object(e)}function r(e,t,i){var r=t[i];if(void 0!==r&&null!==r){if(a.call(e,i)&&(void 0===e[i]||null===e[i]))throw new TypeError("Cannot convert undefined or null to object ("+i+")");e[i]=a.call(e,i)&&o(r)?n(Object(e[i]),t[i]):r}}function n(e,t){if(e===t)return e;t=Object(t);for(var i in t)a.call(t,i)&&r(e,t,i);if(Object.getOwnPropertySymbols)for(var n=Object.getOwnPropertySymbols(t),o=0;oi;i++)g(e[i],t)}function a(e){for(var t,i=0,r=e.length;r>i;i++)t=e[i],E(t,U[c(t)])}function s(e){return function(t){ne(t)&&(g(t,e),o(t.querySelectorAll(z),e))}}function c(e){var t=se.call(e,"is"),i=e.nodeName.toUpperCase(),r=G.call(V,t?N+t.toUpperCase():k+i);return t&&r>-1&&!h(i,t)?-1:r}function h(e,t){return-1t;t++)e=oe[t],j.contains(e)||(i--,oe.splice(t--,1),g(e,T))}function v(e){throw new Error("A "+e+" type is already registered")}function g(e,t){var i,r=c(e);r>-1&&(_(e,U[r]),r=0,t!==S||e[S]?t===T&&!e[T]&&(e[S]=!1,e[T]=!0,r=1):(e[T]=!1,e[S]=!0,r=1,re&&G.call(oe,e)<0&&oe.push(e)),r&&(i=e[t+"Callback"])&&i.call(e))}if(!(n in i)){var y,x,b,w,M,_,E,A="__"+n+(1e5*Math.random()>>0),S="attached",T="detached",C="extends",L="ADDITION",R="MODIFICATION",P="REMOVAL",D="DOMAttrModified",O="DOMContentLoaded",I="DOMSubtreeModified",k="<",N="=",B=/^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,F=["ANNOTATION-XML","COLOR-PROFILE","FONT-FACE","FONT-FACE-SRC","FONT-FACE-URI","FONT-FACE-FORMAT","FONT-FACE-NAME","MISSING-GLYPH"],V=[],U=[],z="",j=i.documentElement,G=V.indexOf||function(e){for(var t=this.length;t--&&this[t]!==e;);return t},H=r.prototype,W=H.hasOwnProperty,q=H.isPrototypeOf,X=r.defineProperty,Y=r.getOwnPropertyDescriptor,Q=r.getOwnPropertyNames,K=r.getPrototypeOf,Z=r.setPrototypeOf,J=!!r.__proto__,$=r.create||function ye(e){return e?(ye.prototype=e,new ye):this},ee=Z||(J?function(e,t){return e.__proto__=t,e}:Q&&Y?function(){function e(e,t){for(var i,r=Q(t),n=0,o=r.length;o>n;n++)i=r[n],W.call(e,i)||X(e,i,Y(t,i))}return function(t,i){do e(t,i);while((i=K(i))&&!q.call(i,t));return t}}():function(e,t){for(var i in t)e[i]=t[i];return e}),te=t.MutationObserver||t.WebKitMutationObserver,ie=(t.HTMLElement||t.Element||t.Node).prototype,re=!q.call(ie,j),ne=re?function(e){return 1===e.nodeType}:function(e){return q.call(ie,e)},oe=re&&[],ae=ie.cloneNode,se=ie.getAttribute,ce=ie.setAttribute,he=ie.removeAttribute,le=i.createElement,ue=te&&{attributes:!0,characterData:!0,attributeOldValue:!0},de=te||function(){me=!1,j.removeEventListener(D,de)},pe=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,10)},fe=!1,me=!0,ve=!0,ge=!0;Z||J?(_=function(e,t){q.call(t,e)||f(e,t)},E=f):(_=function(e,t){e[A]||(e[A]=r(!0),f(e,t))},E=_),re?(me=!1,function(){var t=Y(ie,"addEventListener"),i=t.value,r=function(e){var t=new CustomEvent(D,{bubbles:!0});t.attrName=e,t.prevValue=se.call(this,e),t.newValue=null,t[P]=t.attrChange=2,he.call(this,e),this.dispatchEvent(t)},n=function(t,i){var r=this.hasAttribute(t),n=r&&se.call(this,t);e=new CustomEvent(D,{bubbles:!0}),ce.call(this,t,i),e.attrName=t,e.prevValue=r?n:null,e.newValue=i,r?e[R]=e.attrChange=1:e[L]=e.attrChange=0,this.dispatchEvent(e)},o=function(e){var t,i=e.currentTarget,r=i[A],n=e.propertyName;r.hasOwnProperty(n)&&(r=r[n],t=new CustomEvent(D,{bubbles:!0}),t.attrName=r.name,t.prevValue=r.value||null,t.newValue=r.value=i[n]||null,null==t.prevValue?t[L]=t.attrChange=0:t[R]=t.attrChange=1,i.dispatchEvent(t))};t.value=function(e,t,a){e===D&&this.attributeChangedCallback&&this.setAttribute!==n&&(this[A]={className:{name:"class",value:this.className}},this.setAttribute=n,this.removeAttribute=r,i.call(this,"propertychange",o)),i.call(this,e,t,a)},X(ie,"addEventListener",t)}()):te||(j.addEventListener(D,de),j.setAttribute(A,1),j.removeAttribute(A),me&&(x=function(e){var t,i,r,n=this;if(n===e.target){t=n[A],n[A]=i=w(n);for(r in i){if(!(r in t))return b(0,n,r,t[r],i[r],L);if(i[r]!==t[r])return b(1,n,r,t[r],i[r],R)}for(r in t)if(!(r in i))return b(2,n,r,t[r],i[r],P)}},b=function(e,t,i,r,n,o){var a={attrChange:e,currentTarget:t,attrName:i,prevValue:r,newValue:n};a[o]=e,l(a)},w=function(e){for(var t,i,r={},n=e.attributes,o=0,a=n.length;a>o;o++)t=n[o],i=t.name,"setAttribute"!==i&&(r[i]=t.value);return r})),i[n]=function(e,t){if(r=e.toUpperCase(),fe||(fe=!0,te?(M=function(e,t){function i(e,t){for(var i=0,r=e.length;r>i;t(e[i++]));}return new te(function(r){for(var n,o,a,s=0,c=r.length;c>s;s++)n=r[s],"childList"===n.type?(i(n.addedNodes,e),i(n.removedNodes,t)):(o=n.target,ge&&o.attributeChangedCallback&&"style"!==n.attributeName&&(a=se.call(o,n.attributeName),a!==n.oldValue&&o.attributeChangedCallback(n.attributeName,n.oldValue,a)))})}(s(S),s(T)),M.observe(i,{childList:!0,subtree:!0})):(y=[],pe(function g(){for(;y.length;)y.shift().call(null,y.shift());pe(g)}),i.addEventListener("DOMNodeInserted",u(S)),i.addEventListener("DOMNodeRemoved",u(T))),i.addEventListener(O,d),i.addEventListener("readystatechange",d),i.createElement=function(e,t){var r=le.apply(i,arguments),n=""+e,o=G.call(V,(t?N:k)+(t||n).toUpperCase()),a=o>-1;return t&&(r.setAttribute("is",t=t.toLowerCase()),a&&(a=h(n.toUpperCase(),t))),ge=!i.createElement.innerHTMLHelper,a&&E(r,U[o]),r},ie.cloneNode=function(e){var t=ae.call(this,!!e),i=c(t);return i>-1&&E(t,U[i]),e&&a(t.querySelectorAll(z)),t}),-2e;e++)n.call(this,this._deferreds[e]);this._deferreds=null}function c(e,t,i,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=i,this.reject=r}function h(e,t,i){var r=!1;try{e(function(e){r||(r=!0,t(e))},function(e){r||(r=!0,i(e))})}catch(n){if(r)return;r=!0,i(n)}}var l=setTimeout,u="function"==typeof setImmediate&&setImmediate||function(e){l(e,1)},d=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};r.prototype["catch"]=function(e){return this.then(null,e)},r.prototype.then=function(e,t){var i=this;return new r(function(r,o){n.call(i,new c(e,t,r,o))})},r.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&d(arguments[0])?arguments[0]:arguments);return new r(function(t,i){function r(o,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){r(o,e)},i)}e[o]=a,0===--n&&t(e)}catch(c){i(c)}}if(0===e.length)return t([]);for(var n=e.length,o=0;or;r++)e[r].then(t,i)})},r._setImmediateFn=function(e){u=e},"undefined"!=typeof t&&t.exports?t.exports=r:e.Promise||(e.Promise=r)}(this)},{}],12:[function(e,t,i){"use strict";function r(e,t,i){function r(){s.id=o(r),a()-n>=e&&(t.call(i),n=a())}var n=a(),s=Object.create(null);return s.id=o(r),s}function n(e){o.cancel(e.id)}var o=e("raf"),a=e("time-now");i=t.exports=r,i.clear=n},{raf:13,"time-now":14}],13:[function(e,t,i){function r(e){var t=(new Date).getTime(),i=Math.max(0,16-(t-n)),r=setTimeout(e,i);return n=t,r}i=t.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||r;var n=(new Date).getTime(),o=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.clearTimeout;i.cancel=function(e){o.call(window,e)}},{}],14:[function(e,t){"use strict";t.exports=function(){var e=window&&window.performance;return e&&e.now?e.now.bind(e):function(){return(new Date).getTime()}}()},{}],15:[function(e,t){function i(e){var t=function(e){return e.trim()},i={};return r(e).map(t).filter(Boolean).forEach(function(e){var t=e.indexOf(":"),r=e.substr(0,t).trim(),n=e.substr(t+1).trim();i[r]=n}),i}function r(e){for(var t,i=[],r=0,n=";",o=/url\([^\)]+$/,a="";rs;s++){var c=r[s],h=(new t).parse(c);h.id&&0!==h.id.length||(h.id=i+o++),n[h.id]=h}return n}function o(){var e=Ne.querySelectorAll("scene instance_visual_scene")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return Pe[t.length>0?t:"visual_scene0"]}return null}function a(){var e=Ne.querySelectorAll("instance_kinematics_model")[0];if(e){var t=e.getAttribute("url").replace(/^#/,"");return De[t.length>0?t:"kinematics_model0"]}return null}function s(){Le=[],c(Be)}function c(e){var t=Te.getChildById(e.colladaId,!0),i=null;if(t&&t.keys){i={fps:60,hierarchy:[{node:t,keys:t.keys,sids:t.sids}],node:e,name:"animation_"+e.name,length:0},Le.push(i);for(var r=0,n=t.keys.length;n>r;r++)i.length=Math.max(i.length,t.keys[r].time)}else i={hierarchy:[{keys:[],sids:[]}]};for(var r=0,n=e.children.length;n>r;r++)for(var o=c(e.children[r]),a=0,s=o.hierarchy.length;s>a;a++)i.hierarchy.push({keys:[],sids:[]});return i}function h(){var e,t=1e6,i=-t,r=0;for(var n in ze){var o=ze[n];e=e||o.id;for(var a=0;a=0){var a=t.invBindMatrices[n];r.invBindMatrix=a,r.skinningMatrix=new THREE.Matrix4,r.skinningMatrix.multiplyMatrices(r.world,a),r.animatrix=new THREE.Matrix4,r.animatrix.copy(r.localworld),r.weights=[];for(var o=0;oo.limits.max||i1&&(C=new THREE.MultiMaterial(x)),void 0!==t?(m(L,t),L.morphTargets.length>0?(C.morphTargets=!0,C.skinning=!1):(C.morphTargets=!1,C.skinning=!0),T=new THREE.SkinnedMesh(L,C,!1),T.name="skin_"+ke.length,ke.push(T)):void 0!==i?(l(L,i),C.morphTargets=!0,T=new THREE.Mesh(L,C),T.name="morph_"+Ie.length,Ie.push(T)):T=L.isLineStrip===!0?new THREE.Line(L):new THREE.Mesh(L,C),o.add(T)}}for(r=0;rr;r++){var o,a=e.channels[r],s=a.fullSid,c=a.sampler,h=c.input,l=e.getTransformBySid(a.sid);if(a.arrIndices){o=[];for(var u=0,d=a.arrIndices.length;d>u;u++)o[u]=Ae(a.arrIndices[u])}else o=Se(a.member);if(l){-1===i.indexOf(s)&&i.push(s);for(var u=0,d=h.length;d>u;u++){var p=h[u],f=c.getData(l.type,u,o),m=w(t,p);if(!m){m=new ie(p);var v=M(t,p);t.splice(-1===v?t.length:v,0,m)}m.addTarget(s,l,o,f)}}else console.log('Could not find transform "'+a.sid+'" in node '+e.id)}for(var r=0;rr&&null===i;r++){var o=e[r];if(o.time===t)i=o;else if(o.time>t)break}return i}function M(e,t){for(var i=-1,r=0,n=e.length;n>r&&-1===i;r++){var o=e[r];o.time>=t&&(i=r)}return i}function _(e,t,i,r){var n=A(e,r,i?i-1:0),o=E(e,r,i+1);if(n&&o){var a,s=(t.time-n.time)/(o.time-n.time),c=n.getTarget(r),h=o.getTarget(r).data,l=c.data;if("matrix"===c.type)a=l;else if(l.length){a=[];for(var u=0;u=0?i:i+e.length;i>=0;i--){var r=e[i];if(r.hasTarget(t))return r}return null}function S(){this.id="",this.init_from=""}function T(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function C(){this.method=null,this.source=null,this.targets=null,this.weights=null}function L(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function R(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Group}function P(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function D(){this.sid="",this.type="",this.data=[],this.obj=null}function O(){this.url="",this.skeleton=[],this.instance_material=[]}function I(){this.symbol="",this.target=""}function k(){this.url="",this.instance_material=[]}function N(){this.id="",this.mesh=null}function B(e){this.geometry=e.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function F(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function V(){F.call(this),this.vcount=[]}function U(){F.call(this),this.vcount=1}function z(){F.call(this),this.vcount=3}function j(){this.source="",this.count=0,this.stride=0,this.params=[]}function G(){this.input={}}function H(){this.semantic="",this.offset=0,this.source="",this.set=0}function W(e){this.id=e,this.type=null}function q(){this.id="",this.name="",this.instance_effect=null}function X(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function Y(e,t){this.type=e,this.effect=t,this.material=null}function Q(e){this.effect=e,this.init_from=null,this.format=null}function K(e){this.effect=e,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function Z(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function J(){this.url=""}function $(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function ee(e){this.animation=e,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function te(e){this.id="",this.animation=e,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function ie(e){this.targets=[],this.time=e}function re(){this.id="",this.name="",this.technique=""}function ne(){this.url=""}function oe(){this.id="",this.name="",this.technique=""}function ae(){this.url=""}function se(){this.id="",this.name="",this.joints=[],this.links=[]}function ce(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this["static"]=!1,this.zeroPosition=0,this.middlePosition=0}function he(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function le(){this.joint="",this.transforms=[],this.links=[]}function ue(e){var t=e.getAttribute("id");return void 0!=Ve[t]?Ve[t]:(Ve[t]=new W(t).parse(e),Ve[t])}function de(e){for(var t=me(e),i=[],r=0,n=t.length;n>r;r++)i.push("true"===t[r]||"1"===t[r]?!0:!1);return i}function pe(e){for(var t=me(e),i=[],r=0,n=t.length;n>r;r++)i.push(parseFloat(t[r]));return i}function fe(e){for(var t=me(e),i=[],r=0,n=t.length;n>r;r++)i.push(parseInt(t[r],10));return i}function me(e){return e.length>0?ve(e).split(/\s+/):[]}function ve(e){return e.replace(/^\s+/,"").replace(/\s+$/,"")}function ge(e,t,i){return e.hasAttribute(t)?parseInt(e.getAttribute(t),10):i}function ye(e,t){var i=new THREE.ImageLoader;i.load(t,function(t){e.image=t,e.needsUpdate=!0})}function xe(e,t){e.doubleSided=!1;var i=t.querySelectorAll("extra double_sided")[0];i&&i&&1===parseInt(i.textContent,10)&&(e.doubleSided=!0)}function be(){if(Qe.convertUpAxis!==!0||Ze===Qe.upAxis)Je=null;else switch(Ze){case"X":Je="Y"===Qe.upAxis?"XtoY":"XtoZ";break;case"Y":Je="X"===Qe.upAxis?"YtoX":"YtoZ";break;case"Z":Je="X"===Qe.upAxis?"ZtoX":"ZtoY"}}function we(e,t){if(Qe.convertUpAxis===!0&&Ze!==Qe.upAxis)switch(Je){case"XtoY":var i=e[0];e[0]=t*e[1],e[1]=i;break;case"XtoZ":var i=e[2];e[2]=e[1],e[1]=e[0],e[0]=i;break;case"YtoX":var i=e[0];e[0]=e[1],e[1]=t*i;break;case"YtoZ":var i=e[1];e[1]=t*e[2],e[2]=i;break;case"ZtoX":var i=e[0];e[0]=e[1],e[1]=e[2],e[2]=i;break;case"ZtoY":var i=e[1];e[1]=e[2],e[2]=t*i}}function Me(e,t){if(Qe.convertUpAxis!==!0||Ze===Qe.upAxis)return t;switch(e){case"X":t="XtoY"===Je?-1*t:t;break;case"Y":t="YtoZ"===Je||"YtoX"===Je?-1*t:t;break;case"Z":t="ZtoY"===Je?-1*t:t}return t}function _e(e,t){var i=[e[t],e[t+1],e[t+2]];return we(i,-1),new THREE.Vector3(i[0],i[1],i[2])}function Ee(e){if(Qe.convertUpAxis){var t=[e[0],e[4],e[8]];we(t,-1),e[0]=t[0],e[4]=t[1],e[8]=t[2],t=[e[1],e[5],e[9]],we(t,-1),e[1]=t[0],e[5]=t[1],e[9]=t[2],t=[e[2],e[6],e[10]],we(t,-1),e[2]=t[0],e[6]=t[1],e[10]=t[2],t=[e[0],e[1],e[2]],we(t,-1),e[0]=t[0],e[1]=t[1],e[2]=t[2],t=[e[4],e[5],e[6]],we(t,-1),e[4]=t[0],e[5]=t[1],e[6]=t[2],t=[e[8],e[9],e[10]],we(t,-1),e[8]=t[0],e[9]=t[1],e[10]=t[2],t=[e[3],e[7],e[11]],we(t,-1),e[3]=t[0],e[7]=t[1],e[11]=t[2]}return(new THREE.Matrix4).set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}function Ae(e){if(e>-1&&3>e){var t=["X","Y","Z"],i={X:0,Y:1,Z:2};e=Se(t[e]),e=i[e]}return e}function Se(e){if(Qe.convertUpAxis)switch(e){case"X":switch(Je){case"XtoY":case"XtoZ":case"YtoX":e="Y";break;case"ZtoX":e="Z"}break;case"Y":switch(Je){case"XtoY":case"YtoX":case"ZtoX":e="X";break;case"XtoZ":case"YtoZ":case"ZtoY":e="Z"}break;case"Z":switch(Je){case"XtoZ":e="X";break;case"YtoZ":case"ZtoX":case"ZtoY":e="Y"}}return e}var Te,Ce,Le,Re,Pe,De,Oe,Ie,ke,Ne=null,Be=null,Fe=null,Ve={},Ue={},ze={},je={},Ge={},He={},We={},qe={},Xe={},Ye=THREE.SmoothShading,Qe={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},Ke=1,Ze="Y",Je=null;return S.prototype.parse=function(e){this.id=e.getAttribute("id");for(var t=0;tl;l++){for(var u={},d=0;d=0,c=a.indexOf("(")>=0;if(s)o=a.split("."),a=o.shift(),r=o.shift();else if(c){i=a.split("("),a=i.shift();for(var h=0;hp?m:p,n.semantic){case"TEXCOORD":f.push(n.set)}}for(var v=0;vi;i++)for(r=0;r_;_++)b.push(_e(s.data,x[_]*c))}else t.calcNormals=!0;if(!w&&(w={},n=this.vertices.input.TEXCOORD)){f.push(n.set),s=Ve[n.source],c=s.accessor.params.length;for(var _=0,E=x.length;E>_;_++)a=x[_]*c,void 0===w[n.set]&&(w[n.set]=[]),w[n.set].push(new THREE.Vector2(s.data[a],1-s.data[a+1]))}if(0===M.length&&(n=this.vertices.input.COLOR)){s=Ve[n.source],c=s.accessor.params.length;for(var _=0,E=x.length;E>_;_++)a=x[_]*c,M.push((new THREE.Color).setRGB(s.data[a],s.data[a+1],s.data[a+2]))}var A,S,T=null,C=[];if(3===d)C.push(new THREE.Face3(x[0],x[1],x[2],b,M.length?M:new THREE.Color));else if(4===d)C.push(new THREE.Face3(x[0],x[1],x[3],b.length?[b[0].clone(),b[1].clone(),b[3].clone()]:[],M.length?[M[0],M[1],M[3]]:new THREE.Color)),C.push(new THREE.Face3(x[1],x[2],x[3],b.length?[b[1].clone(),b[2].clone(),b[3].clone()]:[],M.length?[M[1],M[2],M[3]]:new THREE.Color));else if(d>4&&Qe.subdivideFaces){var L=M.length?M:new THREE.Color;for(r=1;d-1>r;)C.push(new THREE.Face3(x[0],x[r],x[r+1],b.length?[b[0].clone(),b[r++].clone(),b[r].clone()]:[],L))}if(C.length)for(var _=0,E=C.length;E>_;_++)for(T=C[_],T.daeMaterial=e.material,t.faces.push(T),r=0;r4?[A[0],A[_+1],A[_+2]]:4===d?0===_?[A[0],A[1],A[3]]:[A[1].clone(),A[2],A[3].clone()]:[A[0],A[1],A[2]],void 0===t.faceVertexUvs[r]&&(t.faceVertexUvs[r]=[]),t.faceVertexUvs[r].push(S);else console.log("dropped face with vcount "+d+" for geometry with id: "+t.id);y+=p*d}},F.prototype.setVertices=function(e){for(var t=0;t0&&(this[i.nodeName]=parseFloat(n[0].textContent))}}return this.create(),this},Y.prototype.create=function(){var e={},t=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var i=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);i>0&&(t=!0,e.transparent=!0,e.opacity=1-i)}var r={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var n in this)switch(n){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var o=this[n];if(o instanceof X)if(o.isTexture()){var a=o.texture,s=this.effect.sampler[a];if(void 0!==s&&void 0!==s.source){var c=this.effect.surface[s.source];if(void 0!==c){var h=Ue[c.init_from];if(h){var l,u=Oe+h.init_from,d=THREE.Loader.Handlers.get(u);null!==d?l=d.load(u):(l=new THREE.Texture,ye(l,u)),l.wrapS=o.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,l.wrapT=o.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,l.offset.x=o.texOpts.offsetU,l.offset.y=o.texOpts.offsetV,l.repeat.x=o.texOpts.repeatU,l.repeat.y=o.texOpts.repeatV,e[r[n]]=l,"emission"===n&&(e.emissive=16777215)}}}}else"diffuse"!==n&&t||("emission"===n?e.emissive=o.color.getHex():e[n]=o.color.getHex());break;case"shininess":e[n]=this[n];break;case"reflectivity":e[n]=this[n],e[n]>0&&(e.envMap=Qe.defaultEnvMap),e.combine=THREE.MixOperation;break;case"index_of_refraction":e.refractionRatio=this[n],1!==this[n]&&(e.envMap=Qe.defaultEnvMap);break;case"transparency":}switch(e.shading=Ye,e.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,void 0!==e.diffuse&&(e.color=e.diffuse,delete e.diffuse),this.type){case"constant":void 0!=e.emissive&&(e.color=e.emissive),this.material=new THREE.MeshBasicMaterial(e);break;case"phong":case"blinn":this.material=new THREE.MeshPhongMaterial(e);break;case"lambert":default:this.material=new THREE.MeshLambertMaterial(e)}return this.material},Q.prototype.parse=function(e){for(var t=0;t=0,n=i.indexOf("(")>=0;if(r)t=i.split("."),this.sid=t.shift(),this.member=t.shift();else if(n){var o=i.split("(");this.sid=o.shift();for(var a=0;a1){r=[],t*=this.strideOut;for(var n=0;ni;i++){var n,o=this.targets[i],a=e.getTarget(o.sid);if("matrix"!==o.transform.type&&a){var s=(t-this.time)/(e.time-this.time),c=a.data,h=o.data;if(0>s&&(s=0),s>1&&(s=1),h.length){n=[];for(var l=0;l=this.limits.max&&(this["static"]=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},he.prototype.parse=function(e){this.sid=e.getAttribute("sid"),this.name=e.getAttribute("name"),this.transforms=[],this.attachments=[];for(var t=0;t=0?a.substring(0,s):a;c=c.toLowerCase();var h=s>=0?a.substring(s+1):"";if(h=h.trim(),"newmtl"===c)i={name:h},n[h]=i;else if(i)if("ka"===c||"kd"===c||"ks"===c){var l=h.split(r,3);i[c]=[parseFloat(l[0]),parseFloat(l[1]),parseFloat(l[2])]}else i[c]=h}}var u=new THREE.MTLLoader.MaterialCreator(this.baseUrl,this.materialOptions);return u.setCrossOrigin(this.crossOrigin),u.setManager(this.manager),u.setMaterials(n),u}},THREE.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:THREE.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:THREE.RepeatWrapping},THREE.MTLLoader.MaterialCreator.prototype={constructor:THREE.MTLLoader.MaterialCreator,setCrossOrigin:function(e){this.crossOrigin=e},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var i in e){var r=e[i],n={};t[i]=n;for(var o in r){var a=!0,s=r[o],c=o.toLowerCase();switch(c){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(s=[s[0]/255,s[1]/255,s[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===s[0]&&0===s[1]&&0===s[1]&&(a=!1)}a&&(n[c]=s)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){var t=this.materialsInfo[e],i={name:e,side:this.side};for(var r in t){var n=t[r];if(""!==n)switch(r.toLowerCase()){case"kd":i.color=(new THREE.Color).fromArray(n);break;case"ks":i.specular=(new THREE.Color).fromArray(n);break;case"map_kd":i.map=this.loadTexture(this.baseUrl+n),i.map.wrapS=this.wrap,i.map.wrapT=this.wrap;break;case"ns":i.shininess=parseFloat(n);break;case"d":1>n&&(i.opacity=n,i.transparent=!0);break;case"Tr":n>0&&(i.opacity=1-n,i.transparent=!0);break;case"map_bump":case"bump":if(i.bumpMap)break;i.bumpMap=this.loadTexture(this.baseUrl+n),i.bumpMap.wrapS=this.wrap,i.bumpMap.wrapT=this.wrap}}return this.materials[e]=new THREE.MeshPhongMaterial(i),this.materials[e]},loadTexture:function(e,t,i,r,n){var o,a=THREE.Loader.Handlers.get(e),s=void 0!==this.manager?this.manager:THREE.DefaultLoadingManager;return null===a&&(a=new THREE.TextureLoader(s)),a.setCrossOrigin&&a.setCrossOrigin(this.crossOrigin),o=a.load(e,i,r,n),void 0!==t&&(o.mapping=t),o}},THREE.EventDispatcher.prototype.apply(THREE.MTLLoader.prototype)},{}],20:[function(){THREE.OBJLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.materials=null},THREE.OBJLoader.prototype={constructor:THREE.OBJLoader,load:function(e,t,i,r){var n=this,o=new THREE.XHRLoader(n.manager);o.setPath(this.path),o.load(e,function(e){t(n.parse(e))},i,r)},setPath:function(e){this.path=e},setMaterials:function(e){this.materials=e},parse:function(e){function t(e){var t={vertices:[],normals:[],uvs:[]},i={name:"",smooth:!0};h={name:e,geometry:t,material:i},l.push(h)}function i(e){var t=parseInt(e);return 3*(t>=0?t-1:t+d.length/3)}function r(e){var t=parseInt(e);return 3*(t>=0?t-1:t+p.length/3)}function n(e){var t=parseInt(e);return 2*(t>=0?t-1:t+f.length/2)}function o(e,t,i){h.geometry.vertices.push(d[e],d[e+1],d[e+2],d[t],d[t+1],d[t+2],d[i],d[i+1],d[i+2])}function a(e,t,i){h.geometry.normals.push(p[e],p[e+1],p[e+2],p[t],p[t+1],p[t+2],p[i],p[i+1],p[i+2])}function s(e,t,i){h.geometry.uvs.push(f[e],f[e+1],f[t],f[t+1],f[i],f[i+1])}function c(e,t,c,h,l,u,d,p,f,m,v,g){var y,x=i(e),b=i(t),w=i(c);void 0===h?o(x,b,w):(y=i(h),o(x,b,y),o(b,w,y)),void 0!==l&&(x=n(l),b=n(u),w=n(d),void 0===h?s(x,b,w):(y=n(p),s(x,b,y),s(b,w,y))),void 0!==f&&(x=r(f),b=r(m),w=r(v),void 0===h?a(x,b,w):(y=r(g),a(x,b,y),a(b,w,y)))}console.time("OBJLoader");var h,l=[],u=!1,d=[],p=[],f=[];t("");for(var m=/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,v=/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,g=/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,y=/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,x=/^f\s+((-?\d+)\/(-?\d+))\s+((-?\d+)\/(-?\d+))\s+((-?\d+)\/(-?\d+))(?:\s+((-?\d+)\/(-?\d+)))?/,b=/^f\s+((-?\d+)\/(-?\d+)\/(-?\d+))\s+((-?\d+)\/(-?\d+)\/(-?\d+))\s+((-?\d+)\/(-?\d+)\/(-?\d+))(?:\s+((-?\d+)\/(-?\d+)\/(-?\d+)))?/,w=/^f\s+((-?\d+)\/\/(-?\d+))\s+((-?\d+)\/\/(-?\d+))\s+((-?\d+)\/\/(-?\d+))(?:\s+((-?\d+)\/\/(-?\d+)))?/,M=/^[og]\s*(.+)?/,_=/^s\s+(\d+|on|off)/,E=e.split("\n"),A=0;AA;A++){h=l[A];var P=h.geometry,D=new THREE.BufferGeometry;D.addAttribute("position",new THREE.BufferAttribute(new Float32Array(P.vertices),3)),P.normals.length>0?D.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(P.normals),3)):D.computeVertexNormals(),P.uvs.length>0&&D.addAttribute("uv",new THREE.BufferAttribute(new Float32Array(P.uvs),2));var O;null!==this.materials&&(O=this.materials.create(h.material.name)),O||(O=new THREE.MeshPhongMaterial,O.name=h.material.name),O.shading=h.material.smooth?THREE.SmoothShading:THREE.FlatShading;var I=new THREE.Mesh(D,O);I.name=h.name,L.add(I)}return console.timeEnd("OBJLoader"),L}}},{}],21:[function(e,i,r){var n={REVISION:"75"};"function"==typeof t&&t.amd?t("three",n):"undefined"!=typeof r&&"undefined"!=typeof i&&(i.exports=n),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Math.sign&&(Math.sign=function(e){return 0>e?-1:e>0?1:+e}),void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}}),void 0===Object.assign&&Object.defineProperty(Object,"assign",{writable:!0,configurable:!0,value:function(e){"use strict";if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),i=1,r=arguments.length;i!==r;++i){var n=arguments[i];if(void 0!==n&&null!==n){n=Object(n);for(var o=Object.keys(n),a=0,s=o.length;a!==s;++a){var c=o[a],h=Object.getOwnPropertyDescriptor(n,c);void 0!==h&&h.enumerable&&(t[c]=n[c])}}}return t}}),n.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2},n.CullFaceNone=0,n.CullFaceBack=1,n.CullFaceFront=2,n.CullFaceFrontBack=3,n.FrontFaceDirectionCW=0,n.FrontFaceDirectionCCW=1,n.BasicShadowMap=0,n.PCFShadowMap=1,n.PCFSoftShadowMap=2,n.FrontSide=0,n.BackSide=1,n.DoubleSide=2,n.FlatShading=1,n.SmoothShading=2,n.NoColors=0,n.FaceColors=1,n.VertexColors=2,n.NoBlending=0,n.NormalBlending=1,n.AdditiveBlending=2,n.SubtractiveBlending=3,n.MultiplyBlending=4,n.CustomBlending=5,n.AddEquation=100,n.SubtractEquation=101,n.ReverseSubtractEquation=102,n.MinEquation=103,n.MaxEquation=104,n.ZeroFactor=200,n.OneFactor=201,n.SrcColorFactor=202,n.OneMinusSrcColorFactor=203,n.SrcAlphaFactor=204,n.OneMinusSrcAlphaFactor=205,n.DstAlphaFactor=206,n.OneMinusDstAlphaFactor=207,n.DstColorFactor=208,n.OneMinusDstColorFactor=209,n.SrcAlphaSaturateFactor=210,n.NeverDepth=0,n.AlwaysDepth=1,n.LessDepth=2,n.LessEqualDepth=3,n.EqualDepth=4,n.GreaterEqualDepth=5,n.GreaterDepth=6,n.NotEqualDepth=7,n.MultiplyOperation=0,n.MixOperation=1,n.AddOperation=2,n.NoToneMapping=0,n.LinearToneMapping=1,n.ReinhardToneMapping=2,n.Uncharted2ToneMapping=3,n.CineonToneMapping=4,n.UVMapping=300,n.CubeReflectionMapping=301,n.CubeRefractionMapping=302,n.EquirectangularReflectionMapping=303,n.EquirectangularRefractionMapping=304,n.SphericalReflectionMapping=305,n.CubeUVReflectionMapping=306,n.CubeUVRefractionMapping=307,n.RepeatWrapping=1e3,n.ClampToEdgeWrapping=1001,n.MirroredRepeatWrapping=1002,n.NearestFilter=1003,n.NearestMipMapNearestFilter=1004,n.NearestMipMapLinearFilter=1005,n.LinearFilter=1006,n.LinearMipMapNearestFilter=1007,n.LinearMipMapLinearFilter=1008,n.UnsignedByteType=1009,n.ByteType=1010,n.ShortType=1011,n.UnsignedShortType=1012,n.IntType=1013,n.UnsignedIntType=1014,n.FloatType=1015,n.HalfFloatType=1025,n.UnsignedShort4444Type=1016,n.UnsignedShort5551Type=1017,n.UnsignedShort565Type=1018,n.AlphaFormat=1019,n.RGBFormat=1020,n.RGBAFormat=1021,n.LuminanceFormat=1022,n.LuminanceAlphaFormat=1023,n.RGBEFormat=n.RGBAFormat,n.RGB_S3TC_DXT1_Format=2001,n.RGBA_S3TC_DXT1_Format=2002,n.RGBA_S3TC_DXT3_Format=2003,n.RGBA_S3TC_DXT5_Format=2004,n.RGB_PVRTC_4BPPV1_Format=2100,n.RGB_PVRTC_2BPPV1_Format=2101,n.RGBA_PVRTC_4BPPV1_Format=2102,n.RGBA_PVRTC_2BPPV1_Format=2103,n.RGB_ETC1_Format=2151,n.LoopOnce=2200,n.LoopRepeat=2201,n.LoopPingPong=2202,n.InterpolateDiscrete=2300,n.InterpolateLinear=2301,n.InterpolateSmooth=2302,n.ZeroCurvatureEnding=2400,n.ZeroSlopeEnding=2401,n.WrapAroundEnding=2402,n.TrianglesDrawMode=0,n.TriangleStripDrawMode=1,n.TriangleFanDrawMode=2,n.LinearEncoding=3e3,n.sRGBEncoding=3001,n.GammaEncoding=3007,n.RGBEEncoding=3002,n.LogLuvEncoding=3003,n.RGBM7Encoding=3004,n.RGBM16Encoding=3005,n.RGBDEncoding=3006,n.Color=function(e){return 3===arguments.length?this.fromArray(arguments):this.set(e)},n.Color.prototype={constructor:n.Color,r:1,g:1,b:1,set:function(e){return e instanceof n.Color?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){this.r=e,this.g=e,this.b=e},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(){function e(e,t,i){return 0>i&&(i+=1),i>1&&(i-=1),1/6>i?e+6*(t-e)*i:.5>i?t:2/3>i?e+6*(t-e)*(2/3-i):e}return function(t,i,r){if(t=n.Math.euclideanModulo(t,1),i=n.Math.clamp(i,0,1),r=n.Math.clamp(r,0,1),0===i)this.r=this.g=this.b=r;else{var o=.5>=r?r*(1+i):r+i-r*i,a=2*r-o;this.r=e(a,o,t+1/3),this.g=e(a,o,t),this.b=e(a,o,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var s=parseFloat(r[1])/360,c=parseInt(r[2],10)/100,h=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(s,c,h)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var l=i[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}if(e&&e.length>0){var l=n.ColorKeywords[e];void 0!==l?this.setHex(l):console.warn("THREE.Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(){var e=this.r,t=this.g,i=this.b;return this.r=e*e,this.g=t*t,this.b=i*i,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(e){var t,i,r=e||{h:0,s:0,l:0},n=this.r,o=this.g,a=this.b,s=Math.max(n,o,a),c=Math.min(n,o,a),h=(c+s)/2;if(c===s)t=0,i=0;else{var l=s-c;switch(i=.5>=h?l/(s+c):l/(2-s-c),s){case n:t=(o-a)/l+(a>o?6:0);break;case o:t=(a-n)/l+2;break;case a:t=(n-o)/l+4}t/=6}return r.h=t,r.s=i,r.l=h,r},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(e,t,i){var r=this.getHSL();return r.h+=e,r.s+=t,r.l+=i,this.setHSL(r.h,r.s,r.l),this},add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e,t){return void 0===t&&(t=0),this.r=e[t],this.g=e[t+1],this.b=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}},n.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},n.Quaternion=function(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1},n.Quaternion.prototype={constructor:n.Quaternion,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get w(){return this._w},set w(e){this._w=e,this.onChangeCallback()},set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(e instanceof n.Euler==!1)throw new Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var i=Math.cos(e._x/2),r=Math.cos(e._y/2),o=Math.cos(e._z/2),a=Math.sin(e._x/2),s=Math.sin(e._y/2),c=Math.sin(e._z/2),h=e.order;return"XYZ"===h?(this._x=a*r*o+i*s*c,this._y=i*s*o-a*r*c,this._z=i*r*c+a*s*o,this._w=i*r*o-a*s*c):"YXZ"===h?(this._x=a*r*o+i*s*c,this._y=i*s*o-a*r*c,this._z=i*r*c-a*s*o,this._w=i*r*o+a*s*c):"ZXY"===h?(this._x=a*r*o-i*s*c,this._y=i*s*o+a*r*c,this._z=i*r*c+a*s*o,this._w=i*r*o-a*s*c):"ZYX"===h?(this._x=a*r*o-i*s*c,this._y=i*s*o+a*r*c,this._z=i*r*c-a*s*o,this._w=i*r*o+a*s*c):"YZX"===h?(this._x=a*r*o+i*s*c,this._y=i*s*o+a*r*c,this._z=i*r*c-a*s*o,this._w=i*r*o-a*s*c):"XZY"===h&&(this._x=a*r*o-i*s*c,this._y=i*s*o-a*r*c,this._z=i*r*c+a*s*o,this._w=i*r*o+a*s*c),t!==!1&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,i=e.elements,r=i[0],n=i[4],o=i[8],a=i[1],s=i[5],c=i[9],h=i[2],l=i[6],u=i[10],d=r+s+u;return d>0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(l-c)*t,this._y=(o-h)*t,this._z=(a-n)*t):r>s&&r>u?(t=2*Math.sqrt(1+r-s-u),this._w=(l-c)/t,this._x=.25*t,this._y=(n+a)/t,this._z=(o+h)/t):s>u?(t=2*Math.sqrt(1+s-r-u),this._w=(o-h)/t,this._x=(n+a)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+u-r-s),this._w=(a-n)/t,this._x=(o+h)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t,i=1e-6;return function(r,o){return void 0===e&&(e=new n.Vector3),t=r.dot(o)+1,i>t?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,o),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z,o=e._w,a=t._x,s=t._y,c=t._z,h=t._w;return this._x=i*h+o*a+r*c-n*s,this._y=r*h+o*s+n*a-i*c,this._z=n*h+o*c+i*s-r*a,this._w=o*h-i*a-r*s-n*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+n*e._z;if(0>a?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=n,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,a),h=Math.sin((1-t)*c)/s,l=Math.sin(t*c)/s;return this._w=o*h+this._w*l,this._x=i*h+this._x*l,this._y=r*h+this._y*l,this._z=n*h+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},Object.assign(n.Quaternion,{slerp:function(e,t,i,r){return i.copy(e).slerp(t,r)},slerpFlat:function(e,t,i,r,n,o,a){var s=i[r+0],c=i[r+1],h=i[r+2],l=i[r+3],u=n[o+0],d=n[o+1],p=n[o+2],f=n[o+3];if(l!==f||s!==u||c!==d||h!==p){var m=1-a,v=s*u+c*d+h*p+l*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,a=Math.sin(a*b)/x}var w=a*g;if(s=s*m+u*w,c=c*m+d*w,h=h*m+p*w,l=l*m+f*w,m===1-a){var M=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=M,c*=M,h*=M,l*=M}}e[t]=s,e[t+1]=c,e[t+2]=h,e[t+3]=l}}),n.Vector2=function(e,t){this.x=e||0,this.y=t||0},n.Vector2.prototype={constructor:n.Vector2,get width(){return this.x},set width(e){this.x=e},get height(){return this.y},set height(e){this.y=e},set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e):(this.x=0,this.y=0),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)), this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new n.Vector2,t=new n.Vector2),e.set(i,i),t.set(r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,i))/i),this},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var e=Math.atan2(this.y,this.x);return 0>e&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e),this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this},rotateAround:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,o=this.y-e.y;return this.x=n*i-o*r+e.x,this.y=n*r+o*i+e.y,this}},n.Vector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},n.Vector3.prototype={constructor:n.Vector3,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e;return function(t){return t instanceof n.Euler==!1&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===e&&(e=new n.Quaternion),this.applyQuaternion(e.setFromEuler(t)),this}}(),applyAxisAngle:function(){var e;return function(t,i){return void 0===e&&(e=new n.Quaternion),this.applyQuaternion(e.setFromAxisAngle(t,i)),this}}(),applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r+n[12],this.y=n[1]*t+n[5]*i+n[9]*r+n[13],this.z=n[2]*t+n[6]*i+n[10]*r+n[14],this},applyProjection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements,o=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,o=e.y,a=e.z,s=e.w,c=s*t+o*r-a*i,h=s*i+a*t-n*r,l=s*r+n*i-o*t,u=-n*t-o*i-a*r;return this.x=c*s+u*-n+h*-a-l*-o,this.y=h*s+u*-o+l*-n-c*-a,this.z=l*s+u*-a+c*-o-h*-n,this},project:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyProjection(e)}}(),unproject:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyProjection(e)}}(),transformDirection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize(),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new n.Vector3,t=new n.Vector3),e.set(i,i,i),t.set(r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,i))/i),this},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e),this},cross:function(e,t){if(void 0!==t)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var i=this.x,r=this.y,n=this.z;return this.x=r*e.z-n*e.y,this.y=n*e.x-i*e.z,this.z=i*e.y-r*e.x,this},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,o=t.x,a=t.y,s=t.z;return this.x=r*s-n*a,this.y=n*o-i*s,this.z=i*a-r*o,this},projectOnVector:function(){var e,t;return function(i){return void 0===e&&(e=new n.Vector3),e.copy(i).normalize(),t=this.dot(e),this.copy(e).multiplyScalar(t)}}(),projectOnPlane:function(){var e;return function(t){return void 0===e&&(e=new n.Vector3),e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e;return function(t){return void 0===e&&(e=new n.Vector3),this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(n.Math.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromMatrixPosition:function(e){return this.setFromMatrixColumn(e,3)},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this},setFromMatrixColumn:function(e,t){return"number"==typeof e&&(console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index )."),e=arguments[1],t=arguments[0]),this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this}},n.Vector4=function(e,t,i,r){this.x=e||0,this.y=t||0,this.z=i||0,this.w=void 0!==r?r:1},n.Vector4.prototype={constructor:n.Vector4,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e,this.w*=e):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*n,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*n,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*n,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return 1e-4>t?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,i,r,n,o=.01,a=.1,s=e.elements,c=s[0],h=s[4],l=s[8],u=s[1],d=s[5],p=s[9],f=s[2],m=s[6],v=s[10];if(Math.abs(h-u)y&&g>x?o>g?(i=0,r=.707106781,n=.707106781):(i=Math.sqrt(g),r=b/i,n=w/i):y>x?o>y?(i=.707106781,r=0,n=.707106781):(r=Math.sqrt(y),i=b/r,n=M/r):o>x?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(x),i=w/n,r=M/n),this.set(i,r,n,t),this}var _=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-h)*(u-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(l-f)/_,this.z=(u-h)/_,this.w=Math.acos((c+d+v-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new n.Vector4,t=new n.Vector4),e.set(i,i,i,i),t.set(r,r,r,r),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},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(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e),this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this.w=e.array[t+3],this}},n.Euler=function(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._order=r||n.Euler.DefaultOrder},n.Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],n.Euler.DefaultOrder="XYZ",n.Euler.prototype={constructor:n.Euler,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get order(){return this._order},set order(e){this._order=e,this.onChangeCallback()},set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){var r=n.Math.clamp,o=e.elements,a=o[0],s=o[4],c=o[8],h=o[1],l=o[5],u=o[9],d=o[2],p=o[6],f=o[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(r(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(p,l),this._z=0)):"YXZ"===t?(this._x=Math.asin(-r(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(c,f),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-d,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===t?(this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-s,l))):"YZX"===t?(this._z=Math.asin(r(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(c,f))):"XZY"===t?(this._z=Math.asin(-r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(p,l),this._y=Math.atan2(c,a)):(this._x=Math.atan2(-u,f),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,i!==!1&&this.onChangeCallback(),this},setFromQuaternion:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,i,r),this}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new n.Quaternion;return function(t){e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new n.Vector3(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},n.Line3=function(e,t){this.start=void 0!==e?e:new n.Vector3,this.end=void 0!==t?t:new n.Vector3},n.Line3.prototype={constructor:n.Line3,set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},center:function(e){var t=e||new n.Vector3;return t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){var t=e||new n.Vector3;return t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){var i=t||new n.Vector3;return this.delta(i).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new n.Vector3,t=new n.Vector3;return function(i,r){e.subVectors(i,this.start),t.subVectors(this.end,this.start);var o=t.dot(t),a=t.dot(e),s=a/o;return r&&(s=n.Math.clamp(s,0,1)),s}}(),closestPointToPoint:function(e,t,i){var r=this.closestPointToPointParameter(e,t),o=i||new n.Vector3;return this.delta(o).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}},n.Box2=function(e,t){this.min=void 0!==e?e:new n.Vector2(+(1/0),+(1/0)),this.max=void 0!==t?t:new n.Vector2(-(1/0),-(1/0))},n.Box2.prototype={constructor:n.Box2,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;i>t;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new n.Vector2;return function(t,i){var r=e.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=+(1/0),this.max.x=this.max.y=-(1/0),this},isEmpty:function(){return this.max.xthis.max.x||e.ythis.max.y?!1:!0},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y?!0:!1},getParameter:function(e,t){var i=t||new n.Vector2;return i.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return e.max.xthis.max.x||e.max.ythis.max.y?!1:!0},clampPoint:function(e,t){var i=t||new n.Vector2;return i.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new n.Vector2;return function(t){var i=e.copy(t).clamp(this.min,this.max);return i.sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},n.Box3=function(e,t){this.min=void 0!==e?e:new n.Vector3(+(1/0),+(1/0),+(1/0)),this.max=void 0!==t?t:new n.Vector3(-(1/0),-(1/0),-(1/0))},n.Box3.prototype={constructor:n.Box3,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){this.makeEmpty();for(var t=+(1/0),i=+(1/0),r=+(1/0),n=-(1/0),o=-(1/0),a=-(1/0),s=0,c=e.length;c>s;s+=3){var h=e[s],l=e[s+1],u=e[s+2];t>h&&(t=h),i>l&&(i=l),r>u&&(r=u),h>n&&(n=h),l>o&&(o=l),u>a&&(a=u)}this.min.set(t,i,r),this.max.set(n,o,a)},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;i>t;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new n.Vector3;return function(t,i){var r=e.copy(i).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}}(),setFromObject:function(){var e;return function(t){void 0===e&&(e=new n.Box3);var i=this;return this.makeEmpty(),t.updateMatrixWorld(!0),t.traverse(function(t){var r=t.geometry;void 0!==r&&(null===r.boundingBox&&r.computeBoundingBox(),r.boundingBox.isEmpty()===!1&&(e.copy(r.boundingBox),e.applyMatrix4(t.matrixWorld),i.union(e)))}),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=+(1/0),this.max.x=this.max.y=this.max.z=-(1/0),this},isEmpty:function(){return this.max.xthis.max.x||e.ythis.max.y||e.zthis.max.z?!1:!0},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z?!0:!1},getParameter:function(e,t){var i=t||new n.Vector3;return i.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z?!1:!0},intersectsSphere:function(){var e;return function(t){return void 0===e&&(e=new n.Vector3),this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=e.constant&&i>=e.constant},clampPoint:function(e,t){var i=t||new n.Vector3;return i.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new n.Vector3;return function(t){var i=e.copy(t).clamp(this.min,this.max);return i.sub(t).length()}}(),getBoundingSphere:function(){var e=new n.Vector3;return function(t){var i=t||new n.Sphere;return i.center=this.center(),i.radius=.5*this.size(e).length(),i}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3,new n.Vector3];return function(t){return e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.makeEmpty(),this.setFromPoints(e),this}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},n.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")},n.Matrix3.prototype={constructor:n.Matrix3,set:function(e,t,i,r,n,o,a,s,c){var h=this.elements;return h[0]=e,h[1]=r,h[2]=a,h[3]=t,h[4]=n,h[5]=s,h[6]=i,h[7]=o,h[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=e.elements;return this.set(t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]),this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToVector3Array:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length);for(var o=0,a=i;r>o;o+=3,a+=3)e.fromArray(t,a),e.applyMatrix3(this),e.toArray(t,a);return t}}(),applyToBuffer:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length/t.itemSize);for(var o=0,a=i;r>o;o++,a++)e.x=t.getX(a),e.y=t.getY(a),e.z=t.getZ(a),e.applyMatrix3(this),t.setXYZ(e.x,e.y,e.z);return t}}(),multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],a=e[5],s=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-i*n*h+i*a*s+r*n*c-r*o*s},getInverse:function(e,t){e instanceof n.Matrix4&&console.warn("THREE.Matrix3.getInverse no longer takes a Matrix4 argument.");var i=e.elements,r=this.elements,o=i[0],a=i[1],s=i[2],c=i[3],h=i[4],l=i[5],u=i[6],d=i[7],p=i[8],f=p*h-l*d,m=l*u-p*c,v=d*c-h*u,g=o*f+a*m+s*v;if(0===g){var y="THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0";if(t)throw new Error(y);return console.warn(y),this.identity()}return r[0]=f,r[1]=s*d-p*a,r[2]=l*a-s*h,r[3]=m,r[4]=p*o-s*u,r[5]=s*c-l*o,r[6]=v,r[7]=a*u-d*o,r[8]=h*o-a*c,this.multiplyScalar(1/g)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},flattenToArrayOffset:function(e,t){var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e},getNormalMatrix:function(e){return this.setFromMatrix4(e).getInverse(this).transpose()},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},fromArray:function(e){return this.elements.set(e),this},toArray:function(){var e=this.elements;return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]]}},n.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")},n.Matrix4.prototype={constructor:n.Matrix4,set:function(e,t,i,r,n,o,a,s,c,h,l,u,d,p,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=n,v[5]=o,v[9]=a,v[13]=s,v[2]=c,v[6]=h,v[10]=l,v[14]=u,v[3]=d,v[7]=p,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new n.Matrix4).fromArray(this.elements)},copy:function(e){return this.elements.set(e.elements),this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:function(){var e;return function(t){void 0===e&&(e=new n.Vector3);var i=this.elements,r=t.elements,o=1/e.setFromMatrixColumn(t,0).length(),a=1/e.setFromMatrixColumn(t,1).length(),s=1/e.setFromMatrixColumn(t,2).length();return i[0]=r[0]*o,i[1]=r[1]*o,i[2]=r[2]*o,i[4]=r[4]*a,i[5]=r[5]*a,i[6]=r[6]*a,i[8]=r[8]*s,i[9]=r[9]*s,i[10]=r[10]*s,this}}(),makeRotationFromEuler:function(e){e instanceof n.Euler==!1&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,i=e.x,r=e.y,o=e.z,a=Math.cos(i),s=Math.sin(i),c=Math.cos(r),h=Math.sin(r),l=Math.cos(o),u=Math.sin(o);if("XYZ"===e.order){var d=a*l,p=a*u,f=s*l,m=s*u;t[0]=c*l,t[4]=-c*u,t[8]=h,t[1]=p+f*h,t[5]=d-m*h,t[9]=-s*c,t[2]=m-d*h,t[6]=f+p*h,t[10]=a*c}else if("YXZ"===e.order){var v=c*l,g=c*u,y=h*l,x=h*u;t[0]=v+x*s,t[4]=y*s-g,t[8]=a*h,t[1]=a*u,t[5]=a*l,t[9]=-s,t[2]=g*s-y,t[6]=x+v*s,t[10]=a*c}else if("ZXY"===e.order){var v=c*l,g=c*u,y=h*l,x=h*u;t[0]=v-x*s,t[4]=-a*u,t[8]=y+g*s,t[1]=g+y*s,t[5]=a*l,t[9]=x-v*s,t[2]=-a*h,t[6]=s,t[10]=a*c}else if("ZYX"===e.order){var d=a*l,p=a*u,f=s*l,m=s*u;t[0]=c*l,t[4]=f*h-p,t[8]=d*h+m,t[1]=c*u,t[5]=m*h+d,t[9]=p*h-f,t[2]=-h,t[6]=s*c,t[10]=a*c}else if("YZX"===e.order){var b=a*c,w=a*h,M=s*c,_=s*h;t[0]=c*l,t[4]=_-b*u,t[8]=M*u+w,t[1]=u,t[5]=a*l,t[9]=-s*l,t[2]=-h*l,t[6]=w*u+M,t[10]=b-_*u}else if("XZY"===e.order){var b=a*c,w=a*h,M=s*c,_=s*h;t[0]=c*l,t[4]=-u,t[8]=h*l,t[1]=b*u+_,t[5]=a*l,t[9]=w*u-M,t[2]=M*u-w,t[6]=s*l,t[10]=_*u+b}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,i=e.x,r=e.y,n=e.z,o=e.w,a=i+i,s=r+r,c=n+n,h=i*a,l=i*s,u=i*c,d=r*s,p=r*c,f=n*c,m=o*a,v=o*s,g=o*c;return t[0]=1-(d+f),t[4]=l-g,t[8]=u+v,t[1]=l+g,t[5]=1-(h+f), t[9]=p-m,t[2]=u-v,t[6]=p+m,t[10]=1-(h+d),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:function(){var e,t,i;return function(r,o,a){void 0===e&&(e=new n.Vector3),void 0===t&&(t=new n.Vector3),void 0===i&&(i=new n.Vector3);var s=this.elements;return i.subVectors(r,o).normalize(),0===i.lengthSq()&&(i.z=1),e.crossVectors(a,i).normalize(),0===e.lengthSq()&&(i.x+=1e-4,e.crossVectors(a,i).normalize()),t.crossVectors(i,e),s[0]=e.x,s[4]=t.x,s[8]=i.x,s[1]=e.y,s[5]=t.y,s[9]=i.y,s[2]=e.z,s[6]=t.z,s[10]=i.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements,n=this.elements,o=i[0],a=i[4],s=i[8],c=i[12],h=i[1],l=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],v=i[14],g=i[3],y=i[7],x=i[11],b=i[15],w=r[0],M=r[4],_=r[8],E=r[12],A=r[1],S=r[5],T=r[9],C=r[13],L=r[2],R=r[6],P=r[10],D=r[14],O=r[3],I=r[7],k=r[11],N=r[15];return n[0]=o*w+a*A+s*L+c*O,n[4]=o*M+a*S+s*R+c*I,n[8]=o*_+a*T+s*P+c*k,n[12]=o*E+a*C+s*D+c*N,n[1]=h*w+l*A+u*L+d*O,n[5]=h*M+l*S+u*R+d*I,n[9]=h*_+l*T+u*P+d*k,n[13]=h*E+l*C+u*D+d*N,n[2]=p*w+f*A+m*L+v*O,n[6]=p*M+f*S+m*R+v*I,n[10]=p*_+f*T+m*P+v*k,n[14]=p*E+f*C+m*D+v*N,n[3]=g*w+y*A+x*L+b*O,n[7]=g*M+y*S+x*R+b*I,n[11]=g*_+y*T+x*P+b*k,n[15]=g*E+y*C+x*D+b*N,this},multiplyToArray:function(e,t,i){var r=this.elements;return this.multiplyMatrices(e,t),i[0]=r[0],i[1]=r[1],i[2]=r[2],i[3]=r[3],i[4]=r[4],i[5]=r[5],i[6]=r[6],i[7]=r[7],i[8]=r[8],i[9]=r[9],i[10]=r[10],i[11]=r[11],i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15],this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToVector3Array:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length);for(var o=0,a=i;r>o;o+=3,a+=3)e.fromArray(t,a),e.applyMatrix4(this),e.toArray(t,a);return t}}(),applyToBuffer:function(){var e;return function(t,i,r){void 0===e&&(e=new n.Vector3),void 0===i&&(i=0),void 0===r&&(r=t.length/t.itemSize);for(var o=0,a=i;r>o;o++,a++)e.x=t.getX(a),e.y=t.getY(a),e.z=t.getZ(a),e.applyMatrix4(this),t.setXYZ(e.x,e.y,e.z);return t}}(),determinant:function(){var e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],o=e[1],a=e[5],s=e[9],c=e[13],h=e[2],l=e[6],u=e[10],d=e[14],p=e[3],f=e[7],m=e[11],v=e[15];return p*(+n*s*l-r*c*l-n*a*u+i*c*u+r*a*d-i*s*d)+f*(+t*s*d-t*c*u+n*o*u-r*o*d+r*c*h-n*s*h)+m*(+t*c*l-t*a*d-n*o*l+i*o*d+n*a*h-i*c*h)+v*(-r*a*h-t*s*l+t*a*u+r*o*l-i*o*u+i*s*h)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},flattenToArrayOffset:function(e,t){var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e},getPosition:function(){var e;return function(){return void 0===e&&(e=new n.Vector3),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),e.setFromMatrixColumn(this,3)}}(),setPosition:function(e){var t=this.elements;return t[12]=e.x,t[13]=e.y,t[14]=e.z,this},getInverse:function(e,t){var i=this.elements,r=e.elements,n=r[0],o=r[1],a=r[2],s=r[3],c=r[4],h=r[5],l=r[6],u=r[7],d=r[8],p=r[9],f=r[10],m=r[11],v=r[12],g=r[13],y=r[14],x=r[15],b=p*y*u-g*f*u+g*l*m-h*y*m-p*l*x+h*f*x,w=v*f*u-d*y*u-v*l*m+c*y*m+d*l*x-c*f*x,M=d*g*u-v*p*u+v*h*m-c*g*m-d*h*x+c*p*x,_=v*p*l-d*g*l-v*h*f+c*g*f+d*h*y-c*p*y,E=n*b+o*w+a*M+s*_;if(0===E){var A="THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0";if(t)throw new Error(A);return console.warn(A),this.identity()}return i[0]=b,i[1]=g*f*s-p*y*s-g*a*m+o*y*m+p*a*x-o*f*x,i[2]=h*y*s-g*l*s+g*a*u-o*y*u-h*a*x+o*l*x,i[3]=p*l*s-h*f*s-p*a*u+o*f*u+h*a*m-o*l*m,i[4]=w,i[5]=d*y*s-v*f*s+v*a*m-n*y*m-d*a*x+n*f*x,i[6]=v*l*s-c*y*s-v*a*u+n*y*u+c*a*x-n*l*x,i[7]=c*f*s-d*l*s+d*a*u-n*f*u-c*a*m+n*l*m,i[8]=M,i[9]=v*p*s-d*g*s-v*o*m+n*g*m+d*o*x-n*p*x,i[10]=c*g*s-v*h*s+v*o*u-n*g*u-c*o*x+n*h*x,i[11]=d*h*s-c*p*s-d*o*u+n*p*u+c*o*m-n*h*m,i[12]=_,i[13]=d*g*a-v*p*a+v*o*f-n*g*f-d*o*y+n*p*y,i[14]=v*h*a-c*g*a-v*o*l+n*g*l+c*o*y-n*h*y,i[15]=c*p*a-d*h*a+d*o*l-n*p*l-c*o*f+n*h*f,this.multiplyScalar(1/E)},scale:function(e){var t=this.elements,i=e.x,r=e.y,n=e.z;return t[0]*=i,t[4]*=r,t[8]*=n,t[1]*=i,t[5]*=r,t[9]*=n,t[2]*=i,t[6]*=r,t[10]*=n,t[3]*=i,t[7]*=r,t[11]*=n,this},getMaxScaleOnAxis:function(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))},makeTranslation:function(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=1-i,o=e.x,a=e.y,s=e.z,c=n*o,h=n*a;return this.set(c*o+i,c*a-r*s,c*s+r*a,0,c*a+r*s,h*a+i,h*s-r*o,0,c*s-r*a,h*s+r*o,n*s*s+i,0,0,0,0,1),this},makeScale:function(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this},compose:function(e,t,i){return this.makeRotationFromQuaternion(t),this.scale(i),this.setPosition(e),this},decompose:function(){var e,t;return function(i,r,o){void 0===e&&(e=new n.Vector3),void 0===t&&(t=new n.Matrix4);var a=this.elements,s=e.set(a[0],a[1],a[2]).length(),c=e.set(a[4],a[5],a[6]).length(),h=e.set(a[8],a[9],a[10]).length(),l=this.determinant();0>l&&(s=-s),i.x=a[12],i.y=a[13],i.z=a[14],t.elements.set(this.elements);var u=1/s,d=1/c,p=1/h;return t.elements[0]*=u,t.elements[1]*=u,t.elements[2]*=u,t.elements[4]*=d,t.elements[5]*=d,t.elements[6]*=d,t.elements[8]*=p,t.elements[9]*=p,t.elements[10]*=p,r.setFromRotationMatrix(t),o.x=s,o.y=c,o.z=h,this}}(),makeFrustum:function(e,t,i,r,n,o){var a=this.elements,s=2*n/(t-e),c=2*n/(r-i),h=(t+e)/(t-e),l=(r+i)/(r-i),u=-(o+n)/(o-n),d=-2*o*n/(o-n);return a[0]=s,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=c,a[9]=l,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makePerspective:function(e,t,i,r){var o=i*Math.tan(n.Math.degToRad(.5*e)),a=-o,s=a*t,c=o*t;return this.makeFrustum(s,c,a,o,i,r)},makeOrthographic:function(e,t,i,r,n,o){var a=this.elements,s=1/(t-e),c=1/(i-r),h=1/(o-n),l=(t+e)*s,u=(i+r)*c,d=(o+n)*h;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-l,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},equals:function(e){for(var t=this.elements,i=e.elements,r=0;16>r;r++)if(t[r]!==i[r])return!1;return!0},fromArray:function(e){return this.elements.set(e),this},toArray:function(){var e=this.elements;return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]}},n.Ray=function(e,t){this.origin=void 0!==e?e:new n.Vector3,this.direction=void 0!==t?t:new n.Vector3},n.Ray.prototype={constructor:n.Ray,set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){var i=t||new n.Vector3;return i.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){this.direction.copy(e).sub(this.origin).normalize()},recast:function(){var e=new n.Vector3;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var i=t||new n.Vector3;i.subVectors(e,this.origin);var r=i.dot(this.direction);return 0>r?i.copy(this.origin):i.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new n.Vector3;return function(t){var i=e.subVectors(t,this.origin).dot(this.direction);return 0>i?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(i).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3;return function(r,n,o,a){e.copy(r).add(n).multiplyScalar(.5),t.copy(n).sub(r).normalize(),i.copy(this.origin).sub(e);var s,c,h,l,u=.5*r.distanceTo(n),d=-this.direction.dot(t),p=i.dot(this.direction),f=-i.dot(t),m=i.lengthSq(),v=Math.abs(1-d*d);if(v>0)if(s=d*f-p,c=d*p-f,l=u*v,s>=0)if(c>=-l)if(l>=c){var g=1/v;s*=g,c*=g,h=s*(s+d*c+2*p)+c*(d*s+c+2*f)+m}else c=u,s=Math.max(0,-(d*c+p)),h=-s*s+c*(c+2*f)+m;else c=-u,s=Math.max(0,-(d*c+p)),h=-s*s+c*(c+2*f)+m;else-l>=c?(s=Math.max(0,-(-d*u+p)),c=s>0?-u:Math.min(Math.max(-u,-f),u),h=-s*s+c*(c+2*f)+m):l>=c?(s=0,c=Math.min(Math.max(-u,-f),u),h=c*(c+2*f)+m):(s=Math.max(0,-(d*u+p)),c=s>0?u:Math.min(Math.max(-u,-f),u),h=-s*s+c*(c+2*f)+m);else c=d>0?-u:u,s=Math.max(0,-(d*c+p)),h=-s*s+c*(c+2*f)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(t).multiplyScalar(c).add(e),h}}(),intersectSphere:function(){var e=new n.Vector3;return function(t,i){e.subVectors(t.center,this.origin);var r=e.dot(this.direction),n=e.dot(e)-r*r,o=t.radius*t.radius;if(n>o)return null;var a=Math.sqrt(o-n),s=r-a,c=r+a;return 0>s&&0>c?null:0>s?this.at(c,i):this.at(s,i)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);if(0===t)return!0;var i=e.normal.dot(this.direction);return 0>i*t?!0:!1},intersectBox:function(e,t){var i,r,n,o,a,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,r=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,r=(e.min.x-u.x)*c),h>=0?(n=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(n=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),i>o||n>r?null:((n>i||i!==i)&&(i=n),(r>o||r!==r)&&(r=o),l>=0?(a=(e.min.z-u.z)*l,s=(e.max.z-u.z)*l):(a=(e.max.z-u.z)*l,s=(e.min.z-u.z)*l),i>s||a>r?null:((a>i||i!==i)&&(i=a),(r>s||r!==r)&&(r=s),0>r?null:this.at(i>=0?i:r,t)))},intersectsBox:function(){var e=new n.Vector3;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3,r=new n.Vector3;return function(n,o,a,s,c){t.subVectors(o,n),i.subVectors(a,n),r.crossVectors(t,i);var h,l=this.direction.dot(r);if(l>0){if(s)return null;h=1}else{if(!(0>l))return null;h=-1,l=-l}e.subVectors(this.origin,n);var u=h*this.direction.dot(i.crossVectors(e,i));if(0>u)return null;var d=h*this.direction.dot(t.cross(e));if(0>d)return null;if(u+d>l)return null;var p=-h*e.dot(r);return 0>p?null:this.at(p/l,c)}}(),applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}},n.Sphere=function(e,t){this.center=void 0!==e?e:new n.Vector3,this.radius=void 0!==t?t:0},n.Sphere.prototype={constructor:n.Sphere,set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new n.Box3;return function(t,i){var r=this.center;void 0!==i?r.copy(i):e.setFromPoints(t).center(r);for(var n=0,o=0,a=t.length;a>o;o++)n=Math.max(n,r.distanceToSquared(t[o]));return this.radius=Math.sqrt(n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return this.radius<=0},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},intersectsBox:function(e){return e.intersectsSphere(this)},intersectsPlane:function(e){return Math.abs(this.center.dot(e.normal)-e.constant)<=this.radius},clampPoint:function(e,t){var i=this.center.distanceToSquared(e),r=t||new n.Vector3;return r.copy(e),i>this.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},getBoundingBox:function(e){var t=e||new n.Box3;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}},n.Frustum=function(e,t,i,r,o,a){this.planes=[void 0!==e?e:new n.Plane,void 0!==t?t:new n.Plane,void 0!==i?i:new n.Plane,void 0!==r?r:new n.Plane,void 0!==o?o:new n.Plane,void 0!==a?a:new n.Plane]},n.Frustum.prototype={constructor:n.Frustum,set:function(e,t,i,r,n,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,i=0;6>i;i++)t[i].copy(e.planes[i]);return this},setFromMatrix:function(e){var t=this.planes,i=e.elements,r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],c=i[5],h=i[6],l=i[7],u=i[8],d=i[9],p=i[10],f=i[11],m=i[12],v=i[13],g=i[14],y=i[15];return t[0].setComponents(a-r,l-s,f-u,y-m).normalize(),t[1].setComponents(a+r,l+s,f+u,y+m).normalize(),t[2].setComponents(a+n,l+c,f+d,y+v).normalize(),t[3].setComponents(a-n,l-c,f-d,y-v).normalize(),t[4].setComponents(a-o,l-h,f-p,y-g).normalize(),t[5].setComponents(a+o,l+h,f+p,y+g).normalize(),this},intersectsObject:function(){var e=new n.Sphere;return function(t){var i=t.geometry;return null===i.boundingSphere&&i.computeBoundingSphere(),e.copy(i.boundingSphere),e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,i=e.center,r=-e.radius,n=0;6>n;n++){var o=t[n].distanceToPoint(i);if(r>o)return!1}return!0},intersectsBox:function(){var e=new n.Vector3,t=new n.Vector3;return function(i){for(var r=this.planes,n=0;6>n;n++){var o=r[n];e.x=o.normal.x>0?i.min.x:i.max.x,t.x=o.normal.x>0?i.max.x:i.min.x,e.y=o.normal.y>0?i.min.y:i.max.y,t.y=o.normal.y>0?i.max.y:i.min.y,e.z=o.normal.z>0?i.min.z:i.max.z,t.z=o.normal.z>0?i.max.z:i.min.z;var a=o.distanceToPoint(e),s=o.distanceToPoint(t);if(0>a&&0>s)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,i=0;6>i;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}},n.Plane=function(e,t){this.normal=void 0!==e?e:new n.Vector3(1,0,0),this.constant=void 0!==t?t:0},n.Plane.prototype={constructor:n.Plane,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new n.Vector3,t=new n.Vector3;return function(i,r,n){var o=e.subVectors(n,r).cross(t.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(o,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return this.orthoPoint(e,t).sub(e).negate()},orthoPoint:function(e,t){var i=this.distanceToPoint(e),r=t||new n.Vector3;return r.copy(this.normal).multiplyScalar(i)},intersectLine:function(){var e=new n.Vector3;return function(t,i){var r=i||new n.Vector3,o=t.delta(e),a=this.normal.dot(o);if(0===a)return 0===this.distanceToPoint(t.start)?r.copy(t.start):void 0;var s=-(t.start.dot(this.normal)+this.constant)/a;return 0>s||s>1?void 0:r.copy(o).multiplyScalar(s).add(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return 0>t&&i>0||0>i&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){var t=e||new n.Vector3;return t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Matrix3;return function(r,n){var o=n||i.getNormalMatrix(r),a=e.copy(this.normal).applyMatrix3(o),s=this.coplanarPoint(t);return s.applyMatrix4(r),this.setFromNormalAndCoplanarPoint(a,s),this}}(),translate:function(e){return this.constant=this.constant-e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},n.Spherical=function(e,t,i){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==i?i:0,this},n.Spherical.prototype={constructor:n.Spherical,set:function(e,t,i){this.radius=e,this.phi=t,this.theta=i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius.copy(e.radius),this.phi.copy(e.phi),this.theta.copy(e.theta),this},makeSafe:function(){var e=1e-6;this.phi=Math.max(e,Math.min(Math.PI-e,this.phi))},setFromVector3:function(e){return this.radius=e.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e.x,e.z),this.phi=Math.acos(n.Math.clamp(e.y/this.radius,-1,1))),this}},n.Math={generateUUID:function(){var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function(){for(var n=0;36>n;n++)8===n||13===n||18===n||23===n?i[n]="-":14===n?i[n]="4":(2>=r&&(r=33554432+16777216*Math.random()|0),e=15&r,r>>=4,i[n]=t[19===n?3&e|8:e]);return i.join("")}}(),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},smoothstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(6*e-15)+10))},random16:function(){return console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead."),Math.random()},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(){var e=Math.PI/180;return function(t){return t*e}}(),radToDeg:function(){var e=180/Math.PI;return function(t){return t*e}}(),isPowerOfTwo:function(e){return 0===(e&e-1)&&0!==e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}},n.Spline=function(e){function t(e,t,i,r,n,o,a){var s=.5*(i-e),c=.5*(r-t);return(2*(t-i)+s+c)*a+(-3*(t-i)-2*s-c)*o+s*n+t}this.points=e;var i,r,o,a,s,c,h,l,u,d=[],p={x:0,y:0,z:0};this.initFromArray=function(e){this.points=[];for(var t=0;tthis.points.length-2?this.points.length-1:r+1,d[3]=r>this.points.length-3?this.points.length-1:r+2,c=this.points[d[0]],h=this.points[d[1]],l=this.points[d[2]],u=this.points[d[3]],a=o*o,s=o*a,p.x=t(c.x,h.x,l.x,u.x,o,a,s),p.y=t(c.y,h.y,l.y,u.y,o,a,s),p.z=t(c.z,h.z,l.z,u.z,o,a,s),p},this.getControlPointsArray=function(){var e,t,i=this.points.length,r=[];for(e=0;i>e;e++)t=this.points[e],r[e]=[t.x,t.y,t.z];return r},this.getLength=function(e){var t,i,r,o,a=0,s=0,c=0,h=new n.Vector3,l=new n.Vector3,u=[],d=0;for(u[0]=0,e||(e=100),r=this.points.length*e,h.copy(this.points[0]),t=1;r>t;t++)i=t/r,o=this.getPoint(i),l.copy(o),d+=l.distanceTo(h),h.copy(o),a=(this.points.length-1)*i,s=Math.floor(a),s!==c&&(u[s]=d,c=s);return u[u.length]=d,{chunks:u,total:d}},this.reparametrizeByArcLength=function(e){var t,i,r,o,a,s,c,h,l=[],u=new n.Vector3,d=this.getLength();for(l.push(u.copy(this.points[0]).clone()),t=1;ti;i++)r=o+i*(1/c)*(a-o),h=this.getPoint(r),l.push(u.copy(h).clone());l.push(u.copy(this.points[t]).clone())}this.points=l}},n.Triangle=function(e,t,i){this.a=void 0!==e?e:new n.Vector3,this.b=void 0!==t?t:new n.Vector3,this.c=void 0!==i?i:new n.Vector3},n.Triangle.normal=function(){var e=new n.Vector3;return function(t,i,r,o){var a=o||new n.Vector3;a.subVectors(r,i),e.subVectors(t,i),a.cross(e);var s=a.lengthSq();return s>0?a.multiplyScalar(1/Math.sqrt(s)):a.set(0,0,0)}}(),n.Triangle.barycoordFromPoint=function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3;return function(r,o,a,s,c){e.subVectors(s,o),t.subVectors(a,o),i.subVectors(r,o);var h=e.dot(e),l=e.dot(t),u=e.dot(i),d=t.dot(t),p=t.dot(i),f=h*d-l*l,m=c||new n.Vector3;if(0===f)return m.set(-2,-1,-1);var v=1/f,g=(d*u-l*p)*v,y=(h*p-l*u)*v;return m.set(1-g-y,y,g)}}(),n.Triangle.containsPoint=function(){var e=new n.Vector3;return function(t,i,r,o){var a=n.Triangle.barycoordFromPoint(t,i,r,o,e);return a.x>=0&&a.y>=0&&a.x+a.y<=1}}(),n.Triangle.prototype={constructor:n.Triangle,set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},area:function(){var e=new n.Vector3,t=new n.Vector3;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){var t=e||new n.Vector3;return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return n.Triangle.normal(this.a,this.b,this.c,e)},plane:function(e){var t=e||new n.Plane;return t.setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return n.Triangle.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return n.Triangle.containsPoint(e,this.a,this.b,this.c)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},n.Interpolant=function(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i},n.Interpolant.prototype={constructor:n.Interpolant,evaluate:function(e){var t=this.parameterPositions,i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{var o;i:{r:if(!(r>e)){for(var a=i+2;;){if(void 0===r){if(n>e)break r;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,n)}if(i===a)break;if(n=r,r=t[++i],r>e)break t}o=t.length;break i}{if(e>=n)break e;var s=t[1];s>e&&(i=2,n=s);for(var a=i-2;;){if(void 0===n)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(i===a)break;if(r=n,n=t[--i-1],e>=n)break t}o=i,i=0}}for(;o>i;){var c=i+o>>>1;eo;o++)r[o]=i[o];for(var o=0;n>o;o++)r[o].call(this,e)}}}},n.Layers=function(){this.mask=1},n.Layers.prototype={constructor:n.Layers,set:function(e){this.mask=1<a;a++)i(o[a],t,r,!0)}e.Raycaster=function(t,i,r,n){this.ray=new e.Ray(t,i),this.near=r||0,this.far=n||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})},e.Raycaster.prototype={constructor:e.Raycaster,linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(t,i){i instanceof e.PerspectiveCamera?(this.ray.origin.setFromMatrixPosition(i.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(i).sub(this.ray.origin).normalize()):i instanceof e.OrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(i),this.ray.direction.set(0,0,-1).transformDirection(i.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(e,r){var n=[];return i(e,this,n,r),n.sort(t),n},intersectObjects:function(e,r){var n=[];if(Array.isArray(e)===!1)return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),n;for(var o=0,a=e.length;a>o;o++)i(e[o],this,n,r);return n.sort(t),n}}}(n),n.Object3D=function(){function e(){o.setFromEuler(r,!1)}function t(){r.setFromQuaternion(o,void 0,!1)}Object.defineProperty(this,"id",{value:n.Object3DIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=n.Object3D.DefaultUp.clone();var i=new n.Vector3,r=new n.Euler,o=new n.Quaternion,a=new n.Vector3(1,1,1);r.onChange(e),o.onChange(t),Object.defineProperties(this,{position:{enumerable:!0,value:i},rotation:{enumerable:!0,value:r},quaternion:{enumerable:!0,value:o},scale:{enumerable:!0,value:a},modelViewMatrix:{value:new n.Matrix4},normalMatrix:{value:new n.Matrix3}}),this.rotationAutoUpdate=!0,this.matrix=new n.Matrix4,this.matrixWorld=new n.Matrix4,this.matrixAutoUpdate=n.Object3D.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new n.Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}},n.Object3D.DefaultUp=new n.Vector3(0,1,0),n.Object3D.DefaultMatrixAutoUpdate=!0,n.Object3D.prototype={constructor:n.Object3D,applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(){var e=new n.Quaternion;return function(t,i){return e.setFromAxisAngle(t,i),this.quaternion.multiply(e),this}}(),rotateX:function(){var e=new n.Vector3(1,0,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateY:function(){var e=new n.Vector3(0,1,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateZ:function(){var e=new n.Vector3(0,0,1);return function(t){return this.rotateOnAxis(e,t)}}(),translateOnAxis:function(){var e=new n.Vector3;return function(t,i){return e.copy(t).applyQuaternion(this.quaternion),this.position.add(e.multiplyScalar(i)),this}}(),translateX:function(){var e=new n.Vector3(1,0,0);return function(t){return this.translateOnAxis(e,t)}}(),translateY:function(){var e=new n.Vector3(0,1,0); return function(t){return this.translateOnAxis(e,t)}}(),translateZ:function(){var e=new n.Vector3(0,0,1);return function(t){return this.translateOnAxis(e,t)}}(),localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var e=new n.Matrix4;return function(t){return t.applyMatrix4(e.getInverse(this.matrixWorld))}}(),lookAt:function(){var e=new n.Matrix4;return function(t){e.lookAt(t,this.position,this.up),this.quaternion.setFromRotationMatrix(e)}}(),add:function(e){if(arguments.length>1){for(var t=0;t1)for(var t=0;ti;i++){var n=this.children[i],o=n.getObjectByProperty(e,t);if(void 0!==o)return o}return void 0},getWorldPosition:function(e){var t=e||new n.Vector3;return this.updateMatrixWorld(!0),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var e=new n.Vector3,t=new n.Vector3;return function(i){var r=i||new n.Quaternion;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,r,t),r}}(),getWorldRotation:function(){var e=new n.Quaternion;return function(t){var i=t||new n.Euler;return this.getWorldQuaternion(e),i.setFromQuaternion(e,this.rotation.order,!1)}}(),getWorldScale:function(){var e=new n.Vector3,t=new n.Quaternion;return function(i){var r=i||new n.Vector3;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,t,r),r}}(),getWorldDirection:function(){var e=new n.Quaternion;return function(t){var i=t||new n.Vector3;return this.getWorldQuaternion(e),i.set(0,0,1).applyQuaternion(e)}}(),raycast:function(){},traverse:function(e){e(this);for(var t=this.children,i=0,r=t.length;r>i;i++)t[i].traverse(e)},traverseVisible:function(e){if(this.visible!==!1){e(this);for(var t=this.children,i=0,r=t.length;r>i;i++)t[i].traverseVisible(e)}},traverseAncestors:function(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){this.matrixAutoUpdate===!0&&this.updateMatrix(),(this.matrixWorldNeedsUpdate===!0||e===!0)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=0,i=this.children.length;i>t;t++)this.children[t].updateMatrixWorld(e)},toJSON:function(e){function t(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}var i=void 0===e,r={};i&&(e={geometries:{},materials:{},textures:{},images:{}},r.metadata={version:4.4,type:"Object",generator:"Object3D.toJSON"});var n={};if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),n.matrix=this.matrix.toArray(),void 0!==this.geometry&&(void 0===e.geometries[this.geometry.uuid]&&(e.geometries[this.geometry.uuid]=this.geometry.toJSON(e)),n.geometry=this.geometry.uuid),void 0!==this.material&&(void 0===e.materials[this.material.uuid]&&(e.materials[this.material.uuid]=this.material.toJSON(e)),n.material=this.material.uuid),this.children.length>0){n.children=[];for(var o=0;o0&&(r.geometries=a),s.length>0&&(r.materials=s),c.length>0&&(r.textures=c),h.length>0&&(r.images=h)}return r.object=n,r},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.rotationAutoUpdate=e.rotationAutoUpdate,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(var i=0;it;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(var t=0,i=e.vertexColors.length;i>t;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}},n.BufferAttribute=function(e,t){this.uuid=n.Math.generateUUID(),this.array=e,this.itemSize=t,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0},n.BufferAttribute.prototype={constructor:n.BufferAttribute,get count(){return this.array.length/this.itemSize},set needsUpdate(e){e===!0&&this.version++},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.dynamic=e.dynamic,this},copyAt:function(e,t,i){e*=this.itemSize,i*=t.itemSize;for(var r=0,n=this.itemSize;n>r;r++)this.array[e+r]=t.array[i+r];return this},copyArray:function(e){return this.array.set(e),this},copyColorsArray:function(e){for(var t=this.array,i=0,r=0,o=e.length;o>r;r++){var a=e[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new n.Color),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this},copyIndicesArray:function(e){for(var t=this.array,i=0,r=0,n=e.length;n>r;r++){var o=e[r];t[i++]=o.a,t[i++]=o.b,t[i++]=o.c}return this},copyVector2sArray:function(e){for(var t=this.array,i=0,r=0,o=e.length;o>r;r++){var a=e[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new n.Vector2),t[i++]=a.x,t[i++]=a.y}return this},copyVector3sArray:function(e){for(var t=this.array,i=0,r=0,o=e.length;o>r;r++){var a=e[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new n.Vector3),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z}return this},copyVector4sArray:function(e){for(var t=this.array,i=0,r=0,o=e.length;o>r;r++){var a=e[r];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new n.Vector4),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},getX:function(e){return this.array[e*this.itemSize]},setX:function(e,t){return this.array[e*this.itemSize]=t,this},getY:function(e){return this.array[e*this.itemSize+1]},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},getZ:function(e){return this.array[e*this.itemSize+2]},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},getW:function(e){return this.array[e*this.itemSize+3]},setW:function(e,t){return this.array[e*this.itemSize+3]=t,this},setXY:function(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,this},clone:function(){return(new this.constructor).copy(this)}},n.Int8Attribute=function(e,t){return new n.BufferAttribute(new Int8Array(e),t)},n.Uint8Attribute=function(e,t){return new n.BufferAttribute(new Uint8Array(e),t)},n.Uint8ClampedAttribute=function(e,t){return new n.BufferAttribute(new Uint8ClampedArray(e),t)},n.Int16Attribute=function(e,t){return new n.BufferAttribute(new Int16Array(e),t)},n.Uint16Attribute=function(e,t){return new n.BufferAttribute(new Uint16Array(e),t)},n.Int32Attribute=function(e,t){return new n.BufferAttribute(new Int32Array(e),t)},n.Uint32Attribute=function(e,t){return new n.BufferAttribute(new Uint32Array(e),t)},n.Float32Attribute=function(e,t){return new n.BufferAttribute(new Float32Array(e),t)},n.Float64Attribute=function(e,t){return new n.BufferAttribute(new Float64Array(e),t)},n.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new n.BufferAttribute(e,t).setDynamic(!0)},n.InstancedBufferAttribute=function(e,t,i){n.BufferAttribute.call(this,e,t),this.meshPerAttribute=i||1},n.InstancedBufferAttribute.prototype=Object.create(n.BufferAttribute.prototype),n.InstancedBufferAttribute.prototype.constructor=n.InstancedBufferAttribute,n.InstancedBufferAttribute.prototype.copy=function(e){return n.BufferAttribute.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},n.InterleavedBuffer=function(e,t){this.uuid=n.Math.generateUUID(),this.array=e,this.stride=t,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0},n.InterleavedBuffer.prototype={constructor:n.InterleavedBuffer,get length(){return this.array.length},get count(){return this.array.length/this.stride},set needsUpdate(e){e===!0&&this.version++},setDynamic:function(e){return this.dynamic=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.stride=e.stride,this.dynamic=e.dynamic,this},copyAt:function(e,t,i){e*=this.stride,i*=t.stride;for(var r=0,n=this.stride;n>r;r++)this.array[e+r]=t.array[i+r];return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},clone:function(){return(new this.constructor).copy(this)}},n.InstancedInterleavedBuffer=function(e,t,i){n.InterleavedBuffer.call(this,e,t),this.meshPerAttribute=i||1},n.InstancedInterleavedBuffer.prototype=Object.create(n.InterleavedBuffer.prototype),n.InstancedInterleavedBuffer.prototype.constructor=n.InstancedInterleavedBuffer,n.InstancedInterleavedBuffer.prototype.copy=function(e){return n.InterleavedBuffer.prototype.copy.call(this,e),this.meshPerAttribute=e.meshPerAttribute,this},n.InterleavedBufferAttribute=function(e,t,i){this.uuid=n.Math.generateUUID(),this.data=e,this.itemSize=t,this.offset=i},n.InterleavedBufferAttribute.prototype={constructor:n.InterleavedBufferAttribute,get length(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count."),this.array.length},get count(){return this.data.count},setX:function(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this},setY:function(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this},setZ:function(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this},setW:function(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this},getX:function(e){return this.data.array[e*this.data.stride+this.offset]},getY:function(e){return this.data.array[e*this.data.stride+this.offset+1]},getZ:function(e){return this.data.array[e*this.data.stride+this.offset+2]},getW:function(e){return this.data.array[e*this.data.stride+this.offset+3]},setXY:function(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this},setXYZ:function(e,t,i,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this},setXYZW:function(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}},n.Geometry=function(){Object.defineProperty(this,"id",{value:n.GeometryIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.elementsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1},n.Geometry.prototype={constructor:n.Geometry,applyMatrix:function(e){for(var t=(new n.Matrix3).getNormalMatrix(e),i=0,r=this.vertices.length;r>i;i++){var o=this.vertices[i];o.applyMatrix4(e)}for(var i=0,r=this.faces.length;r>i;i++){var a=this.faces[i];a.normal.applyMatrix3(t).normalize();for(var s=0,c=a.vertexNormals.length;c>s;s++)a.vertexNormals[s].applyMatrix3(t).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e;return function(t){void 0===e&&(e=new n.Object3D),e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),fromBufferGeometry:function(e){function t(e,t,r,o){var a=void 0!==s?[u[e].clone(),u[t].clone(),u[r].clone()]:[],f=void 0!==c?[i.colors[e].clone(),i.colors[t].clone(),i.colors[r].clone()]:[],m=new n.Face3(e,t,r,a,f,o);i.faces.push(m),void 0!==h&&i.faceVertexUvs[0].push([d[e].clone(),d[t].clone(),d[r].clone()]),void 0!==l&&i.faceVertexUvs[1].push([p[e].clone(),p[t].clone(),p[r].clone()])}var i=this,r=null!==e.index?e.index.array:void 0,o=e.attributes,a=o.position.array,s=void 0!==o.normal?o.normal.array:void 0,c=void 0!==o.color?o.color.array:void 0,h=void 0!==o.uv?o.uv.array:void 0,l=void 0!==o.uv2?o.uv2.array:void 0;void 0!==l&&(this.faceVertexUvs[1]=[]);for(var u=[],d=[],p=[],f=0,m=0;f0)for(var f=0;fm;m+=3)t(r[m],r[m+1],r[m+2],g.materialIndex);else for(var f=0;fi;i++){var o=this.faces[i],a=this.vertices[o.a],s=this.vertices[o.b],c=this.vertices[o.c];e.subVectors(c,s),t.subVectors(a,s),e.cross(t),e.normalize(),o.normal.copy(e)}},computeVertexNormals:function(e){void 0===e&&(e=!0);var t,i,r,o,a,s;for(s=new Array(this.vertices.length),t=0,i=this.vertices.length;i>t;t++)s[t]=new n.Vector3;if(e){var c,h,l,u=new n.Vector3,d=new n.Vector3;for(r=0,o=this.faces.length;o>r;r++)a=this.faces[r],c=this.vertices[a.a],h=this.vertices[a.b],l=this.vertices[a.c],u.subVectors(l,h),d.subVectors(c,h),u.cross(d),s[a.a].add(u),s[a.b].add(u),s[a.c].add(u)}else for(r=0,o=this.faces.length;o>r;r++)a=this.faces[r],s[a.a].add(a.normal),s[a.b].add(a.normal),s[a.c].add(a.normal);for(t=0,i=this.vertices.length;i>t;t++)s[t].normalize();for(r=0,o=this.faces.length;o>r;r++){a=this.faces[r];var p=a.vertexNormals;3===p.length?(p[0].copy(s[a.a]),p[1].copy(s[a.b]),p[2].copy(s[a.c])):(p[0]=s[a.a].clone(),p[1]=s[a.b].clone(),p[2]=s[a.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,r,o;for(i=0,r=this.faces.length;r>i;i++)for(o=this.faces[i],o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]),e=0,t=o.vertexNormals.length;t>e;e++)o.__originalVertexNormals[e]?o.__originalVertexNormals[e].copy(o.vertexNormals[e]):o.__originalVertexNormals[e]=o.vertexNormals[e].clone();var a=new n.Geometry;for(a.faces=this.faces,e=0,t=this.morphTargets.length;t>e;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];var s,c,h=this.morphNormals[e].faceNormals,l=this.morphNormals[e].vertexNormals;for(i=0,r=this.faces.length;r>i;i++)s=new n.Vector3,c={a:new n.Vector3,b:new n.Vector3,c:new n.Vector3},h.push(s),l.push(c)}var u=this.morphNormals[e];a.vertices=this.morphTargets[e].vertices,a.computeFaceNormals(),a.computeVertexNormals();var s,c;for(i=0,r=this.faces.length;r>i;i++)o=this.faces[i],s=u.faceNormals[i],c=u.vertexNormals[i],s.copy(o.normal),c.a.copy(o.vertexNormals[0]),c.b.copy(o.vertexNormals[1]),c.c.copy(o.vertexNormals[2])}for(i=0,r=this.faces.length;r>i;i++)o=this.faces[i],o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals},computeTangents:function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){for(var e=0,t=this.vertices,i=0,r=t.length;r>i;i++)i>0&&(e+=t[i].distanceTo(t[i-1])),this.lineDistances[i]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new n.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new n.Sphere),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,i){if(e instanceof n.Geometry==!1)return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);var r,o=this.vertices.length,a=this.vertices,s=e.vertices,c=this.faces,h=e.faces,l=this.faceVertexUvs[0],u=e.faceVertexUvs[0];void 0===i&&(i=0),void 0!==t&&(r=(new n.Matrix3).getNormalMatrix(t));for(var d=0,p=s.length;p>d;d++){var f=s[d],m=f.clone();void 0!==t&&m.applyMatrix4(t),a.push(m)}for(d=0,p=h.length;p>d;d++){var v,g,y,x=h[d],b=x.vertexNormals,w=x.vertexColors;v=new n.Face3(x.a+o,x.b+o,x.c+o),v.normal.copy(x.normal),void 0!==r&&v.normal.applyMatrix3(r).normalize();for(var M=0,_=b.length;_>M;M++)g=b[M].clone(),void 0!==r&&g.applyMatrix3(r).normalize(),v.vertexNormals.push(g);v.color.copy(x.color);for(var M=0,_=w.length;_>M;M++)y=w[M],v.vertexColors.push(y.clone());v.materialIndex=x.materialIndex+i,c.push(v)}for(d=0,p=u.length;p>d;d++){var E=u[d],A=[];if(void 0!==E){for(var M=0,_=E.length;_>M;M++)A.push(E[M].clone());l.push(A)}}},mergeMesh:function(e){return e instanceof n.Mesh==!1?void console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e):(e.matrixAutoUpdate&&e.updateMatrix(),void this.merge(e.geometry,e.matrix))},mergeVertices:function(){var e,t,i,r,n,o,a,s,c={},h=[],l=[],u=4,d=Math.pow(10,u);for(i=0,r=this.vertices.length;r>i;i++)e=this.vertices[i],t=Math.round(e.x*d)+"_"+Math.round(e.y*d)+"_"+Math.round(e.z*d),void 0===c[t]?(c[t]=i,h.push(this.vertices[i]),l[i]=h.length-1):l[i]=l[c[t]];var p=[];for(i=0,r=this.faces.length;r>i;i++){n=this.faces[i],n.a=l[n.a],n.b=l[n.b],n.c=l[n.c],o=[n.a,n.b,n.c];for(var f=-1,m=0;3>m;m++)if(o[m]===o[(m+1)%3]){f=m,p.push(i);break}}for(i=p.length-1;i>=0;i--){var v=p[i];for(this.faces.splice(v,1),a=0,s=this.faceVertexUvs.length;s>a;a++)this.faceVertexUvs[a].splice(v,1)}var g=this.vertices.length-h.length;return this.vertices=h,g},sortFacesByMaterialIndex:function(){function e(e,t){return e.materialIndex-t.materialIndex}for(var t=this.faces,i=t.length,r=0;i>r;r++)t[r]._id=r;t.sort(e);var n,o,a=this.faceVertexUvs[0],s=this.faceVertexUvs[1];a&&a.length===i&&(n=[]),s&&s.length===i&&(o=[]);for(var r=0;i>r;r++){var c=t[r]._id;n&&n.push(a[c]),o&&o.push(s[c])}n&&(this.faceVertexUvs[0]=n),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){function e(e,t,i){return i?e|1<0,M=g.vertexNormals.length>0,_=1!==g.color.r||1!==g.color.g||1!==g.color.b,E=g.vertexColors.length>0,A=0;if(A=e(A,0,0),A=e(A,1,y),A=e(A,2,x),A=e(A,3,b),A=e(A,4,w),A=e(A,5,M),A=e(A,6,_),A=e(A,7,E),l.push(A),l.push(g.a,g.b,g.c),l.push(g.materialIndex),b){var S=this.faceVertexUvs[0][c];l.push(r(S[0]),r(S[1]),r(S[2]))}if(w&&l.push(t(g.normal)),M){var T=g.vertexNormals;l.push(t(T[0]),t(T[1]),t(T[2]))}if(_&&l.push(i(g.color)),E){var C=g.vertexColors;l.push(i(C[0]),i(C[1]),i(C[2]))}}return n.data={},n.data.vertices=s,n.data.normals=u,p.length>0&&(n.data.colors=p),m.length>0&&(n.data.uvs=[m]),n.data.faces=l,n},clone:function(){return(new n.Geometry).copy(this)},copy:function(e){this.vertices=[],this.faces=[],this.faceVertexUvs=[[]];for(var t=e.vertices,i=0,r=t.length;r>i;i++)this.vertices.push(t[i].clone());for(var n=e.faces,i=0,r=n.length;r>i;i++)this.faces.push(n[i].clone());for(var i=0,r=e.faceVertexUvs.length;r>i;i++){var o=e.faceVertexUvs[i];void 0===this.faceVertexUvs[i]&&(this.faceVertexUvs[i]=[]);for(var a=0,s=o.length;s>a;a++){for(var c=o[a],h=[],l=0,u=c.length;u>l;l++){var d=c[l];h.push(d.clone())}this.faceVertexUvs[i].push(h)}}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.Geometry.prototype),n.GeometryIdCount=0,n.DirectGeometry=function(){Object.defineProperty(this,"id",{value:n.GeometryIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="DirectGeometry",this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1},n.DirectGeometry.prototype={constructor:n.DirectGeometry,computeBoundingBox:n.Geometry.prototype.computeBoundingBox,computeBoundingSphere:n.Geometry.prototype.computeBoundingSphere,computeFaceNormals:function(){console.warn("THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.")},computeVertexNormals:function(){console.warn("THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.")},computeGroups:function(e){for(var t,i,r=[],n=e.faces,o=0;o0,s=o[1]&&o[1].length>0,c=e.morphTargets,h=c.length;if(h>0){t=[];for(var l=0;h>l;l++)t[l]=[];this.morphTargets.position=t}var u,d=e.morphNormals,p=d.length;if(p>0){u=[];for(var l=0;p>l;l++)u[l]=[];this.morphTargets.normal=u}for(var f=e.skinIndices,m=e.skinWeights,v=f.length===r.length,g=m.length===r.length,l=0;lE;E++){var A=c[E].vertices;t[E].push(A[y.a],A[y.b],A[y.c])}for(var E=0;p>E;E++){var S=d[E].vertexNormals[l];u[E].push(S.a,S.b,S.c)}v&&this.skinIndices.push(f[y.a],f[y.b],f[y.c]),g&&this.skinWeights.push(m[y.a],m[y.b],m[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.DirectGeometry.prototype),n.BufferGeometry=function(){Object.defineProperty(this,"id",{value:n.GeometryIdCount++}),this.uuid=n.Math.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}},n.BufferGeometry.prototype={constructor:n.BufferGeometry,getIndex:function(){return this.index},setIndex:function(e){this.index=e},addAttribute:function(e,t){return t instanceof n.BufferAttribute==!1&&t instanceof n.InterleavedBufferAttribute==!1?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(e,new n.BufferAttribute(arguments[1],arguments[2]))):"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(t)):(this.attributes[e]=t,this)},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToVector3Array(t.array),t.needsUpdate=!0);var i=this.attributes.normal;if(void 0!==i){var r=(new n.Matrix3).getNormalMatrix(e);r.applyToVector3Array(i.array),i.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e;return function(t){return void 0===e&&(e=new n.Matrix4),e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e;return function(t,i,r){return void 0===e&&(e=new n.Matrix4),e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e;return function(t){void 0===e&&(e=new n.Object3D),e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){this.computeBoundingBox();var e=this.boundingBox.center().negate();return this.translate(e.x,e.y,e.z),e},setFromObject:function(e){var t=e.geometry;if(e instanceof n.Points||e instanceof n.Line){var i=new n.Float32Attribute(3*t.vertices.length,3),r=new n.Float32Attribute(3*t.colors.length,3);if(this.addAttribute("position",i.copyVector3sArray(t.vertices)),this.addAttribute("color",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var o=new n.Float32Attribute(t.lineDistances.length,1);this.addAttribute("lineDistance",o.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e instanceof n.Mesh&&t instanceof n.Geometry&&this.fromGeometry(t);return this},updateFromObject:function(e){var t=e.geometry;if(e instanceof n.Mesh){var i=t.__directGeometry;if(void 0===i)return this.fromGeometry(t);i.verticesNeedUpdate=t.verticesNeedUpdate,i.normalsNeedUpdate=t.normalsNeedUpdate,i.colorsNeedUpdate=t.colorsNeedUpdate,i.uvsNeedUpdate=t.uvsNeedUpdate,i.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=i}if(t.verticesNeedUpdate===!0){var r=this.attributes.position;void 0!==r&&(r.copyVector3sArray(t.vertices),r.needsUpdate=!0),t.verticesNeedUpdate=!1}if(t.normalsNeedUpdate===!0){var r=this.attributes.normal;void 0!==r&&(r.copyVector3sArray(t.normals),r.needsUpdate=!0),t.normalsNeedUpdate=!1}if(t.colorsNeedUpdate===!0){var r=this.attributes.color;void 0!==r&&(r.copyColorsArray(t.colors),r.needsUpdate=!0),t.colorsNeedUpdate=!1}if(t.uvsNeedUpdate){var r=this.attributes.uv;void 0!==r&&(r.copyVector2sArray(t.uvs),r.needsUpdate=!0),t.uvsNeedUpdate=!1}if(t.lineDistancesNeedUpdate){var r=this.attributes.lineDistance;void 0!==r&&(r.copyArray(t.lineDistances),r.needsUpdate=!0),t.lineDistancesNeedUpdate=!1}return t.groupsNeedUpdate&&(t.computeGroups(e.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new n.DirectGeometry).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(3*e.vertices.length);if(this.addAttribute("position",new n.BufferAttribute(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){var i=new Float32Array(3*e.normals.length);this.addAttribute("normal",new n.BufferAttribute(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.addAttribute("color",new n.BufferAttribute(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var o=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new n.BufferAttribute(o,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var a=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new n.BufferAttribute(a,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var s=e.vertices.length>65535?Uint32Array:Uint16Array,c=new s(3*e.indices.length);this.setIndex(new n.BufferAttribute(c,1).copyIndicesArray(e.indices)); }this.groups=e.groups;for(var h in e.morphTargets){for(var l=[],u=e.morphTargets[h],d=0,p=u.length;p>d;d++){var f=u[d],m=new n.Float32Attribute(3*f.length,3);l.push(m.copyVector3sArray(f))}this.morphAttributes[h]=l}if(e.skinIndices.length>0){var v=new n.Float32Attribute(4*e.skinIndices.length,4);this.addAttribute("skinIndex",v.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var g=new n.Float32Attribute(4*e.skinWeights.length,4);this.addAttribute("skinWeight",g.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){new n.Vector3;return function(){null===this.boundingBox&&(this.boundingBox=new n.Box3);var e=this.attributes.position.array;e&&this.boundingBox.setFromArray(e),(void 0===e||0===e.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.',this)}}(),computeBoundingSphere:function(){var e=new n.Box3,t=new n.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new n.Sphere);var i=this.attributes.position.array;if(i){var r=this.boundingSphere.center;e.setFromArray(i),e.center(r);for(var o=0,a=0,s=i.length;s>a;a+=3)t.fromArray(i,a),o=Math.max(o,r.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.index,t=this.attributes,i=this.groups;if(t.position){var r=t.position.array;if(void 0===t.normal)this.addAttribute("normal",new n.BufferAttribute(new Float32Array(r.length),3));else for(var o=t.normal.array,a=0,s=o.length;s>a;a++)o[a]=0;var c,h,l,u=t.normal.array,d=new n.Vector3,p=new n.Vector3,f=new n.Vector3,m=new n.Vector3,v=new n.Vector3;if(e){var g=e.array;0===i.length&&this.addGroup(0,g.length);for(var y=0,x=i.length;x>y;++y)for(var b=i[y],w=b.start,M=b.count,a=w,s=w+M;s>a;a+=3)c=3*g[a+0],h=3*g[a+1],l=3*g[a+2],d.fromArray(r,c),p.fromArray(r,h),f.fromArray(r,l),m.subVectors(f,p),v.subVectors(d,p),m.cross(v),u[c]+=m.x,u[c+1]+=m.y,u[c+2]+=m.z,u[h]+=m.x,u[h+1]+=m.y,u[h+2]+=m.z,u[l]+=m.x,u[l+1]+=m.y,u[l+2]+=m.z}else for(var a=0,s=r.length;s>a;a+=9)d.fromArray(r,a),p.fromArray(r,a+3),f.fromArray(r,a+6),m.subVectors(f,p),v.subVectors(d,p),m.cross(v),u[a]=m.x,u[a+1]=m.y,u[a+2]=m.z,u[a+3]=m.x,u[a+4]=m.y,u[a+5]=m.z,u[a+6]=m.x,u[a+7]=m.y,u[a+8]=m.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},merge:function(e,t){if(e instanceof n.BufferGeometry==!1)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);void 0===t&&(t=0);var i=this.attributes;for(var r in i)if(void 0!==e.attributes[r])for(var o=i[r],a=o.array,s=e.attributes[r],c=s.array,h=s.itemSize,l=0,u=h*t;lo;o+=3)e=n[o],t=n[o+1],i=n[o+2],r=1/Math.sqrt(e*e+t*t+i*i),n[o]*=r,n[o+1]*=r,n[o+2]*=r},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var e=new n.BufferGeometry,t=this.index.array,i=this.attributes;for(var r in i){for(var o=i[r],a=o.array,s=o.itemSize,c=new a.constructor(t.length*s),h=0,l=0,u=0,d=t.length;d>u;u++){h=t[u]*s;for(var p=0;s>p;p++)c[l++]=a[h++]}e.addAttribute(r,new n.BufferAttribute(c,s))}return e},toJSON:function(){var e={metadata:{version:4.4,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),void 0!==this.parameters){var t=this.parameters;for(var i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};var r=this.index;if(null!==r){var n=Array.prototype.slice.call(r.array);e.data.index={type:r.array.constructor.name,array:n}}var o=this.attributes;for(var i in o){var a=o[i],n=Array.prototype.slice.call(a.array);e.data.attributes[i]={itemSize:a.itemSize,type:a.array.constructor.name,array:n}}var s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new n.BufferGeometry).copy(this)},copy:function(e){var t=e.index;null!==t&&this.setIndex(t.clone());var i=e.attributes;for(var r in i){var n=i[r];this.addAttribute(r,n.clone())}for(var o=e.groups,a=0,s=o.length;s>a;a++){var c=o[a];this.addGroup(c.start,c.count)}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.BufferGeometry.prototype),n.BufferGeometry.MaxIndex=65535,n.InstancedBufferGeometry=function(){n.BufferGeometry.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0},n.InstancedBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.InstancedBufferGeometry.prototype.constructor=n.InstancedBufferGeometry,n.InstancedBufferGeometry.prototype.addGroup=function(e,t,i){this.groups.push({start:e,count:t,instances:i})},n.InstancedBufferGeometry.prototype.copy=function(e){var t=e.index;null!==t&&this.setIndex(t.clone());var i=e.attributes;for(var r in i){var n=i[r];this.addAttribute(r,n.clone())}for(var o=e.groups,a=0,s=o.length;s>a;a++){var c=o[a];this.addGroup(c.start,c.count,c.instances)}return this},n.EventDispatcher.prototype.apply(n.InstancedBufferGeometry.prototype),n.Uniform=function(e,t){this.type=e,this.value=t,this.dynamic=!1},n.Uniform.prototype={constructor:n.Uniform,onUpdate:function(e){return this.dynamic=!0,this.onUpdateCallback=e,this}},n.AnimationClip=function(e,t,i){this.name=e||n.Math.generateUUID(),this.tracks=i,this.duration=void 0!==t?t:-1,this.duration<0&&this.resetDuration(),this.trim(),this.optimize()},n.AnimationClip.prototype={constructor:n.AnimationClip,resetDuration:function(){for(var e=this.tracks,t=0,i=0,r=e.length;i!==r;++i){var n=this.tracks[i];t=Math.max(t,n.times[n.times.length-1])}this.duration=t},trim:function(){for(var e=0;ea;a++){var s=[],c=[];s.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);var h=n.AnimationUtils.getKeyframeOrder(s);s=n.AnimationUtils.sortedArray(s,1,h),c=n.AnimationUtils.sortedArray(c,1,h),0===s[0]&&(s.push(r),c.push(c[0])),o.push(new n.NumberKeyframeTrack(".morphTargetInfluences["+t[a].name+"]",s,c).scale(1/i))}return new n.AnimationClip(e,-1,o)},findByName:function(e,t){for(var i=0;io;o++){var s=e[o],c=s.name.match(r);if(c&&c.length>1){var h=c[1],l=i[h];l||(i[h]=l=[]),l.push(s)}}var u=[];for(var h in i)u.push(n.AnimationClip.CreateFromMorphTargetSequence(h,i[h],t));return u},parseAnimation:function(e,t){if(!e)return console.error(" no animation in JSONLoader data"),null;for(var i=function(e,t,i,r,o){if(0!==i.length){var a=[],s=[];n.AnimationUtils.flattenJSON(i,a,s,r),0!==a.length&&o.push(new e(t,a,s))}},r=[],o=e.name||"default",a=e.length||-1,s=e.fps||30,c=e.hierarchy||[],h=0;ho||0===i)return;this._startTime=null,t=i*o}t*=this._updateTimeScale(e);var a=this._updateTime(t),s=this._updateWeight(e);if(s>0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(a),h[l].accumulate(r,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.pause=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var i=this._clip.duration,r=this.loop,o=this._loopCount,a=!1;switch(r){case n.LoopOnce:if(-1===o&&(this.loopCount=0,this._setEndings(!0,!0,!1)),t>=i)t=i;else{if(!(0>t))break;t=0}this.clampWhenFinished?this.pause=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:0>e?-1:1});break;case n.LoopPingPong:a=!0;case n.LoopRepeat:if(-1===o&&(e>0?(o=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=i||0>t){var s=Math.floor(t/i);t-=i*s,o+=Math.abs(s);var c=this.repetitions-o;if(0>c){this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});break}if(0===c){var h=0>e;this._setEndings(h,!h,a)}else this._setEndings(!1,!1,a);this._loopCount=o,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:s})}if(r===n.LoopPingPong&&1===(1&o))return this.time=t,i-t}return this.time=t,t},_setEndings:function(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=n.ZeroSlopeEnding,r.endingEnd=n.ZeroSlopeEnding):(r.endingStart=e?this.zeroSlopeAtStart?n.ZeroSlopeEnding:n.ZeroCurvatureEnding:n.WrapAroundEnding,r.endingEnd=t?this.zeroSlopeAtEnd?n.ZeroSlopeEnding:n.ZeroCurvatureEnding:n.WrapAroundEnding)},_scheduleFading:function(e,t,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=t,a[1]=n+e,s[1]=i,this}},Object.assign(n.AnimationMixer.prototype,{_bindAction:function(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,o=r.length,a=e._propertyBindings,s=e._interpolants,c=i.uuid,h=this._bindingsByRootAndName,l=h[c];void 0===l&&(l={},h[c]=l);for(var u=0;u!==o;++u){var d=r[u],p=d.name,f=l[p];if(void 0!==f)a[u]=f;else{if(f=a[u],void 0!==f){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,c,p));continue}var m=t&&t._propertyBindings[u].binding.parsedPath;f=new n.PropertyMixer(n.PropertyBinding.create(i,p,m),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,c,p),a[u]=f}s[u].resultBuffer=f.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,i=e._clip.name,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}for(var n=e._propertyBindings,o=0,a=n.length;o!==a;++o){var s=n[o];0===s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0===--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tp){var v=e[p],g=--i,y=e[g];r[y.uuid]=p,e[p]=y,r[d]=g,e[g]=u;for(var f=0,m=c;f!==m;++f){var x=s[f],b=x[g],w=x[p];x[p]=b,void 0===w&&(w=new n.PropertyBinding(u,o[f],a[f])),x[g]=w}}else e[p]!==v&&console.error("Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes...")}this.nCachedObjects_=i},remove:function(){for(var e=this._objects,t=(e.length,this.nCachedObjects_),i=this._indicesByUUID,r=this._bindings,n=r.length,o=0,a=arguments.length;o!==a;++o){var s=arguments[o],c=s.uuid,h=i[c];if(void 0!==h&&h>=t){var l=t++,u=e[l];i[u.uuid]=h,e[h]=u,i[c]=l,e[l]=s;for(var d=0,p=n;d!==p;++d){var f=r[d],m=f[l],v=f[h];f[h]=m,f[l]=v}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,o=n.length,a=0,s=arguments.length;a!==s;++a){var c=arguments[a],h=c.uuid,l=r[h];if(void 0!==l)if(delete r[h],i>l){var u=--i,d=e[u],p=--t,f=e[p];r[d.uuid]=l,e[l]=d,r[f.uuid]=u,e[u]=f,e.pop();for(var m=0,v=o;m!==v;++m){var g=n[m],y=g[u],x=g[p];g[l]=y,g[u]=x,g.pop()}}else{var p=--t,f=e[p];r[f.uuid]=l,e[l]=f,e.pop();for(var m=0,v=o;m!==v;++m){var g=n[m];g[l]=g[p],g.pop()}}}this.nCachedObjects_=i},subscribe_:function(e,t){var i=this._bindingsIndicesByPath,r=i[e],o=this._bindings;if(void 0!==r)return o[r];var a=this._paths,s=this._parsedPaths,c=this._objects,h=c.length,l=this.nCachedObjects_,u=new Array(h);r=o.length,i[e]=r,a.push(e),s.push(t),o.push(u);for(var d=l,p=c.length;d!==p;++d){var f=c[d];u[d]=new n.PropertyBinding(f,e,t)}return u},unsubscribe_:function(e){var t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){var r=this._paths,n=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a],c=e[a];t[c]=i,o[i]=s,o.pop(),n[i]=n[a],n.pop(),r[i]=r[a],r.pop()}}},n.AnimationUtils={arraySlice:function(e,t,i){return n.AnimationUtils.isTypedArray(e)?new e.constructor(e.subarray(t,i)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){function t(t,i){return e[t]-e[i]}for(var i=e.length,r=new Array(i),n=0;n!==i;++n)r[n]=n;return r.sort(t),r},sortedArray:function(e,t,i){for(var r=e.length,n=new e.constructor(r),o=0,a=0;a!==r;++o)for(var s=i[o]*t,c=0;c!==t;++c)n[a++]=e[s+c];return n},flattenJSON:function(e,t,i,r){for(var n=1,o=e[0];void 0!==o&&void 0===o[r];)o=e[n++];if(void 0!==o){var a=o[r];if(void 0!==a)if(Array.isArray(a)){do a=o[r],void 0!==a&&(t.push(o.time),i.push.apply(i,a)),o=e[n++];while(void 0!==o)}else if(void 0!==a.toArray){do a=o[r],void 0!==a&&(t.push(o.time),a.toArray(i,i.length)),o=e[n++];while(void 0!==o)}else do a=o[r],void 0!==a&&(t.push(o.time),i.push(a)),o=e[n++];while(void 0!==o)}}},n.KeyframeTrack=function(e,t,i,r){if(void 0===e)throw new Error("track name is undefined");if(void 0===t||0===t.length)throw new Error("no keyframes in track named "+e);this.name=e,this.times=n.AnimationUtils.convertArray(t,this.TimeBufferType),this.values=n.AnimationUtils.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()},n.KeyframeTrack.prototype={constructor:n.KeyframeTrack,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:n.InterpolateLinear,InterpolantFactoryMethodDiscrete:function(e){return new n.DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodLinear:function(e){return new n.LinearInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:function(e){return new n.CubicInterpolant(this.times,this.values,this.getValueSize(),e)},setInterpolation:function(e){var t=void 0;switch(e){case n.InterpolateDiscrete:t=this.InterpolantFactoryMethodDiscrete;break;case n.InterpolateLinear:t=this.InterpolantFactoryMethodLinear;break;case n.InterpolateSmooth:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}return void console.warn(i)}this.createInterpolant=t},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return n.InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return n.InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return n.InterpolateSmooth}},getValueSize:function(){return this.values.length/this.times.length},shift:function(e){if(0!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]+=e;return this},scale:function(e){if(1!==e)for(var t=this.times,i=0,r=t.length;i!==r;++i)t[i]*=e;return this},trim:function(e,t){for(var i=this.times,r=i.length,o=0,a=r-1;o!==r&&i[o]t;)--a;if(++a,0!==o||a!==r){o>=a&&(a=Math.max(a,1),o=a-1);var s=this.getValueSize();this.times=n.AnimationUtils.arraySlice(i,o,a),this.values=n.AnimationUtils.arraySlice(this.values,o*s,a*s)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("invalid value size in track",this),e=!1);var i=this.times,r=this.values,o=i.length;0===o&&(console.error("track is empty",this),e=!1);for(var a=null,s=0;s!==o;s++){var c=i[s];if("number"==typeof c&&isNaN(c)){console.error("time is not a valid number",this,s,c),e=!1;break}if(null!==a&&a>c){console.error("out of order keys",this,s,c,a),e=!1;break}a=c}if(void 0!==r&&n.AnimationUtils.isTypedArray(r))for(var s=0,h=r.length;s!==h;++s){var l=r[s];if(isNaN(l)){console.error("value is not a valid number",this,s,l),e=!1;break}}return e},optimize:function(){for(var e=this.times,t=this.values,i=this.getValueSize(),r=1,o=1,a=e.length-1;a>=o;++o){var s=!1,c=e[o],h=e[o+1];if(c!==h&&(1!==o||c!==c[0]))for(var l=o*i,u=l-i,d=l+i,p=0;p!==i;++p){var f=t[l+p];if(f!==t[u+p]||f!==t[d+p]){s=!0;break}}if(s){if(o!==r){e[r]=e[o];for(var m=o*i,v=r*i,p=0;p!==i;++p)t[v+p]=t[m+p]}++r}}return r!==e.length&&(this.times=n.AnimationUtils.arraySlice(e,0,r),this.values=n.AnimationUtils.arraySlice(t,0,r*i)),this}},Object.assign(n.KeyframeTrack,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=n.KeyframeTrack._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){console.warn("legacy JSON format detected, converting");var i=[],r=[];n.AnimationUtils.flattenJSON(e.keys,i,r,"value"),e.times=i,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)},toJSON:function(e){var t,i=e.constructor;if(void 0!==i.toJSON)t=i.toJSON(e);else{t={name:e.name,times:n.AnimationUtils.convertArray(e.times,Array),values:n.AnimationUtils.convertArray(e.values,Array)};var r=e.getInterpolation();r!==e.DefaultInterpolation&&(t.interpolation=r)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return n.NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return n.VectorKeyframeTrack;case"color":return n.ColorKeyframeTrack;case"quaternion":return n.QuaternionKeyframeTrack;case"bool":case"boolean":return n.BooleanKeyframeTrack;case"string":return n.StringKeyframeTrack}throw new Error("Unsupported typeName: "+e)}}),n.PropertyBinding=function(e,t,i){this.path=t,this.parsedPath=i||n.PropertyBinding.parseTrackName(t),this.node=n.PropertyBinding.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e},n.PropertyBinding.prototype={constructor:n.PropertyBinding,getValue:function(e,t){this.bind(),this.getValue(e,t)},setValue:function(e,t){this.bind(),this.setValue(e,t)},bind:function(){var e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,o=t.propertyIndex;if(e||(e=n.PropertyBinding.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error(" trying to update node for track: "+this.path+" but it wasn't found.");if(i){var a=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error(" can not bind to material as node does not have a material",this);if(!e.material.materials)return void console.error(" can not bind to material.materials as node.material does not have a materials array",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error(" can not bind to bones as node does not have a skeleton",this);e=e.skeleton.bones;for(var s=0;sn){var a=3*t;this._mixBufferRegion(i,r,a,1-n,t)}for(var s=t,c=t+t;s!==c;++s)if(i[s]!==i[s+t]){o.setValue(i,r);break}},saveOriginalState:function(){var e=this.binding,t=this.buffer,i=this.valueSize,r=3*i;e.getValue(t,r);for(var n=i,o=r;n!==o;++n)t[n]=t[r+n%i];this.cumulativeWeight=0},restoreOriginalState:function(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)},_select:function(e,t,i,r,n){if(r>=.5)for(var o=0;o!==n;++o)e[t+o]=e[i+o]},_slerp:function(e,t,i,r){n.Quaternion.slerpFlat(e,t,e,t,e,i,r)},_lerp:function(e,t,i,r,n){for(var o=1-r,a=0;a!==n;++a){var s=t+a;e[s]=e[s]*o+e[i+a]*r}}},n.BooleanKeyframeTrack=function(e,t,i){n.KeyframeTrack.call(this,e,t,i)},n.BooleanKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.BooleanKeyframeTrack,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:n.IntepolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),n.NumberKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.NumberKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.NumberKeyframeTrack,ValueTypeName:"number"}),n.QuaternionKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.QuaternionKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:n.InterpolateLinear,InterpolantFactoryMethodLinear:function(e){return new n.QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),n.StringKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.StringKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:n.IntepolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),n.VectorKeyframeTrack=function(e,t,i,r){n.KeyframeTrack.call(this,e,t,i,r)},n.VectorKeyframeTrack.prototype=Object.assign(Object.create(n.KeyframeTrack.prototype),{constructor:n.VectorKeyframeTrack,ValueTypeName:"vector"}),n.Audio=function(e){n.Object3D.call(this),this.type="Audio",this.context=e.context,this.source=this.context.createBufferSource(),this.source.onended=this.onEnded.bind(this),this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filter=null},n.Audio.prototype=Object.create(n.Object3D.prototype),n.Audio.prototype.constructor=n.Audio,n.Audio.prototype.getOutput=function(){return this.gain},n.Audio.prototype.load=function(e){var t=new n.AudioBuffer(this.context);return t.load(e),this.setBuffer(t),this},n.Audio.prototype.setNodeSource=function(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this},n.Audio.prototype.setBuffer=function(e){var t=this;return e.onReady(function(e){t.source.buffer=e,t.sourceType="buffer",t.autoplay&&t.play()}),this},n.Audio.prototype.play=function(){if(this.isPlaying===!0)return void console.warn("THREE.Audio: Audio is already playing.");if(this.hasPlaybackControl===!1)return void console.warn("THREE.Audio: this Audio has no playback control.");var e=this.context.createBufferSource();e.buffer=this.source.buffer,e.loop=this.source.loop,e.onended=this.source.onended,e.start(0,this.startTime),e.playbackRate.value=this.playbackRate,this.isPlaying=!0,this.source=e,this.connect()},n.Audio.prototype.pause=function(){return this.hasPlaybackControl===!1?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),void(this.startTime=this.context.currentTime))},n.Audio.prototype.stop=function(){return this.hasPlaybackControl===!1?void console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),void(this.startTime=0))},n.Audio.prototype.connect=function(){null!==this.filter?(this.source.connect(this.filter),this.filter.connect(this.getOutput())):this.source.connect(this.getOutput())},n.Audio.prototype.disconnect=function(){null!==this.filter?(this.source.disconnect(this.filter),this.filter.disconnect(this.getOutput())):this.source.disconnect(this.getOutput())},n.Audio.prototype.getFilter=function(){return this.filter},n.Audio.prototype.setFilter=function(e){void 0===e&&(e=null),this.isPlaying===!0?(this.disconnect(),this.filter=e,this.connect()):this.filter=e},n.Audio.prototype.setPlaybackRate=function(e){return this.hasPlaybackControl===!1?void console.warn("THREE.Audio: this Audio has no playback control."):(this.playbackRate=e,void(this.isPlaying===!0&&(this.source.playbackRate.value=this.playbackRate)))},n.Audio.prototype.getPlaybackRate=function(){return this.playbackRate},n.Audio.prototype.onEnded=function(){this.isPlaying=!1},n.Audio.prototype.setLoop=function(e){return this.hasPlaybackControl===!1?void console.warn("THREE.Audio: this Audio has no playback control."):void(this.source.loop=e)},n.Audio.prototype.getLoop=function(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.source.loop},n.Audio.prototype.setVolume=function(e){this.gain.gain.value=e},n.Audio.prototype.getVolume=function(){return this.gain.gain.value},n.AudioAnalyser=function(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=void 0!==t?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)},n.AudioAnalyser.prototype={constructor:n.AudioAnalyser,getData:function(){return this.analyser.getByteFrequencyData(this.data),this.data}},n.AudioBuffer=function(e){this.context=e,this.ready=!1,this.readyCallbacks=[]},n.AudioBuffer.prototype.load=function(e){var t=this,i=new XMLHttpRequest;return i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){t.context.decodeAudioData(this.response,function(e){t.buffer=e,t.ready=!0;for(var i=0;ii;i+=2){var n=t[i],o=t[i+1];if(n.test(e))return o}return null}},n.XHRLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.XHRLoader.prototype={constructor:n.XHRLoader,load:function(e,t,i,r){void 0!==this.path&&(e=this.path+e);var o=this,a=n.Cache.get(e);if(void 0!==a)return t&&setTimeout(function(){t(a)},0),a;var s=new XMLHttpRequest;return s.overrideMimeType("text/plain"),s.open("GET",e,!0),s.addEventListener("load",function(i){var a=i.target.response;n.Cache.add(e,a),200===this.status?(t&&t(a),o.manager.itemEnd(e)):0===this.status?(console.warn("THREE.XHRLoader: HTTP Status 0 received."),t&&t(a),o.manager.itemEnd(e)):(r&&r(i),o.manager.itemError(e))},!1),void 0!==i&&s.addEventListener("progress",function(e){i(e)},!1),s.addEventListener("error",function(t){r&&r(t),o.manager.itemError(e)},!1),void 0!==this.responseType&&(s.responseType=this.responseType),void 0!==this.withCredentials&&(s.withCredentials=this.withCredentials),s.send(null),o.manager.itemStart(e),s},setPath:function(e){this.path=e},setResponseType:function(e){this.responseType=e},setWithCredentials:function(e){this.withCredentials=e}},n.FontLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.FontLoader.prototype={constructor:n.FontLoader,load:function(e,t,i,r){var o=new n.XHRLoader(this.manager);o.load(e,function(e){t(new n.Font(JSON.parse(e.substring(65,e.length-2))))},i,r)}},n.ImageLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.ImageLoader.prototype={constructor:n.ImageLoader,load:function(e,t,i,r){void 0!==this.path&&(e=this.path+e);var o=this,a=n.Cache.get(e);if(void 0!==a)return o.manager.itemStart(e),t?setTimeout(function(){t(a),o.manager.itemEnd(e)},0):o.manager.itemEnd(e),a;var s=document.createElement("img");return s.addEventListener("load",function(){n.Cache.add(e,this),t&&t(this),o.manager.itemEnd(e)},!1),void 0!==i&&s.addEventListener("progress",function(e){i(e)},!1),s.addEventListener("error",function(t){r&&r(t),o.manager.itemError(e)},!1),void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),o.manager.itemStart(e),s.src=e,s},setCrossOrigin:function(e){this.crossOrigin=e},setPath:function(e){this.path=e}},n.JSONLoader=function(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:n.DefaultLoadingManager,this.withCredentials=!1},n.JSONLoader.prototype={constructor:n.JSONLoader,get statusDomElement(){return void 0===this._statusDomElement&&(this._statusDomElement=document.createElement("div")),console.warn("THREE.JSONLoader: .statusDomElement has been removed."),this._statusDomElement},load:function(e,t,i,r){var o=this,a=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:n.Loader.prototype.extractUrlBase(e),s=new n.XHRLoader(this.manager);s.setWithCredentials(this.withCredentials),s.load(e,function(i){var r=JSON.parse(i),n=r.metadata;if(void 0!==n){var s=n.type;if(void 0!==s){if("object"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+e+" should be loaded with THREE.ObjectLoader instead.");if("scene"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+e+" should be loaded with THREE.SceneLoader instead.")}}var c=o.parse(r,a);t(c.geometry,c.materials)},i,r)},setTexturePath:function(e){this.texturePath=e},parse:function(e,t){function i(t){function i(e,t){return e&1<r;r++)s.faceVertexUvs[r]=[]}for(c=0,h=O.length;h>c;)M=new n.Vector3,M.x=O[c++]*t,M.y=O[c++]*t,M.z=O[c++]*t,s.vertices.push(M);for(c=0,h=D.length;h>c;)if(f=D[c++],m=i(f,0),v=i(f,1),g=i(f,3),y=i(f,4),x=i(f,5),b=i(f,6),w=i(f,7),m){if(E=new n.Face3,E.a=D[c],E.b=D[c+1],E.c=D[c+3],A=new n.Face3,A.a=D[c+1],A.b=D[c+2],A.c=D[c+3],c+=4,v&&(p=D[c++],E.materialIndex=p,A.materialIndex=p),a=s.faces.length,g)for(r=0;N>r;r++)for(C=e.uvs[r],s.faceVertexUvs[r][a]=[],s.faceVertexUvs[r][a+1]=[],o=0;4>o;o++)d=D[c++],R=C[2*d],P=C[2*d+1],L=new n.Vector2(R,P),2!==o&&s.faceVertexUvs[r][a].push(L),0!==o&&s.faceVertexUvs[r][a+1].push(L);if(y&&(u=3*D[c++],E.normal.set(I[u++],I[u++],I[u]),A.normal.copy(E.normal)),x)for(r=0;4>r;r++)u=3*D[c++],T=new n.Vector3(I[u++],I[u++],I[u]),2!==r&&E.vertexNormals.push(T),0!==r&&A.vertexNormals.push(T);if(b&&(l=D[c++],S=k[l],E.color.setHex(S),A.color.setHex(S)),w)for(r=0;4>r;r++)l=D[c++],S=k[l],2!==r&&E.vertexColors.push(new n.Color(S)),0!==r&&A.vertexColors.push(new n.Color(S));s.faces.push(E),s.faces.push(A)}else{if(_=new n.Face3,_.a=D[c++],_.b=D[c++],_.c=D[c++],v&&(p=D[c++],_.materialIndex=p), a=s.faces.length,g)for(r=0;N>r;r++)for(C=e.uvs[r],s.faceVertexUvs[r][a]=[],o=0;3>o;o++)d=D[c++],R=C[2*d],P=C[2*d+1],L=new n.Vector2(R,P),s.faceVertexUvs[r][a].push(L);if(y&&(u=3*D[c++],_.normal.set(I[u++],I[u++],I[u])),x)for(r=0;3>r;r++)u=3*D[c++],T=new n.Vector3(I[u++],I[u++],I[u]),_.vertexNormals.push(T);if(b&&(l=D[c++],_.color.setHex(k[l])),w)for(r=0;3>r;r++)l=D[c++],_.vertexColors.push(new n.Color(k[l]));s.faces.push(_)}}function r(){var t=void 0!==e.influencesPerVertex?e.influencesPerVertex:2;if(e.skinWeights)for(var i=0,r=e.skinWeights.length;r>i;i+=t){var o=e.skinWeights[i],a=t>1?e.skinWeights[i+1]:0,c=t>2?e.skinWeights[i+2]:0,h=t>3?e.skinWeights[i+3]:0;s.skinWeights.push(new n.Vector4(o,a,c,h))}if(e.skinIndices)for(var i=0,r=e.skinIndices.length;r>i;i+=t){var l=e.skinIndices[i],u=t>1?e.skinIndices[i+1]:0,d=t>2?e.skinIndices[i+2]:0,p=t>3?e.skinIndices[i+3]:0;s.skinIndices.push(new n.Vector4(l,u,d,p))}s.bones=e.bones,s.bones&&s.bones.length>0&&(s.skinWeights.length!==s.skinIndices.length||s.skinIndices.length!==s.vertices.length)&&console.warn("When skinning, number of vertices ("+s.vertices.length+"), skinIndices ("+s.skinIndices.length+"), and skinWeights ("+s.skinWeights.length+") should match.")}function o(t){if(void 0!==e.morphTargets)for(var i=0,r=e.morphTargets.length;r>i;i++){s.morphTargets[i]={},s.morphTargets[i].name=e.morphTargets[i].name,s.morphTargets[i].vertices=[];for(var o=s.morphTargets[i].vertices,a=e.morphTargets[i].vertices,c=0,h=a.length;h>c;c+=3){var l=new n.Vector3;l.x=a[c]*t,l.y=a[c+1]*t,l.z=a[c+2]*t,o.push(l)}}if(void 0!==e.morphColors&&e.morphColors.length>0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var u=s.faces,d=e.morphColors[0].colors,i=0,r=u.length;r>i;i++)u[i].color.fromArray(d,3*i)}}function a(){var t=[],i=[];void 0!==e.animation&&i.push(e.animation),void 0!==e.animations&&(e.animations.length?i=i.concat(e.animations):i.push(e.animations));for(var r=0;r0&&(s.animations=t)}var s=new n.Geometry,c=void 0!==e.scale?1/e.scale:1;if(i(c),r(),o(c),a(),s.computeFaceNormals(),s.computeBoundingSphere(),void 0===e.materials||0===e.materials.length)return{geometry:s};var h=n.Loader.prototype.initMaterials(e.materials,t,this.crossOrigin);return{geometry:s,materials:h}}},n.LoadingManager=function(e,t,i){var r=this,n=!1,o=0,a=0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){a++,n===!1&&void 0!==r.onStart&&r.onStart(e,o,a),n=!0},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,a),o===a&&(n=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)}},n.DefaultLoadingManager=new n.LoadingManager,n.BufferGeometryLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager},n.BufferGeometryLoader.prototype={constructor:n.BufferGeometryLoader,load:function(e,t,i,r){var o=this,a=new n.XHRLoader(o.manager);a.load(e,function(e){t(o.parse(JSON.parse(e)))},i,r)},parse:function(e){var t=new n.BufferGeometry,i=e.data.index,r={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};if(void 0!==i){var o=new r[i.type](i.array);t.setIndex(new n.BufferAttribute(o,1))}var a=e.data.attributes;for(var s in a){var c=a[s],o=new r[c.type](c.array);t.addAttribute(s,new n.BufferAttribute(o,c.itemSize))}var h=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==h)for(var l=0,u=h.length;l!==u;++l){var d=h[l];t.addGroup(d.start,d.count,d.materialIndex)}var p=e.data.boundingSphere;if(void 0!==p){var f=new n.Vector3;void 0!==p.center&&f.fromArray(p.center),t.boundingSphere=new n.Sphere(f,p.radius)}return t}},n.MaterialLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager,this.textures={}},n.MaterialLoader.prototype={constructor:n.MaterialLoader,load:function(e,t,i,r){var o=this,a=new n.XHRLoader(o.manager);a.load(e,function(e){t(o.parse(JSON.parse(e)))},i,r)},setTextures:function(e){this.textures=e},getTexture:function(e){var t=this.textures;return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]},parse:function(e){var t=new n[e.type];if(void 0!==e.uuid&&(t.uuid=e.uuid),void 0!==e.name&&(t.name=e.name),void 0!==e.color&&t.color.setHex(e.color),void 0!==e.roughness&&(t.roughness=e.roughness),void 0!==e.metalness&&(t.metalness=e.metalness),void 0!==e.emissive&&t.emissive.setHex(e.emissive),void 0!==e.specular&&t.specular.setHex(e.specular),void 0!==e.shininess&&(t.shininess=e.shininess),void 0!==e.uniforms&&(t.uniforms=e.uniforms),void 0!==e.vertexShader&&(t.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(t.fragmentShader=e.fragmentShader),void 0!==e.vertexColors&&(t.vertexColors=e.vertexColors),void 0!==e.shading&&(t.shading=e.shading),void 0!==e.blending&&(t.blending=e.blending),void 0!==e.side&&(t.side=e.side),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.transparent&&(t.transparent=e.transparent),void 0!==e.alphaTest&&(t.alphaTest=e.alphaTest),void 0!==e.depthTest&&(t.depthTest=e.depthTest),void 0!==e.depthWrite&&(t.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(t.colorWrite=e.colorWrite),void 0!==e.wireframe&&(t.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(t.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.size&&(t.size=e.size),void 0!==e.sizeAttenuation&&(t.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(t.map=this.getTexture(e.map)),void 0!==e.alphaMap&&(t.alphaMap=this.getTexture(e.alphaMap),t.transparent=!0),void 0!==e.bumpMap&&(t.bumpMap=this.getTexture(e.bumpMap)),void 0!==e.bumpScale&&(t.bumpScale=e.bumpScale),void 0!==e.normalMap&&(t.normalMap=this.getTexture(e.normalMap)),void 0!==e.normalScale){var i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),t.normalScale=(new n.Vector2).fromArray(i)}if(void 0!==e.displacementMap&&(t.displacementMap=this.getTexture(e.displacementMap)),void 0!==e.displacementScale&&(t.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(t.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(t.roughnessMap=this.getTexture(e.roughnessMap)),void 0!==e.metalnessMap&&(t.metalnessMap=this.getTexture(e.metalnessMap)),void 0!==e.emissiveMap&&(t.emissiveMap=this.getTexture(e.emissiveMap)),void 0!==e.emissiveIntensity&&(t.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(t.specularMap=this.getTexture(e.specularMap)),void 0!==e.envMap&&(t.envMap=this.getTexture(e.envMap),t.combine=n.MultiplyOperation),e.reflectivity&&(t.reflectivity=e.reflectivity),void 0!==e.lightMap&&(t.lightMap=this.getTexture(e.lightMap)),void 0!==e.lightMapIntensity&&(t.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(t.aoMap=this.getTexture(e.aoMap)),void 0!==e.aoMapIntensity&&(t.aoMapIntensity=e.aoMapIntensity),void 0!==e.materials)for(var r=0,o=e.materials.length;o>r;r++)t.materials.push(this.parse(e.materials[r]));return t}},n.ObjectLoader=function(e){this.manager=void 0!==e?e:n.DefaultLoadingManager,this.texturePath=""},n.ObjectLoader.prototype={constructor:n.ObjectLoader,load:function(e,t,i,r){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var o=this,a=new n.XHRLoader(o.manager);a.load(e,function(e){o.parse(JSON.parse(e),t)},i,r)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var i=this.parseGeometries(e.geometries),r=this.parseImages(e.images,function(){void 0!==t&&t(a)}),n=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,n),a=this.parseObject(e.object,i,o);return e.animations&&(a.animations=this.parseAnimations(e.animations)),(void 0===e.images||0===e.images.length)&&void 0!==t&&t(a),a},parseGeometries:function(e){var t={};if(void 0!==e)for(var i=new n.JSONLoader,r=new n.BufferGeometryLoader,o=0,a=e.length;a>o;o++){var s,c=e[o];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new n[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":s=new n[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new n[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new n[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new n[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":s=new n.DodecahedronGeometry(c.radius,c.detail);break;case"IcosahedronGeometry":s=new n.IcosahedronGeometry(c.radius,c.detail);break;case"OctahedronGeometry":s=new n.OctahedronGeometry(c.radius,c.detail);break;case"TetrahedronGeometry":s=new n.TetrahedronGeometry(c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new n[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new n[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new n[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"LatheGeometry":s=new n.LatheGeometry(c.points,c.segments,c.phiStart,c.phiLength);break;case"BufferGeometry":s=r.parse(c);break;case"Geometry":s=i.parse(c.data,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}s.uuid=c.uuid,void 0!==c.name&&(s.name=c.name),t[c.uuid]=s}return t},parseMaterials:function(e,t){var i={};if(void 0!==e){var r=new n.MaterialLoader;r.setTextures(t);for(var o=0,a=e.length;a>o;o++){var s=r.parse(e[o]);i[s.uuid]=s}}return i},parseAnimations:function(e){for(var t=[],i=0;i0){var a=new n.LoadingManager(t),s=new n.ImageLoader(a);s.setCrossOrigin(this.crossOrigin);for(var c=0,h=e.length;h>c;c++){var l=e[c],u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l.url)?l.url:r.texturePath+l.url;o[l.uuid]=i(u)}}return o},parseTextures:function(e,t){function i(e){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),n[e])}var r={};if(void 0!==e)for(var o=0,a=e.length;a>o;o++){var s=e[o];void 0===s.image&&console.warn('THREE.ObjectLoader: No "image" specified for',s.uuid),void 0===t[s.image]&&console.warn("THREE.ObjectLoader: Undefined image",s.image);var c=new n.Texture(t[s.image]);c.needsUpdate=!0,c.uuid=s.uuid,void 0!==s.name&&(c.name=s.name),void 0!==s.mapping&&(c.mapping=i(s.mapping)),void 0!==s.offset&&(c.offset=new n.Vector2(s.offset[0],s.offset[1])),void 0!==s.repeat&&(c.repeat=new n.Vector2(s.repeat[0],s.repeat[1])),void 0!==s.minFilter&&(c.minFilter=i(s.minFilter)),void 0!==s.magFilter&&(c.magFilter=i(s.magFilter)),void 0!==s.anisotropy&&(c.anisotropy=s.anisotropy),Array.isArray(s.wrap)&&(c.wrapS=i(s.wrap[0]),c.wrapT=i(s.wrap[1])),r[s.uuid]=c}return r},parseObject:function(){var e=new n.Matrix4;return function(t,i,r){function o(e){return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),i[e]}function a(e){return void 0===e?void 0:(void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),r[e])}var s;switch(t.type){case"Scene":s=new n.Scene;break;case"PerspectiveCamera":s=new n.PerspectiveCamera(t.fov,t.aspect,t.near,t.far);break;case"OrthographicCamera":s=new n.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far);break;case"AmbientLight":s=new n.AmbientLight(t.color,t.intensity);break;case"DirectionalLight":s=new n.DirectionalLight(t.color,t.intensity);break;case"PointLight":s=new n.PointLight(t.color,t.intensity,t.distance,t.decay);break;case"SpotLight":s=new n.SpotLight(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":s=new n.HemisphereLight(t.color,t.groundColor,t.intensity);break;case"Mesh":var c=o(t.geometry),h=a(t.material);s=c.bones&&c.bones.length>0?new n.SkinnedMesh(c,h):new n.Mesh(c,h);break;case"LOD":s=new n.LOD;break;case"Line":s=new n.Line(o(t.geometry),a(t.material),t.mode);break;case"PointCloud":case"Points":s=new n.Points(o(t.geometry),a(t.material));break;case"Sprite":s=new n.Sprite(a(t.material));break;case"Group":s=new n.Group;break;default:s=new n.Object3D}if(s.uuid=t.uuid,void 0!==t.name&&(s.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(s.position,s.quaternion,s.scale)):(void 0!==t.position&&s.position.fromArray(t.position),void 0!==t.rotation&&s.rotation.fromArray(t.rotation),void 0!==t.scale&&s.scale.fromArray(t.scale)),void 0!==t.castShadow&&(s.castShadow=t.castShadow),void 0!==t.receiveShadow&&(s.receiveShadow=t.receiveShadow),void 0!==t.visible&&(s.visible=t.visible),void 0!==t.userData&&(s.userData=t.userData),void 0!==t.children)for(var l in t.children)s.add(this.parseObject(t.children[l],i,r));if("LOD"===t.type)for(var u=t.levels,d=0;du;++u)o(u);else h.load(e,function(e){var i=a._parser(e,!0);if(i.isCubemap)for(var r=i.mipmaps.length/i.mipmapCount,o=0;r>o;o++){s[o]={mipmaps:[]};for(var h=0;h0&&(r.alphaTest=this.alphaTest),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),i){var o=t(e.textures),a=t(e.images);o.length>0&&(r.textures=o),a.length>0&&(r.images=a)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.side=e.side,this.opacity=e.opacity,this.transparent=e.transparent,this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.Material.prototype),n.MaterialIdCount=0,n.LineBasicMaterial=function(e){n.Material.call(this),this.type="LineBasicMaterial",this.color=new n.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.blending=n.NormalBlending,this.vertexColors=n.NoColors,this.fog=!0,this.setValues(e)},n.LineBasicMaterial.prototype=Object.create(n.Material.prototype),n.LineBasicMaterial.prototype.constructor=n.LineBasicMaterial,n.LineBasicMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.vertexColors=e.vertexColors,this.fog=e.fog,this},n.LineDashedMaterial=function(e){n.Material.call(this),this.type="LineDashedMaterial",this.color=new n.Color(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.blending=n.NormalBlending,this.vertexColors=n.NoColors,this.fog=!0,this.setValues(e)},n.LineDashedMaterial.prototype=Object.create(n.Material.prototype),n.LineDashedMaterial.prototype.constructor=n.LineDashedMaterial,n.LineDashedMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.linewidth=e.linewidth,this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this.vertexColors=e.vertexColors,this.fog=e.fog,this},n.MeshBasicMaterial=function(e){n.Material.call(this),this.type="MeshBasicMaterial",this.color=new n.Color(16777215),this.map=null,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=n.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=n.SmoothShading,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.setValues(e)},n.MeshBasicMaterial.prototype=Object.create(n.Material.prototype),n.MeshBasicMaterial.prototype.constructor=n.MeshBasicMaterial,n.MeshBasicMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.shading=e.shading,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},n.MeshLambertMaterial=function(e){n.Material.call(this),this.type="MeshLambertMaterial",this.color=new n.Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new n.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=n.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},n.MeshLambertMaterial.prototype=Object.create(n.Material.prototype),n.MeshLambertMaterial.prototype.constructor=n.MeshLambertMaterial,n.MeshLambertMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},n.MeshPhongMaterial=function(e){n.Material.call(this),this.type="MeshPhongMaterial",this.color=new n.Color(16777215),this.specular=new n.Color(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new n.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n.Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=n.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=n.SmoothShading,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},n.MeshPhongMaterial.prototype=Object.create(n.Material.prototype),n.MeshPhongMaterial.prototype.constructor=n.MeshPhongMaterial,n.MeshPhongMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.shading=e.shading,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},n.MeshStandardMaterial=function(e){n.Material.call(this),this.type="MeshStandardMaterial",this.color=new n.Color(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new n.Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new n.Vector2(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.fog=!0,this.shading=n.SmoothShading,this.blending=n.NormalBlending,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=n.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)},n.MeshStandardMaterial.prototype=Object.create(n.Material.prototype),n.MeshStandardMaterial.prototype.constructor=n.MeshStandardMaterial,n.MeshStandardMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.fog=e.fog,this.shading=e.shading,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.vertexColors=e.vertexColors,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},n.MeshDepthMaterial=function(e){n.Material.call(this),this.type="MeshDepthMaterial",this.morphTargets=!1,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)},n.MeshDepthMaterial.prototype=Object.create(n.Material.prototype),n.MeshDepthMaterial.prototype.constructor=n.MeshDepthMaterial,n.MeshDepthMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},n.MeshNormalMaterial=function(e){n.Material.call(this,e),this.type="MeshNormalMaterial",this.wireframe=!1,this.wireframeLinewidth=1,this.morphTargets=!1,this.setValues(e)},n.MeshNormalMaterial.prototype=Object.create(n.Material.prototype),n.MeshNormalMaterial.prototype.constructor=n.MeshNormalMaterial,n.MeshNormalMaterial.prototype.copy=function(e){return n.Material.prototype.copy.call(this,e),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},n.MultiMaterial=function(e){this.uuid=n.Math.generateUUID(),this.type="MultiMaterial",this.materials=e instanceof Array?e:[],this.visible=!0},n.MultiMaterial.prototype={constructor:n.MultiMaterial,toJSON:function(e){for(var t={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},i=this.materials,r=0,n=i.length;n>r;r++){var o=i[r].toJSON(e);delete o.metadata,t.materials.push(o)}return t.visible=this.visible,t},clone:function(){for(var e=new this.constructor,t=0;t2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}if(void 0!==e.textures[this.uuid])return e.textures[this.uuid];var i={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy};if(void 0!==this.image){var r=this.image;void 0===r.uuid&&(r.uuid=n.Math.generateUUID()),void 0===e.images[r.uuid]&&(e.images[r.uuid]={uuid:r.uuid,url:t(r)}),i.image=r.uuid}return e.textures[this.uuid]=i,i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping===n.UVMapping){if(e.multiply(this.repeat),e.add(this.offset),e.x<0||e.x>1)switch(this.wrapS){case n.RepeatWrapping:e.x=e.x-Math.floor(e.x);break;case n.ClampToEdgeWrapping:e.x=e.x<0?0:1;break;case n.MirroredRepeatWrapping:e.x=1===Math.abs(Math.floor(e.x)%2)?Math.ceil(e.x)-e.x:e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case n.RepeatWrapping:e.y=e.y-Math.floor(e.y);break;case n.ClampToEdgeWrapping:e.y=e.y<0?0:1;break;case n.MirroredRepeatWrapping:e.y=1===Math.abs(Math.floor(e.y)%2)?Math.ceil(e.y)-e.y:e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}},n.EventDispatcher.prototype.apply(n.Texture.prototype),n.TextureIdCount=0,n.CanvasTexture=function(e,t,i,r,o,a,s,c,h){n.Texture.call(this,e,t,i,r,o,a,s,c,h),this.needsUpdate=!0},n.CanvasTexture.prototype=Object.create(n.Texture.prototype),n.CanvasTexture.prototype.constructor=n.CanvasTexture,n.CubeTexture=function(e,t,i,r,o,a,s,c,h){e=void 0!==e?e:[],t=void 0!==t?t:n.CubeReflectionMapping,n.Texture.call(this,e,t,i,r,o,a,s,c,h),this.flipY=!1},n.CubeTexture.prototype=Object.create(n.Texture.prototype),n.CubeTexture.prototype.constructor=n.CubeTexture,Object.defineProperty(n.CubeTexture.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}}),n.CompressedTexture=function(e,t,i,r,o,a,s,c,h,l,u){n.Texture.call(this,null,a,s,c,h,l,r,o,u),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1},n.CompressedTexture.prototype=Object.create(n.Texture.prototype),n.CompressedTexture.prototype.constructor=n.CompressedTexture,n.DataTexture=function(e,t,i,r,o,a,s,c,h,l,u){n.Texture.call(this,null,a,s,c,h,l,r,o,u),this.image={data:e,width:t,height:i},this.magFilter=void 0!==h?h:n.NearestFilter,this.minFilter=void 0!==l?l:n.NearestFilter,this.flipY=!1,this.generateMipmaps=!1},n.DataTexture.prototype=Object.create(n.Texture.prototype),n.DataTexture.prototype.constructor=n.DataTexture,n.VideoTexture=function(e,t,i,r,o,a,s,c,h){function l(){requestAnimationFrame(l),e.readyState===e.HAVE_ENOUGH_DATA&&(u.needsUpdate=!0)}n.Texture.call(this,e,t,i,r,o,a,s,c,h),this.generateMipmaps=!1;var u=this;l()},n.VideoTexture.prototype=Object.create(n.Texture.prototype),n.VideoTexture.prototype.constructor=n.VideoTexture,n.Group=function(){n.Object3D.call(this),this.type="Group"},n.Group.prototype=Object.create(n.Object3D.prototype),n.Group.prototype.constructor=n.Group,n.Points=function(e,t){n.Object3D.call(this),this.type="Points",this.geometry=void 0!==e?e:new n.Geometry,this.material=void 0!==t?t:new n.PointsMaterial({color:16777215*Math.random()})},n.Points.prototype=Object.create(n.Object3D.prototype),n.Points.prototype.constructor=n.Points,n.Points.prototype.raycast=function(){var e=new n.Matrix4,t=new n.Ray,i=new n.Sphere;return function(r,o){function a(e,i){var n=t.distanceSqToPoint(e);if(d>n){var a=t.closestPointToPoint(e);a.applyMatrix4(h);var c=r.ray.origin.distanceTo(a);if(cr.far)return;o.push({distance:c,distanceToRay:Math.sqrt(n),point:a.clone(),index:i,face:null,object:s})}}var s=this,c=this.geometry,h=this.matrixWorld,l=r.params.Points.threshold;if(null===c.boundingSphere&&c.computeBoundingSphere(),i.copy(c.boundingSphere),i.applyMatrix4(h),r.ray.intersectsSphere(i)!==!1){e.getInverse(h),t.copy(r.ray).applyMatrix4(e);var u=l/((this.scale.x+this.scale.y+this.scale.z)/3),d=u*u,p=new n.Vector3;if(c instanceof n.BufferGeometry){var f=c.index,m=c.attributes,v=m.position.array;if(null!==f)for(var g=f.array,y=0,x=g.length;x>y;y++){var b=g[y];p.fromArray(v,3*b),a(p,b)}else for(var y=0,w=v.length/3;w>y;y++)p.fromArray(v,3*y),a(p,y)}else for(var M=c.vertices,y=0,w=M.length;w>y;y++)a(M[y],y)}}}(),n.Points.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},n.Line=function(e,t,i){return 1===i?(console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new n.LineSegments(e,t)):(n.Object3D.call(this),this.type="Line",this.geometry=void 0!==e?e:new n.Geometry,void(this.material=void 0!==t?t:new n.LineBasicMaterial({color:16777215*Math.random()})))},n.Line.prototype=Object.create(n.Object3D.prototype),n.Line.prototype.constructor=n.Line,n.Line.prototype.raycast=function(){var e=new n.Matrix4,t=new n.Ray,i=new n.Sphere;return function(r,o){var a=r.linePrecision,s=a*a,c=this.geometry,h=this.matrixWorld;if(null===c.boundingSphere&&c.computeBoundingSphere(),i.copy(c.boundingSphere),i.applyMatrix4(h),r.ray.intersectsSphere(i)!==!1){e.getInverse(h),t.copy(r.ray).applyMatrix4(e);var l=new n.Vector3,u=new n.Vector3,d=new n.Vector3,p=new n.Vector3,f=this instanceof n.LineSegments?2:1;if(c instanceof n.BufferGeometry){var m=c.index,v=c.attributes,g=v.position.array;if(null!==m)for(var y=m.array,x=0,b=y.length-1;b>x;x+=f){var w=y[x],M=y[x+1];l.fromArray(g,3*w),u.fromArray(g,3*M);var _=t.distanceSqToSegment(l,u,p,d);if(!(_>s)){p.applyMatrix4(this.matrixWorld);var E=r.ray.origin.distanceTo(p);Er.far||o.push({distance:E,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}else for(var x=0,b=g.length/3-1;b>x;x+=f){l.fromArray(g,3*x),u.fromArray(g,3*x+3);var _=t.distanceSqToSegment(l,u,p,d);if(!(_>s)){p.applyMatrix4(this.matrixWorld);var E=r.ray.origin.distanceTo(p);Er.far||o.push({distance:E,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}else if(c instanceof n.Geometry)for(var A=c.vertices,S=A.length,x=0;S-1>x;x+=f){var _=t.distanceSqToSegment(A[x],A[x+1],p,d);if(!(_>s)){p.applyMatrix4(this.matrixWorld);var E=r.ray.origin.distanceTo(p);Er.far||o.push({distance:E,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}}}(),n.Line.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},n.LineStrip=0,n.LinePieces=1,n.LineSegments=function(e,t){n.Line.call(this,e,t),this.type="LineSegments"},n.LineSegments.prototype=Object.create(n.Line.prototype),n.LineSegments.prototype.constructor=n.LineSegments,n.Mesh=function(e,t){n.Object3D.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new n.Geometry,this.material=void 0!==t?t:new n.MeshBasicMaterial({color:16777215*Math.random()}),this.drawMode=n.TrianglesDrawMode,this.updateMorphTargets()},n.Mesh.prototype=Object.create(n.Object3D.prototype),n.Mesh.prototype.constructor=n.Mesh,n.Mesh.prototype.setDrawMode=function(e){this.drawMode=e},n.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&this.geometry.morphTargets.length>0){this.morphTargetBase=-1,this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,t=this.geometry.morphTargets.length;t>e;e++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[e].name]=e}},n.Mesh.prototype.getMorphTargetIndexByName=function(e){return void 0!==this.morphTargetDictionary[e]?this.morphTargetDictionary[e]:(console.warn("THREE.Mesh.getMorphTargetIndexByName: morph target "+e+" does not exist. Returning 0."),0)},n.Mesh.prototype.raycast=function(){function e(e,t,i,r,o,a,s){return n.Triangle.barycoordFromPoint(e,t,i,r,v),o.multiplyScalar(v.x),a.multiplyScalar(v.y),s.multiplyScalar(v.z),o.add(a).add(s),o.clone()}function t(e,t,i,r,o,a,s){var c,h=e.material;if(c=h.side===n.BackSide?i.intersectTriangle(a,o,r,!0,s):i.intersectTriangle(r,o,a,h.side!==n.DoubleSide,s),null===c)return null;y.copy(s),y.applyMatrix4(e.matrixWorld);var l=t.ray.origin.distanceTo(y);return lt.far?null:{distance:l,point:y.clone(),object:e}}function i(i,r,o,a,l,u,d,v){s.fromArray(a,3*u),c.fromArray(a,3*d),h.fromArray(a,3*v);var y=t(i,r,o,s,c,h,g);return y&&(l&&(p.fromArray(l,2*u),f.fromArray(l,2*d),m.fromArray(l,2*v),y.uv=e(g,s,c,h,p,f,m)),y.face=new n.Face3(u,d,v,n.Triangle.normal(s,c,h)),y.faceIndex=u),y}var r=new n.Matrix4,o=new n.Ray,a=new n.Sphere,s=new n.Vector3,c=new n.Vector3,h=new n.Vector3,l=new n.Vector3,u=new n.Vector3,d=new n.Vector3,p=new n.Vector2,f=new n.Vector2,m=new n.Vector2,v=new n.Vector3,g=new n.Vector3,y=new n.Vector3;return function(v,y){var x=this.geometry,b=this.material,w=this.matrixWorld;if(void 0!==b&&(null===x.boundingSphere&&x.computeBoundingSphere(),a.copy(x.boundingSphere),a.applyMatrix4(w),v.ray.intersectsSphere(a)!==!1&&(r.getInverse(w),o.copy(v.ray).applyMatrix4(r),null===x.boundingBox||o.intersectsBox(x.boundingBox)!==!1))){var M,_;if(x instanceof n.BufferGeometry){var E,A,S,T=x.index,C=x.attributes,L=C.position.array;if(void 0!==C.uv&&(M=C.uv.array),null!==T)for(var R=T.array,P=0,D=R.length;D>P;P+=3)E=R[P],A=R[P+1],S=R[P+2],_=i(this,v,o,L,M,E,A,S),_&&(_.faceIndex=Math.floor(P/3),y.push(_));else for(var P=0,D=L.length;D>P;P+=9)E=P/3,A=E+1,S=E+2,_=i(this,v,o,L,M,E,A,S),_&&(_.index=E,y.push(_))}else if(x instanceof n.Geometry){var O,I,k,N=b instanceof n.MultiMaterial,B=N===!0?b.materials:null,F=x.vertices,V=x.faces,U=x.faceVertexUvs[0];U.length>0&&(M=U);for(var z=0,j=V.length;j>z;z++){var G=V[z],H=N===!0?B[G.materialIndex]:b;if(void 0!==H){if(O=F[G.a],I=F[G.b],k=F[G.c],H.morphTargets===!0){var W=x.morphTargets,q=this.morphTargetInfluences;s.set(0,0,0),c.set(0,0,0),h.set(0,0,0);for(var X=0,Y=W.length;Y>X;X++){var Q=q[X];if(0!==Q){var K=W[X].vertices;s.addScaledVector(l.subVectors(K[G.a],O),Q),c.addScaledVector(u.subVectors(K[G.b],I),Q),h.addScaledVector(d.subVectors(K[G.c],k),Q)}}s.add(O),c.add(I),h.add(k),O=s,I=c,k=h}if(_=t(this,v,o,O,I,k,g)){if(M){var Z=M[z];p.copy(Z[0]),f.copy(Z[1]),m.copy(Z[2]),_.uv=e(g,O,I,k,p,f,m)}_.face=G,_.faceIndex=z,y.push(_)}}}}}}}(),n.Mesh.prototype.clone=function(){return new this.constructor(this.geometry,this.material).copy(this)},n.Bone=function(e){n.Object3D.call(this),this.type="Bone",this.skin=e},n.Bone.prototype=Object.create(n.Object3D.prototype),n.Bone.prototype.constructor=n.Bone,n.Bone.prototype.copy=function(e){return n.Object3D.prototype.copy.call(this,e),this.skin=e.skin,this},n.Skeleton=function(e,t,i){if(this.useVertexTexture=void 0!==i?i:!0,this.identityMatrix=new n.Matrix4,e=e||[],this.bones=e.slice(0),this.useVertexTexture){var r=Math.sqrt(4*this.bones.length);r=n.Math.nextPowerOfTwo(Math.ceil(r)),r=Math.max(r,4),this.boneTextureWidth=r,this.boneTextureHeight=r,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new n.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,n.RGBAFormat,n.FloatType)}else this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[];for(var o=0,a=this.bones.length;a>o;o++)this.boneInverses.push(new n.Matrix4)}},n.Skeleton.prototype.calculateInverses=function(){this.boneInverses=[];for(var e=0,t=this.bones.length;t>e;e++){var i=new n.Matrix4;this.bones[e]&&i.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(i)}},n.Skeleton.prototype.pose=function(){for(var e,t=0,i=this.bones.length;i>t;t++)e=this.bones[t],e&&e.matrixWorld.getInverse(this.boneInverses[t]);for(var t=0,i=this.bones.length;i>t;t++)e=this.bones[t],e&&(e.parent?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},n.Skeleton.prototype.update=function(){var e=new n.Matrix4;return function(){for(var t=0,i=this.bones.length;i>t;t++){var r=this.bones[t]?this.bones[t].matrixWorld:this.identityMatrix;e.multiplyMatrices(r,this.boneInverses[t]),e.flattenToArrayOffset(this.boneMatrices,16*t)}this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}}(),n.Skeleton.prototype.clone=function(){return new n.Skeleton(this.bones,this.boneInverses,this.useVertexTexture)},n.SkinnedMesh=function(e,t,i){n.Mesh.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new n.Matrix4,this.bindMatrixInverse=new n.Matrix4;var r=[];if(this.geometry&&void 0!==this.geometry.bones){for(var o,a,s=0,c=this.geometry.bones.length;c>s;++s)a=this.geometry.bones[s],o=new n.Bone(this),r.push(o),o.name=a.name,o.position.fromArray(a.pos),o.quaternion.fromArray(a.rotq),void 0!==a.scl&&o.scale.fromArray(a.scl);for(var s=0,c=this.geometry.bones.length;c>s;++s)a=this.geometry.bones[s],-1!==a.parent&&null!==a.parent?r[a.parent].add(r[s]):this.add(r[s])}this.normalizeSkinWeights(),this.updateMatrixWorld(!0),this.bind(new n.Skeleton(r,void 0,i),this.matrixWorld)},n.SkinnedMesh.prototype=Object.create(n.Mesh.prototype),n.SkinnedMesh.prototype.constructor=n.SkinnedMesh,n.SkinnedMesh.prototype.bind=function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},n.SkinnedMesh.prototype.pose=function(){this.skeleton.pose()},n.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof n.Geometry)for(var e=0;ei&&!(e1){e.setFromMatrixPosition(i.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);r[0].object.visible=!0;for(var o=1,a=r.length;a>o&&n>=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;a>o;o++)r[o].object.visible=!1}}}(),n.LOD.prototype.copy=function(e){n.Object3D.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,r=t.length;r>i;i++){var o=t[i];this.addLevel(o.object.clone(),o.distance)}return this},n.LOD.prototype.toJSON=function(e){var t=n.Object3D.prototype.toJSON.call(this,e);t.object.levels=[];for(var i=this.levels,r=0,o=i.length;o>r;r++){var a=i[r];t.object.levels.push({object:a.object.uuid,distance:a.distance})}return t},n.Sprite=function(){var e=new Uint16Array([0,1,2,0,2,3]),t=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),i=new Float32Array([0,0,1,0,1,1,0,1]),r=new n.BufferGeometry;return r.setIndex(new n.BufferAttribute(e,1)),r.addAttribute("position",new n.BufferAttribute(t,3)),r.addAttribute("uv",new n.BufferAttribute(i,2)),function(e){n.Object3D.call(this),this.type="Sprite",this.geometry=r,this.material=void 0!==e?e:new n.SpriteMaterial}}(),n.Sprite.prototype=Object.create(n.Object3D.prototype),n.Sprite.prototype.constructor=n.Sprite,n.Sprite.prototype.raycast=function(){var e=new n.Vector3;return function(t,i){e.setFromMatrixPosition(this.matrixWorld);var r=t.ray.distanceSqToPoint(e),n=this.scale.x*this.scale.y;r>n||i.push({distance:Math.sqrt(r),point:this.position,face:null,object:this})}}(),n.Sprite.prototype.clone=function(){return new this.constructor(this.material).copy(this)},n.Particle=n.Sprite,n.LensFlare=function(e,t,i,r,o){n.Object3D.call(this),this.lensFlares=[],this.positionScreen=new n.Vector3,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,i,r,o)},n.LensFlare.prototype=Object.create(n.Object3D.prototype),n.LensFlare.prototype.constructor=n.LensFlare,n.LensFlare.prototype.add=function(e,t,i,r,o,a){void 0===t&&(t=-1),void 0===i&&(i=0),void 0===a&&(a=1),void 0===o&&(o=new n.Color(16777215)),void 0===r&&(r=n.NormalBlending),i=Math.min(i,Math.max(0,i)),this.lensFlares.push({texture:e,size:t,distance:i,x:0,y:0,z:0,scale:1,rotation:0,opacity:a,color:o,blending:r})},n.LensFlare.prototype.updateLensFlares=function(){var e,t,i=this.lensFlares.length,r=2*-this.positionScreen.x,n=2*-this.positionScreen.y;for(e=0;i>e;e++)t=this.lensFlares[e],t.x=this.positionScreen.x+r*t.distance,t.y=this.positionScreen.y+n*t.distance,t.wantedRotation=t.x*Math.PI*.25,t.rotation+=.25*(t.wantedRotation-t.rotation)},n.LensFlare.prototype.copy=function(e){n.Object3D.prototype.copy.call(this,e),this.positionScreen.copy(e.positionScreen),this.customUpdateCallback=e.customUpdateCallback;for(var t=0,i=e.lensFlares.length;i>t;t++)this.lensFlares.push(e.lensFlares[t]);return this},n.Scene=function(){n.Object3D.call(this),this.type="Scene",this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0},n.Scene.prototype=Object.create(n.Object3D.prototype),n.Scene.prototype.constructor=n.Scene,n.Scene.prototype.copy=function(e,t){return n.Object3D.prototype.copy.call(this,e,t),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this},n.Fog=function(e,t,i){this.name="",this.color=new n.Color(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3},n.Fog.prototype.clone=function(){return new n.Fog(this.color.getHex(),this.near,this.far)},n.FogExp2=function(e,t){this.name="",this.color=new n.Color(e),this.density=void 0!==t?t:25e-5},n.FogExp2.prototype.clone=function(){return new n.FogExp2(this.color.getHex(),this.density)},n.ShaderChunk={},n.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",n.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif\n",n.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n if ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",n.ShaderChunk.aomap_fragment="#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n #endif\n#endif\n",n.ShaderChunk.aomap_pars_fragment="#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif",n.ShaderChunk.begin_vertex="\nvec3 transformed = vec3( position );\n",n.ShaderChunk.beginnormal_vertex="\nvec3 objectNormal = vec3( normal );\n",n.ShaderChunk.bsdfs="bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n return any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n if( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n float maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n return distanceFalloff * maxDistanceCutoffFactor;\n#else\n return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n }\n return 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n return ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n return 1.0 / ( gl * gv );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_GGX_Smith( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n return specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n return sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",n.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vUv );\n vec2 dSTdy = dFdy( vUv );\n float Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n vec3 vSigmaX = dFdx( surf_pos );\n vec3 vSigmaY = dFdy( surf_pos );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 );\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif\n",n.ShaderChunk.color_fragment="#ifdef USE_COLOR\n diffuseColor.rgb *= vColor;\n#endif",n.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n varying vec3 vColor;\n#endif\n",n.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n varying vec3 vColor;\n#endif",n.ShaderChunk.color_vertex="#ifdef USE_COLOR\n vColor.xyz = color.xyz;\n#endif",n.ShaderChunk.common="#define PI 3.14159\n#define PI2 6.28318\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\nstruct GeometricContext {\n vec3 position;\n vec3 normal;\n vec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n float distance = dot( planeNormal, point - pointOnPlane );\n return - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\n",n.ShaderChunk.cube_uv_reflection_fragment="#ifdef ENVMAP_TYPE_CUBE_UV\nconst float cubeUV_textureSize = 1024.0;\nint getFaceFromDirection(vec3 direction) {\n vec3 absDirection = abs(direction);\n int face = -1;\n if( absDirection.x > absDirection.z ) {\n if(absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0 : 3;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n else {\n if(absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2 : 5;\n else\n face = direction.y > 0.0 ? 1 : 4;\n }\n return face;\n}\nconst float cubeUV_maxLods1 = log2(cubeUV_textureSize*0.25) - 1.0;\nconst float cubeUV_rangeClamp = exp2((6.0 - 1.0) * 2.0);\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n float scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n float dxRoughness = dFdx(roughness);\n float dyRoughness = dFdy(roughness);\n vec3 dx = dFdx( vec * scale * dxRoughness );\n vec3 dy = dFdy( vec * scale * dyRoughness );\n float d = max( dot( dx, dx ), dot( dy, dy ) );\n d = clamp(d, 1.0, cubeUV_rangeClamp);\n float mipLevel = 0.5 * log2(d);\n return vec2(floor(mipLevel), fract(mipLevel));\n}\nconst float cubeUV_maxLods2 = log2(cubeUV_textureSize*0.25) - 2.0;\nconst float cubeUV_rcpTextureSize = 1.0 / cubeUV_textureSize;\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n mipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n float a = 16.0 * cubeUV_rcpTextureSize;\n vec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n vec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n float powScale = exp2_packed.x * exp2_packed.y;\n float scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n float mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n bool bRes = mipLevel == 0.0;\n scale = bRes && (scale < a) ? a : scale;\n vec3 r;\n vec2 offset;\n int face = getFaceFromDirection(direction);\n float rcpPowScale = 1.0 / powScale;\n if( face == 0) {\n r = vec3(direction.x, -direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 1) {\n r = vec3(direction.y, direction.x, direction.z);\n offset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 2) {\n r = vec3(direction.z, direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n }\n else if( face == 3) {\n r = vec3(direction.x, direction.z, direction.y);\n offset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else if( face == 4) {\n r = vec3(direction.y, direction.x, -direction.z);\n offset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n else {\n r = vec3(direction.z, -direction.x, direction.y);\n offset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n offset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n }\n r = normalize(r);\n float texelOffset = 0.5 * cubeUV_rcpTextureSize;\n vec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n vec2 base = offset + vec2( texelOffset );\n return base + s * ( scale - 2.0 * texelOffset );\n}\nconst float cubeUV_maxLods3 = log2(cubeUV_textureSize*0.25) - 3.0;\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n float roughnessVal = roughness* cubeUV_maxLods3;\n float r1 = floor(roughnessVal);\n float r2 = r1 + 1.0;\n float t = fract(roughnessVal);\n vec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n float s = mipInfo.y;\n float level0 = mipInfo.x;\n float level1 = level0 + 1.0;\n level1 = level1 > 5.0 ? 5.0 : level1;\n level0 += min( floor( s + 0.5 ), 5.0 );\n vec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n vec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n vec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n vec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n vec4 result = mix(color10, color20, t);\n return vec4(result.rgb, 1.0);\n}\n#endif\n", n.ShaderChunk.defaultnormal_vertex="#ifdef FLIP_SIDED\n objectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",n.ShaderChunk.displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n transformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",n.ShaderChunk.displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif\n",n.ShaderChunk.emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vUv );\n emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",n.ShaderChunk.emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif\n",n.ShaderChunk.encodings_pars_fragment="\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n",n.ShaderChunk.encodings_fragment=" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",n.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToVertex, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n vec4 envColor = texture2D( envMap, sampleUV );\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n #endif\n envColor = envMapTexelToLinear( envColor );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif\n",n.ShaderChunk.envmap_pars_fragment="#if defined( USE_ENVMAP ) || defined( STANDARD )\n uniform float reflectivity;\n uniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n uniform float flipEnvMap;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( STANDARD )\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif\n",n.ShaderChunk.envmap_pars_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG ) && ! defined( STANDARD )\n varying vec3 vReflect;\n uniform float refractionRatio;\n#endif\n",n.ShaderChunk.envmap_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG ) && ! defined( STANDARD )\n vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n#endif\n",n.ShaderChunk.fog_fragment="#ifdef USE_FOG\n #ifdef USE_LOGDEPTHBUF_EXT\n float depth = gl_FragDepthEXT / gl_FragCoord.w;\n #else\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n #endif\n #ifdef FOG_EXP2\n float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",n.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n uniform vec3 fogColor;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",n.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n reflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",n.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",n.ShaderChunk.lights_lambert_vertex="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n vLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n directLight = getPointDirectLightIrradiance( pointLights[ i ], geometry );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n directLight = getSpotDirectLightIrradiance( spotLights[ i ], geometry );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directLight = getDirectionalDirectLightIrradiance( directionalLights[ i ], geometry );\n dotNL = dot( geometry.normal, directLight.direction );\n directLightColor_Diffuse = PI * directLight.color;\n vLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n #ifdef DOUBLE_SIDED\n vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n #endif\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n vLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n #ifdef DOUBLE_SIDED\n vLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n #endif\n }\n#endif\n",n.ShaderChunk.lights_pars="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n IncidentLight getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n directLight.color = directionalLight.color;\n directLight.direction = directionalLight.direction;\n directLight.visible = true;\n return directLight;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n IncidentLight getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n vec3 lVector = pointLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n if ( testLightInRange( lightDistance, pointLight.distance ) ) {\n directLight.color = pointLight.color;\n directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n return directLight;\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n int shadow;\n float shadowBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n IncidentLight getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry ) {\n IncidentLight directLight;\n vec3 lVector = spotLight.position - geometry.position;\n directLight.direction = normalize( lVector );\n float lightDistance = length( lVector );\n float angleCos = dot( directLight.direction, spotLight.direction );\n if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n directLight.color = spotLight.color;\n directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n directLight.visible = true;\n } else {\n directLight.color = vec3( 0.0 );\n directLight.visible = false;\n }\n return directLight;\n }\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n float dotNL = dot( geometry.normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n return irradiance;\n }\n#endif\n#if defined( USE_ENVMAP ) && defined( STANDARD )\n vec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n #else\n vec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n #endif\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n vec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n #else\n vec4 envMapColor = vec4( 0.0 );\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n return PI * envMapColor.rgb * envMapIntensity;\n }\n float getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n float maxMIPLevelScalar = float( maxMIPLevel );\n float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n }\n vec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n #else\n vec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n #endif\n #ifdef DOUBLE_SIDED\n float flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n #else\n float flipNormal = 1.0;\n #endif\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n float specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n #ifdef ENVMAP_TYPE_CUBE\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n #else\n vec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n #endif\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n vec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n #endif\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n #ifdef TEXTURE_LOD_EXT\n vec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #else\n vec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n #endif\n #endif\n envMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n return envMapColor.rgb * envMapIntensity;\n }\n#endif\n",n.ShaderChunk.lights_phong_fragment="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",n.ShaderChunk.lights_phong_pars_fragment="#ifdef USE_ENVMAP\n varying vec3 vWorldPosition;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material ) (0)\n",n.ShaderChunk.lights_phong_pars_vertex="#ifdef USE_ENVMAP\n varying vec3 vWorldPosition;\n#endif\n",n.ShaderChunk.lights_phong_vertex="#ifdef USE_ENVMAP\n vWorldPosition = worldPosition.xyz;\n#endif\n",n.ShaderChunk.lights_standard_fragment="StandardMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\nmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n",n.ShaderChunk.lights_standard_pars_fragment="struct StandardMaterial {\n vec3 diffuseColor;\n float specularRoughness;\n vec3 specularColor;\n};\nvoid RE_Direct_Standard( const in IncidentLight directLight, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n irradiance *= PI;\n #endif\n reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n}\nvoid RE_IndirectDiffuse_Standard( const in vec3 irradiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Standard( const in vec3 radiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectSpecular += radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n}\n#define RE_Direct RE_Direct_Standard\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Standard\n#define RE_IndirectSpecular RE_IndirectSpecular_Standard\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",n.ShaderChunk.lights_template="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n directLight = getPointDirectLightIrradiance( pointLight, geometry );\n #ifdef USE_SHADOWMAP\n directLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n directLight = getSpotDirectLightIrradiance( spotLight, geometry );\n #ifdef USE_SHADOWMAP\n directLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n directLight = getDirectionalDirectLightIrradiance( directionalLight, geometry );\n #ifdef USE_SHADOWMAP\n directLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometry, material, reflectedLight );\n }\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #ifdef USE_LIGHTMAP\n vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n #ifndef PHYSICALLY_CORRECT_LIGHTS\n lightMapIrradiance *= PI;\n #endif\n irradiance += lightMapIrradiance;\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n }\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n irradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n #endif\n RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n vec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n RE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n",n.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",n.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n uniform float logDepthBufFC;\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n #endif\n#endif\n",n.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n #ifdef USE_LOGDEPTHBUF_EXT\n varying float vFragDepth;\n #endif\n uniform float logDepthBufFC;\n#endif",n.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n gl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n #ifdef USE_LOGDEPTHBUF_EXT\n vFragDepth = 1.0 + gl_Position.w;\n #else\n gl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n #endif\n#endif\n",n.ShaderChunk.map_fragment="#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv );\n texelColor = mapTexelToLinear( texelColor );\n diffuseColor *= texelColor;\n#endif\n",n.ShaderChunk.map_pars_fragment="#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n",n.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n vec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n diffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",n.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n uniform vec4 offsetRepeat;\n uniform sampler2D map;\n#endif\n",n.ShaderChunk.metalnessmap_fragment="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vUv );\n metalnessFactor *= texelMetalness.r;\n#endif\n",n.ShaderChunk.metalnessmap_pars_fragment="#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",n.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n objectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n objectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n objectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n objectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",n.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n #ifndef USE_MORPHNORMALS\n uniform float morphTargetInfluences[ 8 ];\n #else\n uniform float morphTargetInfluences[ 4 ];\n #endif\n#endif",n.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n transformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n transformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n transformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n transformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n #ifndef USE_MORPHNORMALS\n transformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n transformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n transformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n transformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n #endif\n#endif\n",n.ShaderChunk.normal_fragment="#ifdef FLAT_SHADED\n vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n #endif\n#endif\n#ifdef USE_NORMALMAP\n normal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",n.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( vUv.st );\n vec2 st1 = dFdy( vUv.st );\n vec3 S = normalize( q0 * st1.t - q1 * st0.t );\n vec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n vec3 N = normalize( surf_norm );\n vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n mapN.xy = normalScale * mapN.xy;\n mat3 tsn = mat3( S, T, N );\n return normalize( tsn * mapN );\n }\n#endif\n",n.ShaderChunk.premultiplied_alpha_fragment="#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",n.ShaderChunk.project_vertex="#ifdef USE_SKINNING\n vec4 mvPosition = modelViewMatrix * skinned;\n#else\n vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",n.ShaderChunk.roughnessmap_fragment="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vUv );\n roughnessFactor *= texelRoughness.r;\n#endif\n",n.ShaderChunk.roughnessmap_pars_fragment="#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",n.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n float unpackDepth( const in vec4 rgba_depth ) {\n 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 );\n return dot( rgba_depth, bit_shift );\n }\n float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n return step( compare, unpackDepth( texture2D( depths, uv ) ) );\n }\n float texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n const vec2 offset = vec2( 0.0, 1.0 );\n vec2 texelSize = vec2( 1.0 ) / size;\n vec2 centroidUV = floor( uv * size + 0.5 ) / size;\n float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n float rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n float rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n vec2 f = fract( uv * size + 0.5 );\n float a = mix( lb, lt, f.y );\n float b = mix( rb, rt, f.y );\n float c = mix( a, b, f.x );\n return c;\n }\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n bool frustumTest = all( frustumTestVec );\n if ( frustumTest ) {\n #if defined( SHADOWMAP_TYPE_PCF )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float dx0 = - texelSize.x * shadowRadius;\n float dy0 = - texelSize.y * shadowRadius;\n float dx1 = + texelSize.x * shadowRadius;\n float dy1 = + texelSize.y * shadowRadius;\n return (\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n texture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n #endif\n }\n return 1.0;\n }\n vec2 cubeToUV( vec3 v, float texelSizeY ) {\n vec3 absV = abs( v );\n float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n absV *= scaleToCube;\n v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n vec2 planar = v.xy;\n float almostATexel = 1.5 * texelSizeY;\n float almostOne = 1.0 - almostATexel;\n if ( absV.z >= almostOne ) {\n if ( v.z > 0.0 )\n planar.x = 4.0 - v.x;\n } else if ( absV.x >= almostOne ) {\n float signX = sign( v.x );\n planar.x = v.z * signX + 2.0 * signX;\n } else if ( absV.y >= almostOne ) {\n float signY = sign( v.y );\n planar.x = v.x + 2.0 * signY + 2.0;\n planar.y = v.z * signY - 2.0;\n }\n return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n }\n float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n float dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n return (\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n ) * ( 1.0 / 9.0 );\n #else\n return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n #endif\n }\n#endif\n", n.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n #endif\n #if NUM_SPOT_LIGHTS > 0\n uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n #endif\n #if NUM_POINT_LIGHTS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n #endif\n#endif\n",n.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n }\n #endif\n#endif\n",n.ShaderChunk.shadowmask_pars_fragment="float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHTS > 0\n DirectionalLight directionalLight;\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n shadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_SPOT_LIGHTS > 0\n SpotLight spotLight;\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n shadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #if NUM_POINT_LIGHTS > 0\n PointLight pointLight;\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n shadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n }\n #endif\n #endif\n return shadow;\n}\n",n.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",n.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n #ifdef BONE_TEXTURE\n uniform sampler2D boneTexture;\n uniform int boneTextureWidth;\n uniform int boneTextureHeight;\n mat4 getBoneMatrix( const in float i ) {\n float j = i * 4.0;\n float x = mod( j, float( boneTextureWidth ) );\n float y = floor( j / float( boneTextureWidth ) );\n float dx = 1.0 / float( boneTextureWidth );\n float dy = 1.0 / float( boneTextureHeight );\n y = dy * ( y + 0.5 );\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n mat4 bone = mat4( v1, v2, v3, v4 );\n return bone;\n }\n #else\n uniform mat4 boneGlobalMatrices[ MAX_BONES ];\n mat4 getBoneMatrix( const in float i ) {\n mat4 bone = boneGlobalMatrices[ int(i) ];\n return bone;\n }\n #endif\n#endif\n",n.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n skinned = bindMatrixInverse * skinned;\n#endif\n",n.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",n.ShaderChunk.specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",n.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",n.ShaderChunk.tonemapping_fragment="#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",n.ShaderChunk.tonemapping_pars_fragment="#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",n.ShaderChunk.uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n varying vec2 vUv2;\n#endif",n.ShaderChunk.uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n attribute vec2 uv2;\n varying vec2 vUv2;\n#endif",n.ShaderChunk.uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n vUv2 = uv2;\n#endif",n.ShaderChunk.uv_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n varying vec2 vUv;\n#endif",n.ShaderChunk.uv_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n varying vec2 vUv;\n uniform vec4 offsetRepeat;\n#endif\n",n.ShaderChunk.uv_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n vUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",n.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( STANDARD ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n #ifdef USE_SKINNING\n vec4 worldPosition = modelMatrix * skinned;\n #else\n vec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n #endif\n#endif\n",n.UniformsUtils={merge:function(e){for(var t={},i=0;ir;r++)je.deleteFramebuffer(t.__webglFramebuffer[r]),je.deleteRenderbuffer(t.__webglDepthbuffer[r]); else je.deleteFramebuffer(t.__webglFramebuffer),je.deleteRenderbuffer(t.__webglDepthbuffer);Ye["delete"](e.texture),Ye["delete"](e)}}function d(e){p(e),Ye["delete"](e)}function p(e){var t=Ye.get(e).program;e.program=void 0,void 0!==t&&Ke.releaseProgram(t)}function f(e,t,i,r){var o;if(i instanceof n.InstancedBufferGeometry&&(o=We.get("ANGLE_instanced_arrays"),null===o))return void console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");void 0===r&&(r=0),Xe.initAttributes();var a=i.attributes,s=t.getAttributes(),c=e.defaultAttributeValues;for(var h in s){var l=s[h];if(l>=0){var u=a[h];if(void 0!==u){var d=u.itemSize,p=Qe.getAttributeBuffer(u);if(u instanceof n.InterleavedBufferAttribute){var f=u.data,m=f.stride,v=u.offset;f instanceof n.InstancedInterleavedBuffer?(Xe.enableAttributeAndDivisor(l,f.meshPerAttribute,o),void 0===i.maxInstancedCount&&(i.maxInstancedCount=f.meshPerAttribute*f.count)):Xe.enableAttribute(l),je.bindBuffer(je.ARRAY_BUFFER,p),je.vertexAttribPointer(l,d,je.FLOAT,!1,m*f.array.BYTES_PER_ELEMENT,(r*m+v)*f.array.BYTES_PER_ELEMENT)}else u instanceof n.InstancedBufferAttribute?(Xe.enableAttributeAndDivisor(l,u.meshPerAttribute,o),void 0===i.maxInstancedCount&&(i.maxInstancedCount=u.meshPerAttribute*u.count)):Xe.enableAttribute(l),je.bindBuffer(je.ARRAY_BUFFER,p),je.vertexAttribPointer(l,d,je.FLOAT,!1,0,r*d*4)}else if(void 0!==c){var g=c[h];if(void 0!==g)switch(g.length){case 2:je.vertexAttrib2fv(l,g);break;case 3:je.vertexAttrib3fv(l,g);break;case 4:je.vertexAttrib4fv(l,g);break;default:je.vertexAttrib1fv(l,g)}}}}Xe.disableUnusedAttributes()}function m(e,t){return Math.abs(t[0])-Math.abs(e[0])}function v(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function g(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function y(e,t,i,r,n){var o,a;i.transparent?(o=de,a=++pe):(o=le,a=++ue);var s=o[a];void 0!==s?(s.id=e.id,s.object=e,s.geometry=t,s.material=i,s.z=Fe.z,s.group=n):(s={id:e.id,object:e,geometry:t,material:i,z:Fe.z,group:n},o.push(s))}function x(e,t){if(e.visible!==!1){if(e.layers.test(t.layers))if(e instanceof n.Light)he.push(e);else if(e instanceof n.Sprite)(e.frustumCulled===!1||Ne.intersectsObject(e)===!0)&&me.push(e);else if(e instanceof n.LensFlare)ve.push(e);else if(e instanceof n.ImmediateRenderObject)ge.sortObjects===!0&&(Fe.setFromMatrixPosition(e.matrixWorld),Fe.applyProjection(Be)),y(e,null,e.material,Fe.z,null);else if((e instanceof n.Mesh||e instanceof n.Line||e instanceof n.Points)&&(e instanceof n.SkinnedMesh&&e.skeleton.update(),e.frustumCulled===!1||Ne.intersectsObject(e)===!0)){var i=e.material;if(i.visible===!0){ge.sortObjects===!0&&(Fe.setFromMatrixPosition(e.matrixWorld),Fe.applyProjection(Be));var r=Qe.update(e);if(i instanceof n.MultiMaterial)for(var o=r.groups,a=i.materials,s=0,c=o.length;c>s;s++){var h=o[s],l=a[h.materialIndex];l.visible===!0&&y(e,r,l,Fe.z,h)}else y(e,r,i,Fe.z,null)}}for(var u=e.children,s=0,c=u.length;c>s;s++)x(u[s],t)}}function b(e,t,i,r){for(var o=0,a=e.length;a>o;o++){var s=e[o],c=s.object,h=s.geometry,l=void 0===r?s.material:r,u=s.group;if(c.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,c.matrixWorld),c.normalMatrix.getNormalMatrix(c.modelViewMatrix),c instanceof n.ImmediateRenderObject){M(l);var d=E(t,i,l,c);Me="",c.render(function(e){ge.renderBufferImmediate(e,d,l)})}else ge.renderBufferDirect(t,i,h,l,c,u)}}function w(e,t,i){var r=Ye.get(e),o=Ke.getParameters(e,Ve,t,i),a=Ke.getProgramCode(e,o),s=r.program,c=!0;if(void 0===s)e.addEventListener("dispose",h);else if(s.code!==a)p(e);else{if(void 0!==o.shaderID)return;c=!1}if(c){if(o.shaderID){var l=n.ShaderLib[o.shaderID];r.__webglShader={name:e.type,uniforms:n.UniformsUtils.clone(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader}}else r.__webglShader={name:e.type,uniforms:e.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader};e.__webglShader=r.__webglShader,s=Ke.acquireProgram(e,o,a),r.program=s,e.program=s}var u=s.getAttributes();if(e.morphTargets){e.numSupportedMorphTargets=0;for(var d=0;d=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var d=0;d=0&&e.numSupportedMorphNormals++}r.uniformsList=[];var f=r.__webglShader.uniforms,m=r.program.getUniforms();for(var v in f){var g=m[v];g&&r.uniformsList.push([r.__webglShader.uniforms[v],g])}(e instanceof n.MeshPhongMaterial||e instanceof n.MeshLambertMaterial||e instanceof n.MeshStandardMaterial||e.lights)&&(r.lightsHash=Ve.hash,f.ambientLightColor.value=Ve.ambient,f.directionalLights.value=Ve.directional,f.spotLights.value=Ve.spot,f.pointLights.value=Ve.point,f.hemisphereLights.value=Ve.hemi,f.directionalShadowMap.value=Ve.directionalShadowMap,f.directionalShadowMatrix.value=Ve.directionalShadowMatrix,f.spotShadowMap.value=Ve.spotShadowMap,f.spotShadowMatrix.value=Ve.spotShadowMatrix,f.pointShadowMap.value=Ve.pointShadowMap,f.pointShadowMatrix.value=Ve.pointShadowMatrix),r.hasDynamicUniforms=!1;for(var y=0,x=r.uniformsList.length;x>y;y++){var b=r.uniformsList[y][0];if(b.dynamic===!0){r.hasDynamicUniforms=!0;break}}}function M(e){_(e),e.transparent===!0?Xe.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):Xe.setBlending(n.NoBlending),Xe.setDepthFunc(e.depthFunc),Xe.setDepthTest(e.depthTest),Xe.setDepthWrite(e.depthWrite),Xe.setColorWrite(e.colorWrite),Xe.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function _(e){e.side!==n.DoubleSide?Xe.enable(je.CULL_FACE):Xe.disable(je.CULL_FACE),Xe.setFlipSided(e.side===n.BackSide)}function E(e,t,i,r){Te=0;var o=Ye.get(i);void 0===o.program&&(i.needsUpdate=!0),void 0!==o.lightsHash&&o.lightsHash!==Ve.hash&&(i.needsUpdate=!0),i.needsUpdate&&(w(i,t,r),i.needsUpdate=!1);var a=!1,s=!1,c=!1,h=o.program,l=h.getUniforms(),u=o.__webglShader.uniforms;if(h.id!==ye&&(je.useProgram(h.program),ye=h.id,a=!0,s=!0,c=!0),i.id!==we&&(we=i.id,s=!0),(a||e!==_e)&&(je.uniformMatrix4fv(l.projectionMatrix,!1,e.projectionMatrix.elements),qe.logarithmicDepthBuffer&&je.uniform1f(l.logDepthBufFC,2/(Math.log(e.far+1)/Math.LN2)),e!==_e&&(_e=e,s=!0,c=!0),(i instanceof n.ShaderMaterial||i instanceof n.MeshPhongMaterial||i instanceof n.MeshStandardMaterial||i.envMap)&&void 0!==l.cameraPosition&&(Fe.setFromMatrixPosition(e.matrixWorld),je.uniform3f(l.cameraPosition,Fe.x,Fe.y,Fe.z)),(i instanceof n.MeshPhongMaterial||i instanceof n.MeshLambertMaterial||i instanceof n.MeshBasicMaterial||i instanceof n.MeshStandardMaterial||i instanceof n.ShaderMaterial||i.skinning)&&void 0!==l.viewMatrix&&je.uniformMatrix4fv(l.viewMatrix,!1,e.matrixWorldInverse.elements),void 0!==l.toneMappingExposure&&je.uniform1f(l.toneMappingExposure,ge.toneMappingExposure),void 0!==l.toneMappingWhitePoint&&je.uniform1f(l.toneMappingWhitePoint,ge.toneMappingWhitePoint)),i.skinning)if(r.bindMatrix&&void 0!==l.bindMatrix&&je.uniformMatrix4fv(l.bindMatrix,!1,r.bindMatrix.elements),r.bindMatrixInverse&&void 0!==l.bindMatrixInverse&&je.uniformMatrix4fv(l.bindMatrixInverse,!1,r.bindMatrixInverse.elements),qe.floatVertexTextures&&r.skeleton&&r.skeleton.useVertexTexture){if(void 0!==l.boneTexture){var d=N();je.uniform1i(l.boneTexture,d),ge.setTexture(r.skeleton.boneTexture,d)}void 0!==l.boneTextureWidth&&je.uniform1i(l.boneTextureWidth,r.skeleton.boneTextureWidth),void 0!==l.boneTextureHeight&&je.uniform1i(l.boneTextureHeight,r.skeleton.boneTextureHeight)}else r.skeleton&&r.skeleton.boneMatrices&&void 0!==l.boneGlobalMatrices&&je.uniformMatrix4fv(l.boneGlobalMatrices,!1,r.skeleton.boneMatrices);return s&&((i instanceof n.MeshPhongMaterial||i instanceof n.MeshLambertMaterial||i instanceof n.MeshStandardMaterial||i.lights)&&I(u,c),t&&i.fog&&R(u,t),(i instanceof n.MeshBasicMaterial||i instanceof n.MeshLambertMaterial||i instanceof n.MeshPhongMaterial||i instanceof n.MeshStandardMaterial)&&S(u,i),i instanceof n.LineBasicMaterial?T(u,i):i instanceof n.LineDashedMaterial?(T(u,i),C(u,i)):i instanceof n.PointsMaterial?L(u,i):i instanceof n.MeshLambertMaterial?P(u,i):i instanceof n.MeshPhongMaterial?D(u,i):i instanceof n.MeshStandardMaterial?O(u,i):i instanceof n.MeshDepthMaterial?(u.mNear.value=e.near,u.mFar.value=e.far,u.opacity.value=i.opacity):i instanceof n.MeshNormalMaterial&&(u.opacity.value=i.opacity),F(o.uniformsList)),k(l,r),void 0!==l.modelMatrix&&je.uniformMatrix4fv(l.modelMatrix,!1,r.matrixWorld.elements),o.hasDynamicUniforms===!0&&A(o.uniformsList,r,e),h}function A(e,t,i){for(var r=[],n=0,o=e.length;o>n;n++){var a=e[n][0],s=a.onUpdateCallback;void 0!==s&&(s.bind(a)(t,i),r.push(e[n]))}F(r)}function S(e,t){e.opacity.value=t.opacity,e.diffuse.value=t.color,t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),e.map.value=t.map,e.specularMap.value=t.specularMap,e.alphaMap.value=t.alphaMap,t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var i;if(t.map?i=t.map:t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap&&(i=t.emissiveMap),void 0!==i){i instanceof n.WebGLRenderTarget&&(i=i.texture);var r=i.offset,o=i.repeat;e.offsetRepeat.value.set(r.x,r.y,o.x,o.y)}e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap instanceof n.WebGLRenderTargetCube?1:-1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio}function T(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function C(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function L(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*De,e.scale.value=te.clientHeight/2,e.map.value=t.map,null!==t.map){var i=t.map.offset,r=t.map.repeat;e.offsetRepeat.value.set(i.x,i.y,r.x,r.y)}}function R(e,t){e.fogColor.value=t.color,t instanceof n.Fog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t instanceof n.FogExp2&&(e.fogDensity.value=t.density)}function P(e,t){t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function D(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function O(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function I(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function k(e,t){je.uniformMatrix4fv(e.modelViewMatrix,!1,t.modelViewMatrix.elements),e.normalMatrix&&je.uniformMatrix3fv(e.normalMatrix,!1,t.normalMatrix.elements)}function N(){var e=Te;return e>=qe.maxTextures&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+qe.maxTextures),Te+=1,e}function B(e,t,i,r){var o,a;if("1i"===t)je.uniform1i(i,r);else if("1f"===t)je.uniform1f(i,r);else if("2f"===t)je.uniform2f(i,r[0],r[1]);else if("3f"===t)je.uniform3f(i,r[0],r[1],r[2]);else if("4f"===t)je.uniform4f(i,r[0],r[1],r[2],r[3]);else if("1iv"===t)je.uniform1iv(i,r);else if("3iv"===t)je.uniform3iv(i,r);else if("1fv"===t)je.uniform1fv(i,r);else if("2fv"===t)je.uniform2fv(i,r);else if("3fv"===t)je.uniform3fv(i,r);else if("4fv"===t)je.uniform4fv(i,r);else if("Matrix2fv"===t)je.uniformMatrix2fv(i,!1,r);else if("Matrix3fv"===t)je.uniformMatrix3fv(i,!1,r);else if("Matrix4fv"===t)je.uniformMatrix4fv(i,!1,r);else if("i"===t)je.uniform1i(i,r);else if("f"===t)je.uniform1f(i,r);else if("v2"===t)je.uniform2f(i,r.x,r.y);else if("v3"===t)je.uniform3f(i,r.x,r.y,r.z);else if("v4"===t)je.uniform4f(i,r.x,r.y,r.z,r.w);else if("c"===t)je.uniform3f(i,r.r,r.g,r.b);else if("s"===t){var s=e.properties;for(var c in s){var h=s[c],l=i[c],u=r[c];B(h,h.type,l,u)}}else if("sa"===t)for(var s=e.properties,d=0,p=r.length;p>d;d++)for(var c in s){var h=s[c],l=i[d][c],u=r[d][c];B(h,h.type,l,u)}else if("iv1"===t)je.uniform1iv(i,r);else if("iv"===t)je.uniform3iv(i,r);else if("fv1"===t)je.uniform1fv(i,r);else if("fv"===t)je.uniform3fv(i,r);else if("v2v"===t){void 0===e._array&&(e._array=new Float32Array(2*r.length));for(var d=0,f=0,m=r.length;m>d;d++,f+=2)e._array[f+0]=r[d].x,e._array[f+1]=r[d].y;je.uniform2fv(i,e._array)}else if("v3v"===t){void 0===e._array&&(e._array=new Float32Array(3*r.length));for(var d=0,v=0,m=r.length;m>d;d++,v+=3)e._array[v+0]=r[d].x,e._array[v+1]=r[d].y,e._array[v+2]=r[d].z;je.uniform3fv(i,e._array)}else if("v4v"===t){void 0===e._array&&(e._array=new Float32Array(4*r.length));for(var d=0,g=0,m=r.length;m>d;d++,g+=4)e._array[g+0]=r[d].x,e._array[g+1]=r[d].y,e._array[g+2]=r[d].z,e._array[g+3]=r[d].w;je.uniform4fv(i,e._array)}else if("m2"===t)je.uniformMatrix2fv(i,!1,r.elements);else if("m3"===t)je.uniformMatrix3fv(i,!1,r.elements);else if("m3v"===t){void 0===e._array&&(e._array=new Float32Array(9*r.length));for(var d=0,m=r.length;m>d;d++)r[d].flattenToArrayOffset(e._array,9*d);je.uniformMatrix3fv(i,!1,e._array)}else if("m4"===t)je.uniformMatrix4fv(i,!1,r.elements);else if("m4v"===t){void 0===e._array&&(e._array=new Float32Array(16*r.length));for(var d=0,m=r.length;m>d;d++)r[d].flattenToArrayOffset(e._array,16*d);je.uniformMatrix4fv(i,!1,e._array)}else if("t"===t){if(o=r,a=N(),je.uniform1i(i,a),!o)return;o instanceof n.CubeTexture||Array.isArray(o.image)&&6===o.image.length?q(o,a):o instanceof n.WebGLRenderTargetCube?X(o.texture,a):o instanceof n.WebGLRenderTarget?ge.setTexture(o.texture,a):ge.setTexture(o,a)}else if("tv"===t){void 0===e._array&&(e._array=[]);for(var d=0,m=e.value.length;m>d;d++)e._array[d]=N();je.uniform1iv(i,e._array);for(var d=0,m=e.value.length;m>d;d++)o=e.value[d],a=e._array[d],o&&(o instanceof n.CubeTexture||o.image instanceof Array&&6===o.image.length?q(o,a):o instanceof n.WebGLRenderTarget?ge.setTexture(o.texture,a):o instanceof n.WebGLRenderTargetCube?X(o.texture,a):ge.setTexture(o,a))}else console.warn("THREE.WebGLRenderer: Unknown uniform type: "+t)}function F(e){for(var t=0,i=e.length;i>t;t++){var r=e[t][0];if(r.needsUpdate!==!1){var n=r.type,o=e[t][1],a=r.value;B(r,n,o,a)}}}function V(e,t){var i,r,o,a,s,c,h=0,l=0,u=0,d=t.matrixWorldInverse,p=0,f=0,m=0,v=0,g=0;for(Ve.shadowsPointLight=0,i=0,r=e.length;r>i;i++)if(o=e[i],a=o.color,s=o.intensity,c=o.distance,o instanceof n.AmbientLight)h+=a.r*s,l+=a.g*s,u+=a.b*s;else if(o instanceof n.DirectionalLight){var y=Ze.get(o);y.color.copy(o.color).multiplyScalar(o.intensity),y.direction.setFromMatrixPosition(o.matrixWorld),Fe.setFromMatrixPosition(o.target.matrixWorld),y.direction.sub(Fe),y.direction.transformDirection(d),y.shadow=o.castShadow,o.castShadow&&(y.shadowBias=o.shadow.bias,y.shadowRadius=o.shadow.radius,y.shadowMapSize=o.shadow.mapSize,Ve.shadows[g++]=o),Ve.directionalShadowMap[p]=o.shadow.map,Ve.directionalShadowMatrix[p]=o.shadow.matrix,Ve.directional[p++]=y}else if(o instanceof n.SpotLight){var y=Ze.get(o);y.position.setFromMatrixPosition(o.matrixWorld),y.position.applyMatrix4(d),y.color.copy(a).multiplyScalar(s),y.distance=c,y.direction.setFromMatrixPosition(o.matrixWorld),Fe.setFromMatrixPosition(o.target.matrixWorld),y.direction.sub(Fe),y.direction.transformDirection(d),y.coneCos=Math.cos(o.angle),y.penumbraCos=Math.cos(o.angle*(1-o.penumbra)),y.decay=0===o.distance?0:o.decay,y.shadow=o.castShadow,o.castShadow&&(y.shadowBias=o.shadow.bias,y.shadowRadius=o.shadow.radius,y.shadowMapSize=o.shadow.mapSize,Ve.shadows[g++]=o),Ve.spotShadowMap[m]=o.shadow.map,Ve.spotShadowMatrix[m]=o.shadow.matrix,Ve.spot[m++]=y}else if(o instanceof n.PointLight){var y=Ze.get(o);y.position.setFromMatrixPosition(o.matrixWorld),y.position.applyMatrix4(d),y.color.copy(o.color).multiplyScalar(o.intensity),y.distance=o.distance,y.decay=0===o.distance?0:o.decay,y.shadow=o.castShadow,o.castShadow&&(y.shadowBias=o.shadow.bias,y.shadowRadius=o.shadow.radius,y.shadowMapSize=o.shadow.mapSize,Ve.shadows[g++]=o),Ve.pointShadowMap[f]=o.shadow.map,void 0===Ve.pointShadowMatrix[f]&&(Ve.pointShadowMatrix[f]=new n.Matrix4),Fe.setFromMatrixPosition(o.matrixWorld).negate(),Ve.pointShadowMatrix[f].identity().setPosition(Fe),Ve.point[f++]=y}else if(o instanceof n.HemisphereLight){var y=Ze.get(o);y.direction.setFromMatrixPosition(o.matrixWorld),y.direction.transformDirection(d),y.direction.normalize(),y.skyColor.copy(o.color).multiplyScalar(s),y.groundColor.copy(o.groundColor).multiplyScalar(s),Ve.hemi[v++]=y}Ve.ambient[0]=h,Ve.ambient[1]=l,Ve.ambient[2]=u,Ve.directional.length=p,Ve.spot.length=m,Ve.point.length=f,Ve.hemi.length=v,Ve.shadows.length=g,Ve.hash=p+","+f+","+m+","+v+","+g}function U(e,t,i){var r;if(i?(je.texParameteri(e,je.TEXTURE_WRAP_S,ee(t.wrapS)),je.texParameteri(e,je.TEXTURE_WRAP_T,ee(t.wrapT)),je.texParameteri(e,je.TEXTURE_MAG_FILTER,ee(t.magFilter)),je.texParameteri(e,je.TEXTURE_MIN_FILTER,ee(t.minFilter))):(je.texParameteri(e,je.TEXTURE_WRAP_S,je.CLAMP_TO_EDGE),je.texParameteri(e,je.TEXTURE_WRAP_T,je.CLAMP_TO_EDGE),(t.wrapS!==n.ClampToEdgeWrapping||t.wrapT!==n.ClampToEdgeWrapping)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",t),je.texParameteri(e,je.TEXTURE_MAG_FILTER,$(t.magFilter)),je.texParameteri(e,je.TEXTURE_MIN_FILTER,$(t.minFilter)),t.minFilter!==n.NearestFilter&&t.minFilter!==n.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",t)),r=We.get("EXT_texture_filter_anisotropic")){if(t.type===n.FloatType&&null===We.get("OES_texture_float_linear"))return;if(t.type===n.HalfFloatType&&null===We.get("OES_texture_half_float_linear"))return;(t.anisotropy>1||Ye.get(t).__currentAnisotropy)&&(je.texParameterf(e,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,ge.getMaxAnisotropy())),Ye.get(t).__currentAnisotropy=t.anisotropy)}}function z(e,t,i){void 0===e.__webglInit&&(e.__webglInit=!0,t.addEventListener("dispose",s),e.__webglTexture=je.createTexture(),Ue.textures++),Xe.activeTexture(je.TEXTURE0+i),Xe.bindTexture(je.TEXTURE_2D,e.__webglTexture),je.pixelStorei(je.UNPACK_FLIP_Y_WEBGL,t.flipY),je.pixelStorei(je.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),je.pixelStorei(je.UNPACK_ALIGNMENT,t.unpackAlignment);var r=j(t.image,qe.maxTextureSize);H(t)&&G(r)===!1&&(r=W(r));var o=G(r),a=ee(t.format),c=ee(t.type);U(je.TEXTURE_2D,t,o);var h,l=t.mipmaps;if(t instanceof n.DataTexture)if(l.length>0&&o){for(var u=0,d=l.length;d>u;u++)h=l[u],Xe.texImage2D(je.TEXTURE_2D,u,a,h.width,h.height,0,a,c,h.data);t.generateMipmaps=!1}else Xe.texImage2D(je.TEXTURE_2D,0,a,r.width,r.height,0,a,c,r.data);else if(t instanceof n.CompressedTexture)for(var u=0,d=l.length;d>u;u++)h=l[u],t.format!==n.RGBAFormat&&t.format!==n.RGBFormat?Xe.getCompressedTextureFormats().indexOf(a)>-1?Xe.compressedTexImage2D(je.TEXTURE_2D,u,a,h.width,h.height,0,h.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Xe.texImage2D(je.TEXTURE_2D,u,a,h.width,h.height,0,a,c,h.data);else if(l.length>0&&o){for(var u=0,d=l.length;d>u;u++)h=l[u],Xe.texImage2D(je.TEXTURE_2D,u,a,a,c,h);t.generateMipmaps=!1}else Xe.texImage2D(je.TEXTURE_2D,0,a,a,c,r);t.generateMipmaps&&o&&je.generateMipmap(je.TEXTURE_2D),e.__version=t.version,t.onUpdate&&t.onUpdate(t)}function j(e,t){if(e.width>t||e.height>t){var i=t/Math.max(e.width,e.height),r=document.createElement("canvas");r.width=Math.floor(e.width*i),r.height=Math.floor(e.height*i);var n=r.getContext("2d");return n.drawImage(e,0,0,e.width,e.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+r.width+"x"+r.height,e),r}return e}function G(e){return n.Math.isPowerOfTwo(e.width)&&n.Math.isPowerOfTwo(e.height)}function H(e){return e.wrapS!==n.ClampToEdgeWrapping||e.wrapT!==n.ClampToEdgeWrapping?!0:e.minFilter!==n.NearestFilter&&e.minFilter!==n.LinearFilter?!0:!1}function W(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElement("canvas");t.width=n.Math.nearestPowerOfTwo(e.width),t.height=n.Math.nearestPowerOfTwo(e.height);var i=t.getContext("2d");return i.drawImage(e,0,0,t.width,t.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}function q(e,t){var i=Ye.get(e);if(6===e.image.length)if(e.version>0&&i.__version!==e.version){i.__image__webglTextureCube||(e.addEventListener("dispose",s),i.__image__webglTextureCube=je.createTexture(),Ue.textures++),Xe.activeTexture(je.TEXTURE0+t),Xe.bindTexture(je.TEXTURE_CUBE_MAP,i.__image__webglTextureCube),je.pixelStorei(je.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var r=e instanceof n.CompressedTexture,o=e.image[0]instanceof n.DataTexture,a=[],c=0;6>c;c++)a[c]=!ge.autoScaleCubemaps||r||o?o?e.image[c].image:e.image[c]:j(e.image[c],qe.maxCubemapSize);var h=a[0],l=G(h),u=ee(e.format),d=ee(e.type);U(je.TEXTURE_CUBE_MAP,e,l);for(var c=0;6>c;c++)if(r)for(var p,f=a[c].mipmaps,m=0,v=f.length;v>m;m++)p=f[m],e.format!==n.RGBAFormat&&e.format!==n.RGBFormat?Xe.getCompressedTextureFormats().indexOf(u)>-1?Xe.compressedTexImage2D(je.TEXTURE_CUBE_MAP_POSITIVE_X+c,m,u,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setCubeTexture()"):Xe.texImage2D(je.TEXTURE_CUBE_MAP_POSITIVE_X+c,m,u,p.width,p.height,0,u,d,p.data);else o?Xe.texImage2D(je.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,u,a[c].width,a[c].height,0,u,d,a[c].data):Xe.texImage2D(je.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,u,u,d,a[c]);e.generateMipmaps&&l&&je.generateMipmap(je.TEXTURE_CUBE_MAP),i.__version=e.version,e.onUpdate&&e.onUpdate(e)}else Xe.activeTexture(je.TEXTURE0+t),Xe.bindTexture(je.TEXTURE_CUBE_MAP,i.__image__webglTextureCube)}function X(e,t){Xe.activeTexture(je.TEXTURE0+t),Xe.bindTexture(je.TEXTURE_CUBE_MAP,Ye.get(e).__webglTexture)}function Y(e,t,i,r){var n=ee(t.texture.format),o=ee(t.texture.type);Xe.texImage2D(r,0,n,t.width,t.height,0,n,o,null),je.bindFramebuffer(je.FRAMEBUFFER,e),je.framebufferTexture2D(je.FRAMEBUFFER,i,r,Ye.get(t.texture).__webglTexture,0),je.bindFramebuffer(je.FRAMEBUFFER,null)}function Q(e,t){je.bindRenderbuffer(je.RENDERBUFFER,e),t.depthBuffer&&!t.stencilBuffer?(je.renderbufferStorage(je.RENDERBUFFER,je.DEPTH_COMPONENT16,t.width,t.height),je.framebufferRenderbuffer(je.FRAMEBUFFER,je.DEPTH_ATTACHMENT,je.RENDERBUFFER,e)):t.depthBuffer&&t.stencilBuffer?(je.renderbufferStorage(je.RENDERBUFFER,je.DEPTH_STENCIL,t.width,t.height),je.framebufferRenderbuffer(je.FRAMEBUFFER,je.DEPTH_STENCIL_ATTACHMENT,je.RENDERBUFFER,e)):je.renderbufferStorage(je.RENDERBUFFER,je.RGBA4,t.width,t.height),je.bindRenderbuffer(je.RENDERBUFFER,null)}function K(e){var t=Ye.get(e),i=e instanceof n.WebGLRenderTargetCube;if(i){t.__webglDepthbuffer=[];for(var r=0;6>r;r++)je.bindFramebuffer(je.FRAMEBUFFER,t.__webglFramebuffer[r]),t.__webglDepthbuffer[r]=je.createRenderbuffer(),Q(t.__webglDepthbuffer[r],e)}else je.bindFramebuffer(je.FRAMEBUFFER,t.__webglFramebuffer),t.__webglDepthbuffer=je.createRenderbuffer(),Q(t.__webglDepthbuffer,e);je.bindFramebuffer(je.FRAMEBUFFER,null)}function Z(e){var t=Ye.get(e),i=Ye.get(e.texture);e.addEventListener("dispose",c),i.__webglTexture=je.createTexture(),Ue.textures++;var r=e instanceof n.WebGLRenderTargetCube,o=n.Math.isPowerOfTwo(e.width)&&n.Math.isPowerOfTwo(e.height);if(r){t.__webglFramebuffer=[];for(var a=0;6>a;a++)t.__webglFramebuffer[a]=je.createFramebuffer()}else t.__webglFramebuffer=je.createFramebuffer();if(r){Xe.bindTexture(je.TEXTURE_CUBE_MAP,i.__webglTexture),U(je.TEXTURE_CUBE_MAP,e.texture,o);for(var a=0;6>a;a++)Y(t.__webglFramebuffer[a],e,je.COLOR_ATTACHMENT0,je.TEXTURE_CUBE_MAP_POSITIVE_X+a);e.texture.generateMipmaps&&o&&je.generateMipmap(je.TEXTURE_CUBE_MAP),Xe.bindTexture(je.TEXTURE_CUBE_MAP,null)}else Xe.bindTexture(je.TEXTURE_2D,i.__webglTexture),U(je.TEXTURE_2D,e.texture,o),Y(t.__webglFramebuffer,e,je.COLOR_ATTACHMENT0,je.TEXTURE_2D),e.texture.generateMipmaps&&o&&je.generateMipmap(je.TEXTURE_2D),Xe.bindTexture(je.TEXTURE_2D,null);e.depthBuffer&&K(e)}function J(e){var t=e instanceof n.WebGLRenderTargetCube?je.TEXTURE_CUBE_MAP:je.TEXTURE_2D,i=Ye.get(e.texture).__webglTexture;Xe.bindTexture(t,i),je.generateMipmap(t),Xe.bindTexture(t,null)}function $(e){return e===n.NearestFilter||e===n.NearestMipMapNearestFilter||e===n.NearestMipMapLinearFilter?je.NEAREST:je.LINEAR}function ee(e){var t;if(e===n.RepeatWrapping)return je.REPEAT;if(e===n.ClampToEdgeWrapping)return je.CLAMP_TO_EDGE;if(e===n.MirroredRepeatWrapping)return je.MIRRORED_REPEAT;if(e===n.NearestFilter)return je.NEAREST;if(e===n.NearestMipMapNearestFilter)return je.NEAREST_MIPMAP_NEAREST;if(e===n.NearestMipMapLinearFilter)return je.NEAREST_MIPMAP_LINEAR;if(e===n.LinearFilter)return je.LINEAR;if(e===n.LinearMipMapNearestFilter)return je.LINEAR_MIPMAP_NEAREST;if(e===n.LinearMipMapLinearFilter)return je.LINEAR_MIPMAP_LINEAR;if(e===n.UnsignedByteType)return je.UNSIGNED_BYTE;if(e===n.UnsignedShort4444Type)return je.UNSIGNED_SHORT_4_4_4_4;if(e===n.UnsignedShort5551Type)return je.UNSIGNED_SHORT_5_5_5_1;if(e===n.UnsignedShort565Type)return je.UNSIGNED_SHORT_5_6_5;if(e===n.ByteType)return je.BYTE;if(e===n.ShortType)return je.SHORT;if(e===n.UnsignedShortType)return je.UNSIGNED_SHORT;if(e===n.IntType)return je.INT;if(e===n.UnsignedIntType)return je.UNSIGNED_INT;if(e===n.FloatType)return je.FLOAT;if(t=We.get("OES_texture_half_float"),null!==t&&e===n.HalfFloatType)return t.HALF_FLOAT_OES;if(e===n.AlphaFormat)return je.ALPHA;if(e===n.RGBFormat)return je.RGB;if(e===n.RGBAFormat)return je.RGBA;if(e===n.LuminanceFormat)return je.LUMINANCE;if(e===n.LuminanceAlphaFormat)return je.LUMINANCE_ALPHA;if(e===n.AddEquation)return je.FUNC_ADD;if(e===n.SubtractEquation)return je.FUNC_SUBTRACT;if(e===n.ReverseSubtractEquation)return je.FUNC_REVERSE_SUBTRACT;if(e===n.ZeroFactor)return je.ZERO;if(e===n.OneFactor)return je.ONE;if(e===n.SrcColorFactor)return je.SRC_COLOR;if(e===n.OneMinusSrcColorFactor)return je.ONE_MINUS_SRC_COLOR;if(e===n.SrcAlphaFactor)return je.SRC_ALPHA;if(e===n.OneMinusSrcAlphaFactor)return je.ONE_MINUS_SRC_ALPHA;if(e===n.DstAlphaFactor)return je.DST_ALPHA;if(e===n.OneMinusDstAlphaFactor)return je.ONE_MINUS_DST_ALPHA;if(e===n.DstColorFactor)return je.DST_COLOR;if(e===n.OneMinusDstColorFactor)return je.ONE_MINUS_DST_COLOR;if(e===n.SrcAlphaSaturateFactor)return je.SRC_ALPHA_SATURATE;if(t=We.get("WEBGL_compressed_texture_s3tc"),null!==t){if(e===n.RGB_S3TC_DXT1_Format)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===n.RGBA_S3TC_DXT1_Format)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===n.RGBA_S3TC_DXT3_Format)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===n.RGBA_S3TC_DXT5_Format)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t=We.get("WEBGL_compressed_texture_pvrtc"),null!==t){if(e===n.RGB_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===n.RGB_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===n.RGBA_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===n.RGBA_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t=We.get("WEBGL_compressed_texture_etc1"),null!==t&&e===n.RGB_ETC1_Format)return t.COMPRESSED_RGB_ETC1_WEBGL;if(t=We.get("EXT_blend_minmax"),null!==t){if(e===n.MinEquation)return t.MIN_EXT;if(e===n.MaxEquation)return t.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",n.REVISION),e=e||{};var te=void 0!==e.canvas?e.canvas:document.createElement("canvas"),ie=void 0!==e.context?e.context:null,re=void 0!==e.alpha?e.alpha:!1,ne=void 0!==e.depth?e.depth:!0,oe=void 0!==e.stencil?e.stencil:!0,ae=void 0!==e.antialias?e.antialias:!1,se=void 0!==e.premultipliedAlpha?e.premultipliedAlpha:!0,ce=void 0!==e.preserveDrawingBuffer?e.preserveDrawingBuffer:!1,he=[],le=[],ue=-1,de=[],pe=-1,fe=new Float32Array(8),me=[],ve=[];this.domElement=te,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=n.LinearToneMapping,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4,this.autoScaleCubemaps=!0;var ge=this,ye=null,xe=null,be=null,we=-1,Me="",_e=null,Ee=new n.Vector4,Ae=null,Se=new n.Vector4,Te=0,Ce=new n.Color(0),Le=0,Re=te.width,Pe=te.height,De=1,Oe=new n.Vector4(0,0,Re,Pe),Ie=!1,ke=new n.Vector4(0,0,Re,Pe),Ne=new n.Frustum,Be=new n.Matrix4,Fe=new n.Vector3,Ve={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[],shadowsPointLight:0},Ue={geometries:0,textures:0},ze={calls:0,vertices:0,faces:0,points:0};this.info={render:ze,memory:Ue,programs:null};var je;try{var Ge={alpha:re,depth:ne,stencil:oe,antialias:ae,premultipliedAlpha:se,preserveDrawingBuffer:ce};if(je=ie||te.getContext("webgl",Ge)||te.getContext("experimental-webgl",Ge),null===je)throw null!==te.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===je.getShaderPrecisionFormat&&(je.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),te.addEventListener("webglcontextlost",a,!1)}catch(He){console.error("THREE.WebGLRenderer: "+He)}var We=new n.WebGLExtensions(je);We.get("OES_texture_float"),We.get("OES_texture_float_linear"),We.get("OES_texture_half_float"),We.get("OES_texture_half_float_linear"),We.get("OES_standard_derivatives"),We.get("ANGLE_instanced_arrays"),We.get("OES_element_index_uint")&&(n.BufferGeometry.MaxIndex=4294967296);var qe=new n.WebGLCapabilities(je,We,e),Xe=new n.WebGLState(je,We,ee),Ye=new n.WebGLProperties,Qe=new n.WebGLObjects(je,Ye,this.info),Ke=new n.WebGLPrograms(this,qe),Ze=new n.WebGLLights;this.info.programs=Ke.programs;var Je=new n.WebGLBufferRenderer(je,We,ze),$e=new n.WebGLIndexedBufferRenderer(je,We,ze);r(),this.context=je,this.capabilities=qe,this.extensions=We,this.properties=Ye,this.state=Xe;var et=new n.WebGLShadowMap(this,Ve,Qe);this.shadowMap=et;var tt=new n.SpritePlugin(this,me),it=new n.LensFlarePlugin(this,ve);this.getContext=function(){return je},this.getContextAttributes=function(){return je.getContextAttributes()},this.forceContextLoss=function(){We.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){var e;return function(){if(void 0!==e)return e;var t=We.get("EXT_texture_filter_anisotropic");return e=null!==t?je.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0; }}(),this.getPrecision=function(){return qe.precision},this.getPixelRatio=function(){return De},this.setPixelRatio=function(e){void 0!==e&&(De=e,this.setSize(ke.z,ke.w,!1))},this.getSize=function(){return{width:Re,height:Pe}},this.setSize=function(e,t,i){Re=e,Pe=t,te.width=e*De,te.height=t*De,i!==!1&&(te.style.width=e+"px",te.style.height=t+"px"),this.setViewport(0,0,e,t)},this.setViewport=function(e,t,i,r){Xe.viewport(ke.set(e,t,i,r))},this.setScissor=function(e,t,i,r){Xe.scissor(Oe.set(e,t,i,r))},this.setScissorTest=function(e){Xe.setScissorTest(Ie=e)},this.getClearColor=function(){return Ce},this.setClearColor=function(e,t){Ce.set(e),Le=void 0!==t?t:1,i(Ce.r,Ce.g,Ce.b,Le)},this.getClearAlpha=function(){return Le},this.setClearAlpha=function(e){Le=e,i(Ce.r,Ce.g,Ce.b,Le)},this.clear=function(e,t,i){var r=0;(void 0===e||e)&&(r|=je.COLOR_BUFFER_BIT),(void 0===t||t)&&(r|=je.DEPTH_BUFFER_BIT),(void 0===i||i)&&(r|=je.STENCIL_BUFFER_BIT),je.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(e,t,i,r){this.setRenderTarget(e),this.clear(t,i,r)},this.resetGLState=o,this.dispose=function(){te.removeEventListener("webglcontextlost",a,!1)},this.renderBufferImmediate=function(e,t,i){Xe.initAttributes();var r=Ye.get(e);e.hasPositions&&!r.position&&(r.position=je.createBuffer()),e.hasNormals&&!r.normal&&(r.normal=je.createBuffer()),e.hasUvs&&!r.uv&&(r.uv=je.createBuffer()),e.hasColors&&!r.color&&(r.color=je.createBuffer());var o=t.getAttributes();if(e.hasPositions&&(je.bindBuffer(je.ARRAY_BUFFER,r.position),je.bufferData(je.ARRAY_BUFFER,e.positionArray,je.DYNAMIC_DRAW),Xe.enableAttribute(o.position),je.vertexAttribPointer(o.position,3,je.FLOAT,!1,0,0)),e.hasNormals){if(je.bindBuffer(je.ARRAY_BUFFER,r.normal),"MeshPhongMaterial"!==i.type&&"MeshStandardMaterial"!==i.type&&i.shading===n.FlatShading)for(var a=0,s=3*e.count;s>a;a+=9){var c=e.normalArray,h=(c[a+0]+c[a+3]+c[a+6])/3,l=(c[a+1]+c[a+4]+c[a+7])/3,u=(c[a+2]+c[a+5]+c[a+8])/3;c[a+0]=h,c[a+1]=l,c[a+2]=u,c[a+3]=h,c[a+4]=l,c[a+5]=u,c[a+6]=h,c[a+7]=l,c[a+8]=u}je.bufferData(je.ARRAY_BUFFER,e.normalArray,je.DYNAMIC_DRAW),Xe.enableAttribute(o.normal),je.vertexAttribPointer(o.normal,3,je.FLOAT,!1,0,0)}e.hasUvs&&i.map&&(je.bindBuffer(je.ARRAY_BUFFER,r.uv),je.bufferData(je.ARRAY_BUFFER,e.uvArray,je.DYNAMIC_DRAW),Xe.enableAttribute(o.uv),je.vertexAttribPointer(o.uv,2,je.FLOAT,!1,0,0)),e.hasColors&&i.vertexColors!==n.NoColors&&(je.bindBuffer(je.ARRAY_BUFFER,r.color),je.bufferData(je.ARRAY_BUFFER,e.colorArray,je.DYNAMIC_DRAW),Xe.enableAttribute(o.color),je.vertexAttribPointer(o.color,3,je.FLOAT,!1,0,0)),Xe.disableUnusedAttributes(),je.drawArrays(je.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,i,r,o,a,s){M(o);var c=E(e,i,o,a),h=!1,l=r.id+"_"+c.id+"_"+o.wireframe;l!==Me&&(Me=l,h=!0);var u=a.morphTargetInfluences;if(void 0!==u){for(var d=[],p=0,v=u.length;v>p;p++){var g=u[p];d.push([g,p])}d.sort(m),d.length>8&&(d.length=8);for(var y=r.morphAttributes,p=0,v=d.length;v>p;p++){var g=d[p];if(fe[p]=g[0],0!==g[0]){var x=g[1];o.morphTargets===!0&&y.position&&r.addAttribute("morphTarget"+p,y.position[x]),o.morphNormals===!0&&y.normal&&r.addAttribute("morphNormal"+p,y.normal[x])}else o.morphTargets===!0&&r.removeAttribute("morphTarget"+p),o.morphNormals===!0&&r.removeAttribute("morphNormal"+p)}var b=c.getUniforms();null!==b.morphTargetInfluences&&je.uniform1fv(b.morphTargetInfluences,fe),h=!0}var x=r.index,w=r.attributes.position;o.wireframe===!0&&(x=Qe.getWireframeAttribute(r));var _;null!==x?(_=$e,_.setIndex(x)):_=Je,h&&(f(o,c,r),null!==x&&je.bindBuffer(je.ELEMENT_ARRAY_BUFFER,Qe.getAttributeBuffer(x)));var A=0,S=1/0;null!==x?S=x.count:void 0!==w&&(S=w.count);var T=r.drawRange.start,C=r.drawRange.count,L=null!==s?s.start:0,R=null!==s?s.count:1/0,P=Math.max(A,T,L),D=Math.min(A+S,T+C,L+R)-1,O=Math.max(0,D-P+1);if(a instanceof n.Mesh)if(o.wireframe===!0)Xe.setLineWidth(o.wireframeLinewidth*t()),_.setMode(je.LINES);else switch(a.drawMode){case n.TrianglesDrawMode:_.setMode(je.TRIANGLES);break;case n.TriangleStripDrawMode:_.setMode(je.TRIANGLE_STRIP);break;case n.TriangleFanDrawMode:_.setMode(je.TRIANGLE_FAN)}else if(a instanceof n.Line){var I=o.linewidth;void 0===I&&(I=1),Xe.setLineWidth(I*t()),_.setMode(a instanceof n.LineSegments?je.LINES:je.LINE_STRIP)}else a instanceof n.Points&&_.setMode(je.POINTS);r instanceof n.InstancedBufferGeometry?r.maxInstancedCount>0&&_.renderInstances(r,P,O):_.render(P,O)},this.render=function(e,t,i,r){if(t instanceof n.Camera==!1)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");var o=e.fog;if(Me="",we=-1,_e=null,e.autoUpdate===!0&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),Be.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Ne.setFromMatrix(Be),he.length=0,ue=-1,pe=-1,me.length=0,ve.length=0,x(e,t),le.length=ue+1,de.length=pe+1,ge.sortObjects===!0&&(le.sort(v),de.sort(g)),V(he,t),et.render(e,t),ze.calls=0,ze.vertices=0,ze.faces=0,ze.points=0,void 0===i&&(i=null),this.setRenderTarget(i),(this.autoClear||r)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),e.overrideMaterial){var a=e.overrideMaterial;b(le,t,o,a),b(de,t,o,a)}else Xe.setBlending(n.NoBlending),b(le,t,o),b(de,t,o);if(tt.render(e,t),it.render(e,t,Se),i){var s=i.texture;s.generateMipmaps&&G(i)&&s.minFilter!==n.NearestFilter&&s.minFilter!==n.LinearFilter&&J(i)}Xe.setDepthTest(!0),Xe.setDepthWrite(!0),Xe.setColorWrite(!0)},this.setFaceCulling=function(e,t){e===n.CullFaceNone?Xe.disable(je.CULL_FACE):(je.frontFace(t===n.FrontFaceDirectionCW?je.CW:je.CCW),je.cullFace(e===n.CullFaceBack?je.BACK:e===n.CullFaceFront?je.FRONT:je.FRONT_AND_BACK),Xe.enable(je.CULL_FACE))},this.setTexture=function(e,t){var i=Ye.get(e);if(e.version>0&&i.__version!==e.version){var r=e.image;return void 0===r?void console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e):r.complete===!1?void console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e):void z(i,e,t)}Xe.activeTexture(je.TEXTURE0+t),Xe.bindTexture(je.TEXTURE_2D,i.__webglTexture)},this.getCurrentRenderTarget=function(){return xe},this.setRenderTarget=function(e){xe=e,e&&void 0===Ye.get(e).__webglFramebuffer&&Z(e);var t,i=e instanceof n.WebGLRenderTargetCube;if(e){var r=Ye.get(e);t=i?r.__webglFramebuffer[e.activeCubeFace]:r.__webglFramebuffer,Ee.copy(e.scissor),Ae=e.scissorTest,Se.copy(e.viewport)}else t=null,Ee.copy(Oe).multiplyScalar(De),Ae=Ie,Se.copy(ke).multiplyScalar(De);if(be!==t&&(je.bindFramebuffer(je.FRAMEBUFFER,t),be=t),Xe.scissor(Ee),Xe.setScissorTest(Ae),Xe.viewport(Se),i){var o=Ye.get(e.texture);je.framebufferTexture2D(je.FRAMEBUFFER,je.COLOR_ATTACHMENT0,je.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,o.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,i,r,o,a){if(e instanceof n.WebGLRenderTarget==!1)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");var s=Ye.get(e).__webglFramebuffer;if(s){var c=!1;s!==be&&(je.bindFramebuffer(je.FRAMEBUFFER,s),c=!0);try{var h=e.texture;if(h.format!==n.RGBAFormat&&ee(h.format)!==je.getParameter(je.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h.type===n.UnsignedByteType||ee(h.type)===je.getParameter(je.IMPLEMENTATION_COLOR_READ_TYPE)||h.type===n.FloatType&&We.get("WEBGL_color_buffer_float")||h.type===n.HalfFloatType&&We.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");je.checkFramebufferStatus(je.FRAMEBUFFER)===je.FRAMEBUFFER_COMPLETE?je.readPixels(t,i,r,o,ee(h.format),ee(h.type),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&je.bindFramebuffer(je.FRAMEBUFFER,be)}}}},n.WebGLRenderTarget=function(e,t,i){this.uuid=n.Math.generateUUID(),this.width=e,this.height=t,this.scissor=new n.Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new n.Vector4(0,0,e,t),i=i||{},void 0===i.minFilter&&(i.minFilter=n.LinearFilter),this.texture=new n.Texture(void 0,void 0,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy),this.depthBuffer=void 0!==i.depthBuffer?i.depthBuffer:!0,this.stencilBuffer=void 0!==i.stencilBuffer?i.stencilBuffer:!0},n.WebGLRenderTarget.prototype={constructor:n.WebGLRenderTarget,setSize:function(e,t){(this.width!==e||this.height!==t)&&(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},n.EventDispatcher.prototype.apply(n.WebGLRenderTarget.prototype),n.WebGLRenderTargetCube=function(e,t,i){n.WebGLRenderTarget.call(this,e,t,i),this.activeCubeFace=0,this.activeMipMapLevel=0},n.WebGLRenderTargetCube.prototype=Object.create(n.WebGLRenderTarget.prototype),n.WebGLRenderTargetCube.prototype.constructor=n.WebGLRenderTargetCube,n.WebGLBufferRenderer=function(e,t,i){function r(e){s=e}function o(t,r){e.drawArrays(s,t,r),i.calls++,i.vertices+=r,s===e.TRIANGLES&&(i.faces+=r/3)}function a(r){var o=t.get("ANGLE_instanced_arrays");if(null===o)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");var a=r.attributes.position,c=0;a instanceof n.InterleavedBufferAttribute?(c=a.data.count,o.drawArraysInstancedANGLE(s,0,c,r.maxInstancedCount)):(c=a.count,o.drawArraysInstancedANGLE(s,0,c,r.maxInstancedCount)),i.calls++,i.vertices+=c*r.maxInstancedCount,s===e.TRIANGLES&&(i.faces+=r.maxInstancedCount*c/3)}var s;this.setMode=r,this.render=o,this.renderInstances=a},n.WebGLIndexedBufferRenderer=function(e,t,i){function r(e){s=e}function n(i){i.array instanceof Uint32Array&&t.get("OES_element_index_uint")?(c=e.UNSIGNED_INT,h=4):(c=e.UNSIGNED_SHORT,h=2)}function o(t,r){e.drawElements(s,r,c,t*h),i.calls++,i.vertices+=r,s===e.TRIANGLES&&(i.faces+=r/3)}function a(r,n,o){var a=t.get("ANGLE_instanced_arrays");return null===a?void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):(a.drawElementsInstancedANGLE(s,o,c,n*h,r.maxInstancedCount),i.calls++,i.vertices+=o*r.maxInstancedCount,void(s===e.TRIANGLES&&(i.faces+=r.maxInstancedCount*o/3)))}var s,c,h;this.setMode=r,this.setIndex=n,this.render=o,this.renderInstances=a},n.WebGLExtensions=function(e){var t={};this.get=function(i){if(void 0!==t[i])return t[i];var r;switch(i){case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":r=e.getExtension("WEBGL_compressed_texture_etc1");break;default:r=e.getExtension(i)}return null===r&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),t[i]=r,r}},n.WebGLCapabilities=function(e,t,i){function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}this.getMaxPrecision=r,this.precision=void 0!==i.precision?i.precision:"highp",this.logarithmicDepthBuffer=void 0!==i.logarithmicDepthBuffer?i.logarithmicDepthBuffer:!1,this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxVertexTextures=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxCubemapSize=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),this.maxAttributes=e.getParameter(e.MAX_VERTEX_ATTRIBS),this.maxVertexUniforms=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this.maxVaryings=e.getParameter(e.MAX_VARYING_VECTORS),this.maxFragmentUniforms=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),this.vertexTextures=this.maxVertexTextures>0,this.floatFragmentTextures=!!t.get("OES_texture_float"),this.floatVertexTextures=this.vertexTextures&&this.floatFragmentTextures;var n=r(this.precision);n!==this.precision&&(console.warn("THREE.WebGLRenderer:",this.precision,"not supported, using",n,"instead."),this.precision=n),this.logarithmicDepthBuffer&&(this.logarithmicDepthBuffer=!!t.get("EXT_frag_depth"))},n.WebGLGeometries=function(e,t,i){function r(e){var t=e.geometry;if(void 0!==l[t.id])return l[t.id];t.addEventListener("dispose",o);var r;return t instanceof n.BufferGeometry?r=t:t instanceof n.Geometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new n.BufferGeometry).setFromObject(e)),r=t._bufferGeometry),l[t.id]=r,i.memory.geometries++,r}function o(e){var r=e.target,n=l[r.id];null!==n.index&&s(n.index),c(n.attributes),r.removeEventListener("dispose",o),delete l[r.id];var a=t.get(r);a.wireframe&&s(a.wireframe),t["delete"](r);var h=t.get(n);h.wireframe&&s(h.wireframe),t["delete"](n),i.memory.geometries--}function a(e){return e instanceof n.InterleavedBufferAttribute?t.get(e.data).__webglBuffer:t.get(e).__webglBuffer}function s(t){var i=a(t);void 0!==i&&(e.deleteBuffer(i),h(t))}function c(e){for(var t in e)s(e[t])}function h(e){t["delete"](e instanceof n.InterleavedBufferAttribute?e.data:e)}var l={};this.get=r},n.WebGLLights=function(){var e={};this.get=function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new n.Vector3,color:new n.Color,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n.Vector2};break;case"SpotLight":i={position:new n.Vector3,direction:new n.Vector3,color:new n.Color,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n.Vector2};break;case"PointLight":i={position:new n.Vector3,color:new n.Color,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n.Vector2};break;case"HemisphereLight":i={direction:new n.Vector3,skyColor:new n.Color,groundColor:new n.Color}}return e[t.id]=i,i}},n.WebGLObjects=function(e,t,i){function r(t){var i=u.get(t);t.geometry instanceof n.Geometry&&i.updateFromObject(t);var r=i.index,a=i.attributes;null!==r&&o(r,e.ELEMENT_ARRAY_BUFFER);for(var s in a)o(a[s],e.ARRAY_BUFFER);var c=i.morphAttributes;for(var s in c)for(var h=c[s],l=0,d=h.length;d>l;l++)o(h[l],e.ARRAY_BUFFER);return i}function o(e,i){var r=e instanceof n.InterleavedBufferAttribute?e.data:e,o=t.get(r);void 0===o.__webglBuffer?a(o,r,i):o.version!==r.version&&s(o,r,i)}function a(t,i,r){t.__webglBuffer=e.createBuffer(),e.bindBuffer(r,t.__webglBuffer);var n=i.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW;e.bufferData(r,i.array,n),t.version=i.version}function s(t,i,r){e.bindBuffer(r,t.__webglBuffer),i.dynamic===!1||-1===i.updateRange.count?e.bufferSubData(r,0,i.array):0===i.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(r,i.updateRange.offset*i.array.BYTES_PER_ELEMENT,i.array.subarray(i.updateRange.offset,i.updateRange.offset+i.updateRange.count)),i.updateRange.count=0),t.version=i.version}function c(e){return e instanceof n.InterleavedBufferAttribute?t.get(e.data).__webglBuffer:t.get(e).__webglBuffer}function h(i){var r=t.get(i);if(void 0!==r.wireframe)return r.wireframe;var a=[],s=i.index,c=i.attributes,h=c.position;if(null!==s)for(var u={},d=s.array,p=0,f=d.length;f>p;p+=3){var m=d[p+0],v=d[p+1],g=d[p+2];l(u,m,v)&&a.push(m,v),l(u,v,g)&&a.push(v,g),l(u,g,m)&&a.push(g,m)}else for(var d=c.position.array,p=0,f=d.length/3-1;f>p;p+=3){var m=p+0,v=p+1,g=p+2;a.push(m,v,v,g,g,m)}var y=h.count>65535?Uint32Array:Uint16Array,x=new n.BufferAttribute(new y(a),1);return o(x,e.ELEMENT_ARRAY_BUFFER),r.wireframe=x,x}function l(e,t,i){if(t>i){var r=t;t=i,i=r}var n=e[t];return void 0===n?(e[t]=[i],!0):-1===n.indexOf(i)?(n.push(i),!0):!1}var u=new n.WebGLGeometries(e,t,i);this.getAttributeBuffer=c,this.getWireframeAttribute=h,this.update=r},n.WebGLProgram=function(){function e(e){switch(e){case n.LinearEncoding:return["Linear","( value )"];case n.sRGBEncoding:return["sRGB","( value )"];case n.RGBEEncoding:return["RGBE","( value )"];case n.RGBM7Encoding:return["RGBM","( value, 7.0 )"];case n.RGBM16Encoding:return["RGBM","( value, 16.0 )"];case n.RGBDEncoding:return["RGBD","( value, 256.0 )"];case n.GammaEncoding:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+e)}}function t(t,i){var r=e(i);return"vec4 "+t+"( vec4 value ) { return "+r[0]+"ToLinear"+r[1]+"; }"}function i(t,i){var r=e(i);return"vec4 "+t+"( vec4 value ) { return LinearTo"+r[0]+r[1]+"; }"}function r(e,t){var i;switch(t){case n.LinearToneMapping:i="Linear";break;case n.ReinhardToneMapping:i="Reinhard";break;case n.Uncharted2ToneMapping:i="Uncharted2";break;case n.CineonToneMapping:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function o(e,t,i){e=e||{};var r=[e.derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""];return r.filter(h).join("\n")}function a(e){var t=[];for(var i in e){var r=e[i];r!==!1&&t.push("#define "+i+" "+r)}return t.join("\n")}function s(e,t){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=0;r>n;n++){var o=e.getActiveUniform(t,n),a=o.name,s=e.getUniformLocation(t,a),c=f.exec(a);if(c){var h=c[1],l=c[2],u=i[h];u||(u=i[h]={}),u[l]=s}else if(c=m.exec(a)){var d=c[1],p=c[2],g=c[3],y=i[d];y||(y=i[d]=[]);var x=y[p];x||(x=y[p]={}),x[g]=s}else if(c=v.exec(a)){var d=c[1];i[d]=s}else i[a]=s}return i}function c(e,t){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),n=0;r>n;n++){var o=e.getActiveAttrib(t,n),a=o.name;i[a]=e.getAttribLocation(t,a)}return i}function h(e){return""!==e}function l(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights)}function u(e){function t(e,t){var i=n.ShaderChunk[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return u(i)}var i=/#include +<([\w\d.]+)>/g;return e.replace(i,t)}function d(e){function t(e,t,i,r){for(var n="",o=parseInt(t);o0?e.gammaFactor:1,L=o(y,v,e.extensions),R=a(x),P=g.createProgram();m instanceof n.RawShaderMaterial?(S="",T=""):(S=["precision "+v.precision+" float;","precision "+v.precision+" int;","#define SHADER_NAME "+m.__webglShader.name,R,v.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+C,"#define MAX_BONES "+v.maxBones,v.map?"#define USE_MAP":"",v.envMap?"#define USE_ENVMAP":"",v.envMap?"#define "+E:"",v.lightMap?"#define USE_LIGHTMAP":"",v.aoMap?"#define USE_AOMAP":"",v.emissiveMap?"#define USE_EMISSIVEMAP":"",v.bumpMap?"#define USE_BUMPMAP":"",v.normalMap?"#define USE_NORMALMAP":"",v.displacementMap&&v.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",v.specularMap?"#define USE_SPECULARMAP":"",v.roughnessMap?"#define USE_ROUGHNESSMAP":"",v.metalnessMap?"#define USE_METALNESSMAP":"",v.alphaMap?"#define USE_ALPHAMAP":"",v.vertexColors?"#define USE_COLOR":"",v.flatShading?"#define FLAT_SHADED":"",v.skinning?"#define USE_SKINNING":"",v.useVertexTexture?"#define BONE_TEXTURE":"",v.morphTargets?"#define USE_MORPHTARGETS":"",v.morphNormals&&v.flatShading===!1?"#define USE_MORPHNORMALS":"",v.doubleSided?"#define DOUBLE_SIDED":"",v.flipSided?"#define FLIP_SIDED":"",v.shadowMapEnabled?"#define USE_SHADOWMAP":"",v.shadowMapEnabled?"#define "+M:"",v.pointLightShadows>0?"#define POINT_LIGHT_SHADOWS":"",v.sizeAttenuation?"#define USE_SIZEATTENUATION":"",v.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",v.logarithmicDepthBuffer&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR"," attribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(h).join("\n"),T=[L,"precision "+v.precision+" float;","precision "+v.precision+" int;","#define SHADER_NAME "+m.__webglShader.name,R,v.alphaTest?"#define ALPHATEST "+v.alphaTest:"","#define GAMMA_FACTOR "+C,v.useFog&&v.fog?"#define USE_FOG":"",v.useFog&&v.fogExp?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.envMap?"#define USE_ENVMAP":"",v.envMap?"#define "+_:"",v.envMap?"#define "+E:"",v.envMap?"#define "+A:"",v.lightMap?"#define USE_LIGHTMAP":"",v.aoMap?"#define USE_AOMAP":"",v.emissiveMap?"#define USE_EMISSIVEMAP":"",v.bumpMap?"#define USE_BUMPMAP":"",v.normalMap?"#define USE_NORMALMAP":"",v.specularMap?"#define USE_SPECULARMAP":"",v.roughnessMap?"#define USE_ROUGHNESSMAP":"",v.metalnessMap?"#define USE_METALNESSMAP":"",v.alphaMap?"#define USE_ALPHAMAP":"",v.vertexColors?"#define USE_COLOR":"",v.flatShading?"#define FLAT_SHADED":"",v.doubleSided?"#define DOUBLE_SIDED":"",v.flipSided?"#define FLIP_SIDED":"",v.shadowMapEnabled?"#define USE_SHADOWMAP":"",v.shadowMapEnabled?"#define "+M:"",v.pointLightShadows>0?"#define POINT_LIGHT_SHADOWS":"",v.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",v.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",v.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",v.logarithmicDepthBuffer&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",v.envMap&&e.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",v.toneMapping!==n.NoToneMapping?"#define TONE_MAPPING":"",v.toneMapping!==n.NoToneMapping?n.ShaderChunk.tonemapping_pars_fragment:"",v.toneMapping!==n.NoToneMapping?r("toneMapping",v.toneMapping):"",v.outputEncoding||v.mapEncoding||v.envMapEncoding||v.emissiveMapEncoding?n.ShaderChunk.encodings_pars_fragment:"",v.mapEncoding?t("mapTexelToLinear",v.mapEncoding):"",v.envMapEncoding?t("envMapTexelToLinear",v.envMapEncoding):"",v.emissiveMapEncoding?t("emissiveMapTexelToLinear",v.emissiveMapEncoding):"",v.outputEncoding?i("linearToOutputTexel",v.outputEncoding):"","\n"].filter(h).join("\n")),b=u(b,v),b=l(b,v),w=u(w,v),w=l(w,v),m instanceof n.ShaderMaterial==!1&&(b=d(b),w=d(w));var D=S+b,O=T+w,I=n.WebGLShader(g,g.VERTEX_SHADER,D),k=n.WebGLShader(g,g.FRAGMENT_SHADER,O);g.attachShader(P,I),g.attachShader(P,k),void 0!==m.index0AttributeName?g.bindAttribLocation(P,0,m.index0AttributeName):v.morphTargets===!0&&g.bindAttribLocation(P,0,"position"),g.linkProgram(P);var N=g.getProgramInfoLog(P),B=g.getShaderInfoLog(I),F=g.getShaderInfoLog(k),V=!0,U=!0;g.getProgramParameter(P,g.LINK_STATUS)===!1?(V=!1,console.error("THREE.WebGLProgram: shader error: ",g.getError(),"gl.VALIDATE_STATUS",g.getProgramParameter(P,g.VALIDATE_STATUS),"gl.getProgramInfoLog",N,B,F)):""!==N?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",N):(""===B||""===F)&&(U=!1),U&&(this.diagnostics={runnable:V,material:m,programLog:N,vertexShader:{log:B,prefix:S},fragmentShader:{log:F,prefix:T}}),g.deleteShader(I),g.deleteShader(k);var z;this.getUniforms=function(){return void 0===z&&(z=s(g,P)),z};var j;return this.getAttributes=function(){return void 0===j&&(j=c(g,P)),j},this.destroy=function(){g.deleteProgram(P),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=p++,this.code=f,this.usedTimes=1,this.program=P,this.vertexShader=I,this.fragmentShader=k,this}}(),n.WebGLPrograms=function(e,t){function i(e){if(t.floatVertexTextures&&e&&e.skeleton&&e.skeleton.useVertexTexture)return 1024;var i=t.maxVertexUniforms,r=Math.floor((i-20)/4),o=r;return void 0!==e&&e instanceof n.SkinnedMesh&&(o=Math.min(e.skeleton.bones.length,o),o0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:o.premultipliedAlpha,alphaTest:o.alphaTest,doubleSided:o.side===n.DoubleSide,flipSided:o.side===n.BackSide};return p},this.getProgramCode=function(e,t){var i=[];if(t.shaderID?i.push(t.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(var r in e.defines)i.push(r),i.push(e.defines[r]);for(var n=0;ns;s++){var h=o[s];if(h.code===r){a=h,++a.usedTimes;break}}return void 0===a&&(a=new n.WebGLProgram(e,r,t,i),o.push(a)),a},this.releaseProgram=function(e){if(0===--e.usedTimes){var t=o.indexOf(e);o[t]=o[o.length-1],o.pop(),e.destroy()}},this.programs=o},n.WebGLProperties=function(){var e={};this.get=function(t){var i=t.uuid,r=e[i];return void 0===r&&(r={},e[i]=r),r},this["delete"]=function(t){delete e[t.uuid]},this.clear=function(){e={}}},n.WebGLShader=function(){function e(e){for(var t=e.split("\n"),i=0;i0&&t.morphTargets,l=e instanceof n.SkinnedMesh&&t.skinning,u=0; h&&(u|=f),l&&(u|=m),a=s[u]}return a.visible=t.visible,a.wireframe=t.wireframe,a.wireframeLinewidth=t.wireframeLinewidth,i&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(r),a}function o(e,t,i){if(e.visible!==!1){if(e.layers.test(t.layers)&&(e instanceof n.Mesh||e instanceof n.Line||e instanceof n.Points)&&e.castShadow&&(e.frustumCulled===!1||c.intersectsObject(e)===!0)){var r=e.material;r.visible===!0&&(e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),p.push(e))}for(var a=e.children,s=0,h=a.length;h>s;s++)o(a[s],t,i)}}for(var a=e.context,s=e.state,c=new n.Frustum,h=new n.Matrix4,l=new n.Vector2,u=new n.Vector3,d=new n.Vector3,p=[],f=1,m=2,v=(f|m)+1,g=new Array(v),y=new Array(v),x=[new n.Vector3(1,0,0),new n.Vector3(-1,0,0),new n.Vector3(0,0,1),new n.Vector3(0,0,-1),new n.Vector3(0,1,0),new n.Vector3(0,-1,0)],b=[new n.Vector3(0,1,0),new n.Vector3(0,1,0),new n.Vector3(0,1,0),new n.Vector3(0,1,0),new n.Vector3(0,0,1),new n.Vector3(0,0,-1)],w=[new n.Vector4,new n.Vector4,new n.Vector4,new n.Vector4,new n.Vector4,new n.Vector4],M=n.ShaderLib.depthRGBA,_=n.UniformsUtils.clone(M.uniforms),E=n.ShaderLib.distanceRGBA,A=n.UniformsUtils.clone(E.uniforms),S=0;S!==v;++S){var T=0!==(S&f),C=0!==(S&m),L=new n.ShaderMaterial({uniforms:_,vertexShader:M.vertexShader,fragmentShader:M.fragmentShader,morphTargets:T,skinning:C});g[S]=L;var R=new n.ShaderMaterial({defines:{USE_SHADOWMAP:""},uniforms:A,vertexShader:E.vertexShader,fragmentShader:E.fragmentShader,morphTargets:T,skinning:C});y[S]=R}var P=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=n.PCFShadowMap,this.cullFace=n.CullFaceFront,this.render=function(f,m){var v,g,y=t.shadows;if(0!==y.length&&P.enabled!==!1&&(P.autoUpdate!==!1||P.needsUpdate!==!1)){s.clearColor(1,1,1,1),s.disable(a.BLEND),s.enable(a.CULL_FACE),a.frontFace(a.CCW),a.cullFace(P.cullFace===n.CullFaceFront?a.FRONT:a.BACK),s.setDepthTest(!0),s.setScissorTest(!1);for(var M=0,_=y.length;_>M;M++){var E=y[M],A=E.shadow,S=A.camera;if(l.copy(A.mapSize),E instanceof n.PointLight){v=6,g=!0;var T=l.x,C=l.y;w[0].set(2*T,C,T,C),w[1].set(0,C,T,C),w[2].set(3*T,C,T,C),w[3].set(T,C,T,C),w[4].set(3*T,0,T,C),w[5].set(T,0,T,C),l.x*=4,l.y*=2}else v=1,g=!1;if(null===A.map){var L={minFilter:n.NearestFilter,magFilter:n.NearestFilter,format:n.RGBAFormat};A.map=new n.WebGLRenderTarget(l.x,l.y,L),E instanceof n.SpotLight&&(S.aspect=l.x/l.y),S.updateProjectionMatrix()}var R=A.map,D=A.matrix;d.setFromMatrixPosition(E.matrixWorld),S.position.copy(d),e.setRenderTarget(R),e.clear();for(var O=0;v>O;O++){if(g){u.copy(S.position),u.add(x[O]),S.up.copy(b[O]),S.lookAt(u);var I=w[O];s.viewport(I)}else u.setFromMatrixPosition(E.target.matrixWorld),S.lookAt(u);S.updateMatrixWorld(),S.matrixWorldInverse.getInverse(S.matrixWorld),D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),D.multiply(S.projectionMatrix),D.multiply(S.matrixWorldInverse),h.multiplyMatrices(S.projectionMatrix,S.matrixWorldInverse),c.setFromMatrix(h),p.length=0,o(f,m,S);for(var k=0,N=p.length;N>k;k++){var B=p[k],F=i.update(B),V=B.material;if(V instanceof n.MultiMaterial)for(var U=F.groups,z=V.materials,j=0,G=U.length;G>j;j++){var H=U[j],W=z[H.materialIndex];if(W.visible===!0){var q=r(B,W,g,d);e.renderBufferDirect(S,null,F,q,B,H)}}else{var q=r(B,V,g,d);e.renderBufferDirect(S,null,F,q,B,null)}}}}var X=e.getClearColor(),Y=e.getClearAlpha();e.setClearColor(X,Y),s.enable(a.BLEND),P.cullFace===n.CullFaceFront&&a.cullFace(a.BACK),P.needsUpdate=!1}}},n.WebGLState=function(e,t,i){var r=this,o=new n.Vector4,a=new Uint8Array(16),s=new Uint8Array(16),c=new Uint8Array(16),h={},l=null,u=null,d=null,p=null,f=null,m=null,v=null,g=null,y=!1,x=null,b=null,w=null,M=null,_=null,E=null,A=null,S=null,T=null,C=null,L=null,R=null,P=null,D=null,O=null,I=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),k=void 0,N={},B=new n.Vector4,F=null,V=null,U=new n.Vector4,z=new n.Vector4,j=e.createTexture();e.bindTexture(e.TEXTURE_2D,j),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.RGB,1,1,0,e.RGB,e.UNSIGNED_BYTE,new Uint8Array(3)),this.init=function(){this.clearColor(0,0,0,1),this.clearDepth(1),this.clearStencil(0),this.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.frontFace(e.CCW),e.cullFace(e.BACK),this.enable(e.CULL_FACE),this.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)},this.initAttributes=function(){for(var e=0,t=a.length;t>e;e++)a[e]=0},this.enableAttribute=function(i){if(a[i]=1,0===s[i]&&(e.enableVertexAttribArray(i),s[i]=1),0!==c[i]){var r=t.get("ANGLE_instanced_arrays");r.vertexAttribDivisorANGLE(i,0),c[i]=0}},this.enableAttributeAndDivisor=function(t,i,r){a[t]=1,0===s[t]&&(e.enableVertexAttribArray(t),s[t]=1),c[t]!==i&&(r.vertexAttribDivisorANGLE(t,i),c[t]=i)},this.disableUnusedAttributes=function(){for(var t=0,i=s.length;i>t;t++)s[t]!==a[t]&&(e.disableVertexAttribArray(t),s[t]=0)},this.enable=function(t){h[t]!==!0&&(e.enable(t),h[t]=!0)},this.disable=function(t){h[t]!==!1&&(e.disable(t),h[t]=!1)},this.getCompressedTextureFormats=function(){if(null===l&&(l=[],t.get("WEBGL_compressed_texture_pvrtc")||t.get("WEBGL_compressed_texture_s3tc")||t.get("WEBGL_compressed_texture_etc1")))for(var i=e.getParameter(e.COMPRESSED_TEXTURE_FORMATS),r=0;r0;var i;i=l?{vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")}:{vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uv;","vec2 pos = position;","if ( renderType == 2 ) {","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["precision mediump float;","uniform lowp int renderType;","uniform sampler2D map;","uniform sampler2D occlusionMap;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","void main() {","if ( renderType == 0 ) {","gl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );","} else if ( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","float visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a;","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a;","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a;","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;","visibility = ( 1.0 - visibility / 4.0 );","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * visibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},s=r(i),c={vertex:p.getAttribLocation(s,"position"),uv:p.getAttribLocation(s,"uv")},h={renderType:p.getUniformLocation(s,"renderType"),map:p.getUniformLocation(s,"map"),occlusionMap:p.getUniformLocation(s,"occlusionMap"),opacity:p.getUniformLocation(s,"opacity"),color:p.getUniformLocation(s,"color"),scale:p.getUniformLocation(s,"scale"),rotation:p.getUniformLocation(s,"rotation"),screenPosition:p.getUniformLocation(s,"screenPosition")}}function r(t){var i=p.createProgram(),r=p.createShader(p.FRAGMENT_SHADER),n=p.createShader(p.VERTEX_SHADER),o="precision "+e.getPrecision()+" float;\n";return p.shaderSource(r,o+t.fragmentShader),p.shaderSource(n,o+t.vertexShader),p.compileShader(r),p.compileShader(n),p.attachShader(i,r),p.attachShader(i,n),p.linkProgram(i),i}var o,a,s,c,h,l,u,d,p=e.context,f=e.state;this.render=function(r,m,v){if(0!==t.length){var g=new n.Vector3,y=v.w/v.z,x=.5*v.z,b=.5*v.w,w=16/v.w,M=new n.Vector2(w*y,w),_=new n.Vector3(1,1,0),E=new n.Vector2(1,1);void 0===s&&i(),p.useProgram(s),f.initAttributes(),f.enableAttribute(c.vertex),f.enableAttribute(c.uv),f.disableUnusedAttributes(),p.uniform1i(h.occlusionMap,0),p.uniform1i(h.map,1),p.bindBuffer(p.ARRAY_BUFFER,o),p.vertexAttribPointer(c.vertex,2,p.FLOAT,!1,16,0),p.vertexAttribPointer(c.uv,2,p.FLOAT,!1,16,8),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,a),f.disable(p.CULL_FACE),f.setDepthWrite(!1);for(var A=0,S=t.length;S>A;A++){w=16/v.w,M.set(w*y,w);var T=t[A];if(g.set(T.matrixWorld.elements[12],T.matrixWorld.elements[13],T.matrixWorld.elements[14]),g.applyMatrix4(m.matrixWorldInverse),g.applyProjection(m.projectionMatrix),_.copy(g),E.x=_.x*x+x,E.y=_.y*b+b,l||E.x>0&&E.x0&&E.yC;C++){var R=T.lensFlares[C];R.opacity>.001&&R.scale>.001&&(_.x=R.x,_.y=R.y,_.z=R.z,w=R.size*R.scale/v.w,M.x=w*y,M.y=w,p.uniform3f(h.screenPosition,_.x,_.y,_.z),p.uniform2f(h.scale,M.x,M.y),p.uniform1f(h.rotation,R.rotation),p.uniform1f(h.opacity,R.opacity),p.uniform3f(h.color,R.color.r,R.color.g,R.color.b),f.setBlending(R.blending,R.blendEquation,R.blendSrc,R.blendDst),e.setTexture(R.texture,1),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0))}}}f.enable(p.CULL_FACE),f.enable(p.DEPTH_TEST),f.setDepthWrite(!0),e.resetGLState()}}},n.SpritePlugin=function(e,t){function i(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),t=new Uint16Array([0,1,2,0,2,3]);a=d.createBuffer(),s=d.createBuffer(),d.bindBuffer(d.ARRAY_BUFFER,a),d.bufferData(d.ARRAY_BUFFER,e,d.STATIC_DRAW),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.bufferData(d.ELEMENT_ARRAY_BUFFER,t,d.STATIC_DRAW),c=r(),h={position:d.getAttribLocation(c,"position"),uv:d.getAttribLocation(c,"uv")},l={uvOffset:d.getUniformLocation(c,"uvOffset"),uvScale:d.getUniformLocation(c,"uvScale"),rotation:d.getUniformLocation(c,"rotation"),scale:d.getUniformLocation(c,"scale"),color:d.getUniformLocation(c,"color"),map:d.getUniformLocation(c,"map"),opacity:d.getUniformLocation(c,"opacity"),modelViewMatrix:d.getUniformLocation(c,"modelViewMatrix"),projectionMatrix:d.getUniformLocation(c,"projectionMatrix"),fogType:d.getUniformLocation(c,"fogType"),fogDensity:d.getUniformLocation(c,"fogDensity"),fogNear:d.getUniformLocation(c,"fogNear"),fogFar:d.getUniformLocation(c,"fogFar"),fogColor:d.getUniformLocation(c,"fogColor"),alphaTest:d.getUniformLocation(c,"alphaTest")};var i=document.createElement("canvas");i.width=8,i.height=8;var o=i.getContext("2d");o.fillStyle="white",o.fillRect(0,0,8,8),u=new n.Texture(i),u.needsUpdate=!0}function r(){var t=d.createProgram(),i=d.createShader(d.VERTEX_SHADER),r=d.createShader(d.FRAGMENT_SHADER);return d.shaderSource(i,["precision "+e.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),d.shaderSource(r,["precision "+e.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),d.compileShader(i),d.compileShader(r),d.attachShader(t,i),d.attachShader(t,r),d.linkProgram(t),t}function o(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}var a,s,c,h,l,u,d=e.context,p=e.state,f=new n.Vector3,m=new n.Quaternion,v=new n.Vector3;this.render=function(r,g){if(0!==t.length){void 0===c&&i(),d.useProgram(c),p.initAttributes(),p.enableAttribute(h.position),p.enableAttribute(h.uv),p.disableUnusedAttributes(),p.disable(d.CULL_FACE),p.enable(d.BLEND),d.bindBuffer(d.ARRAY_BUFFER,a),d.vertexAttribPointer(h.position,2,d.FLOAT,!1,16,0),d.vertexAttribPointer(h.uv,2,d.FLOAT,!1,16,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),d.uniformMatrix4fv(l.projectionMatrix,!1,g.projectionMatrix.elements),p.activeTexture(d.TEXTURE0),d.uniform1i(l.map,0);var y=0,x=0,b=r.fog;b?(d.uniform3f(l.fogColor,b.color.r,b.color.g,b.color.b),b instanceof n.Fog?(d.uniform1f(l.fogNear,b.near),d.uniform1f(l.fogFar,b.far),d.uniform1i(l.fogType,1),y=1,x=1):b instanceof n.FogExp2&&(d.uniform1f(l.fogDensity,b.density),d.uniform1i(l.fogType,2),y=2,x=2)):(d.uniform1i(l.fogType,0),y=0,x=0);for(var w=0,M=t.length;M>w;w++){var _=t[w];_.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,_.matrixWorld),_.z=-_.modelViewMatrix.elements[14]}t.sort(o);for(var E=[],w=0,M=t.length;M>w;w++){var _=t[w],A=_.material;d.uniform1f(l.alphaTest,A.alphaTest),d.uniformMatrix4fv(l.modelViewMatrix,!1,_.modelViewMatrix.elements),_.matrixWorld.decompose(f,m,v),E[0]=v.x,E[1]=v.y;var S=0;r.fog&&A.fog&&(S=x),y!==S&&(d.uniform1i(l.fogType,S),y=S),null!==A.map?(d.uniform2f(l.uvOffset,A.map.offset.x,A.map.offset.y),d.uniform2f(l.uvScale,A.map.repeat.x,A.map.repeat.y)):(d.uniform2f(l.uvOffset,0,0),d.uniform2f(l.uvScale,1,1)),d.uniform1f(l.opacity,A.opacity),d.uniform3f(l.color,A.color.r,A.color.g,A.color.b),d.uniform1f(l.rotation,A.rotation),d.uniform2fv(l.scale,E),p.setBlending(A.blending,A.blendEquation,A.blendSrc,A.blendDst),p.setDepthTest(A.depthTest),p.setDepthWrite(A.depthWrite),A.map&&A.map.image&&A.map.image.width?e.setTexture(A.map,0):e.setTexture(u,0),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0)}p.enable(d.CULL_FACE),e.resetGLState()}}},Object.defineProperties(n.Box2.prototype,{empty:{value:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()}},isIntersectionBox:{value:function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)}}}),Object.defineProperties(n.Box3.prototype,{empty:{value:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()}},isIntersectionBox:{value:function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)}},isIntersectionSphere:{value:function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}}),Object.defineProperties(n.Matrix3.prototype,{multiplyVector3:{value:function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)}},multiplyVector3Array:{value:function(e){return console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(e)}}}),Object.defineProperties(n.Matrix4.prototype,{extractPosition:{value:function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)}},setRotationFromQuaternion:{value:function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)}},multiplyVector3:{value:function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."),e.applyProjection(this)}},multiplyVector4:{value:function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)}},multiplyVector3Array:{value:function(e){return console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(e)}},rotateAxis:{value:function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)}},crossVector:{value:function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)}},translate:{value:function(){console.error("THREE.Matrix4: .translate() has been removed.")}},rotateX:{value:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")}},rotateY:{value:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")}},rotateZ:{value:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")}},rotateByAxis:{value:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}}}),Object.defineProperties(n.Plane.prototype,{isIntersectionLine:{value:function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)}}}),Object.defineProperties(n.Quaternion.prototype,{multiplyVector3:{value:function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)}}}),Object.defineProperties(n.Ray.prototype,{isIntersectionBox:{value:function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)}},isIntersectionPlane:{value:function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)}},isIntersectionSphere:{value:function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)}}}),Object.defineProperties(n.Vector3.prototype,{setEulerFromRotationMatrix:{value:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")}},setEulerFromQuaternion:{value:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")}},getPositionFromMatrix:{value:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)}},getScaleFromMatrix:{value:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)}},getColumnFromMatrix:{value:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)}}}),n.Face4=function(e,t,i,r,o,a,s){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new n.Face3(e,t,i,o,a,s)},n.Vertex=function(e,t,i){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new n.Vector3(e,t,i)},Object.defineProperties(n.Object3D.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},getChildByName:{value:function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)}},renderDepth:{set:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")}},translate:{value:function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties(n,{PointCloud:{value:function(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new n.Points(e,t)}},ParticleSystem:{value:function(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new n.Points(e,t)}}}),Object.defineProperties(n.Light.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(n.BufferAttribute.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count."),this.array.length}}}),Object.defineProperties(n.BufferGeometry.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}},addIndex:{value:function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)}},addDrawCall:{value:function(e,t,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)}},clearDrawCalls:{value:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()}},computeTangents:{value:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")}},computeOffsets:{value:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}}),Object.defineProperties(n.Material.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE."+this.type+": .wrapRGB has been removed."),new n.Color}}}),Object.defineProperties(n,{PointCloudMaterial:{value:function(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new n.PointsMaterial(e)}},ParticleBasicMaterial:{value:function(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new n.PointsMaterial(e)}},ParticleSystemMaterial:{value:function(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new n.PointsMaterial(e)}}}),Object.defineProperties(n.MeshPhongMaterial.prototype,{metal:{ get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(n.ShaderMaterial.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),Object.defineProperties(n.WebGLRenderer.prototype,{supportsFloatTextures:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")}},supportsHalfFloatTextures:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")}},supportsStandardDerivatives:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")}},supportsCompressedTextureS3TC:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")}},supportsCompressedTexturePVRTC:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")}},supportsBlendMinMax:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")}},supportsVertexTextures:{value:function(){return this.capabilities.vertexTextures}},supportsInstancedArrays:{value:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")}},enableScissorTest:{value:function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)}},initMaterial:{value:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")}},addPrePlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")}},addPostPlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")}},updateShadowMap:{value:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}},shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace."),this.shadowMap.cullFace=e}}}),Object.defineProperties(n.WebGLRenderTarget.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),n.GeometryUtils={merge:function(e,t,i){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");var r;t instanceof n.Mesh&&(t.matrixAutoUpdate&&t.updateMatrix(),r=t.matrix,t=t.geometry),e.merge(t,r,i)},center:function(e){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),e.center()}},n.ImageUtils={crossOrigin:void 0,loadTexture:function(e,t,i,r){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var o=new n.TextureLoader;o.setCrossOrigin(this.crossOrigin);var a=o.load(e,i,void 0,r);return t&&(a.mapping=t),a},loadTextureCube:function(e,t,i,r){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var o=new n.CubeTextureLoader;o.setCrossOrigin(this.crossOrigin);var a=o.load(e,i,void 0,r);return t&&(a.mapping=t),a},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.")}},n.Projector=function(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js."),this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pickingRay=function(){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}},n.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js"),this.domElement=document.createElement("canvas"),this.clear=function(){},this.render=function(){},this.setClearColor=function(){},this.setSize=function(){}},n.MeshFaceMaterial=n.MultiMaterial,n.CurveUtils={tangentQuadraticBezier:function(e,t,i,r){return 2*(1-e)*(i-t)+2*e*(r-i)},tangentCubicBezier:function(e,t,i,r,n){return-3*t*(1-e)*(1-e)+3*i*(1-e)*(1-e)-6*e*i*(1-e)+6*e*r*(1-e)-3*e*e*r+3*e*e*n},tangentSpline:function(e){var t=6*e*e-6*e,i=3*e*e-4*e+1,r=-6*e*e+6*e,n=3*e*e-2*e;return t+i+r+n},interpolate:function(e,t,i,r,n){var o=.5*(i-e),a=.5*(r-t),s=n*n,c=n*s;return(2*t-2*i+o+a)*c+(-3*t+3*i-2*o-a)*s+o*n+t}},n.SceneUtils={createMultiMaterialObject:function(e,t){for(var i=new n.Group,r=0,o=t.length;o>r;r++)i.add(new n.Mesh(e,t[r]));return i},detach:function(e,t,i){e.applyMatrix(t.matrixWorld),t.remove(e),i.add(e)},attach:function(e,t,i){var r=new n.Matrix4;r.getInverse(i.matrixWorld),e.applyMatrix(r),t.remove(e),i.add(e)}},n.ShapeUtils={area:function(e){for(var t=e.length,i=0,r=t-1,n=0;t>n;r=n++)i+=e[r].x*e[n].y-e[n].x*e[r].y;return.5*i},triangulate:function(){function e(e,t,i,r,n,o){var a,s,c,h,l,u,d,p,f;if(s=e[o[t]].x,c=e[o[t]].y,h=e[o[i]].x,l=e[o[i]].y,u=e[o[r]].x,d=e[o[r]].y,Number.EPSILON>(h-s)*(d-c)-(l-c)*(u-s))return!1;var m,v,g,y,x,b,w,M,_,E,A,S,T,C,L;for(m=u-h,v=d-l,g=s-u,y=c-d,x=h-s,b=l-c,a=0;n>a;a++)if(p=e[o[a]].x,f=e[o[a]].y,!(p===s&&f===c||p===h&&f===l||p===u&&f===d)&&(w=p-s,M=f-c,_=p-h,E=f-l,A=p-u,S=f-d,L=m*E-v*_,T=x*M-b*w,C=g*S-y*A,L>=-Number.EPSILON&&C>=-Number.EPSILON&&T>=-Number.EPSILON))return!1;return!0}return function(t,i){var r=t.length;if(3>r)return null;var o,a,s,c=[],h=[],l=[];if(n.ShapeUtils.area(t)>0)for(a=0;r>a;a++)h[a]=a;else for(a=0;r>a;a++)h[a]=r-1-a;var u=r,d=2*u;for(a=u-1;u>2;){if(d--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),i?l:c;if(o=a,o>=u&&(o=0),a=o+1,a>=u&&(a=0),s=a+1,s>=u&&(s=0),e(t,o,a,s,u,h)){var p,f,m,v,g;for(p=h[o],f=h[a],m=h[s],c.push([t[p],t[f],t[m]]),l.push([h[o],h[a],h[s]]),v=a,g=a+1;u>g;v++,g++)h[v]=h[g];u--,d=2*u}}return i?l:c}}(),triangulateShape:function(e,t){function i(e,t,i){return e.x!==t.x?e.xNumber.EPSILON){var f;if(d>0){if(0>p||p>d)return[];if(f=h*l-c*u,0>f||f>d)return[]}else{if(p>0||d>p)return[];if(f=h*l-c*u,f>0||d>f)return[]}if(0===f)return!o||0!==p&&p!==d?[e]:[];if(f===d)return!o||0!==p&&p!==d?[t]:[];if(0===p)return[r];if(p===d)return[n];var m=f/d;return[{x:e.x+m*a,y:e.y+m*s}]}if(0!==p||h*l!==c*u)return[];var v=0===a&&0===s,g=0===c&&0===h;if(v&&g)return e.x!==r.x||e.y!==r.y?[]:[e];if(v)return i(r,n,e)?[e]:[];if(g)return i(e,t,r)?[r]:[];var y,x,b,w,M,_,E,A;return 0!==a?(e.x=b?E>w?[]:w===E?o?[]:[M]:A>=w?[M,x]:[M,_]:b>A?[]:b===A?o?[]:[y]:A>=w?[y,x]:[y,_]}function o(e,t,i,r){var n=t.x-e.x,o=t.y-e.y,a=i.x-e.x,s=i.y-e.y,c=r.x-e.x,h=r.y-e.y,l=n*s-o*a,u=n*h-o*c;if(Math.abs(l)>Number.EPSILON){var d=c*s-h*a;return l>0?u>=0&&d>=0:u>=0||d>=0}return u>0}function a(e,t){function i(e,t){var i=y.length-1,r=e-1;0>r&&(r=i);var n=e+1;n>i&&(n=0);var a=o(y[e],y[r],y[n],s[t]);if(!a)return!1;var c=s.length-1,h=t-1;0>h&&(h=c);var l=t+1;return l>c&&(l=0),a=o(s[t],s[h],s[l],y[e]),a?!0:!1}function n(e,t){var i,n,o;for(i=0;i0)return!0;return!1}function a(e,i){var n,o,a,s,c;for(n=0;n0)return!0;return!1}for(var s,c,h,l,u,d,p,f,m,v,g,y=e.concat(),x=[],b=[],w=0,M=t.length;M>w;w++)x.push(w);for(var _=0,E=2*x.length;x.length>0;){if(E--,0>E){console.log("Infinite Loop! Holes left:"+x.length+", Probably Hole outside Shape!");break}for(h=_;h=0)break;b[p]=!0}if(c>=0)break}}return y}for(var s,c,h,l,u,d,p={},f=e.concat(),m=0,v=t.length;v>m;m++)Array.prototype.push.apply(f,t[m]);for(s=0,c=f.length;c>s;s++)u=f[s].x+":"+f[s].y,void 0!==p[u]&&console.warn("THREE.Shape: Duplicate point",u),p[u]=s;var g=a(e,t),y=n.ShapeUtils.triangulate(g,!1);for(s=0,c=y.length;c>s;s++)for(l=y[s],h=0;3>h;h++)u=l[h].x+":"+l[h].y,d=p[u],void 0!==d&&(l[h]=d);return y.concat()},isClockWise:function(e){return n.ShapeUtils.area(e)<0},b2:function(){function e(e,t){var i=1-e;return i*i*t}function t(e,t){return 2*(1-e)*e*t}function i(e,t){return e*e*t}return function(r,n,o,a){return e(r,n)+t(r,o)+i(r,a)}}(),b3:function(){function e(e,t){var i=1-e;return i*i*i*t}function t(e,t){var i=1-e;return 3*i*i*e*t}function i(e,t){var i=1-e;return 3*i*e*e*t}function r(e,t){return e*e*e*t}return function(n,o,a,s,c){return e(n,o)+t(n,a)+i(n,s)+r(n,c)}}()},n.Curve=function(){},n.Curve.prototype={constructor:n.Curve,getPoint:function(){return console.warn("THREE.Curve: Warning, getPoint() not implemented!"),null},getPointAt:function(e){var t=this.getUtoTmapping(e);return this.getPoint(t)},getPoints:function(e){e||(e=5);var t,i=[];for(t=0;e>=t;t++)i.push(this.getPoint(t/e));return i},getSpacedPoints:function(e){e||(e=5);var t,i=[];for(t=0;e>=t;t++)i.push(this.getPointAt(t/e));return i},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,r=[],n=this.getPoint(0),o=0;for(r.push(0),i=1;e>=i;i++)t=this.getPoint(i/e),o+=t.distanceTo(n),r.push(o),n=t;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var i,r=this.getLengths(),n=0,o=r.length;i=t?t:e*r[o-1];for(var a,s=0,c=o-1;c>=s;)if(n=Math.floor(s+(c-s)/2),a=r[n]-i,0>a)s=n+1;else{if(!(a>0)){c=n;break}c=n-1}if(n=c,r[n]===i){var h=n/(o-1);return h}var l=r[n],u=r[n+1],d=u-l,p=(i-l)/d,h=(n+p)/(o-1);return h},getTangent:function(e){var t=1e-4,i=e-t,r=e+t;0>i&&(i=0),r>1&&(r=1);var n=this.getPoint(i),o=this.getPoint(r),a=o.clone().sub(n);return a.normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)}},n.Curve.create=function(e,t){return e.prototype=Object.create(n.Curve.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},n.CurvePath=function(){this.curves=[],this.autoClose=!1},n.CurvePath.prototype=Object.create(n.Curve.prototype),n.CurvePath.prototype.constructor=n.CurvePath,n.CurvePath.prototype.add=function(e){this.curves.push(e)},n.CurvePath.prototype.closePath=function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new n.LineCurve(t,e))},n.CurvePath.prototype.getPoint=function(e){for(var t=e*this.getLength(),i=this.getCurveLengths(),r=0;r=t){var n=i[r]-t,o=this.curves[r],a=1-n/o.getLength();return o.getPointAt(a)}r++}return null},n.CurvePath.prototype.getLength=function(){var e=this.getCurveLengths();return e[e.length-1]},n.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,i=0,r=this.curves.length;r>i;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e},n.CurvePath.prototype.createPointsGeometry=function(e){var t=this.getPoints(e);return this.createGeometry(t)},n.CurvePath.prototype.createSpacedPointsGeometry=function(e){var t=this.getSpacedPoints(e);return this.createGeometry(t)},n.CurvePath.prototype.createGeometry=function(e){for(var t=new n.Geometry,i=0,r=e.length;r>i;i++){var o=e[i];t.vertices.push(new n.Vector3(o.x,o.y,o.z||0))}return t},n.Font=function(e){this.data=e},n.Font.prototype={constructor:n.Font,generateShapes:function(e,t,i){function r(e){for(var i=String(e).split(""),r=t/a.resolution,n=0,s=[],c=0;c_;){var A=M[_++];switch(A){case"m":s=M[_++]*t+r,c=M[_++]*t,y.moveTo(s,c);break;case"l":s=M[_++]*t+r,c=M[_++]*t,y.lineTo(s,c);break;case"q":if(h=M[_++]*t+r,l=M[_++]*t,p=M[_++]*t+r,f=M[_++]*t,y.quadraticCurveTo(p,f,h,l),g=x[x.length-1]){u=g.x,d=g.y;for(var S=1;i>=S;S++){var T=S/i;b(T,u,p,h),b(T,d,f,l)}}break;case"b":if(h=M[_++]*t+r,l=M[_++]*t,p=M[_++]*t+r,f=M[_++]*t,m=M[_++]*t+r,v=M[_++]*t,y.bezierCurveTo(p,f,m,v,h,l),g=x[x.length-1]){u=g.x,d=g.y;for(var S=1;i>=S;S++){var T=S/i;w(T,u,p,m,h),w(T,d,f,v,l)}}}}return{offset:o.ha*t,path:y}}}void 0===t&&(t=100),void 0===i&&(i=4);for(var a=this.data,s=r(e),c=[],h=0,l=s.length;l>h;h++)Array.prototype.push.apply(c,s[h].toShapes());return c}},n.Path=function(e){n.CurvePath.call(this),this.actions=[],e&&this.fromPoints(e)},n.Path.prototype=Object.create(n.CurvePath.prototype),n.Path.prototype.constructor=n.Path,n.Path.prototype.fromPoints=function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,i=e.length;i>t;t++)this.lineTo(e[t].x,e[t].y)},n.Path.prototype.moveTo=function(e,t){this.actions.push({action:"moveTo",args:[e,t]})},n.Path.prototype.lineTo=function(e,t){var i=this.actions[this.actions.length-1].args,r=i[i.length-2],o=i[i.length-1],a=new n.LineCurve(new n.Vector2(r,o),new n.Vector2(e,t));this.curves.push(a),this.actions.push({action:"lineTo",args:[e,t]})},n.Path.prototype.quadraticCurveTo=function(e,t,i,r){var o=this.actions[this.actions.length-1].args,a=o[o.length-2],s=o[o.length-1],c=new n.QuadraticBezierCurve(new n.Vector2(a,s),new n.Vector2(e,t),new n.Vector2(i,r));this.curves.push(c),this.actions.push({action:"quadraticCurveTo",args:[e,t,i,r]})},n.Path.prototype.bezierCurveTo=function(e,t,i,r,o,a){var s=this.actions[this.actions.length-1].args,c=s[s.length-2],h=s[s.length-1],l=new n.CubicBezierCurve(new n.Vector2(c,h),new n.Vector2(e,t),new n.Vector2(i,r),new n.Vector2(o,a));this.curves.push(l),this.actions.push({action:"bezierCurveTo",args:[e,t,i,r,o,a]})},n.Path.prototype.splineThru=function(e){var t=Array.prototype.slice.call(arguments),i=this.actions[this.actions.length-1].args,r=i[i.length-2],o=i[i.length-1],a=[new n.Vector2(r,o)];Array.prototype.push.apply(a,e);var s=new n.SplineCurve(a);this.curves.push(s),this.actions.push({action:"splineThru",args:t})},n.Path.prototype.arc=function(e,t,i,r,n,o){var a=this.actions[this.actions.length-1].args,s=a[a.length-2],c=a[a.length-1];this.absarc(e+s,t+c,i,r,n,o)},n.Path.prototype.absarc=function(e,t,i,r,n,o){this.absellipse(e,t,i,i,r,n,o)},n.Path.prototype.ellipse=function(e,t,i,r,n,o,a,s){var c=this.actions[this.actions.length-1].args,h=c[c.length-2],l=c[c.length-1];this.absellipse(e+h,t+l,i,r,n,o,a,s)},n.Path.prototype.absellipse=function(e,t,i,r,o,a,s,c){var h=[e,t,i,r,o,a,s,c||0],l=new n.EllipseCurve(e,t,i,r,o,a,s,c);this.curves.push(l);var u=l.getPoint(1);h.push(u.x),h.push(u.y),this.actions.push({action:"ellipse",args:h})},n.Path.prototype.getSpacedPoints=function(e){e||(e=40);for(var t=[],i=0;e>i;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t},n.Path.prototype.getPoints=function(e){e=e||12;for(var t,i,r,o,a,s,c,h,l,u,d,p=n.ShapeUtils.b2,f=n.ShapeUtils.b3,m=[],v=0,g=this.actions.length;g>v;v++){var y=this.actions[v],x=y.action,b=y.args;switch(x){case"moveTo":m.push(new n.Vector2(b[0],b[1]));break;case"lineTo":m.push(new n.Vector2(b[0],b[1]));break;case"quadraticCurveTo":t=b[2],i=b[3],a=b[0],s=b[1],m.length>0?(l=m[m.length-1],c=l.x,h=l.y):(l=this.actions[v-1].args,c=l[l.length-2],h=l[l.length-1]);for(var w=1;e>=w;w++){var M=w/e;u=p(M,c,a,t),d=p(M,h,s,i),m.push(new n.Vector2(u,d))}break;case"bezierCurveTo":t=b[4],i=b[5],a=b[0],s=b[1],r=b[2],o=b[3],m.length>0?(l=m[m.length-1],c=l.x,h=l.y):(l=this.actions[v-1].args,c=l[l.length-2],h=l[l.length-1]);for(var w=1;e>=w;w++){var M=w/e;u=f(M,c,a,r,t),d=f(M,h,s,o,i),m.push(new n.Vector2(u,d))}break;case"splineThru":l=this.actions[v-1].args;var _=new n.Vector2(l[l.length-2],l[l.length-1]),E=[_],A=e*b[0].length;E=E.concat(b[0]);for(var S=new n.SplineCurve(E),w=1;A>=w;w++)m.push(S.getPointAt(w/A));break;case"arc":for(var T,C=b[0],L=b[1],R=b[2],P=b[3],D=b[4],O=!!b[5],I=D-P,k=2*e,w=1;k>=w;w++){var M=w/k;O||(M=1-M),T=P+M*I,u=C+R*Math.cos(T),d=L+R*Math.sin(T),m.push(new n.Vector2(u,d))}break;case"ellipse":var T,N,B,C=b[0],L=b[1],F=b[2],V=b[3],P=b[4],D=b[5],O=!!b[6],U=b[7],I=D-P,k=2*e;0!==U&&(N=Math.cos(U),B=Math.sin(U));for(var w=1;k>=w;w++){var M=w/k;if(O||(M=1-M),T=P+M*I,u=C+F*Math.cos(T),d=L+V*Math.sin(T),0!==U){var z=u,j=d;u=(z-C)*N-(j-L)*B+C,d=(z-C)*B+(j-L)*N+L}m.push(new n.Vector2(u,d))}}}var G=m[m.length-1];return Math.abs(G.x-m[0].x)r;r++){var a=e[r],s=a.args,c=a.action;"moveTo"===c&&0!==i.actions.length&&(t.push(i),i=new n.Path),i[c].apply(i,s)}return 0!==i.actions.length&&t.push(i),t}function r(e){for(var t=[],i=0,r=e.length;r>i;i++){var o=e[i],a=new n.Shape;a.actions=o.actions,a.curves=o.curves,t.push(a)}return t}function o(e,t){for(var i=t.length,r=!1,n=i-1,o=0;i>o;n=o++){var a=t[n],s=t[o],c=s.x-a.x,h=s.y-a.y;if(Math.abs(h)>Number.EPSILON){if(0>h&&(a=t[o],c=-c,s=t[n],h=-h),e.ys.y)continue;if(e.y===a.y){if(e.x===a.x)return!0}else{var l=h*(e.x-a.x)-c*(e.y-a.y);if(0===l)return!0;if(0>l)continue;r=!r}}else{if(e.y!==a.y)continue;if(s.x<=e.x&&e.x<=a.x||a.x<=e.x&&e.x<=s.x)return!0}}return r}var a=n.ShapeUtils.isClockWise,s=i(this.actions);if(0===s.length)return[];if(t===!0)return r(s);var c,h,l,u=[];if(1===s.length)return h=s[0],l=new n.Shape,l.actions=h.actions,l.curves=h.curves,u.push(l),u;var d=!a(s[0].getPoints());d=e?!d:d;var p,f=[],m=[],v=[],g=0;m[g]=void 0,v[g]=[];for(var y=0,x=s.length;x>y;y++)h=s[y],p=h.getPoints(),c=a(p),c=e?!c:c,c?(!d&&m[g]&&g++,m[g]={s:new n.Shape,p:p},m[g].s.actions=h.actions,m[g].s.curves=h.curves,d&&g++,v[g]=[]):v[g].push({h:h,p:p[0]});if(!m[0])return r(s);if(m.length>1){for(var b=!1,w=[],M=0,_=m.length;_>M;M++)f[M]=[];for(var M=0,_=m.length;_>M;M++)for(var E=v[M],A=0;A0&&(b||(v=f))}for(var L,y=0,R=m.length;R>y;y++){l=m[y].s,u.push(l),L=v[y];for(var P=0,D=L.length;D>P;P++)l.holes.push(L[P].h)}return u},n.Shape=function(){n.Path.apply(this,arguments),this.holes=[]},n.Shape.prototype=Object.create(n.Path.prototype),n.Shape.prototype.constructor=n.Shape,n.Shape.prototype.extrude=function(e){return new n.ExtrudeGeometry(this,e)},n.Shape.prototype.makeGeometry=function(e){return new n.ShapeGeometry(this,e)},n.Shape.prototype.getPointsHoles=function(e){for(var t=[],i=0,r=this.holes.length;r>i;i++)t[i]=this.holes[i].getPoints(e);return t},n.Shape.prototype.extractAllPoints=function(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}},n.Shape.prototype.extractPoints=function(e){return this.extractAllPoints(e)},n.LineCurve=function(e,t){this.v1=e,this.v2=t},n.LineCurve.prototype=Object.create(n.Curve.prototype),n.LineCurve.prototype.constructor=n.LineCurve,n.LineCurve.prototype.getPoint=function(e){var t=this.v2.clone().sub(this.v1);return t.multiplyScalar(e).add(this.v1),t},n.LineCurve.prototype.getPointAt=function(e){return this.getPoint(e)},n.LineCurve.prototype.getTangent=function(){var e=this.v2.clone().sub(this.v1);return e.normalize()},n.QuadraticBezierCurve=function(e,t,i){this.v0=e,this.v1=t,this.v2=i},n.QuadraticBezierCurve.prototype=Object.create(n.Curve.prototype),n.QuadraticBezierCurve.prototype.constructor=n.QuadraticBezierCurve,n.QuadraticBezierCurve.prototype.getPoint=function(e){var t=n.ShapeUtils.b2;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x),t(e,this.v0.y,this.v1.y,this.v2.y))},n.QuadraticBezierCurve.prototype.getTangent=function(e){var t=n.CurveUtils.tangentQuadraticBezier;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x),t(e,this.v0.y,this.v1.y,this.v2.y)).normalize()},n.CubicBezierCurve=function(e,t,i,r){this.v0=e,this.v1=t,this.v2=i,this.v3=r},n.CubicBezierCurve.prototype=Object.create(n.Curve.prototype),n.CubicBezierCurve.prototype.constructor=n.CubicBezierCurve,n.CubicBezierCurve.prototype.getPoint=function(e){var t=n.ShapeUtils.b3;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),t(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y))},n.CubicBezierCurve.prototype.getTangent=function(e){var t=n.CurveUtils.tangentCubicBezier;return new n.Vector2(t(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),t(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y)).normalize()},n.SplineCurve=function(e){this.points=void 0==e?[]:e},n.SplineCurve.prototype=Object.create(n.Curve.prototype),n.SplineCurve.prototype.constructor=n.SplineCurve,n.SplineCurve.prototype.getPoint=function(e){var t=this.points,i=(t.length-1)*e,r=Math.floor(i),o=i-r,a=t[0===r?r:r-1],s=t[r],c=t[r>t.length-2?t.length-1:r+1],h=t[r>t.length-3?t.length-1:r+2],l=n.CurveUtils.interpolate;return new n.Vector2(l(a.x,s.x,c.x,h.x,o),l(a.y,s.y,c.y,h.y,o))},n.EllipseCurve=function(e,t,i,r,n,o,a,s){this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0},n.EllipseCurve.prototype=Object.create(n.Curve.prototype),n.EllipseCurve.prototype.constructor=n.EllipseCurve,n.EllipseCurve.prototype.getPoint=function(e){var t=this.aEndAngle-this.aStartAngle;0>t&&(t+=2*Math.PI),t>2*Math.PI&&(t-=2*Math.PI);var i;i=this.aClockwise===!0?this.aEndAngle+(1-e)*(2*Math.PI-t):this.aStartAngle+e*t;var r=this.aX+this.xRadius*Math.cos(i),o=this.aY+this.yRadius*Math.sin(i);if(0!==this.aRotation){var a=Math.cos(this.aRotation),s=Math.sin(this.aRotation),c=r,h=o;r=(c-this.aX)*a-(h-this.aY)*s+this.aX,o=(c-this.aX)*s+(h-this.aY)*a+this.aY}return new n.Vector2(r,o)},n.ArcCurve=function(e,t,i,r,o,a){n.EllipseCurve.call(this,e,t,i,i,r,o,a)},n.ArcCurve.prototype=Object.create(n.EllipseCurve.prototype),n.ArcCurve.prototype.constructor=n.ArcCurve,n.LineCurve3=n.Curve.create(function(e,t){this.v1=e,this.v2=t},function(e){var t=new n.Vector3;return t.subVectors(this.v2,this.v1),t.multiplyScalar(e),t.add(this.v1),t}),n.QuadraticBezierCurve3=n.Curve.create(function(e,t,i){this.v0=e,this.v1=t,this.v2=i},function(e){var t=n.ShapeUtils.b2;return new n.Vector3(t(e,this.v0.x,this.v1.x,this.v2.x),t(e,this.v0.y,this.v1.y,this.v2.y),t(e,this.v0.z,this.v1.z,this.v2.z))}),n.CubicBezierCurve3=n.Curve.create(function(e,t,i,r){this.v0=e,this.v1=t,this.v2=i,this.v3=r},function(e){var t=n.ShapeUtils.b3;return new n.Vector3(t(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),t(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),t(e,this.v0.z,this.v1.z,this.v2.z,this.v3.z))}),n.SplineCurve3=n.Curve.create(function(e){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3"),this.points=void 0==e?[]:e},function(e){var t=this.points,i=(t.length-1)*e,r=Math.floor(i),o=i-r,a=t[0==r?r:r-1],s=t[r],c=t[r>t.length-2?t.length-1:r+1],h=t[r>t.length-3?t.length-1:r+2],l=n.CurveUtils.interpolate;return new n.Vector3(l(a.x,s.x,c.x,h.x,o),l(a.y,s.y,c.y,h.y,o),l(a.z,s.z,c.z,h.z,o))}),n.CatmullRomCurve3=function(){function e(){}var t=new n.Vector3,i=new e,r=new e,o=new e;return e.prototype.init=function(e,t,i,r){this.c0=e,this.c1=i,this.c2=-3*e+3*t-2*i-r,this.c3=2*e-2*t+i+r},e.prototype.initNonuniformCatmullRom=function(e,t,i,r,n,o,a){var s=(t-e)/n-(i-e)/(n+o)+(i-t)/o,c=(i-t)/o-(r-t)/(o+a)+(r-i)/a;s*=o,c*=o,this.init(t,i,s,c)},e.prototype.initCatmullRom=function(e,t,i,r,n){this.init(t,i,n*(i-e),n*(r-t))},e.prototype.calc=function(e){var t=e*e,i=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*i},n.Curve.create(function(e){this.points=e||[],this.closed=!1},function(e){var a,s,c,h,l=this.points;h=l.length,2>h&&console.log("duh, you need at least 2 points"),a=(h-(this.closed?0:1))*e,s=Math.floor(a),c=a-s,this.closed?s+=s>0?0:(Math.floor(Math.abs(s)/l.length)+1)*l.length:0===c&&s===h-1&&(s=h-2,c=1);var u,d,p,f;if(this.closed||s>0?u=l[(s-1)%h]:(t.subVectors(l[0],l[1]).add(l[0]),u=t),d=l[s%h],p=l[(s+1)%h],this.closed||h>s+2?f=l[(s+2)%h]:(t.subVectors(l[h-1],l[h-2]).add(l[h-1]),f=t),void 0===this.type||"centripetal"===this.type||"chordal"===this.type){var m="chordal"===this.type?.5:.25,v=Math.pow(u.distanceToSquared(d),m),g=Math.pow(d.distanceToSquared(p),m),y=Math.pow(p.distanceToSquared(f),m);1e-4>g&&(g=1),1e-4>v&&(v=g),1e-4>y&&(y=g),i.initNonuniformCatmullRom(u.x,d.x,p.x,f.x,v,g,y),r.initNonuniformCatmullRom(u.y,d.y,p.y,f.y,v,g,y),o.initNonuniformCatmullRom(u.z,d.z,p.z,f.z,v,g,y)}else if("catmullrom"===this.type){var x=void 0!==this.tension?this.tension:.5;i.initCatmullRom(u.x,d.x,p.x,f.x,x),r.initCatmullRom(u.y,d.y,p.y,f.y,x),o.initCatmullRom(u.z,d.z,p.z,f.z,x)}var b=new n.Vector3(i.calc(c),r.calc(c),o.calc(c));return b})}(),n.ClosedSplineCurve3=function(e){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3."),n.CatmullRomCurve3.call(this,e),this.type="catmullrom",this.closed=!0},n.ClosedSplineCurve3.prototype=Object.create(n.CatmullRomCurve3.prototype),n.BoxGeometry=function(e,t,i,r,o,a){n.Geometry.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:o,depthSegments:a},this.fromBufferGeometry(new n.BoxBufferGeometry(e,t,i,r,o,a)),this.mergeVertices()},n.BoxGeometry.prototype=Object.create(n.Geometry.prototype),n.BoxGeometry.prototype.constructor=n.BoxGeometry,n.CubeGeometry=n.BoxGeometry,n.BoxBufferGeometry=function(e,t,i,r,o,a){function s(e,t,i){var r=0;return r+=e*t*2,r+=e*i*2,r+=i*t*2,4*r}function c(e,t,i,r,o,a,s,c,l,u,w){for(var M=a/l,_=s/u,E=a/2,A=s/2,S=c/2,T=l+1,C=u+1,L=0,R=0,P=new n.Vector3,D=0;C>D;D++)for(var O=D*_-A,I=0;T>I;I++){var k=I*M-E;P[e]=k*r,P[t]=O*o,P[i]=S,p[v]=P.x,p[v+1]=P.y,p[v+2]=P.z,P[e]=0,P[t]=0,P[i]=c>0?1:-1,f[v]=P.x,f[v+1]=P.y,f[v+2]=P.z,m[g]=I/l,m[g+1]=1-D/u,v+=3,g+=2,L+=1}for(D=0;u>D;D++)for(I=0;l>I;I++){var N=x+I+T*D,B=x+I+T*(D+1),F=x+(I+1)+T*(D+1),V=x+(I+1)+T*D;d[y]=N,d[y+1]=B,d[y+2]=V,d[y+3]=B,d[y+4]=F,d[y+5]=V,y+=6,R+=6}h.addGroup(b,R,w),b+=R,x+=L}n.BufferGeometry.call(this),this.type="BoxBufferGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:o,depthSegments:a};var h=this;r=Math.floor(r)||1,o=Math.floor(o)||1,a=Math.floor(a)||1;var l=s(r,o,a),u=l/4*6,d=new(u>65535?Uint32Array:Uint16Array)(u),p=new Float32Array(3*l),f=new Float32Array(3*l),m=new Float32Array(2*l),v=0,g=0,y=0,x=0,b=0;c("z","y","x",-1,-1,i,t,e,a,o,0),c("z","y","x",1,-1,i,t,-e,a,o,1),c("x","z","y",1,1,e,i,t,r,a,2),c("x","z","y",1,-1,e,i,-t,r,a,3),c("x","y","z",1,-1,e,t,i,r,o,4),c("x","y","z",-1,-1,e,t,-i,r,o,5),this.setIndex(new n.BufferAttribute(d,1)),this.addAttribute("position",new n.BufferAttribute(p,3)),this.addAttribute("normal",new n.BufferAttribute(f,3)),this.addAttribute("uv",new n.BufferAttribute(m,2))},n.BoxBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.BoxBufferGeometry.prototype.constructor=n.BoxBufferGeometry,n.CircleGeometry=function(e,t,i,r){n.Geometry.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new n.CircleBufferGeometry(e,t,i,r))},n.CircleGeometry.prototype=Object.create(n.Geometry.prototype),n.CircleGeometry.prototype.constructor=n.CircleGeometry,n.CircleBufferGeometry=function(e,t,i,r){n.BufferGeometry.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},e=e||50,t=void 0!==t?Math.max(3,t):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI; var o=t+2,a=new Float32Array(3*o),s=new Float32Array(3*o),c=new Float32Array(2*o);s[2]=1,c[0]=.5,c[1]=.5;for(var h=0,l=3,u=2;t>=h;h++,l+=3,u+=2){var d=i+h/t*r;a[l]=e*Math.cos(d),a[l+1]=e*Math.sin(d),s[l+2]=1,c[u]=(a[l]/e+1)/2,c[u+1]=(a[l+1]/e+1)/2}for(var p=[],l=1;t>=l;l++)p.push(l,l+1,0);this.setIndex(new n.BufferAttribute(new Uint16Array(p),1)),this.addAttribute("position",new n.BufferAttribute(a,3)),this.addAttribute("normal",new n.BufferAttribute(s,3)),this.addAttribute("uv",new n.BufferAttribute(c,2)),this.boundingSphere=new n.Sphere(new n.Vector3,e)},n.CircleBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.CircleBufferGeometry.prototype.constructor=n.CircleBufferGeometry,n.CylinderBufferGeometry=function(e,t,i,r,o,a,s,c){function h(){var e=(r+1)*(o+1);return a===!1&&(e+=2*(r+1)+2*r),e}function l(){var e=r*o*2*3;return a===!1&&(e+=2*r*3),e}function u(){var a,h,l=new n.Vector3,u=new n.Vector3,d=(t-e)/i;for(h=0;o>=h;h++){var p=[],f=h/o,_=f*(t-e)+e;for(a=0;r>=a;a++){var E=a/r;u.x=_*Math.sin(E*c+s),u.y=-f*i+M,u.z=_*Math.cos(E*c+s),v.setXYZ(x,u.x,u.y,u.z),l.copy(u),(0===e&&0===h||0===t&&h===o)&&(l.x=Math.sin(E*c+s),l.z=Math.cos(E*c+s)),l.setY(Math.sqrt(l.x*l.x+l.z*l.z)*d).normalize(),g.setXYZ(x,l.x,l.y,l.z),y.setXY(x,E,1-f),p.push(x),x++}w.push(p)}for(a=0;r>a;a++)for(h=0;o>h;h++){var A=w[h][a],S=w[h+1][a],T=w[h+1][a+1],C=w[h][a+1];m.setX(b,A),b++,m.setX(b,S),b++,m.setX(b,C),b++,m.setX(b,S),b++,m.setX(b,T),b++,m.setX(b,C),b++}}function d(i){var o,a,h,l=new n.Vector2,u=new n.Vector3,d=i===!0?e:t,p=i===!0?1:-1;for(a=x,o=1;r>=o;o++)v.setXYZ(x,0,M*p,0),g.setXYZ(x,0,p,0),i===!0?(l.x=o/r,l.y=0):(l.x=(o-1)/r,l.y=1),y.setXY(x,l.x,l.y),x++;for(h=x,o=0;r>=o;o++){var f=o/r;u.x=d*Math.sin(f*c+s),u.y=M*p,u.z=d*Math.cos(f*c+s),v.setXYZ(x,u.x,u.y,u.z),g.setXYZ(x,0,p,0),y.setXY(x,f,i===!0?1:0),x++}for(o=0;r>o;o++){var w=a+o,_=h+o;i===!0?(m.setX(b,_),b++,m.setX(b,_+1),b++,m.setX(b,w),b++):(m.setX(b,_+1),b++,m.setX(b,_),b++,m.setX(b,w),b++)}}n.BufferGeometry.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:c},e=void 0!==e?e:20,t=void 0!==t?t:20,i=void 0!==i?i:100,r=Math.floor(r)||8,o=Math.floor(o)||1,a=void 0!==a?a:!1,s=void 0!==s?s:0,c=void 0!==c?c:2*Math.PI;var p=h(),f=l(),m=new n.BufferAttribute(new(f>65535?Uint32Array:Uint16Array)(f),1),v=new n.BufferAttribute(new Float32Array(3*p),3),g=new n.BufferAttribute(new Float32Array(3*p),3),y=new n.BufferAttribute(new Float32Array(2*p),2),x=0,b=0,w=[],M=i/2;u(),a===!1&&(e>0&&d(!0),t>0&&d(!1)),this.setIndex(m),this.addAttribute("position",v),this.addAttribute("normal",g),this.addAttribute("uv",y)},n.CylinderBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.CylinderBufferGeometry.prototype.constructor=n.CylinderBufferGeometry,n.CylinderGeometry=function(e,t,i,r,o,a,s,c){n.Geometry.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:c},this.fromBufferGeometry(new n.CylinderBufferGeometry(e,t,i,r,o,a,s,c)),this.mergeVertices()},n.CylinderGeometry.prototype=Object.create(n.Geometry.prototype),n.CylinderGeometry.prototype.constructor=n.CylinderGeometry,n.EdgesGeometry=function(e,t){function i(e,t){return e-t}n.BufferGeometry.call(this),t=void 0!==t?t:1;var r,o=Math.cos(n.Math.degToRad(t)),a=[0,0],s={},c=["a","b","c"];e instanceof n.BufferGeometry?(r=new n.Geometry,r.fromBufferGeometry(e)):r=e.clone(),r.mergeVertices(),r.computeFaceNormals();for(var h=r.vertices,l=r.faces,u=0,d=l.length;d>u;u++)for(var p=l[u],f=0;3>f;f++){a[0]=p[c[f]],a[1]=p[c[(f+1)%3]],a.sort(i);var m=a.toString();void 0===s[m]?s[m]={vert1:a[0],vert2:a[1],face1:u,face2:void 0}:s[m].face2=u}var v=[];for(var m in s){var g=s[m];if(void 0===g.face2||l[g.face1].normal.dot(l[g.face2].normal)<=o){var y=h[g.vert1];v.push(y.x),v.push(y.y),v.push(y.z),y=h[g.vert2],v.push(y.x),v.push(y.y),v.push(y.z)}}this.addAttribute("position",new n.BufferAttribute(new Float32Array(v),3))},n.EdgesGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.EdgesGeometry.prototype.constructor=n.EdgesGeometry,n.ExtrudeGeometry=function(e,t){return"undefined"==typeof e?void(e=[]):(n.Geometry.call(this),this.type="ExtrudeGeometry",e=Array.isArray(e)?e:[e],this.addShapeList(e,t),void this.computeFaceNormals())},n.ExtrudeGeometry.prototype=Object.create(n.Geometry.prototype),n.ExtrudeGeometry.prototype.constructor=n.ExtrudeGeometry,n.ExtrudeGeometry.prototype.addShapeList=function(e,t){for(var i=e.length,r=0;i>r;r++){var n=e[r];this.addShape(n,t)}},n.ExtrudeGeometry.prototype.addShape=function(e,t){function i(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(i).add(e)}function r(e,t,i){var r,o,a=1,s=e.x-t.x,c=e.y-t.y,h=i.x-e.x,l=i.y-e.y,u=s*s+c*c,d=s*l-c*h;if(Math.abs(d)>Number.EPSILON){var p=Math.sqrt(u),f=Math.sqrt(h*h+l*l),m=t.x-c/p,v=t.y+s/p,g=i.x-l/f,y=i.y+h/f,x=((g-m)*l-(y-v)*h)/(s*l-c*h);r=m+s*x-e.x,o=v+c*x-e.y;var b=r*r+o*o;if(2>=b)return new n.Vector2(r,o);a=Math.sqrt(b/2)}else{var w=!1;s>Number.EPSILON?h>Number.EPSILON&&(w=!0):s<-Number.EPSILON?h<-Number.EPSILON&&(w=!0):Math.sign(c)===Math.sign(l)&&(w=!0),w?(r=-c,o=s,a=Math.sqrt(u)):(r=s,o=c,a=Math.sqrt(u/2))}return new n.Vector2(r/a,o/a)}function o(){if(b){var e=0,t=G*e;for(q=0;H>q;q++)j=k[q],h(j[2]+t,j[1]+t,j[0]+t);for(e=M+2*x,t=G*e,q=0;H>q;q++)j=k[q],h(j[0]+t,j[1]+t,j[2]+t)}else{for(q=0;H>q;q++)j=k[q],h(j[2],j[1],j[0]);for(q=0;H>q;q++)j=k[q],h(j[0]+G*M,j[1]+G*M,j[2]+G*M)}}function a(){var e=0;for(s(N,e),e+=N.length,T=0,C=O.length;C>T;T++)S=O[T],s(S,e),e+=S.length}function s(e,t){var i,r;for(q=e.length;--q>=0;){i=q,r=q-1,0>r&&(r=e.length-1);var n=0,o=M+2*x;for(n=0;o>n;n++){var a=G*n,s=G*(n+1),c=t+i+a,h=t+r+a,u=t+r+s,d=t+i+s;l(c,h,u,d,e,n,o,i,r)}}}function c(e,t,i){L.vertices.push(new n.Vector3(e,t,i))}function h(e,t,i){e+=R,t+=R,i+=R,L.faces.push(new n.Face3(e,t,i,null,null,0));var r=A.generateTopUV(L,e,t,i);L.faceVertexUvs[0].push(r)}function l(e,t,i,r){e+=R,t+=R,i+=R,r+=R,L.faces.push(new n.Face3(e,t,r,null,null,1)),L.faces.push(new n.Face3(t,i,r,null,null,1));var o=A.generateSideWallUV(L,e,t,i,r);L.faceVertexUvs[0].push([o[0],o[1],o[3]]),L.faceVertexUvs[0].push([o[1],o[2],o[3]])}var u,d,p,f,m,v=void 0!==t.amount?t.amount:100,g=void 0!==t.bevelThickness?t.bevelThickness:6,y=void 0!==t.bevelSize?t.bevelSize:g-2,x=void 0!==t.bevelSegments?t.bevelSegments:3,b=void 0!==t.bevelEnabled?t.bevelEnabled:!0,w=void 0!==t.curveSegments?t.curveSegments:12,M=void 0!==t.steps?t.steps:1,_=t.extrudePath,E=!1,A=void 0!==t.UVGenerator?t.UVGenerator:n.ExtrudeGeometry.WorldUVGenerator;_&&(u=_.getSpacedPoints(M),E=!0,b=!1,d=void 0!==t.frames?t.frames:new n.TubeGeometry.FrenetFrames(_,M,!1),p=new n.Vector3,f=new n.Vector3,m=new n.Vector3),b||(x=0,g=0,y=0);var S,T,C,L=this,R=this.vertices.length,P=e.extractPoints(w),D=P.shape,O=P.holes,I=!n.ShapeUtils.isClockWise(D);if(I){for(D=D.reverse(),T=0,C=O.length;C>T;T++)S=O[T],n.ShapeUtils.isClockWise(S)&&(O[T]=S.reverse());I=!1}var k=n.ShapeUtils.triangulateShape(D,O),N=D;for(T=0,C=O.length;C>T;T++)S=O[T],D=D.concat(S);for(var B,F,V,U,z,j,G=D.length,H=k.length,W=[],q=0,X=N.length,Y=X-1,Q=q+1;X>q;q++,Y++,Q++)Y===X&&(Y=0),Q===X&&(Q=0),W[q]=r(N[q],N[Y],N[Q]);var K,Z=[],J=W.concat();for(T=0,C=O.length;C>T;T++){for(S=O[T],K=[],q=0,X=S.length,Y=X-1,Q=q+1;X>q;q++,Y++,Q++)Y===X&&(Y=0),Q===X&&(Q=0),K[q]=r(S[q],S[Y],S[Q]);Z.push(K),J=J.concat(K)}for(B=0;x>B;B++){for(V=B/x,U=g*(1-V),F=y*Math.sin(V*Math.PI/2),q=0,X=N.length;X>q;q++)z=i(N[q],W[q],F),c(z.x,z.y,-U);for(T=0,C=O.length;C>T;T++)for(S=O[T],K=Z[T],q=0,X=S.length;X>q;q++)z=i(S[q],K[q],F),c(z.x,z.y,-U)}for(F=y,q=0;G>q;q++)z=b?i(D[q],J[q],F):D[q],E?(f.copy(d.normals[0]).multiplyScalar(z.x),p.copy(d.binormals[0]).multiplyScalar(z.y),m.copy(u[0]).add(f).add(p),c(m.x,m.y,m.z)):c(z.x,z.y,0);var $;for($=1;M>=$;$++)for(q=0;G>q;q++)z=b?i(D[q],J[q],F):D[q],E?(f.copy(d.normals[$]).multiplyScalar(z.x),p.copy(d.binormals[$]).multiplyScalar(z.y),m.copy(u[$]).add(f).add(p),c(m.x,m.y,m.z)):c(z.x,z.y,v/M*$);for(B=x-1;B>=0;B--){for(V=B/x,U=g*(1-V),F=y*Math.sin(V*Math.PI/2),q=0,X=N.length;X>q;q++)z=i(N[q],W[q],F),c(z.x,z.y,v+U);for(T=0,C=O.length;C>T;T++)for(S=O[T],K=Z[T],q=0,X=S.length;X>q;q++)z=i(S[q],K[q],F),E?c(z.x,z.y+u[M-1].y,u[M-1].x+U):c(z.x,z.y,v+U)}o(),a()},n.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(e,t,i,r){var o=e.vertices,a=o[t],s=o[i],c=o[r];return[new n.Vector2(a.x,a.y),new n.Vector2(s.x,s.y),new n.Vector2(c.x,c.y)]},generateSideWallUV:function(e,t,i,r,o){var a=e.vertices,s=a[t],c=a[i],h=a[r],l=a[o];return Math.abs(s.y-c.y)<.01?[new n.Vector2(s.x,1-s.z),new n.Vector2(c.x,1-c.z),new n.Vector2(h.x,1-h.z),new n.Vector2(l.x,1-l.z)]:[new n.Vector2(s.y,1-s.z),new n.Vector2(c.y,1-c.z),new n.Vector2(h.y,1-h.z),new n.Vector2(l.y,1-l.z)]}},n.ShapeGeometry=function(e,t){n.Geometry.call(this),this.type="ShapeGeometry",Array.isArray(e)===!1&&(e=[e]),this.addShapeList(e,t),this.computeFaceNormals()},n.ShapeGeometry.prototype=Object.create(n.Geometry.prototype),n.ShapeGeometry.prototype.constructor=n.ShapeGeometry,n.ShapeGeometry.prototype.addShapeList=function(e,t){for(var i=0,r=e.length;r>i;i++)this.addShape(e[i],t);return this},n.ShapeGeometry.prototype.addShape=function(e,t){void 0===t&&(t={});var i,r,o,a=void 0!==t.curveSegments?t.curveSegments:12,s=t.material,c=void 0===t.UVGenerator?n.ExtrudeGeometry.WorldUVGenerator:t.UVGenerator,h=this.vertices.length,l=e.extractPoints(a),u=l.shape,d=l.holes,p=!n.ShapeUtils.isClockWise(u);if(p){for(u=u.reverse(),i=0,r=d.length;r>i;i++)o=d[i],n.ShapeUtils.isClockWise(o)&&(d[i]=o.reverse());p=!1}var f=n.ShapeUtils.triangulateShape(u,d);for(i=0,r=d.length;r>i;i++)o=d[i],u=u.concat(o);var m,v,g=u.length,y=f.length;for(i=0;g>i;i++)m=u[i],this.vertices.push(new n.Vector3(m.x,m.y,0));for(i=0;y>i;i++){v=f[i];var x=v[0]+h,b=v[1]+h,w=v[2]+h;this.faces.push(new n.Face3(x,b,w,null,null,s)),this.faceVertexUvs[0].push(c.generateTopUV(this,x,b,w))}},n.LatheBufferGeometry=function(e,t,i,r){n.BufferGeometry.call(this),this.type="LatheBufferGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t)||12,i=i||0,r=r||2*Math.PI,r=n.Math.clamp(r,0,2*Math.PI);var o,a,s,c=(t+1)*e.length,h=t*e.length*2*3,l=new n.BufferAttribute(new(h>65535?Uint32Array:Uint16Array)(h),1),u=new n.BufferAttribute(new Float32Array(3*c),3),d=new n.BufferAttribute(new Float32Array(2*c),2),p=0,f=0,m=(1/(e.length-1),1/t),v=new n.Vector3,g=new n.Vector2;for(a=0;t>=a;a++){var y=i+a*m*r,x=Math.sin(y),b=Math.cos(y);for(s=0;s<=e.length-1;s++)v.x=e[s].x*x,v.y=e[s].y,v.z=e[s].x*b,u.setXYZ(p,v.x,v.y,v.z),g.x=a/t,g.y=s/(e.length-1),d.setXY(p,g.x,g.y),p++}for(a=0;t>a;a++)for(s=0;sy;y++)for(var x=y*d-a,b=0;h>b;b++){var w=b*u-o;p[v]=w,p[v+1]=-x,f[v+2]=1,m[g]=b/s,m[g+1]=1-y/c,v+=3,g+=2}v=0;for(var M=new(p.length/3>65535?Uint32Array:Uint16Array)(s*c*6),y=0;c>y;y++)for(var b=0;s>b;b++){var _=b+h*y,E=b+h*(y+1),A=b+1+h*(y+1),S=b+1+h*y;M[v]=_,M[v+1]=E,M[v+2]=S,M[v+3]=E,M[v+4]=A,M[v+5]=S,v+=6}this.setIndex(new n.BufferAttribute(M,1)),this.addAttribute("position",new n.BufferAttribute(p,3)),this.addAttribute("normal",new n.BufferAttribute(f,3)),this.addAttribute("uv",new n.BufferAttribute(m,2))},n.PlaneBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.PlaneBufferGeometry.prototype.constructor=n.PlaneBufferGeometry,n.RingBufferGeometry=function(e,t,i,r,o,a){n.BufferGeometry.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:o,thetaLength:a},e=e||20,t=t||50,o=void 0!==o?o:0,a=void 0!==a?a:2*Math.PI,i=void 0!==i?Math.max(3,i):8,r=void 0!==r?Math.max(1,r):1;var s,c,h,l=(i+1)*(r+1),u=i*r*2*3,d=new n.BufferAttribute(new(u>65535?Uint32Array:Uint16Array)(u),1),p=new n.BufferAttribute(new Float32Array(3*l),3),f=new n.BufferAttribute(new Float32Array(3*l),3),m=new n.BufferAttribute(new Float32Array(2*l),2),v=0,g=0,y=e,x=(t-e)/r,b=new n.Vector3,w=new n.Vector2;for(c=0;r>=c;c++){for(h=0;i>=h;h++)s=o+h/i*a,b.x=y*Math.cos(s),b.y=y*Math.sin(s),p.setXYZ(v,b.x,b.y,b.z),f.setXYZ(v,0,0,1),w.x=(b.x/t+1)/2,w.y=(b.y/t+1)/2,m.setXY(v,w.x,w.y),v++;y+=x}for(c=0;r>c;c++){var M=c*(i+1);for(h=0;i>h;h++){s=h+M;var _=s,E=s+i+1,A=s+i+2,S=s+1;d.setX(g,_),g++,d.setX(g,E),g++,d.setX(g,A),g++,d.setX(g,_),g++,d.setX(g,A),g++,d.setX(g,S),g++}}this.setIndex(d),this.addAttribute("position",p),this.addAttribute("normal",f),this.addAttribute("uv",m)},n.RingBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.RingBufferGeometry.prototype.constructor=n.RingBufferGeometry,n.RingGeometry=function(e,t,i,r,o,a){n.Geometry.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new n.RingBufferGeometry(e,t,i,r,o,a))},n.RingGeometry.prototype=Object.create(n.Geometry.prototype),n.RingGeometry.prototype.constructor=n.RingGeometry,n.SphereGeometry=function(e,t,i,r,o,a,s){n.Geometry.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:o,thetaStart:a,thetaLength:s},this.fromBufferGeometry(new n.SphereBufferGeometry(e,t,i,r,o,a,s))},n.SphereGeometry.prototype=Object.create(n.Geometry.prototype),n.SphereGeometry.prototype.constructor=n.SphereGeometry,n.SphereBufferGeometry=function(e,t,i,r,o,a,s){n.BufferGeometry.call(this),this.type="SphereBufferGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:o,thetaStart:a,thetaLength:s},e=e||50,t=Math.max(3,Math.floor(t)||8),i=Math.max(2,Math.floor(i)||6),r=void 0!==r?r:0,o=void 0!==o?o:2*Math.PI,a=void 0!==a?a:0,s=void 0!==s?s:Math.PI;for(var c=a+s,h=(t+1)*(i+1),l=new n.BufferAttribute(new Float32Array(3*h),3),u=new n.BufferAttribute(new Float32Array(3*h),3),d=new n.BufferAttribute(new Float32Array(2*h),2),p=0,f=[],m=new n.Vector3,v=0;i>=v;v++){for(var g=[],y=v/i,x=0;t>=x;x++){var b=x/t,w=-e*Math.cos(r+b*o)*Math.sin(a+y*s),M=e*Math.cos(a+y*s),_=e*Math.sin(r+b*o)*Math.sin(a+y*s);m.set(w,M,_).normalize(),l.setXYZ(p,w,M,_),u.setXYZ(p,m.x,m.y,m.z),d.setXY(p,b,1-y),g.push(p),p++}f.push(g)}for(var E=[],v=0;i>v;v++)for(var x=0;t>x;x++){var A=f[v][x+1],S=f[v][x],T=f[v+1][x],C=f[v+1][x+1];(0!==v||a>0)&&E.push(A,S,C),(v!==i-1||c65535?n.Uint32Attribute:n.Uint16Attribute)(E,1)),this.addAttribute("position",l),this.addAttribute("normal",u),this.addAttribute("uv",d),this.boundingSphere=new n.Sphere(new n.Vector3,e)},n.SphereBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.SphereBufferGeometry.prototype.constructor=n.SphereBufferGeometry,n.TextGeometry=function(e,t){t=t||{};var i=t.font;if(i instanceof n.Font==!1)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new n.Geometry;var r=i.generateShapes(e,t.size,t.curveSegments);t.amount=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),n.ExtrudeGeometry.call(this,r,t),this.type="TextGeometry"},n.TextGeometry.prototype=Object.create(n.ExtrudeGeometry.prototype),n.TextGeometry.prototype.constructor=n.TextGeometry,n.TorusBufferGeometry=function(e,t,i,r,o){n.BufferGeometry.call(this),this.type="TorusBufferGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:o},e=e||100,t=t||40,i=Math.floor(i)||8,r=Math.floor(r)||6,o=o||2*Math.PI;var a,s,c=(i+1)*(r+1),h=i*r*2*3,l=new(h>65535?Uint32Array:Uint16Array)(h),u=new Float32Array(3*c),d=new Float32Array(3*c),p=new Float32Array(2*c),f=0,m=0,v=0,g=new n.Vector3,y=new n.Vector3,x=new n.Vector3;for(a=0;i>=a;a++)for(s=0;r>=s;s++){var b=s/r*o,w=a/i*Math.PI*2;y.x=(e+t*Math.cos(w))*Math.cos(b),y.y=(e+t*Math.cos(w))*Math.sin(b),y.z=t*Math.sin(w),u[f]=y.x,u[f+1]=y.y,u[f+2]=y.z,g.x=e*Math.cos(b),g.y=e*Math.sin(b),x.subVectors(y,g).normalize(),d[f]=x.x,d[f+1]=x.y,d[f+2]=x.z,p[m]=s/r,p[m+1]=a/i,f+=3,m+=2}for(a=1;i>=a;a++)for(s=1;r>=s;s++){var M=(r+1)*a+s-1,_=(r+1)*(a-1)+s-1,E=(r+1)*(a-1)+s,A=(r+1)*a+s;l[v]=M,l[v+1]=_,l[v+2]=A,l[v+3]=_,l[v+4]=E,l[v+5]=A,v+=6}this.setIndex(new n.BufferAttribute(l,1)),this.addAttribute("position",new n.BufferAttribute(u,3)),this.addAttribute("normal",new n.BufferAttribute(d,3)),this.addAttribute("uv",new n.BufferAttribute(p,2))},n.TorusBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.TorusBufferGeometry.prototype.constructor=n.TorusBufferGeometry,n.TorusGeometry=function(e,t,i,r,o){n.Geometry.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:o},this.fromBufferGeometry(new n.TorusBufferGeometry(e,t,i,r,o))},n.TorusGeometry.prototype=Object.create(n.Geometry.prototype),n.TorusGeometry.prototype.constructor=n.TorusGeometry,n.TorusKnotBufferGeometry=function(e,t,i,r,o,a){function s(e,t,i,r,n){var o=Math.cos(e),a=Math.sin(e),s=i/t*e,c=Math.cos(s);n.x=r*(2+c)*.5*o,n.y=r*(2+c)*a*.5,n.z=r*Math.sin(s)*.5}n.BufferGeometry.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:o,q:a},e=e||100,t=t||40,i=Math.floor(i)||64,r=Math.floor(r)||8,o=o||2,a=a||3;var c,h,l=(r+1)*(i+1),u=r*i*2*3,d=new n.BufferAttribute(new(u>65535?Uint32Array:Uint16Array)(u),1),p=new n.BufferAttribute(new Float32Array(3*l),3),f=new n.BufferAttribute(new Float32Array(3*l),3),m=new n.BufferAttribute(new Float32Array(2*l),2),v=0,g=0,y=new n.Vector3,x=new n.Vector3,b=new n.Vector2,w=new n.Vector3,M=new n.Vector3,_=new n.Vector3,E=new n.Vector3,A=new n.Vector3;for(c=0;i>=c;++c){var S=c/i*o*Math.PI*2;for(s(S,o,a,e,w),s(S+.01,o,a,e,M),E.subVectors(M,w),A.addVectors(M,w),_.crossVectors(E,A),A.crossVectors(_,E),_.normalize(),A.normalize(),h=0;r>=h;++h){var T=h/r*Math.PI*2,C=-t*Math.cos(T),L=t*Math.sin(T);y.x=w.x+(C*A.x+L*_.x),y.y=w.y+(C*A.y+L*_.y),y.z=w.z+(C*A.z+L*_.z),p.setXYZ(v,y.x,y.y,y.z),x.subVectors(y,w).normalize(),f.setXYZ(v,x.x,x.y,x.z),b.x=c/i,b.y=h/r,m.setXY(v,b.x,b.y),v++}}for(h=1;i>=h;h++)for(c=1;r>=c;c++){var R=(r+1)*(h-1)+(c-1),P=(r+1)*h+(c-1),D=(r+1)*h+c,O=(r+1)*(h-1)+c;d.setX(g,R),g++,d.setX(g,P),g++,d.setX(g,O),g++,d.setX(g,P),g++,d.setX(g,D),g++,d.setX(g,O),g++}this.setIndex(d),this.addAttribute("position",p),this.addAttribute("normal",f),this.addAttribute("uv",m)},n.TorusKnotBufferGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.TorusKnotBufferGeometry.prototype.constructor=n.TorusKnotBufferGeometry,n.TorusKnotGeometry=function(e,t,i,r,o,a,s){n.Geometry.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:o,q:a},void 0!==s&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new n.TorusKnotBufferGeometry(e,t,i,r,o,a)),this.mergeVertices()},n.TorusKnotGeometry.prototype=Object.create(n.Geometry.prototype),n.TorusKnotGeometry.prototype.constructor=n.TorusKnotGeometry,n.TubeGeometry=function(e,t,i,r,o,a){function s(e,t,i){return R.vertices.push(new n.Vector3(e,t,i))-1}n.Geometry.call(this),this.type="TubeGeometry",this.parameters={path:e,segments:t,radius:i,radialSegments:r,closed:o,taper:a},t=t||64,i=i||1,r=r||8,o=o||!1,a=a||n.TubeGeometry.NoTaper;var c,h,l,u,d,p,f,m,v,g,y,x,b,w,M,_,E,A,S,T,C,L=[],R=this,P=t+1,D=new n.Vector3,O=new n.TubeGeometry.FrenetFrames(e,t,o),I=O.tangents,k=O.normals,N=O.binormals;for(this.tangents=I,this.normals=k,this.binormals=N,g=0;P>g;g++)for(L[g]=[],u=g/(P-1),v=e.getPointAt(u),c=I[g],h=k[g],l=N[g],p=i*a(u),y=0;r>y;y++)d=y/r*2*Math.PI,f=-p*Math.cos(d),m=p*Math.sin(d),D.copy(v),D.x+=f*h.x+m*l.x,D.y+=f*h.y+m*l.y,D.z+=f*h.z+m*l.z,L[g][y]=s(D.x,D.y,D.z);for(g=0;t>g;g++)for(y=0;r>y;y++)x=o?(g+1)%t:g+1,b=(y+1)%r,w=L[g][y],M=L[x][y],_=L[x][b],E=L[g][b],A=new n.Vector2(g/t,y/r),S=new n.Vector2((g+1)/t,y/r),T=new n.Vector2((g+1)/t,(y+1)/r),C=new n.Vector2(g/t,(y+1)/r),this.faces.push(new n.Face3(w,M,E)),this.faceVertexUvs[0].push([A,S,C]),this.faces.push(new n.Face3(M,_,E)),this.faceVertexUvs[0].push([S.clone(),T,C.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},n.TubeGeometry.prototype=Object.create(n.Geometry.prototype),n.TubeGeometry.prototype.constructor=n.TubeGeometry,n.TubeGeometry.NoTaper=function(){return 1},n.TubeGeometry.SinusoidalTaper=function(e){return Math.sin(Math.PI*e)},n.TubeGeometry.FrenetFrames=function(e,t,i){function r(){f[0]=new n.Vector3,m[0]=new n.Vector3,a=Number.MAX_VALUE,s=Math.abs(p[0].x),c=Math.abs(p[0].y),h=Math.abs(p[0].z),a>=s&&(a=s,d.set(1,0,0)),a>=c&&(a=c,d.set(0,1,0)),a>=h&&d.set(0,0,1),v.crossVectors(p[0],d).normalize(),f[0].crossVectors(p[0],v),m[0].crossVectors(p[0],f[0])}var o,a,s,c,h,l,u,d=new n.Vector3,p=[],f=[],m=[],v=new n.Vector3,g=new n.Matrix4,y=t+1;for(this.tangents=p,this.normals=f,this.binormals=m,l=0;y>l;l++)u=l/(y-1),p[l]=e.getTangentAt(u),p[l].normalize();for(r(),l=1;y>l;l++)f[l]=f[l-1].clone(),m[l]=m[l-1].clone(),v.crossVectors(p[l-1],p[l]),v.length()>Number.EPSILON&&(v.normalize(),o=Math.acos(n.Math.clamp(p[l-1].dot(p[l]),-1,1)),f[l].applyMatrix4(g.makeRotationAxis(v,o))),m[l].crossVectors(p[l],f[l]);if(i)for(o=Math.acos(n.Math.clamp(f[0].dot(f[y-1]),-1,1)),o/=y-1,p[0].dot(v.crossVectors(f[0],f[y-1]))>0&&(o=-o),l=1;y>l;l++)f[l].applyMatrix4(g.makeRotationAxis(p[l],o*l)),m[l].crossVectors(p[l],f[l])},n.PolyhedronGeometry=function(e,t,i,r){function o(e){var t=e.normalize().clone();t.index=u.vertices.push(t)-1;var i=c(e)/2/Math.PI+.5,r=h(e)/Math.PI+.5;return t.uv=new n.Vector2(i,1-r),t}function a(e,t,i,r){var o=new n.Face3(e.index,t.index,i.index,[e.clone(),t.clone(),i.clone()],void 0,r);u.faces.push(o),b.copy(e).add(t).add(i).divideScalar(3);var a=c(b);u.faceVertexUvs[0].push([l(e.uv,e,a),l(t.uv,t,a),l(i.uv,i,a)])}function s(e,t){for(var i=Math.pow(2,t),r=o(u.vertices[e.a]),n=o(u.vertices[e.b]),s=o(u.vertices[e.c]),c=[],h=e.materialIndex,l=0;i>=l;l++){c[l]=[];for(var d=o(r.clone().lerp(s,l/i)),p=o(n.clone().lerp(s,l/i)),f=i-l,m=0;f>=m;m++)c[l][m]=0===m&&l===i?d:o(d.clone().lerp(p,m/f))}for(var l=0;i>l;l++)for(var m=0;2*(i-l)-1>m;m++){var v=Math.floor(m/2);m%2===0?a(c[l][v+1],c[l+1][v],c[l][v],h):a(c[l][v+1],c[l+1][v+1],c[l+1][v],h)}}function c(e){return Math.atan2(e.z,-e.x)}function h(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}function l(e,t,i){return 0>i&&1===e.x&&(e=new n.Vector2(e.x-1,e.y)),0===t.x&&0===t.z&&(e=new n.Vector2(i/2/Math.PI+.5,e.y)),e.clone()}n.Geometry.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r},i=i||1,r=r||0;for(var u=this,d=0,p=e.length;p>d;d+=3)o(new n.Vector3(e[d],e[d+1],e[d+2]));for(var f=this.vertices,m=[],d=0,v=0,p=t.length;p>d;d+=3,v++){var g=f[t[d]],y=f[t[d+1]],x=f[t[d+2]];m[v]=new n.Face3(g.index,y.index,x.index,[g.clone(),y.clone(),x.clone()],void 0,v)}for(var b=new n.Vector3,d=0,p=m.length;p>d;d++)s(m[d],r);for(var d=0,p=this.faceVertexUvs[0].length;p>d;d++){var w=this.faceVertexUvs[0][d],M=w[0].x,_=w[1].x,E=w[2].x,A=Math.max(M,_,E),S=Math.min(M,_,E);A>.9&&.1>S&&(.2>M&&(w[0].x+=1),.2>_&&(w[1].x+=1),.2>E&&(w[2].x+=1))}for(var d=0,p=this.vertices.length;p>d;d++)this.vertices[d].multiplyScalar(i);this.mergeVertices(),this.computeFaceNormals(),this.boundingSphere=new n.Sphere(new n.Vector3,i)},n.PolyhedronGeometry.prototype=Object.create(n.Geometry.prototype),n.PolyhedronGeometry.prototype.constructor=n.PolyhedronGeometry,n.DodecahedronGeometry=function(e,t){var i=(1+Math.sqrt(5))/2,r=1/i,o=[-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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];n.PolyhedronGeometry.call(this,o,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}},n.DodecahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.DodecahedronGeometry.prototype.constructor=n.DodecahedronGeometry,n.IcosahedronGeometry=function(e,t){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[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];n.PolyhedronGeometry.call(this,r,o,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}},n.IcosahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.IcosahedronGeometry.prototype.constructor=n.IcosahedronGeometry,n.OctahedronGeometry=function(e,t){var i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];n.PolyhedronGeometry.call(this,i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}},n.OctahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.OctahedronGeometry.prototype.constructor=n.OctahedronGeometry,n.TetrahedronGeometry=function(e,t){var i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];n.PolyhedronGeometry.call(this,i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}},n.TetrahedronGeometry.prototype=Object.create(n.PolyhedronGeometry.prototype),n.TetrahedronGeometry.prototype.constructor=n.TetrahedronGeometry,n.ParametricGeometry=function(e,t,i){n.Geometry.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i};var r,o,a,s,c,h=this.vertices,l=this.faces,u=this.faceVertexUvs[0],d=t+1;for(r=0;i>=r;r++)for(c=r/i,o=0;t>=o;o++)s=o/t,a=e(s,c),h.push(a);var p,f,m,v,g,y,x,b;for(r=0;i>r;r++)for(o=0;t>o;o++)p=r*d+o,f=r*d+o+1,m=(r+1)*d+o+1,v=(r+1)*d+o,g=new n.Vector2(o/t,r/i),y=new n.Vector2((o+1)/t,r/i),x=new n.Vector2((o+1)/t,(r+1)/i),b=new n.Vector2(o/t,(r+1)/i),l.push(new n.Face3(p,f,v)),u.push([g,y,b]),l.push(new n.Face3(f,m,v)),u.push([y.clone(),x,b.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},n.ParametricGeometry.prototype=Object.create(n.Geometry.prototype),n.ParametricGeometry.prototype.constructor=n.ParametricGeometry,n.WireframeGeometry=function(e){function t(e,t){return e-t}n.BufferGeometry.call(this);var i=[0,0],r={},o=["a","b","c"];if(e instanceof n.Geometry){for(var a=e.vertices,s=e.faces,c=0,h=new Uint32Array(6*s.length),l=0,u=s.length;u>l;l++)for(var d=s[l],p=0;3>p;p++){i[0]=d[o[p]],i[1]=d[o[(p+1)%3]],i.sort(t);var f=i.toString();void 0===r[f]&&(h[2*c]=i[0],h[2*c+1]=i[1],r[f]=!0,c++)}for(var m=new Float32Array(2*c*3),l=0,u=c;u>l;l++)for(var p=0;2>p;p++){var v=a[h[2*l+p]],g=6*l+3*p;m[g+0]=v.x,m[g+1]=v.y,m[g+2]=v.z}this.addAttribute("position",new n.BufferAttribute(m,3))}else if(e instanceof n.BufferGeometry)if(null!==e.index){var y=e.index.array,a=e.attributes.position,x=e.groups,c=0;0===x.length&&e.addGroup(0,y.length);for(var h=new Uint32Array(2*y.length),b=0,w=x.length;w>b;++b)for(var M=x[b],_=M.start,E=M.count,l=_,A=_+E;A>l;l+=3)for(var p=0;3>p;p++){i[0]=y[l+p],i[1]=y[l+(p+1)%3],i.sort(t);var f=i.toString();void 0===r[f]&&(h[2*c]=i[0],h[2*c+1]=i[1],r[f]=!0,c++)}for(var m=new Float32Array(2*c*3),l=0,u=c;u>l;l++)for(var p=0;2>p;p++){var g=6*l+3*p,S=h[2*l+p];m[g+0]=a.getX(S),m[g+1]=a.getY(S),m[g+2]=a.getZ(S)}this.addAttribute("position",new n.BufferAttribute(m,3))}else{for(var a=e.attributes.position.array,c=a.length/3,T=c/3,m=new Float32Array(2*c*3),l=0,u=T;u>l;l++)for(var p=0;3>p;p++){var g=18*l+6*p,C=9*l+3*p;m[g+0]=a[C],m[g+1]=a[C+1],m[g+2]=a[C+2];var S=9*l+3*((p+1)%3);m[g+3]=a[S],m[g+4]=a[S+1],m[g+5]=a[S+2]}this.addAttribute("position",new n.BufferAttribute(m,3))}},n.WireframeGeometry.prototype=Object.create(n.BufferGeometry.prototype),n.WireframeGeometry.prototype.constructor=n.WireframeGeometry,n.AxisHelper=function(e){e=e||1;var t=new Float32Array([0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e]),i=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]),r=new n.BufferGeometry;r.addAttribute("position",new n.BufferAttribute(t,3)),r.addAttribute("color",new n.BufferAttribute(i,3));var o=new n.LineBasicMaterial({vertexColors:n.VertexColors});n.LineSegments.call(this,r,o)},n.AxisHelper.prototype=Object.create(n.LineSegments.prototype),n.AxisHelper.prototype.constructor=n.AxisHelper,n.ArrowHelper=function(){var e=new n.Geometry;e.vertices.push(new n.Vector3(0,0,0),new n.Vector3(0,1,0));var t=new n.CylinderGeometry(0,.5,1,5,1);return t.translate(0,-.5,0),function(i,r,o,a,s,c){n.Object3D.call(this),void 0===a&&(a=16776960),void 0===o&&(o=1),void 0===s&&(s=.2*o),void 0===c&&(c=.2*s),this.position.copy(r),this.line=new n.Line(e,new n.LineBasicMaterial({color:a})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new n.Mesh(t,new n.MeshBasicMaterial({color:a})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(i),this.setLength(o,s,c)}}(),n.ArrowHelper.prototype=Object.create(n.Object3D.prototype),n.ArrowHelper.prototype.constructor=n.ArrowHelper,n.ArrowHelper.prototype.setDirection=function(){var e,t=new n.Vector3;return function(i){i.y>.99999?this.quaternion.set(0,0,0,1):i.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(i.z,0,-i.x).normalize(),e=Math.acos(i.y),this.quaternion.setFromAxisAngle(t,e))}}(),n.ArrowHelper.prototype.setLength=function(e,t,i){void 0===t&&(t=.2*e),void 0===i&&(i=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},n.ArrowHelper.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},n.BoxHelper=function(e){var t=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new n.BufferGeometry;r.setIndex(new n.BufferAttribute(t,1)),r.addAttribute("position",new n.BufferAttribute(i,3)),n.LineSegments.call(this,r,new n.LineBasicMaterial({color:16776960})),void 0!==e&&this.update(e)},n.BoxHelper.prototype=Object.create(n.LineSegments.prototype),n.BoxHelper.prototype.constructor=n.BoxHelper,n.BoxHelper.prototype.update=function(){var e=new n.Box3;return function(t){ if(e.setFromObject(t),!e.isEmpty()){var i=e.min,r=e.max,n=this.geometry.attributes.position,o=n.array;o[0]=r.x,o[1]=r.y,o[2]=r.z,o[3]=i.x,o[4]=r.y,o[5]=r.z,o[6]=i.x,o[7]=i.y,o[8]=r.z,o[9]=r.x,o[10]=i.y,o[11]=r.z,o[12]=r.x,o[13]=r.y,o[14]=i.z,o[15]=i.x,o[16]=r.y,o[17]=i.z,o[18]=i.x,o[19]=i.y,o[20]=i.z,o[21]=r.x,o[22]=i.y,o[23]=i.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}}}(),n.BoundingBoxHelper=function(e,t){var i=void 0!==t?t:8947848;this.object=e,this.box=new n.Box3,n.Mesh.call(this,new n.BoxGeometry(1,1,1),new n.MeshBasicMaterial({color:i,wireframe:!0}))},n.BoundingBoxHelper.prototype=Object.create(n.Mesh.prototype),n.BoundingBoxHelper.prototype.constructor=n.BoundingBoxHelper,n.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object),this.box.size(this.scale),this.box.center(this.position)},n.CameraHelper=function(e){function t(e,t,r){i(e,r),i(t,r)}function i(e,t){r.vertices.push(new n.Vector3),r.colors.push(new n.Color(t)),void 0===a[e]&&(a[e]=[]),a[e].push(r.vertices.length-1)}var r=new n.Geometry,o=new n.LineBasicMaterial({color:16777215,vertexColors:n.FaceColors}),a={},s=16755200,c=16711680,h=43775,l=16777215,u=3355443;t("n1","n2",s),t("n2","n4",s),t("n4","n3",s),t("n3","n1",s),t("f1","f2",s),t("f2","f4",s),t("f4","f3",s),t("f3","f1",s),t("n1","f1",s),t("n2","f2",s),t("n3","f3",s),t("n4","f4",s),t("p","n1",c),t("p","n2",c),t("p","n3",c),t("p","n4",c),t("u1","u2",h),t("u2","u3",h),t("u3","u1",h),t("c","t",l),t("p","c",u),t("cn1","cn2",u),t("cn3","cn4",u),t("cf1","cf2",u),t("cf3","cf4",u),n.LineSegments.call(this,r,o),this.camera=e,this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()},n.CameraHelper.prototype=Object.create(n.LineSegments.prototype),n.CameraHelper.prototype.constructor=n.CameraHelper,n.CameraHelper.prototype.update=function(){function e(e,n,a,s){r.set(n,a,s).unproject(o);var c=i[e];if(void 0!==c)for(var h=0,l=c.length;l>h;h++)t.vertices[c[h]].copy(r)}var t,i,r=new n.Vector3,o=new n.Camera;return function(){t=this.geometry,i=this.pointMap;var r=1,n=1;o.projectionMatrix.copy(this.camera.projectionMatrix),e("c",0,0,-1),e("t",0,0,1),e("n1",-r,-n,-1),e("n2",r,-n,-1),e("n3",-r,n,-1),e("n4",r,n,-1),e("f1",-r,-n,1),e("f2",r,-n,1),e("f3",-r,n,1),e("f4",r,n,1),e("u1",.7*r,1.1*n,-1),e("u2",.7*-r,1.1*n,-1),e("u3",0,2*n,-1),e("cf1",-r,0,1),e("cf2",r,0,1),e("cf3",0,-n,1),e("cf4",0,n,1),e("cn1",-r,0,-1),e("cn2",r,0,-1),e("cn3",0,-n,-1),e("cn4",0,n,-1),t.verticesNeedUpdate=!0}}(),n.DirectionalLightHelper=function(e,t){n.Object3D.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,t=t||1;var i=new n.Geometry;i.vertices.push(new n.Vector3(-t,t,0),new n.Vector3(t,t,0),new n.Vector3(t,-t,0),new n.Vector3(-t,-t,0),new n.Vector3(-t,t,0));var r=new n.LineBasicMaterial({fog:!1});r.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.lightPlane=new n.Line(i,r),this.add(this.lightPlane),i=new n.Geometry,i.vertices.push(new n.Vector3,new n.Vector3),r=new n.LineBasicMaterial({fog:!1}),r.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine=new n.Line(i,r),this.add(this.targetLine),this.update()},n.DirectionalLightHelper.prototype=Object.create(n.Object3D.prototype),n.DirectionalLightHelper.prototype.constructor=n.DirectionalLightHelper,n.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},n.DirectionalLightHelper.prototype.update=function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Vector3;return function(){e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),i.subVectors(t,e),this.lightPlane.lookAt(i),this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine.geometry.vertices[1].copy(i),this.targetLine.geometry.verticesNeedUpdate=!0,this.targetLine.material.color.copy(this.lightPlane.material.color)}}(),n.EdgesHelper=function(e,t,i){var r=void 0!==t?t:16777215;n.LineSegments.call(this,new n.EdgesGeometry(e.geometry,i),new n.LineBasicMaterial({color:r})),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1},n.EdgesHelper.prototype=Object.create(n.LineSegments.prototype),n.EdgesHelper.prototype.constructor=n.EdgesHelper,n.FaceNormalsHelper=function(e,t,i,r){this.object=e,this.size=void 0!==t?t:1;var o=void 0!==i?i:16776960,a=void 0!==r?r:1,s=0,c=this.object.geometry;c instanceof n.Geometry?s=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");var h=new n.BufferGeometry,l=new n.Float32Attribute(2*s*3,3);h.addAttribute("position",l),n.LineSegments.call(this,h,new n.LineBasicMaterial({color:o,linewidth:a})),this.matrixAutoUpdate=!1,this.update()},n.FaceNormalsHelper.prototype=Object.create(n.LineSegments.prototype),n.FaceNormalsHelper.prototype.constructor=n.FaceNormalsHelper,n.FaceNormalsHelper.prototype.update=function(){var e=new n.Vector3,t=new n.Vector3,i=new n.Matrix3;return function(){this.object.updateMatrixWorld(!0),i.getNormalMatrix(this.object.matrixWorld);for(var r=this.object.matrixWorld,n=this.geometry.attributes.position,o=this.object.geometry,a=o.vertices,s=o.faces,c=0,h=0,l=s.length;l>h;h++){var u=s[h],d=u.normal;e.copy(a[u.a]).add(a[u.b]).add(a[u.c]).divideScalar(3).applyMatrix4(r),t.copy(d).applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),n.setXYZ(c,e.x,e.y,e.z),c+=1,n.setXYZ(c,t.x,t.y,t.z),c+=1}return n.needsUpdate=!0,this}}(),n.GridHelper=function(e,t){var i=new n.Geometry,r=new n.LineBasicMaterial({vertexColors:n.VertexColors});this.color1=new n.Color(4473924),this.color2=new n.Color(8947848);for(var o=-e;e>=o;o+=t){i.vertices.push(new n.Vector3(-e,0,o),new n.Vector3(e,0,o),new n.Vector3(o,0,-e),new n.Vector3(o,0,e));var a=0===o?this.color1:this.color2;i.colors.push(a,a,a,a)}n.LineSegments.call(this,i,r)},n.GridHelper.prototype=Object.create(n.LineSegments.prototype),n.GridHelper.prototype.constructor=n.GridHelper,n.GridHelper.prototype.setColors=function(e,t){this.color1.set(e),this.color2.set(t),this.geometry.colorsNeedUpdate=!0},n.HemisphereLightHelper=function(e,t){n.Object3D.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.colors=[new n.Color,new n.Color];var i=new n.SphereGeometry(t,4,2);i.rotateX(-Math.PI/2);for(var r=0,o=8;o>r;r++)i.faces[r].color=this.colors[4>r?0:1];var a=new n.MeshBasicMaterial({vertexColors:n.FaceColors,wireframe:!0});this.lightSphere=new n.Mesh(i,a),this.add(this.lightSphere),this.update()},n.HemisphereLightHelper.prototype=Object.create(n.Object3D.prototype),n.HemisphereLightHelper.prototype.constructor=n.HemisphereLightHelper,n.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose(),this.lightSphere.material.dispose()},n.HemisphereLightHelper.prototype.update=function(){var e=new n.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(e.setFromMatrixPosition(this.light.matrixWorld).negate()),this.lightSphere.geometry.colorsNeedUpdate=!0}}(),n.PointLightHelper=function(e,t){this.light=e,this.light.updateMatrixWorld();var i=new n.SphereGeometry(t,4,2),r=new n.MeshBasicMaterial({wireframe:!0,fog:!1});r.color.copy(this.light.color).multiplyScalar(this.light.intensity),n.Mesh.call(this,i,r),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1},n.PointLightHelper.prototype=Object.create(n.Mesh.prototype),n.PointLightHelper.prototype.constructor=n.PointLightHelper,n.PointLightHelper.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},n.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)},n.SkeletonHelper=function(e){this.bones=this.getBoneList(e);for(var t=new n.Geometry,i=0;iu;u++)for(var p=h[u],f=0,m=p.vertexNormals.length;m>f;f++){var v=c[p[r[f]]],g=p.vertexNormals[f];e.copy(v).applyMatrix4(o),t.copy(g).applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),a.setXYZ(l,e.x,e.y,e.z),l+=1,a.setXYZ(l,t.x,t.y,t.z),l+=1}else if(s instanceof n.BufferGeometry)for(var y=s.attributes.position,x=s.attributes.normal,l=0,f=0,m=y.count;m>f;f++)e.set(y.getX(f),y.getY(f),y.getZ(f)).applyMatrix4(o),t.set(x.getX(f),x.getY(f),x.getZ(f)),t.applyMatrix3(i).normalize().multiplyScalar(this.size).add(e),a.setXYZ(l,e.x,e.y,e.z),l+=1,a.setXYZ(l,t.x,t.y,t.z),l+=1;return a.needsUpdate=!0,this}}(),n.WireframeHelper=function(e,t){var i=void 0!==t?t:16777215;n.LineSegments.call(this,new n.WireframeGeometry(e.geometry),new n.LineBasicMaterial({color:i})),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1},n.WireframeHelper.prototype=Object.create(n.LineSegments.prototype),n.WireframeHelper.prototype.constructor=n.WireframeHelper,n.ImmediateRenderObject=function(e){n.Object3D.call(this),this.material=e,this.render=function(){}},n.ImmediateRenderObject.prototype=Object.create(n.Object3D.prototype),n.ImmediateRenderObject.prototype.constructor=n.ImmediateRenderObject,n.MorphBlendMesh=function(e,t){n.Mesh.call(this,e,t),this.animationsMap={},this.animationsList=[];var i=this.geometry.morphTargets.length,r="__default",o=0,a=i-1,s=i/1;this.createAnimation(r,o,a,s),this.setAnimationWeight(r,1)},n.MorphBlendMesh.prototype=Object.create(n.Mesh.prototype),n.MorphBlendMesh.prototype.constructor=n.MorphBlendMesh,n.MorphBlendMesh.prototype.createAnimation=function(e,t,i,r){var n={start:t,end:i,length:i-t+1,fps:r,duration:(i-t)/r,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[e]=n,this.animationsList.push(n)},n.MorphBlendMesh.prototype.autoCreateAnimations=function(e){for(var t,i=/([a-z]+)_?(\d+)/i,r={},n=this.geometry,o=0,a=n.morphTargets.length;a>o;o++){var s=n.morphTargets[o],c=s.name.match(i);if(c&&c.length>1){var h=c[1];r[h]||(r[h]={start:1/0,end:-(1/0)});var l=r[h];ol.end&&(l.end=o),t||(t=h)}}for(var h in r){var l=r[h];this.createAnimation(h,l.start,l.end,e)}this.firstAnimation=t},n.MorphBlendMesh.prototype.setAnimationDirectionForward=function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},n.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},n.MorphBlendMesh.prototype.setAnimationFPS=function(e,t){var i=this.animationsMap[e];i&&(i.fps=t,i.duration=(i.end-i.start)/i.fps)},n.MorphBlendMesh.prototype.setAnimationDuration=function(e,t){var i=this.animationsMap[e];i&&(i.duration=t,i.fps=(i.end-i.start)/i.duration)},n.MorphBlendMesh.prototype.setAnimationWeight=function(e,t){var i=this.animationsMap[e];i&&(i.weight=t)},n.MorphBlendMesh.prototype.setAnimationTime=function(e,t){var i=this.animationsMap[e];i&&(i.time=t)},n.MorphBlendMesh.prototype.getAnimationTime=function(e){var t=0,i=this.animationsMap[e];return i&&(t=i.time),t},n.MorphBlendMesh.prototype.getAnimationDuration=function(e){var t=-1,i=this.animationsMap[e];return i&&(t=i.duration),t},n.MorphBlendMesh.prototype.playAnimation=function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):console.warn("THREE.MorphBlendMesh: animation["+e+"] undefined in .playAnimation()")},n.MorphBlendMesh.prototype.stopAnimation=function(e){var t=this.animationsMap[e];t&&(t.active=!1)},n.MorphBlendMesh.prototype.update=function(e){for(var t=0,i=this.animationsList.length;i>t;t++){var r=this.animationsList[t];if(r.active){var o=r.duration/r.length;r.time+=r.direction*e,r.mirroredLoop?(r.time>r.duration||r.time<0)&&(r.direction*=-1,r.time>r.duration&&(r.time=r.duration,r.directionBackwards=!0),r.time<0&&(r.time=0,r.directionBackwards=!1)):(r.time=r.time%r.duration,r.time<0&&(r.time+=r.duration));var a=r.start+n.Math.clamp(Math.floor(r.time/o),0,r.length-1),s=r.weight;a!==r.currentFrame&&(this.morphTargetInfluences[r.lastFrame]=0,this.morphTargetInfluences[r.currentFrame]=1*s,this.morphTargetInfluences[a]=0,r.lastFrame=r.currentFrame,r.currentFrame=a);var c=r.time%o/o;r.directionBackwards&&(c=1-c),r.currentFrame!==r.lastFrame?(this.morphTargetInfluences[r.currentFrame]=c*s,this.morphTargetInfluences[r.lastFrame]=(1-c)*s):this.morphTargetInfluences[r.currentFrame]=s}}},"undefined"!=typeof r?("undefined"!=typeof i&&i.exports&&(r=i.exports=n),r.THREE=n):this.THREE=n},{}],22:[function(e,i,r){!function(e){if("performance"in e==!1&&(e.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in e.performance==!1){var t=e.performance.timing&&e.performance.timing.navigationStart?performance.timing.navigationStart:Date.now();e.performance.now=function(){return Date.now()-t}}}(this);var n=n||function(){var e=[];return{REVISION:"14",getAll:function(){return e},removeAll:function(){e=[]},add:function(t){e.push(t)},remove:function(t){var i=e.indexOf(t);-1!==i&&e.splice(i,1)},update:function(t){if(0===e.length)return!1;var i=0;for(t=void 0!==t?t:window.performance.now();ie;e++)m[e].stop()},this.delay=function(e){return u=e,this},this.repeat=function(e){return s=e,this},this.yoyo=function(e){return c=e,this},this.easing=function(e){return p=e,this},this.interpolation=function(e){return f=e,this},this.chain=function(){return m=arguments,this},this.onStart=function(e){return v=e,this},this.onUpdate=function(e){return y=e,this},this.onComplete=function(e){return x=e,this},this.onStop=function(e){return b=e,this},this.update=function(e){var n;if(d>e)return!0;g===!1&&(null!==v&&v.call(t),g=!0);var h=(e-d)/a;h=h>1?1:h;var b=p(h);for(n in r){var w=i[n]||0,M=r[n];M instanceof Array?t[n]=f(M,b):("string"==typeof M&&(M=w+parseFloat(M,10)),"number"==typeof M&&(t[n]=w+(M-w)*b))}if(null!==y&&y.call(t,b),1==h){if(s>0){isFinite(s)&&s--;for(n in o){if("string"==typeof r[n]&&(o[n]=o[n]+parseFloat(r[n],10)),c){var _=o[n];o[n]=r[n],r[n]=_}i[n]=o[n]}return c&&(l=!l),d=e+u,!0}null!==x&&x.call(t);for(var E=0,A=m.length;A>E;E++)m[E].start(e);return!1}return!0}},n.Easing={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 1-Math.cos(e*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.cos(Math.PI*e))}},Exponential:{In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(-Math.pow(2,-10*(e-1))+2)}},Circular:{In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}},Elastic:{In:function(e){var t,i=.1,r=.4;return 0===e?0:1===e?1:(!i||1>i?(i=1,t=r/4):t=r*Math.asin(1/i)/(2*Math.PI),-(i*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/r)))},Out:function(e){var t,i=.1,r=.4;return 0===e?0:1===e?1:(!i||1>i?(i=1,t=r/4):t=r*Math.asin(1/i)/(2*Math.PI),i*Math.pow(2,-10*e)*Math.sin(2*(e-t)*Math.PI/r)+1)},InOut:function(e){var t,i=.1,r=.4;return 0===e?0:1===e?1:(!i||1>i?(i=1,t=r/4):t=r*Math.asin(1/i)/(2*Math.PI),(e*=2)<1?-.5*i*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/r):i*Math.pow(2,-10*(e-=1))*Math.sin(2*(e-t)*Math.PI/r)*.5+1)}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?.5*e*e*((t+1)*e-t):.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-n.Easing.Bounce.Out(1-e)},Out:function(e){return 1/2.75>e?7.5625*e*e:2/2.75>e?7.5625*(e-=1.5/2.75)*e+.75:2.5/2.75>e?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return.5>e?.5*n.Easing.Bounce.In(2*e):.5*n.Easing.Bounce.Out(2*e-1)+.5}}},n.Interpolation={Linear:function(e,t){var i=e.length-1,r=i*t,o=Math.floor(r),a=n.Interpolation.Utils.Linear;return 0>t?a(e[0],e[1],r):t>1?a(e[i],e[i-1],i-r):a(e[o],e[o+1>i?i:o+1],r-o)},Bezier:function(e,t){var i,r=0,o=e.length-1,a=Math.pow,s=n.Interpolation.Utils.Bernstein;for(i=0;o>=i;i++)r+=a(1-t,o-i)*a(t,i)*e[i]*s(o,i);return r},CatmullRom:function(e,t){var i=e.length-1,r=i*t,o=Math.floor(r),a=n.Interpolation.Utils.CatmullRom;return e[0]===e[i]?(0>t&&(o=Math.floor(r=i*(1+t))),a(e[(o-1+i)%i],e[o],e[(o+1)%i],e[(o+2)%i],r-o)):0>t?e[0]-(a(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[i]-(a(e[i],e[i],e[i-1],e[i-1],r-i)-e[i]):a(e[o?o-1:0],e[o],e[o+1>i?i:o+1],e[o+2>i?i:o+2],r-o)},Utils:{Linear:function(e,t,i){return(t-e)*i+e},Bernstein:function(e,t){var i=n.Interpolation.Utils.Factorial;return i(e)/i(t)/i(e-t)},Factorial:function(){var e=[1];return function(t){var i,r=1;if(e[t])return e[t];for(i=t;i>1;i--)r*=i;return e[t]=r}}(),CatmullRom:function(e,t,i,r,n){var o=.5*(i-e),a=.5*(r-t),s=n*n,c=n*s;return(2*t-2*i+o+a)*c+(-3*t+3*i-2*o-a)*s+o*n+t}}},function(e){"function"==typeof t&&t.amd?t([],function(){return n}):"object"==typeof r?i.exports=n:e.TWEEN=n}(this)},{}],23:[function(e){!function t(i,r,n){function o(s,c){if(!r[s]){if(!i[s]){var h="function"==typeof e&&e;if(!c&&h)return h(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[s]={exports:{}};i[s][0].call(u.exports,function(e){var t=i[s][1][e];return o(t?t:e)},u,u.exports,t,i,r,n)}return r[s].exports}for(var a="function"==typeof e&&e,s=0;sc.MAX_TIMESTEP?(console.warn("Invalid timestamps detected. Time step between successive gyroscope sensor samples is very small or not monotonic"),void(this.previousTimestampS=r)):(this.accelerometer.set(-t.x,-t.y,-t.z),this.gyroscope.set(i.alpha,i.beta,i.gamma),(this.isIOS||this.isFirefoxAndroid)&&this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addAccelMeasurement(this.accelerometer,r),this.filter.addGyroMeasurement(this.gyroscope,r),void(this.previousTimestampS=r))},i.prototype.onScreenOrientationChange_=function(){this.setScreenTransform_()},i.prototype.setScreenTransform_=function(){switch(this.worldToScreenQ.set(0,0,0,1),window.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new s.Vector3(0,0,1),-Math.PI/2);break;case-90:this.worldToScreenQ.setFromAxisAngle(new s.Vector3(0,0,1),Math.PI/2);break;case 180:}},t.exports=i},{"./base.js":1,"./complementary-filter.js":3,"./pose-predictor.js":7,"./three-math.js":9,"./touch-panner.js":10,"./util.js":11}],5:[function(e){var t=e("./webvr-polyfill.js");window.WebVRConfig=window.WebVRConfig||{},new t},{"./webvr-polyfill.js":12}],6:[function(e,t){function i(){this.deviceId="webvr-polyfill:mouse-keyboard",this.deviceName="VR Position Device (webvr-polyfill:mouse-keyboard)",window.addEventListener("keydown",this.onKeyDown_.bind(this)),window.addEventListener("mousemove",this.onMouseMove_.bind(this)),window.addEventListener("mousedown",this.onMouseDown_.bind(this)),window.addEventListener("mouseup",this.onMouseUp_.bind(this)),this.phi=0,this.theta=0,this.targetAngle=null,this.euler=new n.Euler,this.orientation=new n.Quaternion,this.rotateStart=new n.Vector2,this.rotateEnd=new n.Vector2,this.rotateDelta=new n.Vector2}var r=e("./base.js").PositionSensorVRDevice,n=e("./three-math.js"),o=e("./util.js"),a=.15,s=80,c=.5,h=.3;i.prototype=new r,i.prototype.getState=function(){return this.euler.set(this.phi,this.theta,0,"YXZ"),this.orientation.setFromEuler(this.euler),{hasOrientation:!0,orientation:this.orientation,hasPosition:!1,position:null}},i.prototype.onKeyDown_=function(e){38==e.keyCode?this.animatePhi_(this.phi+a):39==e.keyCode?this.animateTheta_(this.theta-a):40==e.keyCode?this.animatePhi_(this.phi-a):37==e.keyCode&&this.animateTheta_(this.theta+a)},i.prototype.animateTheta_=function(e){this.animateKeyTransitions_("theta",e)},i.prototype.animatePhi_=function(e){e=o.clamp(e,-Math.PI/2,Math.PI/2),this.animateKeyTransitions_("phi",e)},i.prototype.animateKeyTransitions_=function(e,t){this.angleAnimation&&clearInterval(this.angleAnimation);var i=this[e],r=new Date;this.angleAnimation=setInterval(function(){var n=new Date-r;if(n>=s)return this[e]=t,void clearInterval(this.angleAnimation);var o=n/s;this[e]=i+(t-i)*o}.bind(this),1e3/60)},i.prototype.onMouseDown_=function(e){this.rotateStart.set(e.clientX,e.clientY),this.isDragging=!0},i.prototype.onMouseMove_=function(e){if(this.isDragging||this.isPointerLocked_()){if(this.isPointerLocked_()){var t=e.movementX||e.mozMovementX||0,i=e.movementY||e.mozMovementY||0;this.rotateEnd.set(this.rotateStart.x-t,this.rotateStart.y-i)}else this.rotateEnd.set(e.clientX,e.clientY);this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd);var r=document.body;this.phi+=2*Math.PI*this.rotateDelta.y/r.clientHeight*h,this.theta+=2*Math.PI*this.rotateDelta.x/r.clientWidth*c,this.phi=o.clamp(this.phi,-Math.PI/2,Math.PI/2)}},i.prototype.onMouseUp_=function(){this.isDragging=!1},i.prototype.isPointerLocked_=function(){var e=document.pointerLockElement||document.mozPointerLockElement||document.webkitPointerLockElement;return void 0!==e},i.prototype.resetSensor=function(){console.error("Not implemented yet.")},t.exports=i},{"./base.js":1,"./three-math.js":9,"./util.js":11}],7:[function(e,t){function i(e){this.predictionTimeS=e,this.previousQ=new r.Quaternion,this.previousTimestampS=null,this.deltaQ=new r.Quaternion,this.outQ=new r.Quaternion}var r=e("./three-math.js"),n=!1;i.prototype.getPrediction=function(e,t,i){if(!this.previousTimestampS)return this.previousQ.copy(e),this.previousTimestampS=i,e;var o=new r.Vector3;o.copy(t),o.normalize();var a=t.length();if(a0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(l-c)*t,this._y=(o-h)*t,this._z=(a-n)*t):r>s&&r>u?(t=2*Math.sqrt(1+r-s-u),this._w=(l-c)/t,this._x=.25*t,this._y=(n+a)/t,this._z=(o+h)/t):s>u?(t=2*Math.sqrt(1+s-r-u),this._w=(o-h)/t,this._x=(n+a)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+u-r-s),this._w=(a-n)/t,this._x=(o+h)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t,r=1e-6;return function(n,o){return void 0===e&&(e=new i.Vector3),t=n.dot(o)+1,r>t?(t=0,Math.abs(n.x)>Math.abs(n.z)?e.set(-n.y,n.x,0):e.set(0,-n.z,n.y)):e.crossVectors(n,o),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z,o=e._w,a=t._x,s=t._y,c=t._z,h=t._w;return this._x=i*h+o*a+r*c-n*s,this._y=r*h+o*s+n*a-i*c,this._z=n*h+o*c+i*s-r*a,this._w=o*h-i*a-r*s-n*c,this.onChangeCallback(),this},multiplyVector3:function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+n*e._z;if(0>a?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=n,this;var s=Math.acos(a),c=Math.sqrt(1-a*a);if(Math.abs(c)<.001)return this._w=.5*(o+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var h=Math.sin((1-t)*s)/c,l=Math.sin(t*s)/c;return this._w=o*h+this._w*l,this._x=i*h+this._x*l,this._y=r*h+this._y*l,this._z=n*h+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){},clone:function(){return new i.Quaternion(this._x,this._y,this._z,this._w)}},i.Quaternion.slerp=function(e,t,i,r){return i.copy(e).slerp(t,r)},i.Vector2=function(e,t){this.x=e||0,this.y=t||0},i.Vector2.prototype={constructor:i.Vector2,set:function(e,t){return this.x=e,this.y=t,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScalar:function(e){return this.x+=e,this.y+=e,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){if(0!==e){var t=1/e;this.x*=t,this.y*=t}else this.x=0,this.y=0;return this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this},clampScalar:function(){var e,t;return function(r,n){return void 0===e&&(e=new i.Vector2,t=new i.Vector2),e.set(r,r),t.set(n,n),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this},clone:function(){return new i.Vector2(this.x,this.y)}},i.Vector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},i.Vector3.prototype={constructor:i.Vector3,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e;return function(t){return t instanceof i.Euler==!1&&console.error("THREE.Vector3: .applyEuler() now expects a Euler rotation rather than a Vector3 and order."),void 0===e&&(e=new i.Quaternion),this.applyQuaternion(e.setFromEuler(t)),this}}(),applyAxisAngle:function(){var e;return function(t,r){return void 0===e&&(e=new i.Quaternion),this.applyQuaternion(e.setFromAxisAngle(t,r)),this}}(),applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r+n[12],this.y=n[1]*t+n[5]*i+n[9]*r+n[13],this.z=n[2]*t+n[6]*i+n[10]*r+n[14],this},applyProjection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements,o=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,o=e.y,a=e.z,s=e.w,c=s*t+o*r-a*i,h=s*i+a*t-n*r,l=s*r+n*i-o*t,u=-n*t-o*i-a*r;return this.x=c*s+u*-n+h*-a-l*-o,this.y=h*s+u*-o+l*-n-c*-a,this.z=l*s+u*-a+c*-o-h*-n,this},project:function(){var e;return function(t){return void 0===e&&(e=new i.Matrix4),e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyProjection(e)}}(),unproject:function(){var e;return function(t){return void 0===e&&(e=new i.Matrix4),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyProjection(e)}}(),transformDirection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize(),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){if(0!==e){var t=1/e;this.x*=t,this.y*=t,this.z*=t}else this.x=0,this.y=0,this.z=0;return this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this.zt.z&&(this.z=t.z),this},clampScalar:function(){var e,t;return function(r,n){return void 0===e&&(e=new i.Vector3,t=new i.Vector3),e.set(r,r,r),t.set(n,n,n),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},cross:function(e,t){if(void 0!==t)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var i=this.x,r=this.y,n=this.z;return this.x=r*e.z-n*e.y,this.y=n*e.x-i*e.z,this.z=i*e.y-r*e.x,this},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,o=t.x,a=t.y,s=t.z;return this.x=r*s-n*a,this.y=n*o-i*s,this.z=i*a-r*o,this},projectOnVector:function(){var e,t;return function(r){return void 0===e&&(e=new i.Vector3),e.copy(r).normalize(),t=this.dot(e),this.copy(e).multiplyScalar(t)}}(),projectOnPlane:function(){var e;return function(t){return void 0===e&&(e=new i.Vector3),e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e;return function(t){return void 0===e&&(e=new i.Vector3),this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/(this.length()*e.length());return Math.acos(i.Math.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},setFromMatrixPosition:function(e){return this.x=e.elements[12],this.y=e.elements[13],this.z=e.elements[14],this},setFromMatrixScale:function(e){var t=this.set(e.elements[0],e.elements[1],e.elements[2]).length(),i=this.set(e.elements[4],e.elements[5],e.elements[6]).length(),r=this.set(e.elements[8],e.elements[9],e.elements[10]).length();return this.x=t,this.y=i,this.z=r,this},setFromMatrixColumn:function(e,t){var i=4*e,r=t.elements;return this.x=r[i],this.y=r[i+1],this.z=r[i+2],this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromAttribute:function(e,t,i){return void 0===i&&(i=0),t=t*e.itemSize+i,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this},clone:function(){return new i.Vector3(this.x,this.y,this.z)}},i.Euler=function(e,t,r,n){this._x=e||0,this._y=t||0,this._z=r||0,this._order=n||i.Euler.DefaultOrder},i.Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],i.Euler.DefaultOrder="XYZ",i.Euler.prototype={constructor:i.Euler,_x:0,_y:0,_z:0,_order:i.Euler.DefaultOrder,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get order(){return this._order},set order(e){this._order=e,this.onChangeCallback()},set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,r){var n=i.Math.clamp,o=e.elements,a=o[0],s=o[4],c=o[8],h=o[1],l=o[5],u=o[9],d=o[2],p=o[6],f=o[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(n(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(p,l),this._z=0)):"YXZ"===t?(this._x=Math.asin(-n(u,-1,1)),Math.abs(u)<.99999?(this._y=Math.atan2(c,f),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-d,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(n(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===t?(this._y=Math.asin(-n(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(p,f),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-s,l))):"YZX"===t?(this._z=Math.asin(n(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-d,a)):(this._x=0,this._y=Math.atan2(c,f))):"XZY"===t?(this._z=Math.asin(-n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(p,l),this._y=Math.atan2(c,a)):(this._x=Math.atan2(-u,f),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,r!==!1&&this.onChangeCallback(),this},setFromQuaternion:function(){var e;return function(t,r,n){return void 0===e&&(e=new i.Matrix4),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,r,n),this}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new i.Quaternion;return function(t){e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(){return[this._x,this._y,this._z,this._order]},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new i.Vector3(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){},clone:function(){return new i.Euler(this._x,this._y,this._z,this._order)}},i.Math={generateUUID:function(){var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=new Array(36),r=0;return function(){for(var n=0;36>n;n++)8==n||13==n||18==n||23==n?i[n]="-":14==n?i[n]="4":(2>=r&&(r=33554432+16777216*Math.random()|0),e=15&r,r>>=4,i[n]=t[19==n?3&e|8:e]);return i.join("")}}(),clamp:function(e,t,i){return t>e?t:e>i?i:e},clampBottom:function(e,t){return t>e?t:e},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},smoothstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*(3-2*e))},smootherstep:function(e,t,i){return t>=e?0:e>=i?1:(e=(e-t)/(i-t),e*e*e*(e*(6*e-15)+10))},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(e,t){return Math.floor(this.randFloat(e,t))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(){var e=Math.PI/180;return function(t){return t*e}}(),radToDeg:function(){var e=180/Math.PI;return function(t){return t*e}}(),isPowerOfTwo:function(e){return 0===(e&e-1)&&0!==e},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}}),t.exports=i},{}],10:[function(e,t){function i(){window.addEventListener("touchstart",this.onTouchStart_.bind(this)),window.addEventListener("touchmove",this.onTouchMove_.bind(this)),window.addEventListener("touchend",this.onTouchEnd_.bind(this)),this.isTouching=!1,this.rotateStart=new r.Vector2,this.rotateEnd=new r.Vector2,this.rotateDelta=new r.Vector2,this.theta=0,this.orientation=new r.Quaternion}var r=e("./three-math.js"),n=e("./util.js"),o=.5;i.prototype.getOrientation=function(){return this.orientation.setFromEuler(new r.Euler(0,0,this.theta)),this.orientation},i.prototype.resetSensor=function(){this.theta=0},i.prototype.onTouchStart_=function(e){1==e.touches.length&&(this.rotateStart.set(e.touches[0].pageX,e.touches[0].pageY),this.isTouching=!0)},i.prototype.onTouchMove_=function(e){if(this.isTouching){this.rotateEnd.set(e.touches[0].pageX,e.touches[0].pageY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd),n.isIOS()&&(this.rotateDelta.x*=-1);var t=document.body;this.theta+=2*Math.PI*this.rotateDelta.x/t.clientWidth*o}},i.prototype.onTouchEnd_=function(){this.isTouching=!1},t.exports=i},{"./three-math.js":9,"./util.js":11}],11:[function(e,t){var i=window.Util||{};i.MIN_TIMESTEP=.001,i.MAX_TIMESTEP=1,i.clamp=function(e,t,i){return Math.min(Math.max(t,e),i)},i.isIOS=function(){return/iPad|iPhone|iPod/.test(navigator.platform)},i.isFirefoxAndroid=function(){return-1!==navigator.userAgent.indexOf("Firefox")&&-1!==navigator.userAgent.indexOf("Android")},i.isTimestampDeltaValid=function(e){return isNaN(e)?!1:e<=i.MIN_TIMESTEP?!1:e>i.MAX_TIMESTEP?!1:!0},t.exports=i},{}],12:[function(e,t){function i(){this.devices=[],this.isWebVRAvailable()||this.enablePolyfill()}var r=e("./cardboard-hmd-vr-device.js"),n=e("./fusion-position-sensor-vr-device.js"),o=e("./mouse-keyboard-position-sensor-vr-device.js"),a=e("./base.js").HMDVRDevice,s=e("./base.js").PositionSensorVRDevice;i.prototype.isWebVRAvailable=function(){return"getVRDevices"in navigator||"mozGetVRDevices"in navigator},i.prototype.enablePolyfill=function(){this.isCardboardCompatible()&&this.devices.push(new r),this.isMobile()?this.devices.push(new n):WebVRConfig.MOUSE_KEYBOARD_CONTROLS_DISABLED||this.devices.push(new o),navigator.getVRDevices=this.getVRDevices.bind(this),window.HMDVRDevice=a,window.PositionSensorVRDevice=s},i.prototype.getVRDevices=function(){var e=this.devices;return new Promise(function(t,i){try{t(e)}catch(r){i(r)}})},i.prototype.isMobile=function(){return/Android/i.test(navigator.userAgent)||/iPhone|iPad|iPod/i.test(navigator.userAgent)},i.prototype.isCardboardCompatible=function(){return this.isMobile()||WebVRConfig.FORCE_ENABLE_VR},t.exports=i},{"./base.js":1,"./cardboard-hmd-vr-device.js":2,"./fusion-position-sensor-vr-device.js":4,"./mouse-keyboard-position-sensor-vr-device.js":6}]},{},[5])},{}],24:[function(e,t){t.exports={name:"aframe",version:"0.2.0",description:"Building blocks for the VR Web",main:"dist/aframe.js",scripts:{browserify:"browserify src/index.js -s 'AFRAME' -p browserify-derequire",build:"mkdirp build/ && npm run browserify -- --debug -o build/aframe.js",dev:"npm run build && node ./scripts/budo",dist:"mkdirp dist/ && npm run browserify -s -- --debug | exorcist dist/aframe.js.map > dist/aframe.js && uglifyjs dist/aframe.js -c warnings=false -m -o dist/aframe.min.js","gh-pages":"npm run ghpages",ghpages:"node ./scripts/gh-pages",lint:"semistandard -v | snazzy",precommit:"npm run lint",preghpages:"npm run dist && rimraf gh-pages && mkdirp gh-pages && cp -r {.nojekyll,dist,lib,examples,index.html,style} gh-pages/. 2>/dev/null || : && git checkout dist/ && replace 'build/aframe.js' 'dist/aframe.min.js' gh-pages/ -r --silent","release:bump":"npm run dist && git commit -am 'bump dist' && npm version patch --preminor","release:push":"npm login && npm publish && git push --follow-tags",start:"npm run dev",test:"karma start ./tests/karma.conf.js","test:ci":"TEST_ENV=ci karma start ./tests/karma.conf.js --single-run",version:"npm run dist"},repository:"aframevr/aframe",license:"MIT",dependencies:{"browserify-css":"^0.8.2",debug:"^2.2.0","deep-assign":"^2.0.0","document-register-element":"dmarcos/document-register-element#8ccc532b7","promise-polyfill":"^3.1.0","object-assign":"^4.0.1",polymerize:"^1.0.0",present:"0.0.6","request-interval":"^1.0.0","style-attr":"^1.0.2",three:"^0.75.0","tween.js":"^15.0.0","webvr-polyfill":"borismus/webvr-polyfill#3f47796"},devDependencies:{browserify:"^11.0.1","browserify-derequire":"^0.9.4",budo:"^8.1.0",chai:"^3.5.0","chai-shallow-deep-equal":"^1.3.0",exorcist:"^0.4.0","gh-pages":"^0.6.0",husky:"^0.10.1",karma:"^0.13.15","karma-browserify":"^4.4.0","karma-chai-shallow-deep-equal":"0.0.4","karma-env-preprocessor":"^0.1.1","karma-firefox-launcher":"^0.1.6","karma-mocha":"^0.2.0","karma-mocha-reporter":"^1.1.0","karma-sinon-chai":"^1.1.0",lolex:"^1.4.0",mkdirp:"0.5.1",mocha:"^2.3.3","mozilla-download":"^1.0.5",open:"0.0.5",replace:"^0.3.0",rimraf:"2.5.0",semistandard:"^7.0.2",sinon:"^1.17.3","sinon-chai":"^2.8.0",snazzy:"^3.0.0",uglifyjs:"^2.4.10"},link:!0,browserify:{transform:["browserify-css",["polymerize",{match:".*.html$"}]]},semistandard:{ignore:["build/**","dist/**","examples/_js/**","examples/**/shaders/*.js","vendor/**"]},keywords:["aframe","vr","webvr","3d","three","components","elements"],"browserify-css":{minify:!0},engines:{node:">= 0.12.7",npm:"^2.12.1"}}},{}],25:[function(e,t){var i=e("../core/component").registerComponent,r=e("../lib/three");t.exports.Component=i("camera",{schema:{active:{"default":!0},far:{"default":1e4},fov:{"default":80,min:0},near:{"default":.5,min:0}},init:function(){var e=this.camera=new r.PerspectiveCamera;this.el.setObject3D("camera",e)},remove:function(){this.el.removeObject3D("camera")},update:function(e){var t=this.el,i=this.data,r=this.camera,n=this.system;r.aspect=i.aspect||window.innerWidth/window.innerHeight,r.far=i.far,r.fov=i.fov,r.near=i.near,r.updateProjectionMatrix(),e&&e.active===i.active||(i.active&&n.activeCameraEl!==this.el?n.setActiveCamera(t,r):i.active||n.activeCameraEl!==this.el||n.disableActiveCamera())}})},{"../core/component":56,"../lib/three":90}],26:[function(e,t){var i=e("../core/component").registerComponent,r=e("../lib/three"),n=new r.ColladaLoader;n.options.convertUpAxis=!0,t.exports.Component=i("collada-model",{schema:{type:"src"},init:function(){this.model=null},update:function(){var e=this,t=this.el,i=this.data;i&&(this.remove(),n.load(i,function(i){e.model=i.scene,t.setObject3D("mesh",e.model),t.emit("model-loaded",{format:"collada",model:e.model})}))},remove:function(){this.model&&this.el.removeObject3D("mesh")}})},{"../core/component":56,"../lib/three":90}],27:[function(e,t){var i=e("../core/component").registerComponent,r=e("../utils/");t.exports.Component=i("cursor",{schema:{timeout:{"default":1500,min:0},maxDistance:{"default":5,min:0},fuse:{"default":!1}},dependencies:["raycaster"],init:function(){this.raycaster=this.el.components.raycaster,this.schema.fuse["default"]=r.isMobile(),this.attachEventListeners()},attachEventListeners:function(){var e=this.el,t=e.sceneEl.canvas;return t?(t.addEventListener("mousedown",this.onMouseDown.bind(this)),t.addEventListener("mouseup",this.onMouseUp.bind(this)),e.addEventListener("intersection",this.onIntersection.bind(this)),void e.addEventListener("intersectioncleared",this.onIntersectionCleared.bind(this))):void e.sceneEl.addEventListener("render-target-loaded",this.attachEventListeners.bind(this))},onMouseDown:function(){this.emit("mousedown"),this.mouseDownEl=this.intersectedEl},onMouseUp:function(){this.emit("mouseup"),this.data.fuse||this.intersectedEl&&this.mouseDownEl===this.intersectedEl&&this.emit("click")},emit:function(e){var t=this.intersectedEl;this.el.emit(e,{target:this.intersectedEl}),t&&t.emit(e)},emitter:function(e){return function(){this.emit(e)}.bind(this)},onIntersection:function(e){function t(){i.el.removeState("fusing"),i.emit("click")}var i=this,r=this.data,n=e.detail.el,o=e.detail.distance;this.intersectedEl!==n&&(o>=this.data.maxDistance||(this.intersectedEl=n,n.addState("hovered"),n.emit("mouseenter"),this.el.addState("hovering"),0!==r.timeout&&r.fuse&&(this.el.addState("fusing"),this.fuseTimeout=setTimeout(t,r.timeout))))},onIntersectionCleared:function(e){var t=e.detail.el;t&&this.intersectedEl&&(t.removeState("hovered"),t.emit("mouseleave"),this.el.removeState("hovering"),this.el.removeState("fusing"),this.intersectedEl=null,clearTimeout(this.fuseTimeout))}})},{"../core/component":56,"../utils/":102}],28:[function(e,t){function i(e){switch("cube"===e.primitive&&u('geometry.primitive="cube" should be "box"'),e.primitive){case"box":return new a.BoxGeometry(e.width,e.height,e.depth);case"circle":return new a.CircleGeometry(e.radius,e.segments,l(e.thetaStart),l(e.thetaLength));case"cone":return new a.CylinderGeometry(e.radiusTop,e.radiusBottom,e.height,e.segmentsRadial,e.segmentsHeight,e.openEnded,l(e.thetaStart),l(e.thetaLength));case"cylinder":return new a.CylinderGeometry(e.radius,e.radius,e.height,e.segmentsRadial,e.segmentsHeight,e.openEnded,l(e.thetaStart),l(e.thetaLength));case"plane":return new a.PlaneBufferGeometry(e.width,e.height);case"ring":return new a.RingGeometry(e.radiusInner,e.radiusOuter,e.segmentsTheta,e.segmentsPhi,l(e.thetaStart),l(e.thetaLength));case"sphere":return 360===e.thetaLength&&(e.thetaLength=180),new a.SphereBufferGeometry(e.radius,e.segmentsWidth,e.segmentsHeight,l(e.phiStart),l(e.phiLength),l(e.thetaStart),l(e.thetaLength));case"torus":return new a.TorusGeometry(e.radius,2*e.radiusTubular,e.segmentsRadial,e.segmentsTubular,l(e.arc));case"torusKnot":return new a.TorusKnotGeometry(e.radius,2*e.radiusTubular,e.segmentsTubular,e.segmentsRadial,e.p,e.q);default:return u("Primitive type not supported: "+e.primitive),new a.Geometry}}function r(e,t,i){var r=h.makeTranslation(t.x-i.x,t.y-i.y,t.z-i.z);e.applyMatrix(r),e.verticesNeedsUpdate=!0}var n=e("../utils/debug"),o=e("../core/component").registerComponent,a=e("../lib/three"),s=e("../utils"),c=1,h=new a.Matrix4,l=a.Math.degToRad,u=n("components:geometry:warn");t.exports.Component=o("geometry",{schema:{arc:{"default":360,"if":{primitive:["torus"]}},depth:{"default":1,min:0,"if":{primitive:["box"]}},height:{"default":1,min:0,"if":{primitive:["box","plane","cone"]}},openEnded:{"default":!1,"if":{primitive:["cylinder","cone"]}},p:{"default":2,"if":{primitive:["torusKnot"]},type:"int"},primitive:{"default":"",oneOf:["","box","circle","cone","cylinder","plane","ring","sphere","torus","torusKnot"]},q:{"default":3,"if":{primitive:["torusKnot"]},type:"int"},phiLength:{"default":360,"if":{primitive:["sphere"]}},phiStart:{"default":0,min:0,"if":{primitive:["sphere"]}},radius:{"default":c,min:0,"if":{primitive:["circle","cylinder","sphere","torus","torusKnot"]}},radiusBottom:{"default":c,min:0,"if":{primitive:["cylinder","cone"]}},radiusInner:{"default":.8,min:0,"if":{primitive:["ring"]}},radiusOuter:{"default":1.2,min:0,"if":{primitive:["ring"]}},radiusTop:{"default":c,"if":{primitive:["cylinder","cone"]}},radiusTubular:{"default":.2,min:0,"if":{primitive:["torus","torusKnot"]}},segments:{"default":32,min:0,"if":{primitive:["circle"]},type:"int"},segmentsHeight:{"default":18, min:0,"if":{primitive:["cylinder","sphere","cone"]},type:"int"},segmentsPhi:{"default":8,min:0,"if":{primitive:["ring"]},type:"int"},segmentsRadial:{"default":36,min:0,"if":{primitive:["cylinder","torusKnot","cone"]},type:"int"},segmentsTheta:{"default":32,min:0,"if":{primitive:["ring"]},type:"int"},segmentsTubular:{"default":32,min:0,"if":{primitive:["torus","torusKnot"]},type:"int"},segmentsWidth:{"default":36,min:0,"if":{primitive:["sphere"]},type:"int"},thetaLength:{"default":360,min:0,"if":{primitive:["circle","cylinder","ring","sphere","cone"]}},thetaStart:{"default":0,"if":{primitive:["circle","cylinder","ring","sphere","cone"]}},translate:{type:"vec3"},width:{"default":1,min:0,"if":{primitive:["box","plane"]}}},update:function(e){e=e||{};var t=this.data,n=e.translate||this.schema.translate["default"],o=s.diff(e,t),c=this.el.getOrCreateObject3D("mesh",a.Mesh),h=c.geometry,l=!(1===Object.keys(o).length&&"translate"in o),u=!s.deepEqual(t.translate,n);l&&(c.geometry.dispose(),h=c.geometry=i(this.data,this.schema)),u&&r(h,t.translate,n)},remove:function(){this.el.getObject3D("mesh").geometry.dispose(),this.el.getObject3D("mesh").geometry=new a.Geometry}})},{"../core/component":56,"../lib/three":90,"../utils":102,"../utils/debug":101}],29:[function(e){e("./camera"),e("./collada-model"),e("./cursor"),e("./geometry"),e("./light"),e("./look-at"),e("./look-controls"),e("./material"),e("./obj-model"),e("./position"),e("./raycaster"),e("./rotation"),e("./scale"),e("./sound"),e("./visible"),e("./wasd-controls"),e("./scene/canvas"),e("./scene/fog"),e("./scene/keyboard-shortcuts"),e("./scene/stats"),e("./scene/vr-mode-ui"),e("./loader")},{"./camera":25,"./collada-model":26,"./cursor":27,"./geometry":28,"./light":30,"./loader":31,"./look-at":32,"./look-controls":33,"./material":34,"./obj-model":35,"./position":36,"./raycaster":37,"./rotation":38,"./scale":39,"./scene/canvas":40,"./scene/fog":41,"./scene/keyboard-shortcuts":42,"./scene/stats":43,"./scene/vr-mode-ui":44,"./sound":45,"./visible":46,"./wasd-controls":47}],30:[function(e,t){function i(e){var t=e.angle,i=new a.Color(e.color).getHex(),r=e.decay,n=e.distance,o=new a.Color(e.groundColor).getHex(),h=e.intensity,l=e.type;switch(l.toLowerCase()){case"ambient":return new a.AmbientLight(i,h);case"directional":return new a.DirectionalLight(i,h);case"hemisphere":return new a.HemisphereLight(i,o,h);case"point":return new a.PointLight(i,h,n,r);case"spot":return new a.SpotLight(i,h,n,s(t),e.exponent,r);default:c("%s is not a valid light type. Choose from ambient, directional, hemisphere, point, spot.",l)}}var r=e("../utils").diff,n=e("../utils/debug"),o=e("../core/component").registerComponent,a=e("../lib/three"),s=a.Math.degToRad,c=n("components:light:warn");t.exports.Component=o("light",{schema:{angle:{"default":60,"if":{type:["spot"]}},color:{type:"color"},groundColor:{type:"color","if":{type:["hemisphere"]}},decay:{"default":1,"if":{type:["point","spot"]}},distance:{"default":0,min:0,"if":{type:["point","spot"]}},exponent:{"default":10,"if":{type:["spot"]}},intensity:{"default":1,min:0,"if":{type:["ambient","directional","hemisphere","point","spot"]}},type:{"default":"directional",oneOf:["ambient","directional","hemisphere","point","spot"]}},init:function(){var e=this.el;this.light=null,this.system.registerLight(e)},update:function(e){var t=this.data,i=r(t,e||{}),n=this.light;return!n||"type"in i?void this.setLight(this.data):void Object.keys(i).forEach(function(e){var i=t[e];-1!==["color","groundColor"].indexOf(e)&&(i=new a.Color(i)),n[e]=i})},setLight:function(e){var t=this.el,r=i(e);r&&(this.light&&t.removeObject3D("light"),this.light=r,this.light.el=t,t.setObject3D("light",this.light))},remove:function(){this.el.removeObject3D("light")}})},{"../core/component":56,"../lib/three":90,"../utils":102,"../utils/debug":101}],31:[function(e,t){var i=e("../utils/debug"),r=e("../core/component").registerComponent,n=e("../utils/src-loader").parseUrl,o=e("../lib/three"),a=i("components:loader:warn");t.exports.Component=r("loader",{dependencies:["material"],schema:{src:{"default":""},format:{"default":"obj",oneOf:["obj","collada"]}},init:function(){a("loader component is deprecated. Use collada-model or obj-model component instead.")},update:function(){var e=this.el,t=this.data,i=this.model,r=n(t.src),o=t.format;if(i&&e.removeObject3D("mesh"),!r)return void a("Model URL not provided");switch(o){case"obj":this.loadObj(r);break;case"collada":this.loadCollada(r);break;default:a("Model format not supported")}},loadObj:function(e){var t=this.el,i=new o.OBJLoader;i.load(e,function(e){this.model=e,this.applyMaterial(),t.setObject3D("mesh",e)})},applyMaterial:function(){var e=this.el.components.material.material;this.model&&this.model.traverse(function(t){t instanceof o.Mesh&&(t.material=e)})},loadCollada:function(e){var t=this,i=this.el,r=new o.ColladaLoader;r.options.convertUpAxis=!0,r.load(e,function(e){t.model=e.scene,i.setObject3D("mesh",e.scene)})}})},{"../core/component":56,"../lib/three":90,"../utils/debug":101,"../utils/src-loader":104}],32:[function(e,t){var i=e("../utils/debug"),r=e("../utils/coordinates"),n=e("../core/component").registerComponent,o=e("../lib/three"),a=i("components:look-at:warn"),s=r.isCoordinate;t.exports.Component=n("look-at",{schema:{"default":"",parse:function(e){return s(e)||"object"==typeof e?r.parse(e):e},stringify:function(e){return"object"==typeof e?r.stringify(e):e}},init:function(){this.target3D=null,this.vector=new o.Vector3},update:function(){var e,t=this,i=t.data,r=t.el.object3D;return!i||"object"==typeof i&&!Object.keys(i).length?t.remove():"object"==typeof i?r.lookAt(new o.Vector3(i.x,i.y,i.z)):(e=t.el.sceneEl.querySelector(i),e?e.hasLoaded?t.beginTracking(e):e.addEventListener("loaded",function(){t.beginTracking(e)}):void a('"'+i+'" does not point to a valid entity to look-at'))},tick:function(){var e=this.target3D;return e?this.el.object3D.lookAt(this.vector.setFromMatrixPosition(e.matrixWorld)):void 0},beginTracking:function(e){this.target3D=e.object3D}})},{"../core/component":56,"../lib/three":90,"../utils/coordinates":100,"../utils/debug":101}],33:[function(e,t){var i=e("../core/component").registerComponent,r=e("../lib/three"),n=Math.PI/2;t.exports.Component=i("look-controls",{dependencies:["position","rotation"],schema:{enabled:{"default":!0}},init:function(){this.previousPosition=new r.Vector3,this.deltaPosition=new r.Vector3,this.setupMouseControls(),this.setupHMDControls(),this.bindMethods()},update:function(){this.data.enabled&&(this.controls.update(),this.updateOrientation(),this.updatePosition())},play:function(){this.previousPosition.set(0,0,0),this.addEventListeners()},pause:function(){this.removeEventListeners()},tick:function(){this.update()},remove:function(){this.pause()},bindMethods:function(){this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.releaseMouse=this.releaseMouse.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this)},setupMouseControls:function(){this.mouseDown=!1,this.pitchObject=new r.Object3D,this.yawObject=new r.Object3D,this.yawObject.position.y=10,this.yawObject.add(this.pitchObject)},setupHMDControls:function(){this.dolly=new r.Object3D,this.euler=new r.Euler,this.controls=new r.VRControls(this.dolly),this.zeroQuaternion=new r.Quaternion},addEventListeners:function(){var e=this.el.sceneEl,t=e.canvas;return t?(t.addEventListener("mousedown",this.onMouseDown,!1),t.addEventListener("mousemove",this.onMouseMove,!1),t.addEventListener("mouseup",this.releaseMouse,!1),t.addEventListener("mouseout",this.releaseMouse,!1),t.addEventListener("touchstart",this.onTouchStart),t.addEventListener("touchmove",this.onTouchMove),void t.addEventListener("touchend",this.onTouchEnd)):void e.addEventListener("render-target-loaded",this.addEventListeners.bind(this))},removeEventListeners:function(){var e=document.querySelector("a-scene"),t=e&&e.canvas;t&&(t.removeEventListener("mousedown",this.onMouseDown),t.removeEventListener("mousemove",this.onMouseMove),t.removeEventListener("mouseup",this.releaseMouse),t.removeEventListener("mouseout",this.releaseMouse),t.removeEventListener("touchstart",this.onTouchStart),t.removeEventListener("touchmove",this.onTouchMove),t.removeEventListener("touchend",this.onTouchEnd))},updateOrientation:function(){var e=new r.Euler;return e.order="YXZ",function(){var t=this.pitchObject,i=this.yawObject,n=this.calculateHMDQuaternion();e.setFromQuaternion(n),this.el.setAttribute("rotation",{x:r.Math.radToDeg(e.x)+r.Math.radToDeg(t.rotation.x),y:r.Math.radToDeg(e.y)+r.Math.radToDeg(i.rotation.y),z:r.Math.radToDeg(e.z)})}}(),calculateHMDQuaternion:function(){var e=new r.Quaternion;return function(){var t=this.dolly;return this.zeroed||t.quaternion.equals(this.zeroQuaternion)||(this.zeroOrientation(),this.zeroed=!0),e.copy(this.zeroQuaternion).multiply(t.quaternion),e}}(),updatePosition:function(){var e=this.el,t=this.calculateDeltaPosition(),i=e.getComputedAttribute("position");e.setAttribute("position",{x:i.x+t.x,y:i.y+t.y,z:i.z+t.z})},calculateDeltaPosition:function(){var e=this.dolly,t=this.deltaPosition,i=this.previousPosition;return t.copy(e.position),t.sub(i),i.copy(e.position),t},updateHMDQuaternion:function(){var e=new r.Quaternion;return function(){var t=this.dolly;return this.controls.update(),this.zeroed||t.quaternion.equals(this.zeroQuaternion)||(this.zeroOrientation(),this.zeroed=!0),e.copy(this.zeroQuaternion).multiply(t.quaternion),e}}(),zeroOrientation:function(){var e=new r.Euler;e.setFromQuaternion(this.dolly.quaternion.clone().inverse()),e.z=0,e.x=0,this.zeroQuaternion.setFromEuler(e)},onMouseMove:function(e){var t=this.pitchObject,i=this.yawObject,r=this.previousMouseEvent;if(this.mouseDown&&this.data.enabled){var o=e.movementX||e.mozMovementX,a=e.movementY||e.mozMovementY;(void 0===o||void 0===a)&&(o=e.screenX-r.screenX,a=e.screenY-r.screenY),this.previousMouseEvent=e,i.rotation.y-=.002*o,t.rotation.x-=.002*a,t.rotation.x=Math.max(-n,Math.min(n,t.rotation.x))}},onMouseDown:function(e){this.mouseDown=!0,this.previousMouseEvent=e},releaseMouse:function(){this.mouseDown=!1},onTouchStart:function(e){1===e.touches.length&&(this.touchStart={x:e.touches[0].pageX,y:e.touches[0].pageY},this.touchStarted=!0)},onTouchMove:function(e){var t,i=this.yawObject;this.touchStarted&&(t=2*Math.PI*(e.touches[0].pageX-this.touchStart.x)/this.el.sceneEl.canvas.clientWidth,i.rotation.y-=.5*t,this.touchStart={x:e.touches[0].pageX,y:e.touches[0].pageY})},onTouchEnd:function(){this.touchStarted=!1}})},{"../core/component":56,"../lib/three":90}],34:[function(e,t){function i(e){switch(e){case"back":return s.BackSide;case"double":return s.DoubleSide;default:return s.FrontSide}}function r(e,t){e.dispose(),t.unregisterMaterial(e)}var n=e("../utils/debug"),o=e("../utils"),a=e("../core/component"),s=e("../lib/three"),c=e("../core/shader"),h=n("components:material:error"),l=o.diff,u=a.registerComponent,d=c.shaders,p=c.shaderNames;t.exports.Component=u("material",{schema:{shader:{"default":"standard",oneOf:p},transparent:{"default":!1},opacity:{"default":1,min:0,max:1},side:{"default":"front",oneOf:["front","back","double"]},depthTest:{"default":!0}},init:function(){this.material=null},update:function(e){var t=this.data,i=e?l(e,t):t;(!this.shader||i.shader)&&this.updateShader(t.shader),this.shader.update(this.data),this.updateMaterial()},updateSchema:function(e){var t=e.shader,i=this.data&&this.data.shader,r=t||i,n=d[r]&&d[r].schema;n||h("Unknown shader schema "+r),i&&t===i||(this.extendSchema(n),this.updateBehavior())},updateBehavior:function(){var e=this.el.sceneEl,t=this.schema,i=this,r={},n=function(e){function t(t){r[t]=e}var n=Object.keys(r);n.forEach(t),i.shader.update(r)},o=Object.keys(t);o.forEach(function(o){"time"===t[o].type&&(i.tick=n,r[o]=!0,e.addBehavior(i))}),0===Object.keys(r).length&&e.removeBehavior(this)},updateShader:function(e){var t,i=this.data,r=d[e]&&d[e].Shader;if(!r)throw new Error("Unknown shader "+e);this.shader=new r,this.shader.el=this.el,t=this.shader.init(i),this.setMaterial(t),this.updateSchema(i)},updateMaterial:function(){var e=this.data,t=this.material;t.side=i(e.side),t.opacity=e.opacity,t.transparent=e.transparent!==!1||e.opacity<1,t.depthTest=e.depthTest!==!1},remove:function(){var e=new s.MeshBasicMaterial,t=this.material,i=this.el.getObject3D("mesh");i&&(i.material=e),r(t,this.system)},setMaterial:function(e){var t=this.el.getOrCreateObject3D("mesh",s.Mesh),i=this.system;this.material&&r(this.material,i),this.material=t.material=e,i.registerMaterial(e)}})},{"../core/component":56,"../core/shader":63,"../lib/three":90,"../utils":102,"../utils/debug":101}],35:[function(e,t){var i=e("../utils/debug"),r=e("../core/component").registerComponent,n=e("../lib/three"),o=i("components:obj-model:warn");t.exports.Component=r("obj-model",{dependencies:["material"],schema:{mtl:{type:"src"},obj:{type:"src"}},init:function(){this.model=null,this.objLoader=new n.OBJLoader,this.mtlLoader=new n.MTLLoader(this.objLoader.manager)},update:function(){var e=this.data;e.obj&&(this.remove(),this.loadObj(e.obj,e.mtl))},remove:function(){this.model&&this.el.removeObject3D("mesh")},loadObj:function(e,t){var i=this,r=this.el,a=this.mtlLoader,s=this.objLoader;return t?(HTMLElement.prototype.getAttribute.call(r,"material")&&o("Material component properties are ignored when a .MTL is provided"),a.setBaseUrl(t.substr(0,t.lastIndexOf("/")+1)),void a.load(t,function(t){t.preload(),s.setMaterials(t),s.load(e,function(e){i.model=e,r.setObject3D("mesh",e),r.emit("model-loaded",{format:"obj",model:e})})})):void s.load(e,function(e){var t=r.components.material.material;e.traverse(function(e){e instanceof n.Mesh&&(e.material=t)}),i.model=e,r.setObject3D("mesh",e),r.emit("model-loaded",{format:"obj",model:e})})}})},{"../core/component":56,"../lib/three":90,"../utils/debug":101}],36:[function(e,t){var i=e("../core/component").registerComponent;t.exports.Component=i("position",{schema:{type:"vec3"},update:function(){var e=this.el.object3D,t=this.data;e.position.set(t.x,t.y,t.z)}})},{"../core/component":56}],37:[function(e,t){var i=e("../core/component").registerComponent,r=e("request-interval"),n=e("../lib/three");t.exports.Component=i("raycaster",{init:function(){this.raycaster=new n.Raycaster,this.intersectedEl=null},play:function(){this.pollForHoverIntersections()},pause:function(){var e=this.pollInterval;e&&r.clear(this.pollInterval)},remove:function(){this.pause()},pollForHoverIntersections:function(){this.pollInterval=r(100,this.getIntersections.bind(this))},getIntersections:function(){var e=this.getClosestIntersected();return e?void this.handleIntersection(e):void(this.intersectedEl&&this.clearExistingIntersection())},intersect:function(e){var t=this.el,i=this.raycaster,r=t.object3D,o=t.parentNode.object3D,a=(new n.Vector3).setFromMatrixPosition(o.matrixWorld),s=(new n.Vector3).setFromMatrixPosition(r.matrixWorld),c=s.sub(a).normalize();return i.set(a,c),i.intersectObjects(e,!0)},getClosestIntersected:function(){for(var e,t=this.el.sceneEl.object3D,i=this.el,r=this.intersect(t.children),n=0;n")},remove:function(){var e=this.el.object3D.fog;e&&(e.density=0,e.far=0,e.near=0)}})},{"../../core/component":56,"../../lib/three":90,"../../utils/debug":101}],42:[function(e,t){var i=e("../../core/component").registerComponent,r=e("../../utils/").shouldCaptureKeyEvent,n=e("../../lib/three"),o=new n.VRControls(new n.Object3D);t.exports.Component=i("keyboard-shortcuts",{schema:{enterVR:{"default":!0},resetSensor:{"default":!0}},init:function(){var e=this,t=this.el;this.listener=window.addEventListener("keyup",function(i){r(i)&&(e.enterVREnabled&&70===i.keyCode&&t.enterVR(),e.resetSensorEnabled&&90===i.keyCode&&o.resetSensor())},!1)},update:function(){var e=this.data;this.enterVREnabled=e.enterVR,this.resetSensorEnabled=e.resetSensor},remove:function(){window.removeEventListener("keyup",this.listener)}})},{"../../core/component":56,"../../lib/three":90,"../../utils/":102}],43:[function(e,t){function i(e){var t=new a(e.renderer),i=new s(e),r=e.isMobile?[]:[t,i];return new n({css:[],values:{fps:{caption:"fps",below:30}},groups:[{caption:"Framerate",values:["fps","raf"]}],plugins:r})}var r=e("../../core/component").registerComponent,n=e("../../../vendor/rStats");e("../../../vendor/rStats.extras"),e("../../lib/rStatsAframe");var o="a-hidden",a=window.threeStats,s=window.aframeStats;t.exports.Component=r("stats",{init:function(){var e=this.el;this.stats=i(e),this.statsEl=document.querySelector(".rs-base"),this.hideBound=this.hide.bind(this),this.showBound=this.show.bind(this),e.addEventListener("enter-vr",this.hideBound),e.addEventListener("exit-vr",this.showBound)},remove:function(){this.el.removeEventListener("enter-vr",this.hideBound),this.el.removeEventListener("exit-vr",this.showBound),this.statsEl.parentNode.removeChild(this.statsEl)},tick:function(){var e=this.stats;e("rAF").tick(),e("FPS").frame(),e().update()},hide:function(){this.statsEl.classList.add(o)},show:function(){this.statsEl.classList.remove(o)}})},{"../../../vendor/rStats":107,"../../../vendor/rStats.extras":106,"../../core/component":56,"../../lib/rStatsAframe":89}],44:[function(e,t){function i(e,t){function i(){return c.update(),a=s.quaternion,0!==a._x||0!==a._y||0!==a._z?!0:void 0}var r,n,o,a,f,m,v=t||window.hasNonPolyfillWebVRSupport;return m=document.createElement("div"),m.classList.add(h),r=document.createElement("div"),r.className=p,o=document.createElement("p"),n=document.createElement("a"),n.setAttribute("href","http://mozvr.com/#start"),n.setAttribute("target","_blank"),n.innerHTML="Learn more.",f=document.createElement("button"),f.className=d,m.appendChild(f),r&&(r.appendChild(o),r.appendChild(n),m.appendChild(r)),i()||t||(o.innerHTML="Your browser supports WebVR. To enter VR, connect a headset, or use a mobile phone.",m.setAttribute(l,"")),v?f.addEventListener("click",e):(o.innerHTML="Your browser does not support WebVR. To enter VR, use a VR-compatible browser or a mobile phone.",m.setAttribute(u,"")),m}function r(e){var t=document.createElement("div");t.className=m,t.classList.add(f);var i=document.createElement("button");return i.innerHTML="Exit VR",i.addEventListener("click",e),t.appendChild(i),t}var n=e("../../core/component").registerComponent,o=e("../../lib/three"),a=e("../../utils/"),s=new o.Object3D,c=new o.VRControls(s),h="a-enter-vr",l="data-a-enter-vr-no-headset",u="data-a-enter-vr-no-webvr",d="a-enter-vr-button",p="a-enter-vr-modal",f="a-hidden",m="a-orientation-modal";t.exports.Component=n("vr-mode-ui",{dependencies:["canvas"],schema:{enabled:{"default":!0}},init:function(){var e=this,t=this.el;this.enterVR=t.enterVR.bind(t),this.exitVR=t.exitVR.bind(t),this.insideLoader=!1,this.enterVREl=null,this.orientationModalEl=null,t.addEventListener("enter-vr",this.updateEnterVRInterface.bind(this)),t.addEventListener("exit-vr",this.updateEnterVRInterface.bind(this)),window.addEventListener("message",function(t){"loaderReady"===t.data.type&&(e.insideLoader=!0,e.remove())}),window.addEventListener("orientationchange",this.toggleOrientationModalIfNeeded.bind(this))},update:function(){var e=this.el;return!this.data.enabled||this.insideLoader?this.remove():void(this.enterVREl||this.orientationModalEl||(this.enterVREl=i(this.enterVR,e.isMobile),this.el.appendChild(this.enterVREl),this.orientationModalEl=r(this.exitVR),this.el.appendChild(this.orientationModalEl),this.updateEnterVRInterface()))},remove:function(){[this.enterVREl,this.orientationModalEl].forEach(function(e){e&&e.parentNode.removeChild(e)})},updateEnterVRInterface:function(){this.toggleEnterVRButtonIfNeeded(),this.toggleOrientationModalIfNeeded()},toggleEnterVRButtonIfNeeded:function(){if(this.enterVREl){var e=this.el;e.is("vr-mode")?this.enterVREl.classList.add(f):this.enterVREl.classList.remove(f)}},toggleOrientationModalIfNeeded:function(){var e=this.el;this.orientationModalEl&&e.isMobile&&(!a.isLandscape()&&e.is("vr-mode")?this.orientationModalEl.classList.remove(f):this.orientationModalEl.classList.add(f))}})},{"../../core/component":56,"../../lib/three":90,"../../utils/":102}],45:[function(e,t){var i=e("../utils/debug"),r=e("../utils").diff,n=e("../core/component").registerComponent,o=e("../lib/three"),a=i("components:sound:warn");t.exports.Component=n("sound",{schema:{src:{"default":""},on:{"default":"click"},autoplay:{"default":!1},loop:{"default":!1},volume:{"default":1}},init:function(){this.listener=null,this.sound=null},update:function(e){var t=this.data,i=r(e||{},t),n=this.el,o=this.sound,s=t.src,c="src"in i;if(c){if(!s)return void a("Audio source was not specified with `src`");o=this.setupSound()}(c||"autoplay"in i)&&(o.autoplay=t.autoplay),(c||"loop"in i)&&o.setLoop(t.loop),(c||"volume"in i)&&o.setVolume(t.volume),"on"in i&&(e&&e.on&&n.removeEventListener(e.on),n.addEventListener(t.on,this.play.bind(this))),c&&o.load(s)},remove:function(){this.el.removeObject3D("sound"),this.sound.disconnect()},setupSound:function(){var e=this.el,t=e.sceneEl,i=this.sound;i&&(this.stop(),e.removeObject3D("sound"));var r=this.listener=t.audioListener||new o.AudioListener;return t.audioListener=r,t.camera&&t.camera.add(r),t.addEventListener("camera-set-active",function(e){e.detail.cameraEl.getObject3D("camera").add(r)}),i=this.sound=new o.PositionalAudio(r),e.setObject3D("sound",i),i.source.onended=function(){i.onEnded(),e.emit("sound-ended")},i},play:function(){this.sound.source.buffer&&this.sound.play()},stop:function(){this.sound.source.buffer&&this.sound.stop()},pause:function(){this.sound.source.buffer&&this.sound.isPlaying&&this.sound.pause()}})},{"../core/component":56,"../lib/three":90,"../utils":102,"../utils/debug":101}],46:[function(e,t){var i=e("../core/component").registerComponent;t.exports.Component=i("visible",{schema:{type:"boolean","default":!0},update:function(){this.el.object3D.visible=this.data}})},{"../core/component":56}],47:[function(e,t){var i=e("../core/component").registerComponent,r=e("../utils/").shouldCaptureKeyEvent,n=e("../lib/three"),o=.2;t.exports.Component=i("wasd-controls",{schema:{easing:{"default":20},acceleration:{"default":65},enabled:{"default":!0},fly:{"default":!1},wsAxis:{"default":"z",oneOf:["x","y","z"]},adAxis:{"default":"x",oneOf:["x","y","z"]},wsInverted:{"default":!1},wsEnabled:{"default":!0},adInverted:{"default":!1},adEnabled:{"default":!0}},init:function(){this.velocity=new n.Vector3,this.keys={},this.onBlur=this.onBlur.bind(this),this.onFocus=this.onFocus.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.attachVisibilityEventListeners()},update:function(e){var t,i=this.data,r=i.acceleration,n=i.easing,a=this.velocity,s=this.prevTime=this.prevTime||Date.now(),c=window.performance.now(),h=(c-s)/1e3,l=this.keys,u=i.adAxis,d=i.wsAxis,p=i.adInverted?-1:1,f=i.wsInverted?-1:1,m=this.el;if(this.prevTime=c,e||h>o)return a[u]=0,void(a[d]=0);a[u]-=a[u]*n*h,a[d]-=a[d]*n*h;var v=m.getComputedAttribute("position");i.enabled&&(i.adEnabled&&(l[65]&&(a[u]-=p*r*h),l[68]&&(a[u]+=p*r*h)),i.wsEnabled&&(l[87]&&(a[d]-=f*r*h),l[83]&&(a[d]+=f*r*h))),t=this.getMovementVector(h),m.object3D.translateX(t.x),m.object3D.translateY(t.y),m.object3D.translateZ(t.z),m.setAttribute("position",{x:v.x+t.x,y:v.y+t.y,z:v.z+t.z})},play:function(){this.attachKeyEventListeners()},pause:function(){this.keys={},this.removeKeyEventListeners()},tick:function(){this.update()},remove:function(){this.pause(),this.removeVisibilityEventListeners()},attachVisibilityEventListeners:function(){window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus),document.addEventListener("visibilitychange",this.onVisibilityChange)},removeVisibilityEventListeners:function(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),document.removeEventListener("visibilitychange",this.onVisibilityChange)},attachKeyEventListeners:function(){window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)},removeKeyEventListeners:function(){window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp)},onBlur:function(){this.pause()},onFocus:function(){this.play()},onVisibilityChange:function(){document.hidden?this.onBlur():this.onFocus()},onKeyDown:function(e){r(e)&&(this.keys[e.keyCode]=!0)},onKeyUp:function(e){r(e)&&(this.keys[e.keyCode]=!1)},getMovementVector:function(){var e=new n.Vector3(0,0,0),t=new n.Euler(0,0,0,"YXZ");return function(i){var r=this.velocity,o=this.el.getAttribute("rotation");return e.copy(r),e.multiplyScalar(i),o?(this.data.fly||(o.x=0),t.set(n.Math.degToRad(o.x),n.Math.degToRad(o.y),0),e.applyEuler(t),e):e}}()})},{"../core/component":56,"../lib/three":90,"../utils/":102}],48:[function(e,t){var i=e("tween.js"),r={alternate:"alternate",alternateReverse:"alternate-reverse",normal:"normal",reverse:"reverse"},n={linear:i.Easing.Linear.None,ease:i.Easing.Cubic.InOut,"ease-in":i.Easing.Cubic.In,"ease-out":i.Easing.Cubic.Out,"ease-in-out":i.Easing.Cubic.InOut,"ease-cubic":i.Easing.Cubic.In,"ease-in-cubic":i.Easing.Cubic.In,"ease-out-cubic":i.Easing.Cubic.Out,"ease-in-out-cubic":i.Easing.Cubic.InOut,"ease-quad":i.Easing.Quadratic.InOut,"ease-in-quad":i.Easing.Quadratic.In,"ease-out-quad":i.Easing.Quadratic.Out,"ease-in-out-quad":i.Easing.Quadratic.InOut,"ease-quart":i.Easing.Quartic.InOut,"ease-in-quart":i.Easing.Quartic.In,"ease-out-quart":i.Easing.Quartic.Out,"ease-in-out-quart":i.Easing.Quartic.InOut,"ease-quint":i.Easing.Quintic.InOut,"ease-in-quint":i.Easing.Quintic.In,"ease-out-quint":i.Easing.Quintic.Out,"ease-in-out-quint":i.Easing.Quintic.InOut,"ease-sine":i.Easing.Sinusoidal.InOut,"ease-in-sine":i.Easing.Sinusoidal.In,"ease-out-sine":i.Easing.Sinusoidal.Out,"ease-in-out-sine":i.Easing.Sinusoidal.InOut,"ease-expo":i.Easing.Exponential.InOut,"ease-in-expo":i.Easing.Exponential.In,"ease-out-expo":i.Easing.Exponential.Out,"ease-in-out-expo":i.Easing.Exponential.InOut,"ease-circ":i.Easing.Circular.InOut,"ease-in-circ":i.Easing.Circular.In,"ease-out-circ":i.Easing.Circular.Out,"ease-in-out-circ":i.Easing.Circular.InOut,"ease-elastic":i.Easing.Elastic.InOut,"ease-in-elastic":i.Easing.Elastic.In,"ease-out-elastic":i.Easing.Elastic.Out,"ease-in-out-elastic":i.Easing.Elastic.InOut,"ease-back":i.Easing.Back.InOut,"ease-in-back":i.Easing.Back.In,"ease-out-back":i.Easing.Back.Out,"ease-in-out-back":i.Easing.Back.InOut,"ease-bounce":i.Easing.Bounce.InOut,"ease-in-bounce":i.Easing.Bounce.In,"ease-out-bounce":i.Easing.Bounce.Out,"ease-in-out-bounce":i.Easing.Bounce.InOut},o={backwards:"backwards",both:"both",forwards:"forwards",none:"none"},a={indefinite:"indefinite"},s={attribute:"rotation",begin:"0",dur:1e3,easing:"ease",direction:r.normal,fill:o.forwards,from:void 0,repeat:0,to:void 0};t.exports.defaults=s,t.exports.directions=r,t.exports.easingFunctions=n,t.exports.fills=o,t.exports.repeats=a},{"tween.js":22}],49:[function(e,t){function i(e){return d.extend({},e)}function r(e,t,i,r,a){function s(){v=x[0],m=x[1],f=e.components[v],f||(e.setAttribute(v,""),f=e.components[v]),p=f.schema,b[t]=void 0===i?e.getComputedAttribute(v)[m]:i,b[t]=h(b[t],p[m]),w[t]=h(r,p[m]),g=function(i){t in i&&e.setAttribute(v,m,i[t])}}function l(){b=i?c.parse(i):a,w=c.parse(r),g=function(i){e.setAttribute(t,i)}}function u(){b[t]=void 0===i?!1:n(i),b[t]=o(b[t]),w[t]=o(n(r)),g=function(i){e.setAttribute(t,!!i[t])}}function d(){b[t]=parseFloat(void 0===i?e.getAttribute(t):i),w[t]=parseFloat(r),g=function(i){e.setAttribute(t,i[t])}}var p,f,m,v,g,x=t.split("."),b={},w={};return 2===x.length?s():r&&y(r)?l():-1!==["true","false"].indexOf(r)?u():d(),{from:b,partialSetAttribute:g,to:w}}function n(e){return"true"===e?!0:!1}function o(e){return e?1:0}var a=e("./a-node"),s=e("../constants/animation"),c=e("../utils/").coordinates,h=e("./schema").parseProperty,l=e("./a-register-element").registerElement,u=e("tween.js"),d=e("../utils/"),p=s.defaults,f=s.directions,m=s.easingFunctions,v=s.fills,g=s.repeats,y=c.isCoordinate;t.exports.AAnimation=l("a-animation",{prototype:Object.create(a.prototype,{createdCallback:{value:function(){this.bindMethods(),this.isRunning=!1,this.partialSetAttribute=function(){},this.tween=null}},attachedCallback:{value:function(){function e(){t.applyMixin(),t.update(),t.load()}var t=this,i=t.el=t.parentNode;i.isNode?i.hasLoaded?e():i.addEventListener("loaded",e.bind(t)):i.addEventListener("nodeready",e.bind(t))}},attributeChangedCallback:{value:function(){this.hasLoaded&&this.isRunning&&(this.stop(),this.applyMixin(),this.update())}},detachedCallback:{value:function(){this.isRunning&&this.stop()}},getTween:{value:function(){var e,t,n,o,a=this,s=a.data,c=a.el,h=s.attribute,l=parseInt(s.begin,10),d=c.getComputedAttribute(h),p=a.getDirection(s.direction),y=m[s.easing],x=s.fill,b=s.repeat===g.indefinite?1/0:0,w=!1;return e=r(c,h,s.from||a.initialValue,s.to,d),t=e.from,n=e.to,a.partialSetAttribute=e.partialSetAttribute,void 0===a.count&&(a.count=b===1/0?0:parseInt(s.repeat,10)),isNaN(l)&&(l=0),a.initialValue=a.initialValue||i(d),b===1/0&&x===v.forwards&&-1!==[f.alternate,f.alternateReverse].indexOf(s.direction)&&(w=!0),p===f.reverse&&(o=n,n=i(t), t=i(o)),-1!==[v.backwards,v.both].indexOf(x)&&a.partialSetAttribute(t),new u.Tween(i(t)).to(n,s.dur).delay(l).easing(y).repeat(b).yoyo(w).onUpdate(function(){a.partialSetAttribute(this)}).onComplete(a.onCompleted.bind(a))}},update:{value:function(){var e=this.data,t=e.begin;this.removeEventListeners(this.evt),this.addEventListeners(t),this.evt=t,isNaN(t)||(this.stop(),this.start())},writable:window.debug},onCompleted:{value:function(){var e=this.data;return this.isRunning=!1,-1!==[v.backwards,v.none].indexOf(e.fill)&&this.partialSetAttribute(this.initialValue),0===this.count?(this.count=void 0,void this.emit("animationend")):(this.isRunning=!1,this.count--,void this.start())}},start:{value:function(){!this.isRunning&&this.el.isPlaying&&(this.tween=this.getTween(),this.isRunning=!0,this.tween.start(),this.emit("animationstart"))},writable:!0},stop:{value:function(){var e=this.tween;e&&(e.stop(),this.isRunning=!1,-1!==[v.backwards,v.none].indexOf(this.data.fill)&&this.partialSetAttribute(this.initialValue),this.emit("animationstop"))},writable:!0},getDirection:{value:function(e){return e===f.alternate?(this.prevDirection=this.prevDirection===f.normal?f.reverse:f.normal,this.prevDirection):e===f.alternateReverse?(this.prevDirection=this.prevDirection===f.reverse?f.normal:f.reverse,this.prevDirection):e}},bindMethods:{value:function(){this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.onStateAdded=this.onStateAdded.bind(this),this.onStateRemoved=this.onStateRemoved.bind(this)}},addEventListeners:{value:function(e){var t=this.el,i=this;d.splitString(e).forEach(function(e){t.addEventListener(e,i.start)}),isNaN(e)||t.addEventListener("play",this.start),t.addEventListener("pause",this.stop),t.addEventListener("stateadded",this.onStateAdded),t.addEventListener("stateremoved",this.onStateRemoved)}},removeEventListeners:{value:function(e){var t=this.el,i=this.start;d.splitString(e).forEach(function(e){t.removeEventListener(e,i)}),t.removeEventListener("stateadded",this.onStateAdded),t.removeEventListener("stateremoved",this.onStateRemoved)}},onStateAdded:{value:function(e){e.detail.state===this.data.begin&&this.start()},writable:!0},onStateRemoved:{value:function(e){e.detail.state===this.data.begin&&this.stop()},writable:!0},applyMixin:{value:function(){var e,t,i,r={};i=document.querySelector("#"+this.getAttribute("mixin")),t=i?d.getElData(i,p):{},e=d.getElData(this,p),d.extend(r,p,t,e),this.data=r}}})}),t.exports.getAnimationValues=r},{"../constants/animation":48,"../utils/":102,"./a-node":54,"./a-register-element":55,"./schema":62,"tween.js":22}],50:[function(e,t){function i(e){return e.hasAttribute("autoplay")||"auto"===e.getAttribute("preload")?new Promise(function(t,i){function r(){for(var i=0,r=0;r=e.duration&&t()}return 4===e.readyState?t():e.error?i():(e.addEventListener("loadeddata",r,!1),e.addEventListener("progress",r,!1),void e.addEventListener("error",i,!1))}):void 0}var r=e("./a-node"),n=e("../utils/debug"),o=e("./a-register-element").registerElement,a=e("../lib/three"),s=new a.XHRLoader,c=n("core:a-assets:warn");t.exports=o("a-assets",{prototype:Object.create(r.prototype,{createdCallback:{value:function(){this.isAssets=!0}},attachedCallback:{value:function(){var e=this,t=[],r=this.querySelectorAll("audio"),n=this.querySelectorAll("img"),o=parseInt(this.getAttribute("timeout"),10)||3e3,a=this.querySelectorAll("video");if("A-SCENE"!==this.parentNode.tagName)throw new Error(" must be a child of a .");for(var s=0;s did not contain exactly six elements each with a `src` attribute.")},writable:window.debug}})})},{"../utils/debug":101,"./a-register-element":55}],52:[function(e,t){function i(e,t){return void 0!==e.defaultComponents[t]?!0:e.hasAttribute(t)?!0:r(t,e.mixinEls)}function r(e,t){var i,r=!1;for(i=0;i has been DEPRECATED. Use instead.'),this.hasAttribute("type")&&console.log(" has been DEPRECATED. Use instead."),this.listener=this.attachEventListener(),this.load()}},detachedCallback:{value:function(){var e=this.listener;e&&this.removeEventListener(this.name,e)}},attachEventListener:{value:function(){var e=this.attributes,t=this.el,i=this.name,r=this.targetEls;return t.addEventListener(i,function(){for(var t,i,n,o,a,s=0;s is deprecated. Use instead."},n))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],69:[function(e){var t=e("../registerPrimitive");t("a-camera",{defaultAttributes:{camera:{},"look-controls":{},"wasd-controls":{}},mappings:{active:"camera.active",far:"camera.far",fov:"camera.fov","look-controls-enabled":"look-controls.enabled",near:"camera.near","wasd-controls-enabled":"wasd-controls.enabled"},deprecatedMappings:{"cursor-color":"a-camera[cursor-color] has been removed. Use a-cursor[color] instead.","cursor-maxdistance":"a-camera[cursor-maxdistance] has been removed. Use a-cursor[max-distance] instead.","cursor-offset":"a-camera[cursor-offset] has been removed. Use a-cursor[position] instead.","cursor-opacity":"a-camera[cursor-offset] has been removed. Use a-cursor[opacity] instead.","cursor-scale":"a-camera[cursor-scale] has been removed. Use a-cursor[scale] instead.","cursor-visible":"a-camera[cursor-visible] has been removed. Use a-cursor[visible] instead."}})},{"../registerPrimitive":87}],70:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-circle",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"circle"}},mappings:{radius:"geometry.radius",segments:"geometry.segments","theta-length":"geometry.theta-length","theta-start":"geometry.theta-start"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],71:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-collada-model",r.extendDeep({},t(),{mappings:{src:"collada-model"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],72:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-cone",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"cone"}},mappings:{height:"geometry.height","open-ended":"geometry.openEnded","radius-bottom":"geometry.radiusBottom","radius-top":"geometry.radiusTop","segments-height":"geometry.segmentsHeight","segments-radial":"geometry.segmentsRadial","theta-length":"geometry.thetaLength","theta-start":"geometry.thetaStart",translate:"geometry.translate"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],73:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-cursor",r.extendDeep({},t(),{defaultAttributes:{cursor:{maxDistance:1e3},geometry:{primitive:"ring",radiusOuter:.016,radiusInner:.01,segmentsTheta:64},material:{shader:"flat",opacity:.8},position:{x:0,y:0,z:-1}},mappings:{fuse:"cursor.fuse","max-distance":"cursor.maxDistance",timeout:"cursor.timeout"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],74:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-curvedimage",r.extendDeep({},t(),{defaultAttributes:{geometry:{height:1,primitive:"cylinder",radius:2,segmentsRadial:48,thetaLength:270,openEnded:!0,thetaStart:0},material:{color:"#FFF",shader:"flat",side:"double",transparent:!0,repeat:"-1 1"}},mappings:{height:"geometry.height","open-ended":"geometry.openEnded",radius:"geometry.radius",segments:"geometry.segmentsRadial",start:"geometry.thetaStart","theta-length":"geometry.thetaLength","theta-start":"geometry.thetaStart",translate:"geometry.translate",width:"geometry.thetaLength"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],75:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-cylinder",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"cylinder"}},mappings:{height:"geometry.height","open-ended":"geometry.openEnded",radius:"geometry.radius","radius-bottom":"geometry.radiusBottom","radius-top":"geometry.radiusTop","segments-radial":"geometry.segmentsRadial","theta-length":"geometry.thetaLength","theta-start":"geometry.thetaStart",translate:"geometry.translate"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],76:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-image",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"plane"},material:{color:"#FFF",shader:"flat",side:"double",transparent:!0}},mappings:{height:"geometry.height",translate:"geometry.translate",width:"geometry.width"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],77:[function(e){var t=e("../registerPrimitive");t("a-light",{defaultAttributes:{light:{}},mappings:{angle:"light.angle",color:"light.color","ground-color":"light.groundColor",decay:"light.decay",distance:"light.distance",exponent:"light.exponent",intensity:"light.intensity",type:"light.type"}})},{"../registerPrimitive":87}],78:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-model",r.extend({},t(),{deprecated:" is deprecated. Use or instead.",defaultAttributes:{loader:{format:"collada"},material:{color:"#FFF"}},mappings:{src:"loader.src",format:"loader.format"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],79:[function(e){var t=e("../getMeshMixin")(),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-obj-model",r.extendDeep({},t,{mappings:{src:"obj-model.obj",mtl:"obj-model.mtl"},transforms:{mtl:t.transforms.src}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],80:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-plane",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"plane"}},mappings:{height:"geometry.height",translate:"geometry.translate",width:"geometry.width"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],81:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-ring",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"ring"}},mappings:{"radius-inner":"geometry.radiusInner","radius-outer":"geometry.radiusOuter","segments-phi":"geometry.segments-phi","segments-theta":"geometry.segments-theta","theta-length":"geometry.theta-length","theta-start":"geometry.theta-start"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],82:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-sky",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"sphere",radius:100,segmentsWidth:64,segmentsHeight:20},material:{color:"#FFF",shader:"flat"},scale:"-1 1 1"},mappings:{radius:"geometry.radius","segments-width":"geometry.segmentsWidth","segments-height":"geometry.segmentsHeight"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],83:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-sphere",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"sphere"}},mappings:{radius:"geometry.radius","segments-height":"geometry.segmentsHeight","segments-width":"geometry.segmentsWidth",translate:"geometry.translate"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],84:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-torus",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"torus"}},mappings:{arc:"geometry.arc",radius:"geometry.radius","radius-tubular":"geometry.radiusTubular","segments-radial":"geometry.segmentsRadial","segments-tubular":"geometry.segmentsTubular"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],85:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-video",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"plane"},material:{color:"#FFF",shader:"flat",side:"double",transparent:!0}},mappings:{height:"geometry.height",translate:"geometry.translate",width:"geometry.width"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],86:[function(e){var t=e("../getMeshMixin"),i=e("../registerPrimitive"),r=e("../../../utils/");i("a-videosphere",r.extendDeep({},t(),{defaultAttributes:{geometry:{primitive:"sphere",radius:5e3,segmentsWidth:64,segmentsHeight:64},material:{color:"#FFF",shader:"flat"},scale:"-1 1 1"},mappings:{radius:"geometry.radius","segments-height":"geometry.segmentsHeight","segments-width":"geometry.segmentsWidth"}}))},{"../../../utils/":102,"../getMeshMixin":66,"../registerPrimitive":87}],87:[function(e,t){function i(e){var t={};return Object.keys(e).forEach(function(i){var r=e[i];t[i]="object"==typeof r?a.extend({},r):r}),t}var r=e("../../core/a-entity"),n=e("../../core/component").components,o=e("../../core/a-register-element").registerElement,a=e("../../utils/"),s=a.debug,c=s("extras:primitives");t.exports=function(e,t){return e=e.toLowerCase(),c("Registering <%s>",e),o(e,{prototype:Object.create(r.prototype,{defaultAttributes:{value:t.defaultAttributes||{}},deprecated:{value:t.deprecated||null},deprecatedMappings:{value:t.deprecatedMappings||{}},mappings:{value:t.mappings||{}},transforms:{value:t.transforms||{}},createdCallback:{value:function(){this.componentData={},t.deprecated&&console.warn(t.deprecated)}},attachedCallback:{value:function(){var e=this,t=this.attributes;this.componentData=i(this.defaultAttributes),Object.keys(this.componentData).forEach(function(t){e.hasAttribute(t)||e.setAttribute(t,e.componentData[t])}),Object.keys(t).forEach(function(i){var r=t[i];e.syncAttributeToComponent(r.name,r.value)})}},attributeChangedCallback:{value:function(e,t,i){return this.mappings[e]?void this.syncAttributeToComponent(e,i):void r.prototype.attributeChangedCallback.call(this,e,t,i)}},syncAttributeToComponent:{value:function(e,t){var i,r,o;e in this.deprecatedMappings&&console.warn(this.deprecatedMappings[e]),e&&this.mappings[e]&&(i=this.mappings[e],-1!==i.indexOf(".")&&(r=this.mappings[e].split("."),i=r[0],o=r[1]),n[i]&&(t=this.getTransformedValue(e,t),this.componentData[i]||(this.componentData[i]=this.defaultAttributes[i]||{}),o?this.componentData[i][o]=t:this.componentData[i]=t,this.setAttribute(i,this.componentData[i])))}},getTransformedValue:{value:function(e,t){return this.transforms&&this.transforms[e]?this.transforms[e].bind(this)(t):t}}})})}},{"../../core/a-entity":52,"../../core/a-register-element":55,"../../core/component":56,"../../utils/":102}],88:[function(e,t){window.Promise=window.Promise||e("promise-polyfill"),e("present"),e("./style/aframe.css"),e("./style/rStats.css");var i=e("./core/scene/a-scene"),r=e("./core/component").components,n=e("./core/component").registerComponent,o=e("./extras/primitives/registerPrimitive"),a=e("./core/shader").registerShader,s=e("./core/system").registerSystem,c=e("./core/shader").shaders,h=e("./core/system").systems,l=window.THREE=e("./lib/three"),u=window.TWEEN=e("tween.js"),d=e("../package"),p=e("./utils/");e("./systems/index"),e("./components/index"),e("./shaders/index");var f=e("./core/a-node"),m=e("./core/a-entity");window.hasNonPolyfillWebVRSupport=!!navigator.getVRDevices,window.WebVRConfig={TOUCH_PANNER_DISABLED:!0,MOUSE_KEYBOARD_CONTROLS_DISABLED:!0},e("webvr-polyfill"),e("./core/a-animation"),e("./core/a-assets"),e("./core/a-cubemap"),e("./core/a-mixin"),e("./extras/declarative-events/"),e("./extras/primitives/"),console.log("A-Frame Version:",d.version),console.log("three Version:",d.dependencies.three),console.log("WebVR Polyfill Version:",d.dependencies["webvr-polyfill"]),t.exports=window.AFRAME={AEntity:m,ANode:f,AScene:i,components:r,registerComponent:n,registerShader:a,registerSystem:s,registerPrimitive:o,shaders:c,systems:h,THREE:l,TWEEN:u,utils:p,version:d.version}},{"../package":24,"./components/index":29,"./core/a-animation":49,"./core/a-assets":50,"./core/a-cubemap":51,"./core/a-entity":52,"./core/a-mixin":53,"./core/a-node":54,"./core/component":56,"./core/scene/a-scene":58,"./core/shader":63,"./core/system":64,"./extras/declarative-events/":65,"./extras/primitives/":67,"./extras/primitives/registerPrimitive":87,"./lib/three":90,"./shaders/index":92,"./style/aframe.css":94,"./style/rStats.css":95,"./systems/index":97,"./utils/":102,present:10,"promise-polyfill":11,"tween.js":22,"webvr-polyfill":23}],89:[function(e,t){window.aframeStats=function(e){function t(){o("te").set(a.querySelectorAll("a-entity").length),o("lt").set(window.performance.getEntriesByName("render-started")[0].startTime.toFixed(0))}function i(){}function r(){}function n(e){o=e}var o=null,a=e,s={te:{caption:"Entities"},lt:{caption:"Load Time"}},c=[{caption:"A-Frame",values:["te","lt"]}];return{update:t,start:i,end:r,attach:n,values:s,groups:c,fractions:[]}},"object"==typeof t&&(t.exports={aframeStats:window.aframeStats})},{}],90:[function(e,t){(function(i){var r=i.THREE=e("three");r.TextureLoader&&(r.TextureLoader.prototype.crossOrigin=""),r.ImageLoader&&(r.ImageLoader.prototype.crossOrigin=""),r.Cache&&(r.Cache.enabled=!0),e("../../node_modules/three/examples/js/loaders/OBJLoader"),e("../../node_modules/three/examples/js/loaders/MTLLoader"),e("../../node_modules/three/examples/js/loaders/ColladaLoader"),e("../../node_modules/three/examples/js/controls/VRControls"),e("../../node_modules/three/examples/js/effects/VREffect"),t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../node_modules/three/examples/js/controls/VRControls":16,"../../node_modules/three/examples/js/effects/VREffect":17,"../../node_modules/three/examples/js/loaders/ColladaLoader":18,"../../node_modules/three/examples/js/loaders/MTLLoader":19,"../../node_modules/three/examples/js/loaders/OBJLoader":20,three:21}],91:[function(e,t){function i(e){var t={fog:e.fog,color:new n.Color(e.color)};return t}var r=e("../core/shader").registerShader,n=e("../lib/three"),o=e("../utils/");t.exports.Component=r("flat",{schema:{color:{type:"color"},fog:{"default":!0},height:{"default":256},repeat:{"default":""},src:{"default":""},width:{"default":512}},init:function(e){return this.textureSrc=null,this.material=new n.MeshBasicMaterial(i(e)),this.updateTexture(e),this.material},update:function(e){return this.updateMaterial(e),this.updateTexture(e),this.material},updateTexture:function(e){var t=this.el,i=e.src,r=this.material,n=t.sceneEl.systems.material;if(i){if(i===this.textureSrc)return;return this.textureSrc=i,void o.srcLoader.validateSrc(i,function(i){n.loadImage(t,r,e,i)},function(i){n.loadVideo(t,r,e,i)})}o.material.updateMaterialTexture(r,null)},updateMaterial:function(e){var t=this.material;e=i(e),Object.keys(e).forEach(function(i){t[i]=e[i]})}})},{"../core/shader":63,"../lib/three":90,"../utils/":102}],92:[function(e){e("./flat"),e("./standard")},{"./flat":91,"./standard":93}],93:[function(e,t){function i(e){var t={color:new n.Color(e.color),metalness:e.metalness,roughness:e.roughness};return t}var r=e("../core/shader").registerShader,n=e("../lib/three"),o=e("../utils/"),a=new n.CubeTextureLoader,s={};t.exports.Component=r("standard",{schema:{color:{type:"color"},envMap:{"default":""},fog:{"default":!0},height:{"default":256},metalness:{"default":0,min:0,max:1},repeat:{"default":""},src:{"default":""},roughness:{"default":.5,min:0,max:1},width:{"default":512}},init:function(e){return this.material=new n.MeshStandardMaterial(i(e)),this.updateTexture(e),this.updateEnvMap(e),this.material},update:function(e){return this.updateMaterial(e),this.updateTexture(e),this.updateEnvMap(e),this.material},updateTexture:function(e){var t=this.el,i=e.src,r=this.material,n=t.sceneEl.systems.material;if(i){if(i===this.textureSrc)return;this.textureSrc=i,o.srcLoader.validateSrc(i,function(i){n.loadImage(t,r,e,i)},function(i){n.loadVideo(t,r,e,i)})}else o.material.updateMaterialTexture(r,null)},updateMaterial:function(e){var t=this.material;e=i(e),Object.keys(e).forEach(function(i){t[i]=e[i]})},updateEnvMap:function(e){var t=this,i=this.material,r=e.envMap;return!r||this.isLoadingEnvMap?(i.envMap=null,void(i.needsUpdate=!0)):(this.isLoadingEnvMap=!0,s[r]?void s[r].then(function(e){t.isLoadingEnvMap=!1,i.envMap=e,i.needsUpdate=!0}):void(s[r]=new Promise(function(e){o.srcLoader.validateCubemapSrc(r,function(r){a.load(r,function(r){t.isLoadingEnvMap=!1,i.envMap=r,e(r)})})})))}})},{"../core/shader":63,"../lib/three":90,"../utils/":102}],94:[function(e,t){var i="html{bottom:0;left:0;position:fixed;right:0;top:0}body{height:100%;margin:0;overflow:hidden;padding:0;width:100%}.a-hidden{display:none!important}.a-canvas{height:100%;left:0;position:absolute;top:0;width:100%}a-assets,a-scene img,a-scene video{display:none}.a-enter-vr{align-items:flex-end;-webkit-align-items:flex-end;bottom:5px;display:flex;display:-webkit-flex;font-family:sans-serif,monospace;font-size:13px;font-weight:200;line-height:16px;height:72px;position:fixed;right:5px}.a-enter-vr-button{background:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20245.82%20141.73%22%3E%3Cdefs%3E%3Cstyle%3E.a%7Bfill%3A%23fff%3Bfill-rule%3Aevenodd%3B%7D%3C%2Fstyle%3E%3C%2Fdefs%3E%3Ctitle%3Emask%3C%2Ftitle%3E%3Cpath%20class%3D%22a%22%20d%3D%22M175.56%2C111.37c-22.52%2C0-40.77-18.84-40.77-42.07S153%2C27.24%2C175.56%2C27.24s40.77%2C18.84%2C40.77%2C42.07S198.08%2C111.37%2C175.56%2C111.37ZM26.84%2C69.31c0-23.23%2C18.25-42.07%2C40.77-42.07s40.77%2C18.84%2C40.77%2C42.07-18.26%2C42.07-40.77%2C42.07S26.84%2C92.54%2C26.84%2C69.31ZM27.27%2C0C11.54%2C0%2C0%2C12.34%2C0%2C28.58V110.9c0%2C16.24%2C11.54%2C30.83%2C27.27%2C30.83H99.57c2.17%2C0%2C4.19-1.83%2C5.4-3.7L116.47%2C118a8%2C8%2C0%2C0%2C1%2C12.52-.18l11.51%2C20.34c1.2%2C1.86%2C3.22%2C3.61%2C5.39%2C3.61h72.29c15.74%2C0%2C27.63-14.6%2C27.63-30.83V28.58C245.82%2C12.34%2C233.93%2C0%2C218.19%2C0H27.27Z%22%2F%3E%3C%2Fsvg%3E) 50% 50%/70% 70% no-repeat rgba(0,0,0,.35);border:0;bottom:0;color:#FFF;cursor:pointer;height:50px;position:absolute;right:0;transition:background-color .05s ease;-webkit-transition:background-color .05s ease;width:60px;z-index:999999}.a-enter-vr-button:active,.a-enter-vr-button:hover{background-color:#666}[data-a-enter-vr-no-webvr] .a-enter-vr-button{border-color:#666;opacity:.65}[data-a-enter-vr-no-webvr] .a-enter-vr-button:active,[data-a-enter-vr-no-webvr] .a-enter-vr-button:hover{background-color:rgba(0,0,0,.35);cursor:not-allowed}.a-enter-vr-modal{background-color:#666;border-radius:0;color:#FFF;height:32px;margin-right:70px;padding:9px;width:280px;position:relative;display:none}.a-enter-vr-modal:after{border-bottom:10px solid transparent;border-left:10px solid #666;border-top:10px solid transparent;display:inline-block;content:'';position:absolute;right:-5px;top:5px;width:0;height:0}.a-enter-vr-modal p{margin:0;display:inline}.a-enter-vr-modal p:after{content:' '}.a-enter-vr-modal a{color:#FFF;display:inline}[data-a-enter-vr-no-headset].a-enter-vr:hover .a-enter-vr-modal,[data-a-enter-vr-no-webvr].a-enter-vr:hover .a-enter-vr-modal{display:block}.a-orientation-modal{position:absolute;width:100%;height:100%;top:0;left:0;background:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20version%3D%221.1%22%20x%3D%220px%22%20y%3D%220px%22%20viewBox%3D%220%200%2090%2090%22%20enable-background%3D%22new%200%200%2090%2090%22%20xml%3Aspace%3D%22preserve%22%3E%3Cpolygon%20points%3D%220%2C0%200%2C0%200%2C0%20%22%3E%3C/polygon%3E%3Cg%3E%3Cpath%20d%3D%22M71.545%2C48.145h-31.98V20.743c0-2.627-2.138-4.765-4.765-4.765H18.456c-2.628%2C0-4.767%2C2.138-4.767%2C4.765v42.789%20%20%20c0%2C2.628%2C2.138%2C4.766%2C4.767%2C4.766h5.535v0.959c0%2C2.628%2C2.138%2C4.765%2C4.766%2C4.765h42.788c2.628%2C0%2C4.766-2.137%2C4.766-4.765V52.914%20%20%20C76.311%2C50.284%2C74.173%2C48.145%2C71.545%2C48.145z%20M18.455%2C16.935h16.344c2.1%2C0%2C3.808%2C1.708%2C3.808%2C3.808v27.401H37.25V22.636%20%20%20c0-0.264-0.215-0.478-0.479-0.478H16.482c-0.264%2C0-0.479%2C0.214-0.479%2C0.478v36.585c0%2C0.264%2C0.215%2C0.478%2C0.479%2C0.478h7.507v7.644%20%20%20h-5.534c-2.101%2C0-3.81-1.709-3.81-3.81V20.743C14.645%2C18.643%2C16.354%2C16.935%2C18.455%2C16.935z%20M16.96%2C23.116h19.331v25.031h-7.535%20%20%20c-2.628%2C0-4.766%2C2.139-4.766%2C4.768v5.828h-7.03V23.116z%20M71.545%2C73.064H28.757c-2.101%2C0-3.81-1.708-3.81-3.808V52.914%20%20%20c0-2.102%2C1.709-3.812%2C3.81-3.812h42.788c2.1%2C0%2C3.809%2C1.71%2C3.809%2C3.812v16.343C75.354%2C71.356%2C73.645%2C73.064%2C71.545%2C73.064z%22%3E%3C/path%3E%3Cpath%20d%3D%22M28.919%2C58.424c-1.466%2C0-2.659%2C1.193-2.659%2C2.66c0%2C1.466%2C1.193%2C2.658%2C2.659%2C2.658c1.468%2C0%2C2.662-1.192%2C2.662-2.658%20%20%20C31.581%2C59.617%2C30.387%2C58.424%2C28.919%2C58.424z%20M28.919%2C62.786c-0.939%2C0-1.703-0.764-1.703-1.702c0-0.939%2C0.764-1.704%2C1.703-1.704%20%20%20c0.94%2C0%2C1.705%2C0.765%2C1.705%2C1.704C30.623%2C62.022%2C29.858%2C62.786%2C28.919%2C62.786z%22%3E%3C/path%3E%3Cpath%20d%3D%22M69.654%2C50.461H33.069c-0.264%2C0-0.479%2C0.215-0.479%2C0.479v20.288c0%2C0.264%2C0.215%2C0.478%2C0.479%2C0.478h36.585%20%20%20c0.263%2C0%2C0.477-0.214%2C0.477-0.478V50.939C70.131%2C50.676%2C69.917%2C50.461%2C69.654%2C50.461z%20M69.174%2C51.417V70.75H33.548V51.417H69.174z%22%3E%3C/path%3E%3Cpath%20d%3D%22M45.201%2C30.296c6.651%2C0%2C12.233%2C5.351%2C12.551%2C11.977l-3.033-2.638c-0.193-0.165-0.507-0.142-0.675%2C0.048%20%20%20c-0.174%2C0.198-0.153%2C0.501%2C0.045%2C0.676l3.883%2C3.375c0.09%2C0.075%2C0.198%2C0.115%2C0.312%2C0.115c0.141%2C0%2C0.273-0.061%2C0.362-0.166%20%20%20l3.371-3.877c0.173-0.2%2C0.151-0.502-0.047-0.675c-0.194-0.166-0.508-0.144-0.676%2C0.048l-2.592%2C2.979%20%20%20c-0.18-3.417-1.629-6.605-4.099-9.001c-2.538-2.461-5.877-3.817-9.404-3.817c-0.264%2C0-0.479%2C0.215-0.479%2C0.479%20%20%20C44.72%2C30.083%2C44.936%2C30.296%2C45.201%2C30.296z%22%3E%3C/path%3E%3C/g%3E%3C/svg%3E) center center/50% 50% no-repeat rgba(244,244,244,1)}.a-orientation-modal:after{display:block;content:\"Insert phone into Cardboard holder.\";color:#333;font-family:sans-serif,monospace;font-size:13px;text-align:center;position:absolute;width:100%;top:70%;transform:translateY(-70%)}.a-orientation-modal button{background:url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20version%3D%221.1%22%20x%3D%220px%22%20y%3D%220px%22%20viewBox%3D%220%200%20100%20100%22%20enable-background%3D%22new%200%200%20100%20100%22%20xml%3Aspace%3D%22preserve%22%3E%3Cpath%20fill%3D%22%23000000%22%20d%3D%22M55.209%2C50l17.803-17.803c1.416-1.416%2C1.416-3.713%2C0-5.129c-1.416-1.417-3.713-1.417-5.129%2C0L50.08%2C44.872%20%20L32.278%2C27.069c-1.416-1.417-3.714-1.417-5.129%2C0c-1.417%2C1.416-1.417%2C3.713%2C0%2C5.129L44.951%2C50L27.149%2C67.803%20%20c-1.417%2C1.416-1.417%2C3.713%2C0%2C5.129c0.708%2C0.708%2C1.636%2C1.062%2C2.564%2C1.062c0.928%2C0%2C1.856-0.354%2C2.564-1.062L50.08%2C55.13l17.803%2C17.802%20%20c0.708%2C0.708%2C1.637%2C1.062%2C2.564%2C1.062s1.856-0.354%2C2.564-1.062c1.416-1.416%2C1.416-3.713%2C0-5.129L55.209%2C50z%22%3E%3C/path%3E%3C/svg%3E);width:50px;height:50px;border:none;text-indent:-9999px}@media (min-width:480px){.a-enter-vr{bottom:20px;right:20px}.a-enter-vr-modal{width:400px}}";e("browserify-css").createStyle(i,{href:"src/style/aframe.css"}),t.exports=i},{"browserify-css":1}],95:[function(e,t){var i=".rs-base{background-color:#EF2D5E;border-radius:0;font:10px monospace;left:5px;line-height:1em;opacity:.75;overflow:hidden;padding:10px;position:fixed;top:5px;width:300px;z-index:10000}.rs-base div.hidden{display:none}.rs-base h1{color:#fff;cursor:pointer;font-size:1.4em;font-weight:300;margin:0 0 5px;padding:0}.rs-group{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-direction:column-reverse;flex-direction:column-reverse;margin-bottom:5px}.rs-group:last-child{margin-bottom:0}.rs-counter-base{align-items:center;display:-webkit-box;display:-webkit-flex;display:flex;height:10px;-webkit-justify-content:space-between;justify-content:space-between;margin:2px 0}.rs-counter-id{font-weight:300;-webkit-box-ordinal-group:0;-webkit-order:0;order:0;width:50px}.rs-counter-value{font-weight:300;-webkit-box-ordinal-group:1;-webkit-order:1;order:1;text-align:right;width:35px}.rs-canvas{-webkit-box-ordinal-group:2;-webkit-order:2;order:2}@media (min-width:480px){.rs-base{left:20px;top:20px}}";e("browserify-css").createStyle(i,{href:"src/style/rStats.css"}),t.exports=i},{"browserify-css":1}],96:[function(e,t){function i(e){var t,i=e.camera;i&&(t=e.querySelector("["+n+"]"),t&&e.removeChild(t))}var r=e("../core/system").registerSystem,n="data-aframe-default-camera";t.exports.System=r("camera",{init:function(){this.activeCameraEl=null,this.setupDefaultCamera()},setupDefaultCamera:function(){var e,t,i=this.sceneEl;setTimeout(function(){var r=i.querySelector("[camera]");return r&&r.isEntity?void i.emit("camera-ready",{cameraEl:r}):(e=document.createElement("a-entity"),e.setAttribute("position",{x:0,y:1.8,z:4}),e.setAttribute(n,""),t=document.createElement("a-entity"),t.setAttribute("camera",{active:!0}),t.setAttribute("wasd-controls"),t.setAttribute("look-controls"),e.appendChild(t),i.appendChild(e),void i.emit("camera-ready",{cameraEl:t}))})},disableActiveCamera:function(){var e=this.sceneEl,t=e.querySelectorAll("[camera]"),i=t[t.length-1];i.setAttribute("camera","active",!0)},setActiveCamera:function(e,t){var r,o,a=this.sceneEl,s=a.querySelectorAll("[camera]"),c=a.querySelector("["+n+"]"),h=c&&c.querySelector("[camera]");for(e!==h&&i(a),this.activeCameraEl=e,a.isPlaying&&e.play(),e.setAttribute("camera","active",!0),a.camera=t,a.emit("camera-set-active",{cameraEl:e}),o=0;o or