From 1ae08d8b6195d5de5d3eae033c70d8e8c8613a19 Mon Sep 17 00:00:00 2001 From: vlin17 Date: Mon, 5 Mar 2018 17:01:16 -0800 Subject: [PATCH] Dreamview: consolidate navigation/standard mode --- modules/dreamview/frontend/dist/app.bundle.js | 14 ++-- .../dreamview/frontend/dist/app.bundle.js.map | 2 +- .../Navigation/navigation_viewer.html | 21 ------ modules/dreamview/frontend/dist/index.html | 2 + .../frontend/dist/navigation.bundle.js | 2 - .../frontend/dist/navigation.bundle.js.map | 1 - .../src/components/Layouts/MainView.js | 22 ++++--- .../components/Navigation/BaiduMapAdapter.js | 15 ++++- .../components/Navigation/GoogleMapAdapter.js | 18 +++++- .../src/components/Navigation/MapNavigator.js | 14 +++- .../Navigation/WindowResizeControl.js | 53 +++++++++++++++ .../src/components/Navigation/entry.js | 24 ------- .../src/components/Navigation/index.js | 64 +++++++++++++++++-- .../src/components/SideBar/ButtonPanel.js | 8 +-- .../frontend/src/components/SideBar/index.js | 3 +- .../frontend/src/components/Tasks/Others.js | 2 +- .../src/components/Tasks/QuickStart.js | 3 +- modules/dreamview/frontend/src/index.hbs | 2 + modules/dreamview/frontend/src/store/index.js | 2 +- .../store/websocket/websocket_navigation.js | 64 ------------------- .../src/store/websocket/websocket_realtime.js | 11 +++- .../dreamview/frontend/src/styles/main.scss | 21 ++++++ modules/dreamview/frontend/webpack.config.js | 5 -- 23 files changed, 220 insertions(+), 153 deletions(-) delete mode 100644 modules/dreamview/frontend/dist/components/Navigation/navigation_viewer.html delete mode 100644 modules/dreamview/frontend/dist/navigation.bundle.js delete mode 100644 modules/dreamview/frontend/dist/navigation.bundle.js.map create mode 100644 modules/dreamview/frontend/src/components/Navigation/WindowResizeControl.js delete mode 100644 modules/dreamview/frontend/src/components/Navigation/entry.js delete mode 100644 modules/dreamview/frontend/src/store/websocket/websocket_navigation.js diff --git a/modules/dreamview/frontend/dist/app.bundle.js b/modules/dreamview/frontend/dist/app.bundle.js index 6f7fe29a4a..c623db2bf1 100644 --- a/modules/dreamview/frontend/dist/app.bundle.js +++ b/modules/dreamview/frontend/dist/app.bundle.js @@ -1,9 +1,9 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=198)}([function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,n){"use strict";t.__esModule=!0;var r=n(26),i=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=function(){function e(e,t){for(var n=0;n6?l-6:0),c=6;c>",s=s||i,null==r[i]){if(t){var n=null===r[i]?"null":"undefined";return new Error("The "+a+" `"+s+"` is marked as required in `"+o+"`, but its value is `"+n+"`.")}return null}return e.apply(void 0,[r,i,o,a,s].concat(u))})}var r=t.bind(null,!1);return r.isRequired=t.bind(null,!0),r}function i(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function o(e){var t=void 0===e?"undefined":T(e);return Array.isArray(e)?"array":e instanceof RegExp?"object":i(t,e)?"symbol":t}function a(e){var t=o(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function s(e,t){return r(function(r,i,s,l,u){return n.i(_.untracked)(function(){if(e&&o(r[i])===t.toLowerCase())return null;var n=void 0;switch(t){case"Array":n=_.isObservableArray;break;case"Object":n=_.isObservableObject;break;case"Map":n=_.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+t)}var l=r[i];if(!n(l)){var c=a(l),d=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+u+"` of type `"+c+"` supplied to `"+s+"`, expected `mobx.Observable"+t+"`"+d+".")}return null})})}function l(e,t){return r(function(r,i,o,a,l){for(var u=arguments.length,c=Array(u>5?u-5:0),d=5;d2&&void 0!==arguments[2]&&arguments[2],r=e[t],i=re[t],o=r?!0===n?function(){i.apply(this,arguments),r.apply(this,arguments)}:function(){r.apply(this,arguments),i.apply(this,arguments)}:i;e[t]=o}function y(e,t){if(b(e,t))return!0;if("object"!==(void 0===e?"undefined":T(e))||null===e||"object"!==(void 0===t?"undefined":T(t))||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var i=0;i",r=this._reactInternalInstance&&this._reactInternalInstance._rootNodeID||this._reactInternalFiber&&this._reactInternalFiber._debugID,i=!1,o=!1;e.call(this,"props"),e.call(this,"state");var a=this.render.bind(this),s=null,l=!1,u=function(){return s=new _.Reaction(n+"#"+r+".render()",function(){if(!l&&(l=!0,"function"==typeof t.componentWillReact&&t.componentWillReact(),!0!==t.__$mobxIsUnmounted)){var e=!0;try{o=!0,i||M.Component.prototype.forceUpdate.call(t),e=!1}finally{o=!1,e&&s.dispose()}}}),s.reactComponent=t,c.$mobx=s,t.render=c,c()},c=function(){l=!1;var e=void 0,n=void 0;if(s.track(function(){J&&(t.__$mobRenderStart=Date.now());try{n=_.extras.allowStateChanges(!1,a)}catch(t){e=t}J&&(t.__$mobRenderEnd=Date.now())}),e)throw ne.emit(e),e;return n};this.render=u}},componentWillUnmount:function(){if(!0!==Q&&(this.render.$mobx&&this.render.$mobx.dispose(),this.__$mobxIsUnmounted=!0,J)){var e=f(this);e&&ee&&ee.delete(e),te.emit({event:"destroy",component:this,node:e})}},componentDidMount:function(){J&&p(this)},componentDidUpdate:function(){J&&p(this)},shouldComponentUpdate:function(e,t){return Q&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==t||!y(this.props,e)}},ie=x(function(e){var t=e.children,n=e.inject,r=e.render,i=t||r;if(void 0===i)return null;if(!n)return i();var o=h(n)(i);return S.a.createElement(o,null)});ie.displayName="Observer";var oe=function(e,t,n,r,i){var o="children"===t?"render":"children";if("function"==typeof e[t]&&"function"==typeof e[o])return new Error("Invalid prop,do not use children and render in the same time in`"+n);if("function"!=typeof e[t]&&"function"!=typeof e[o])return new Error("Invalid prop `"+i+"` of type `"+T(e[t])+"` supplied to `"+n+"`, expected `function`.")};ie.propTypes={render:oe,children:oe};var ae,se,le={children:!0,key:!0,ref:!0},ue=(se=ae=function(e){function t(){return k(this,t),P(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return O(t,e),C(t,[{key:"render",value:function(){return M.Children.only(this.props.children)}},{key:"getChildContext",value:function(){var e={},t=this.context.mobxStores;if(t)for(var n in t)e[n]=t[n];for(var r in this.props)le[r]||"suppressChangedStoreWarning"===r||(e[r]=this.props[r]);return{mobxStores:e}}},{key:"componentWillReceiveProps",value:function(e){if(Object.keys(e).length!==Object.keys(this.props).length&&console.warn("MobX Provider: The set of provided stores has changed. Please avoid changing stores as the change might not propagate to all children"),!e.suppressChangedStoreWarning)for(var t in e)le[t]||this.props[t]===e[t]||console.warn("MobX Provider: Provided store '"+t+"' has changed. Please avoid replacing stores as the change might not propagate to all children")}}]),t}(M.Component),ae.contextTypes={mobxStores:q},ae.childContextTypes={mobxStores:q.isRequired},se);if(!M.Component)throw new Error("mobx-react requires React to be available");if(!_.extras)throw new Error("mobx-react requires mobx to be available");"function"==typeof E.unstable_batchedUpdates&&_.extras.setReactionScheduler(E.unstable_batchedUpdates);var ce=function(e){return ne.on(e)};if("object"===("undefined"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__?"undefined":T(__MOBX_DEVTOOLS_GLOBAL_HOOK__))){var de={spy:_.spy,extras:_.extras},he={renderReporter:te,componentByNodeRegistery:ee,trackComponents:m};__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobxReact(he,de)}},function(e,t,n){"use strict";var r=n(7);e.exports={_set:function(e,t){return r.merge(this[e]||(this[e]={}),t)}}},function(e,t,n){var r=n(56)("wks"),i=n(40),o=n(13).Symbol,a="function"==typeof o;(e.exports=function(e){return r[e]||(r[e]=a&&o[e]||(a?o:i)("Symbol."+e))}).store=r},function(e,t,n){var r=n(13),i=n(6),o=n(28),a=n(23),s=function(e,t,n){var l,u,c,d=e&s.F,h=e&s.G,f=e&s.S,p=e&s.P,m=e&s.B,g=e&s.W,v=h?i:i[t]||(i[t]={}),y=v.prototype,b=h?r:f?r[t]:(r[t]||{}).prototype;h&&(n=t);for(l in n)(u=!d&&b&&void 0!==b[l])&&l in v||(c=u?b[l]:n[l],v[l]=h&&"function"!=typeof b[l]?n[l]:m&&u?o(c,r):g&&b[l]==c?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t.prototype=e.prototype,t}(c):p&&"function"==typeof c?o(Function.call,c):c,p&&((v.virtual||(v.virtual={}))[l]=c,e&s.R&&y&&!y[l]&&a(y,l,c)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,e.exports=s},function(e,t){var n=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},,function(e,t,n){"use strict";function r(){}function i(e,t){this.x=e||0,this.y=t||0}function o(e,t,n,r,a,s,l,u,c,d){Object.defineProperty(this,"id",{value:ps++}),this.uuid=fs.generateUUID(),this.name="",this.image=void 0!==e?e:o.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:o.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:la,this.wrapT=void 0!==r?r:la,this.magFilter=void 0!==a?a:fa,this.minFilter=void 0!==s?s:ma,this.anisotropy=void 0!==c?c:1,this.format=void 0!==l?l:Pa,this.type=void 0!==u?u:ga,this.offset=new i(0,0),this.repeat=new i(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==d?d:rs,this.version=0,this.onUpdate=null}function a(e,t,n,r){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==r?r:1}function s(e,t,n){this.uuid=fs.generateUUID(),this.width=e,this.height=t,this.scissor=new a(0,0,e,t),this.scissorTest=!1,this.viewport=new a(0,0,e,t),n=n||{},void 0===n.minFilter&&(n.minFilter=fa),this.texture=new o(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function l(e,t,n){s.call(this,e,t,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function u(e,t,n,r){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==r?r:1}function c(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}function d(){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.")}function h(e,t,n,r,i,a,s,l,u,c){e=void 0!==e?e:[],t=void 0!==t?t:ea,o.call(this,e,t,n,r,i,a,s,l,u,c),this.flipY=!1}function f(){this.seq=[],this.map={}}function p(e,t,n){var r=e[0];if(r<=0||r>0)return e;var i=t*n,o=vs[i];if(void 0===o&&(o=new Float32Array(i),vs[i]=o),0!==t){r.toArray(o,0);for(var a=1,s=0;a!==t;++a)s+=n,e[a].toArray(o,s)}return o}function m(e,t){var n=ys[t];void 0===n&&(n=new Int32Array(t),ys[t]=n);for(var r=0;r!==t;++r)n[r]=e.allocTextureUnit();return n}function g(e,t){e.uniform1f(this.addr,t)}function v(e,t){e.uniform1i(this.addr,t)}function y(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)}function b(e,t){void 0!==t.x?e.uniform3f(this.addr,t.x,t.y,t.z):void 0!==t.r?e.uniform3f(this.addr,t.r,t.g,t.b):e.uniform3fv(this.addr,t)}function x(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)}function w(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)}function _(e,t){e.uniformMatrix3fv(this.addr,!1,t.elements||t)}function M(e,t){e.uniformMatrix4fv(this.addr,!1,t.elements||t)}function S(e,t,n){var r=n.allocTextureUnit();e.uniform1i(this.addr,r),n.setTexture2D(t||ms,r)}function E(e,t,n){var r=n.allocTextureUnit();e.uniform1i(this.addr,r),n.setTextureCube(t||gs,r)}function T(e,t){e.uniform2iv(this.addr,t)}function k(e,t){e.uniform3iv(this.addr,t)}function C(e,t){e.uniform4iv(this.addr,t)}function O(e){switch(e){case 5126:return g;case 35664:return y;case 35665:return b;case 35666:return x;case 35674:return w;case 35675:return _;case 35676:return M;case 35678:return S;case 35680:return E;case 5124:case 35670:return v;case 35667:case 35671:return T;case 35668:case 35672:return k;case 35669:case 35673:return C}}function P(e,t){e.uniform1fv(this.addr,t)}function A(e,t){e.uniform1iv(this.addr,t)}function R(e,t){e.uniform2fv(this.addr,p(t,this.size,2))}function L(e,t){e.uniform3fv(this.addr,p(t,this.size,3))}function I(e,t){e.uniform4fv(this.addr,p(t,this.size,4))}function D(e,t){e.uniformMatrix2fv(this.addr,!1,p(t,this.size,4))}function z(e,t){e.uniformMatrix3fv(this.addr,!1,p(t,this.size,9))}function N(e,t){e.uniformMatrix4fv(this.addr,!1,p(t,this.size,16))}function B(e,t,n){var r=t.length,i=m(n,r);e.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTexture2D(t[o]||ms,i[o])}function F(e,t,n){var r=t.length,i=m(n,r);e.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTextureCube(t[o]||gs,i[o])}function U(e){switch(e){case 5126:return P;case 35664:return R;case 35665:return L;case 35666:return I;case 35674:return D;case 35675:return z;case 35676:return N;case 35678:return B;case 35680:return F;case 5124:case 35670:return A;case 35667:case 35671:return T;case 35668:case 35672:return k;case 35669:case 35673:return C}}function j(e,t,n){this.id=e,this.addr=n,this.setValue=O(t.type)}function W(e,t,n){this.id=e,this.addr=n,this.size=t.size,this.setValue=U(t.type)}function V(e){this.id=e,f.call(this)}function G(e,t){e.seq.push(t),e.map[t.id]=t}function H(e,t,n){var r=e.name,i=r.length;for(bs.lastIndex=0;;){var o=bs.exec(r),a=bs.lastIndex,s=o[1],l="]"===o[2],u=o[3];if(l&&(s|=0),void 0===u||"["===u&&a+2===i){G(n,void 0===u?new j(s,e,t):new W(s,e,t));break}var c=n.map,d=c[s];void 0===d&&(d=new V(s),G(n,d)),n=d}}function Y(e,t,n){f.call(this),this.renderer=n;for(var r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),i=0;i.001&&A.scale>.001&&(M.x=A.x,M.y=A.y,M.z=A.z,w=A.size*A.scale/g.w,_.x=w*y,_.y=w,p.uniform3f(d.screenPosition,M.x,M.y,M.z),p.uniform2f(d.scale,_.x,_.y),p.uniform1f(d.rotation,A.rotation),p.uniform1f(d.opacity,A.opacity),p.uniform3f(d.color,A.color.r,A.color.g,A.color.b),m.setBlending(A.blending,A.blendEquation,A.blendSrc,A.blendDst),e.setTexture2D(A.texture,1),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0))}}}m.enable(p.CULL_FACE),m.enable(p.DEPTH_TEST),m.setDepthWrite(!0),e.resetGLState()}}}function J(e,t){function n(){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=p.createBuffer(),s=p.createBuffer(),p.bindBuffer(p.ARRAY_BUFFER,a),p.bufferData(p.ARRAY_BUFFER,e,p.STATIC_DRAW),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,s),p.bufferData(p.ELEMENT_ARRAY_BUFFER,t,p.STATIC_DRAW),l=r(),d={position:p.getAttribLocation(l,"position"),uv:p.getAttribLocation(l,"uv")},h={uvOffset:p.getUniformLocation(l,"uvOffset"),uvScale:p.getUniformLocation(l,"uvScale"),rotation:p.getUniformLocation(l,"rotation"),scale:p.getUniformLocation(l,"scale"),color:p.getUniformLocation(l,"color"),map:p.getUniformLocation(l,"map"),opacity:p.getUniformLocation(l,"opacity"),modelViewMatrix:p.getUniformLocation(l,"modelViewMatrix"),projectionMatrix:p.getUniformLocation(l,"projectionMatrix"),fogType:p.getUniformLocation(l,"fogType"),fogDensity:p.getUniformLocation(l,"fogDensity"),fogNear:p.getUniformLocation(l,"fogNear"),fogFar:p.getUniformLocation(l,"fogFar"),fogColor:p.getUniformLocation(l,"fogColor"),alphaTest:p.getUniformLocation(l,"alphaTest")};var n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=8,n.height=8;var i=n.getContext("2d");i.fillStyle="white",i.fillRect(0,0,8,8),f=new o(n),f.needsUpdate=!0}function r(){var t=p.createProgram(),n=p.createShader(p.VERTEX_SHADER),r=p.createShader(p.FRAGMENT_SHADER);return p.shaderSource(n,["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")),p.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")),p.compileShader(n),p.compileShader(r),p.attachShader(t,n),p.attachShader(t,r),p.linkProgram(t),t}function i(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,l,d,h,f,p=e.context,m=e.state,g=new c,v=new u,y=new c;this.render=function(r,o){if(0!==t.length){void 0===l&&n(),p.useProgram(l),m.initAttributes(),m.enableAttribute(d.position),m.enableAttribute(d.uv),m.disableUnusedAttributes(),m.disable(p.CULL_FACE),m.enable(p.BLEND),p.bindBuffer(p.ARRAY_BUFFER,a),p.vertexAttribPointer(d.position,2,p.FLOAT,!1,16,0),p.vertexAttribPointer(d.uv,2,p.FLOAT,!1,16,8),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,s),p.uniformMatrix4fv(h.projectionMatrix,!1,o.projectionMatrix.elements),m.activeTexture(p.TEXTURE0),p.uniform1i(h.map,0);var u=0,c=0,b=r.fog;b?(p.uniform3f(h.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(p.uniform1f(h.fogNear,b.near),p.uniform1f(h.fogFar,b.far),p.uniform1i(h.fogType,1),u=1,c=1):b.isFogExp2&&(p.uniform1f(h.fogDensity,b.density),p.uniform1i(h.fogType,2),u=2,c=2)):(p.uniform1i(h.fogType,0),u=0,c=0);for(var x=0,w=t.length;x0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function ie(e,t){this.normal=void 0!==e?e:new c(1,0,0),this.constant=void 0!==t?t:0}function oe(e,t,n,r,i,o){this.planes=[void 0!==e?e:new ie,void 0!==t?t:new ie,void 0!==n?n:new ie,void 0!==r?r:new ie,void 0!==i?i:new ie,void 0!==o?o:new ie]}function ae(e,t,n,r){function o(t,n,r,i){var o=t.geometry,a=null,s=S,l=t.customDepthMaterial;if(r&&(s=E,l=t.customDistanceMaterial),l)a=l;else{var u=!1;n.morphTargets&&(o&&o.isBufferGeometry?u=o.morphAttributes&&o.morphAttributes.position&&o.morphAttributes.position.length>0:o&&o.isGeometry&&(u=o.morphTargets&&o.morphTargets.length>0));var c=t.isSkinnedMesh&&n.skinning,d=0;u&&(d|=w),c&&(d|=_),a=s[d]}if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var h=a.uuid,f=n.uuid,p=T[h];void 0===p&&(p={},T[h]=p);var m=p[f];void 0===m&&(m=a.clone(),p[f]=m),a=m}a.visible=n.visible,a.wireframe=n.wireframe;var g=n.side;return B.renderSingleSided&&g==lo&&(g=ao),B.renderReverseSided&&(g===ao?g=so:g===so&&(g=ao)),a.side=g,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(i),a}function l(e,t,n){if(!1!==e.visible){if(0!=(e.layers.mask&t.layers.mask)&&(e.isMesh||e.isLine||e.isPoints)&&e.castShadow&&(!1===e.frustumCulled||!0===f.intersectsObject(e))){!0===e.material.visible&&(e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),x.push(e))}for(var r=e.children,i=0,o=r.length;in&&(n=e[t]);return n}function ke(){return ks++}function Ce(){Object.defineProperty(this,"id",{value:ke()}),this.uuid=fs.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Oe(){Object.defineProperty(this,"id",{value:ke()}),this.uuid=fs.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function Pe(e,t){ce.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new Oe,this.material=void 0!==t?t:new pe({color:16777215*Math.random()}),this.drawMode=es,this.updateMorphTargets()}function Ae(e,t,n,r,i,o){Ce.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:o},this.fromBufferGeometry(new Re(e,t,n,r,i,o)),this.mergeVertices()}function Re(e,t,n,r,i,o){function a(e,t,n,r,i,o,a,m,g,v,y){var b,x,w=o/g,_=a/v,M=o/2,S=a/2,E=m/2,T=g+1,k=v+1,C=0,O=0,P=new c;for(x=0;x0?1:-1,d.push(P.x,P.y,P.z),h.push(b/g),h.push(1-x/v),C+=1}}for(x=0;x");return Qe(n)}var n=/#include +<([\w\d.]+)>/g;return e.replace(n,t)}function $e(e){function t(e,t,n,r){for(var i="",o=parseInt(t);o0?e.gammaFactor:1,g=qe(o,r,e.extensions),v=Xe(a),y=i.createProgram();n.isRawShaderMaterial?(f=[v,"\n"].filter(Ke).join("\n"),p=[g,v,"\n"].filter(Ke).join("\n")):(f=["precision "+r.precision+" float;","precision "+r.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,v,r.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+r.maxBones,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+d:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.displacementMap&&r.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.vertexColors?"#define USE_COLOR":"",r.flatShading?"#define FLAT_SHADED":"",r.skinning?"#define USE_SKINNING":"",r.useVertexTexture?"#define BONE_TEXTURE":"",r.morphTargets?"#define USE_MORPHTARGETS":"",r.morphNormals&&!1===r.flatShading?"#define USE_MORPHNORMALS":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+r.numClippingPlanes,r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+u:"",r.sizeAttenuation?"#define USE_SIZEATTENUATION":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.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","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ke).join("\n"),p=[g,"precision "+r.precision+" float;","precision "+r.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,v,r.alphaTest?"#define ALPHATEST "+r.alphaTest:"","#define GAMMA_FACTOR "+m,r.useFog&&r.fog?"#define USE_FOG":"",r.useFog&&r.fogExp?"#define FOG_EXP2":"",r.map?"#define USE_MAP":"",r.envMap?"#define USE_ENVMAP":"",r.envMap?"#define "+c:"",r.envMap?"#define "+d:"",r.envMap?"#define "+h:"",r.lightMap?"#define USE_LIGHTMAP":"",r.aoMap?"#define USE_AOMAP":"",r.emissiveMap?"#define USE_EMISSIVEMAP":"",r.bumpMap?"#define USE_BUMPMAP":"",r.normalMap?"#define USE_NORMALMAP":"",r.specularMap?"#define USE_SPECULARMAP":"",r.roughnessMap?"#define USE_ROUGHNESSMAP":"",r.metalnessMap?"#define USE_METALNESSMAP":"",r.alphaMap?"#define USE_ALPHAMAP":"",r.vertexColors?"#define USE_COLOR":"",r.gradientMap?"#define USE_GRADIENTMAP":"",r.flatShading?"#define FLAT_SHADED":"",r.doubleSided?"#define DOUBLE_SIDED":"",r.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+r.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(r.numClippingPlanes-r.numClipIntersection),r.shadowMapEnabled?"#define USE_SHADOWMAP":"",r.shadowMapEnabled?"#define "+u:"",r.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",r.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",r.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",r.logarithmicDepthBuffer&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",r.envMap&&e.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",r.toneMapping!==Xo?"#define TONE_MAPPING":"",r.toneMapping!==Xo?ws.tonemapping_pars_fragment:"",r.toneMapping!==Xo?Ye("toneMapping",r.toneMapping):"",r.outputEncoding||r.mapEncoding||r.envMapEncoding||r.emissiveMapEncoding?ws.encodings_pars_fragment:"",r.mapEncoding?Ge("mapTexelToLinear",r.mapEncoding):"",r.envMapEncoding?Ge("envMapTexelToLinear",r.envMapEncoding):"",r.emissiveMapEncoding?Ge("emissiveMapTexelToLinear",r.emissiveMapEncoding):"",r.outputEncoding?He("linearToOutputTexel",r.outputEncoding):"",r.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Ke).join("\n")),s=Qe(s,r),s=Je(s,r),l=Qe(l,r),l=Je(l,r),n.isShaderMaterial||(s=$e(s),l=$e(l));var b=f+s,x=p+l,w=We(i,i.VERTEX_SHADER,b),_=We(i,i.FRAGMENT_SHADER,x);i.attachShader(y,w),i.attachShader(y,_),void 0!==n.index0AttributeName?i.bindAttribLocation(y,0,n.index0AttributeName):!0===r.morphTargets&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);var M=i.getProgramInfoLog(y),S=i.getShaderInfoLog(w),E=i.getShaderInfoLog(_),T=!0,k=!0;!1===i.getProgramParameter(y,i.LINK_STATUS)?(T=!1,console.error("THREE.WebGLProgram: shader error: ",i.getError(),"gl.VALIDATE_STATUS",i.getProgramParameter(y,i.VALIDATE_STATUS),"gl.getProgramInfoLog",M,S,E)):""!==M?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",M):""!==S&&""!==E||(k=!1),k&&(this.diagnostics={runnable:T,material:n,programLog:M,vertexShader:{log:S,prefix:f},fragmentShader:{log:E,prefix:p}}),i.deleteShader(w),i.deleteShader(_);var C;this.getUniforms=function(){return void 0===C&&(C=new Y(i,y,e)),C};var O;return this.getAttributes=function(){return void 0===O&&(O=Ze(i,y)),O},this.destroy=function(){i.deleteProgram(y),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=Cs++,this.code=t,this.usedTimes=1,this.program=y,this.vertexShader=w,this.fragmentShader=_,this}function tt(e,t){function n(e){if(t.floatVertexTextures&&e&&e.skeleton&&e.skeleton.useVertexTexture)return 1024;var n=t.maxVertexUniforms,r=Math.floor((n-20)/4),i=r;return void 0!==e&&e&&e.isSkinnedMesh&&(i=Math.min(e.skeleton.bones.length,i))0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:i.premultipliedAlpha,alphaTest:i.alphaTest,doubleSided:i.side===lo,flipSided:i.side===so,depthPacking:void 0!==i.depthPacking&&i.depthPacking}},this.getProgramCode=function(e,t){var n=[];if(t.shaderID?n.push(t.shaderID):(n.push(e.fragmentShader),n.push(e.vertexShader)),void 0!==e.defines)for(var r in e.defines)n.push(r),n.push(e.defines[r]);for(var i=0;i65535?_e:xe)(o,1);return i(p,e.ELEMENT_ARRAY_BUFFER),r.wireframe=p,p}var c=new nt(e,t,n);return{getAttributeBuffer:s,getAttributeProperties:l,getWireframeAttribute:u,update:r}}function it(e,t,n,r,i,o,a){function s(e,t){if(e.width>t||e.height>t){var n=t/Math.max(e.width,e.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=Math.floor(e.width*n),r.height=Math.floor(e.height*n);return r.getContext("2d").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 l(e){return fs.isPowerOfTwo(e.width)&&fs.isPowerOfTwo(e.height)}function u(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");t.width=fs.nearestPowerOfTwo(e.width),t.height=fs.nearestPowerOfTwo(e.height);return t.getContext("2d").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 c(e){return e.wrapS!==la||e.wrapT!==la||e.minFilter!==ca&&e.minFilter!==fa}function d(t){return t===ca||t===da||t===ha?e.NEAREST:e.LINEAR}function h(e){var t=e.target;t.removeEventListener("dispose",h),p(t),k.textures--}function f(e){var t=e.target;t.removeEventListener("dispose",f),m(t),k.textures--}function p(t){var n=r.get(t);if(t.image&&n.__image__webglTextureCube)e.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture)}r.delete(t)}function m(t){var n=r.get(t),i=r.get(t.texture);if(t){if(void 0!==i.__webglTexture&&e.deleteTexture(i.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(var o=0;o<6;o++)e.deleteFramebuffer(n.__webglFramebuffer[o]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[o]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer);r.delete(t.texture),r.delete(t)}}function g(t,i){var o=r.get(t);if(t.version>0&&o.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==a.complete)return void x(o,t,i);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",t)}}n.activeTexture(e.TEXTURE0+i),n.bindTexture(e.TEXTURE_2D,o.__webglTexture)}function v(t,a){var u=r.get(t);if(6===t.image.length)if(t.version>0&&u.__version!==t.version){u.__image__webglTextureCube||(t.addEventListener("dispose",h),u.__image__webglTextureCube=e.createTexture(),k.textures++),n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var c=t&&t.isCompressedTexture,d=t.image[0]&&t.image[0].isDataTexture,f=[],p=0;p<6;p++)f[p]=c||d?d?t.image[p].image:t.image[p]:s(t.image[p],i.maxCubemapSize);var m=f[0],g=l(m),v=o(t.format),y=o(t.type);b(e.TEXTURE_CUBE_MAP,t,g);for(var p=0;p<6;p++)if(c)for(var x,w=f[p].mipmaps,_=0,M=w.length;_-1?n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+p,_,v,x.width,x.height,0,x.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+p,_,v,x.width,x.height,0,v,y,x.data);else d?n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,v,f[p].width,f[p].height,0,v,y,f[p].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,v,v,y,f[p]);t.generateMipmaps&&g&&e.generateMipmap(e.TEXTURE_CUBE_MAP),u.__version=t.version,t.onUpdate&&t.onUpdate(t)}else n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)}function y(t,i){n.activeTexture(e.TEXTURE0+i),n.bindTexture(e.TEXTURE_CUBE_MAP,r.get(t).__webglTexture)}function b(n,a,s){var l;if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,o(a.wrapS)),e.texParameteri(n,e.TEXTURE_WRAP_T,o(a.wrapT)),e.texParameteri(n,e.TEXTURE_MAG_FILTER,o(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,o(a.minFilter))):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),a.wrapS===la&&a.wrapT===la||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),e.texParameteri(n,e.TEXTURE_MAG_FILTER,d(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,d(a.minFilter)),a.minFilter!==ca&&a.minFilter!==fa&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),l=t.get("EXT_texture_filter_anisotropic")){if(a.type===_a&&null===t.get("OES_texture_float_linear"))return;if(a.type===Ma&&null===t.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function x(t,r,a){void 0===t.__webglInit&&(t.__webglInit=!0,r.addEventListener("dispose",h),t.__webglTexture=e.createTexture(),k.textures++),n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment);var d=s(r.image,i.maxTextureSize);c(r)&&!1===l(d)&&(d=u(d));var f=l(d),p=o(r.format),m=o(r.type);b(e.TEXTURE_2D,r,f);var g,v=r.mipmaps;if(r.isDepthTexture){var y=e.DEPTH_COMPONENT;if(r.type===_a){if(!C)throw new Error("Float Depth Texture only supported in WebGL2.0");y=e.DEPTH_COMPONENT32F}else C&&(y=e.DEPTH_COMPONENT16);r.format===Ia&&y===e.DEPTH_COMPONENT&&r.type!==ba&&r.type!==wa&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=ba,m=o(r.type)),r.format===Da&&(y=e.DEPTH_STENCIL,r.type!==ka&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=ka,m=o(r.type))),n.texImage2D(e.TEXTURE_2D,0,y,d.width,d.height,0,p,m,null)}else if(r.isDataTexture)if(v.length>0&&f){for(var x=0,w=v.length;x-1?n.compressedTexImage2D(e.TEXTURE_2D,x,p,g.width,g.height,0,g.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(e.TEXTURE_2D,x,p,g.width,g.height,0,p,m,g.data);else if(v.length>0&&f){for(var x=0,w=v.length;x=1,ce=null,de={},he=new a,fe=new a,pe={};return pe[e.TEXTURE_2D]=s(e.TEXTURE_2D,e.TEXTURE_2D,1),pe[e.TEXTURE_CUBE_MAP]=s(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),{buffers:{color:B,depth:F,stencil:U},init:l,initAttributes:u,enableAttribute:c,enableAttributeAndDivisor:d,disableUnusedAttributes:h,enable:f,disable:p,getCompressedTextureFormats:m,setBlending:g,setColorWrite:v,setDepthTest:y,setDepthWrite:b,setDepthFunc:x,setStencilTest:w,setStencilWrite:_,setStencilFunc:M,setStencilOp:S,setFlipSided:E,setCullFace:T,setLineWidth:k,setPolygonOffset:C,getScissorTest:O,setScissorTest:P,activeTexture:A,bindTexture:R,compressedTexImage2D:L,texImage2D:I,scissor:D,viewport:z,reset:N}}function st(e,t,n){function r(){if(void 0!==o)return o;var n=t.get("EXT_texture_filter_anisotropic");return o=null!==n?e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}function i(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o,a=void 0!==n.precision?n.precision:"highp",s=i(a);s!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);var l=!0===n.logarithmicDepthBuffer&&!!t.get("EXT_frag_depth"),u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),c=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),h=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),p=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),m=e.getParameter(e.MAX_VARYING_VECTORS),g=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),v=c>0,y=!!t.get("OES_texture_float");return{getMaxAnisotropy:r,getMaxPrecision:i,precision:a,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:c,maxTextureSize:d,maxCubemapSize:h,maxAttributes:f,maxVertexUniforms:p,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y}}function lt(e){var t={};return{get:function(n){if(void 0!==t[n])return t[n];var r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;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(n)}return null===r&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),t[n]=r,r}}}function ut(){function e(){u.value!==r&&(u.value=r,u.needsUpdate=i>0),n.numPlanes=i,n.numIntersection=0}function t(e,t,r,i){var o=null!==e?e.length:0,a=null;if(0!==o){if(a=u.value,!0!==i||null===a){var c=r+4*o,d=t.matrixWorldInverse;l.getNormalMatrix(d),(null===a||a.length=0){var c=o[l];if(void 0!==c){var d=c.normalized,h=c.itemSize,f=dt.getAttributeProperties(c),p=f.__webglBuffer,m=f.type,g=f.bytesPerElement;if(c.isInterleavedBufferAttribute){var v=c.data,y=v.stride,b=c.offset;v&&v.isInstancedInterleavedBuffer?(et.enableAttributeAndDivisor(u,v.meshPerAttribute,i),void 0===n.maxInstancedCount&&(n.maxInstancedCount=v.meshPerAttribute*v.count)):et.enableAttribute(u),Ke.bindBuffer(Ke.ARRAY_BUFFER,p),Ke.vertexAttribPointer(u,h,m,d,y*g,(r*y+b)*g)}else c.isInstancedBufferAttribute?(et.enableAttributeAndDivisor(u,c.meshPerAttribute,i),void 0===n.maxInstancedCount&&(n.maxInstancedCount=c.meshPerAttribute*c.count)):et.enableAttribute(u),Ke.bindBuffer(Ke.ARRAY_BUFFER,p),Ke.vertexAttribPointer(u,h,m,d,0,r*h*g)}else if(void 0!==s){var x=s[l];if(void 0!==x)switch(x.length){case 2:Ke.vertexAttrib2fv(u,x);break;case 3:Ke.vertexAttrib3fv(u,x);break;case 4:Ke.vertexAttrib4fv(u,x);break;default:Ke.vertexAttrib1fv(u,x)}}}}et.disableUnusedAttributes()}function h(e,t){return Math.abs(t[0])-Math.abs(e[0])}function f(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.material.program&&t.material.program&&e.material.program!==t.material.program?e.material.program.id-t.material.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function p(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 m(e,t,n,r,i){var o,a;n.transparent?(o=re,a=++ie):(o=ee,a=++te);var s=o[a];void 0!==s?(s.id=e.id,s.object=e,s.geometry=t,s.material=n,s.z=He.z,s.group=i):(s={id:e.id,object:e,geometry:t,material:n,z:He.z,group:i},o.push(s))}function g(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Ve.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),y(Ve)}function v(e){return Ve.center.set(0,0,0),Ve.radius=.7071067811865476,Ve.applyMatrix4(e.matrixWorld),y(Ve)}function y(e){if(!Le.intersectsSphere(e))return!1;var t=De.numPlanes;if(0===t)return!0;var n=ce.clippingPlanes,r=e.center,i=-e.radius,o=0;do{if(n[o].distanceToPoint(r)=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var h=0;h=0&&e.numSupportedMorphNormals++}var f=r.__webglShader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(r.numClippingPlanes=De.numPlanes,r.numIntersection=De.numIntersection,f.clippingPlanes=De.uniform),r.fog=t,r.lightsHash=Xe.hash,e.lights&&(f.ambientLightColor.value=Xe.ambient,f.directionalLights.value=Xe.directional,f.spotLights.value=Xe.spot,f.rectAreaLights.value=Xe.rectArea,f.pointLights.value=Xe.point,f.hemisphereLights.value=Xe.hemi,f.directionalShadowMap.value=Xe.directionalShadowMap,f.directionalShadowMatrix.value=Xe.directionalShadowMatrix,f.spotShadowMap.value=Xe.spotShadowMap,f.spotShadowMatrix.value=Xe.spotShadowMatrix,f.pointShadowMap.value=Xe.pointShadowMap,f.pointShadowMatrix.value=Xe.pointShadowMatrix);var p=r.program.getUniforms(),m=Y.seqWithValue(p.seq,f);r.uniformsList=m}function _(e){e.side===lo?et.disable(Ke.CULL_FACE):et.enable(Ke.CULL_FACE),et.setFlipSided(e.side===so),!0===e.transparent?et.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):et.setBlending(mo),et.setDepthFunc(e.depthFunc),et.setDepthTest(e.depthTest),et.setDepthWrite(e.depthWrite),et.setColorWrite(e.colorWrite),et.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function M(e,t,n,r){we=0;var i=nt.get(n);if(je&&(We||e!==ve)){var o=e===ve&&n.id===me;De.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,i,o)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==t?n.needsUpdate=!0:n.lights&&i.lightsHash!==Xe.hash?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===De.numPlanes&&i.numIntersection===De.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(w(n,t,r),n.needsUpdate=!1);var a=!1,s=!1,l=!1,u=i.program,c=u.getUniforms(),d=i.__webglShader.uniforms;if(u.id!==de&&(Ke.useProgram(u.program),de=u.id,a=!0,s=!0,l=!0),n.id!==me&&(me=n.id,s=!0),a||e!==ve){if(c.set(Ke,e,"projectionMatrix"),$e.logarithmicDepthBuffer&&c.setValue(Ke,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),e!==ve&&(ve=e,s=!0,l=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var h=c.map.cameraPosition;void 0!==h&&h.setValue(Ke,He.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&c.setValue(Ke,"viewMatrix",e.matrixWorldInverse),c.set(Ke,ce,"toneMappingExposure"),c.set(Ke,ce,"toneMappingWhitePoint")}if(n.skinning){c.setOptional(Ke,r,"bindMatrix"),c.setOptional(Ke,r,"bindMatrixInverse");var f=r.skeleton;f&&($e.floatVertexTextures&&f.useVertexTexture?(c.set(Ke,f,"boneTexture"),c.set(Ke,f,"boneTextureWidth"),c.set(Ke,f,"boneTextureHeight")):c.setOptional(Ke,f,"boneMatrices"))}return s&&(n.lights&&D(d,l),t&&n.fog&&C(d,t),(n.isMeshBasicMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.isMeshNormalMaterial||n.isMeshDepthMaterial)&&S(d,n),n.isLineBasicMaterial?E(d,n):n.isLineDashedMaterial?(E(d,n),T(d,n)):n.isPointsMaterial?k(d,n):n.isMeshLambertMaterial?O(d,n):n.isMeshToonMaterial?A(d,n):n.isMeshPhongMaterial?P(d,n):n.isMeshPhysicalMaterial?L(d,n):n.isMeshStandardMaterial?R(d,n):n.isMeshDepthMaterial?n.displacementMap&&(d.displacementMap.value=n.displacementMap,d.displacementScale.value=n.displacementScale,d.displacementBias.value=n.displacementBias):n.isMeshNormalMaterial&&I(d,n),void 0!==d.ltcMat&&(d.ltcMat.value=THREE.UniformsLib.LTC_MAT_TEXTURE),void 0!==d.ltcMag&&(d.ltcMag.value=THREE.UniformsLib.LTC_MAG_TEXTURE),Y.upload(Ke,i.uniformsList,d,ce)),c.set(Ke,r,"modelViewMatrix"),c.set(Ke,r,"normalMatrix"),c.setValue(Ke,"modelMatrix",r.matrixWorld),u}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.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var n;if(t.map?n=t.map:t.specularMap?n=t.specularMap:t.displacementMap?n=t.displacementMap:t.normalMap?n=t.normalMap:t.bumpMap?n=t.bumpMap:t.roughnessMap?n=t.roughnessMap:t.metalnessMap?n=t.metalnessMap:t.alphaMap?n=t.alphaMap:t.emissiveMap&&(n=t.emissiveMap),void 0!==n){n.isWebGLRenderTarget&&(n=n.texture);var r=n.offset,i=n.repeat;e.offsetRepeat.value.set(r.x,r.y,i.x,i.y)}e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio}function E(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function T(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function k(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*Te,e.scale.value=.5*Ee,e.map.value=t.map,null!==t.map){var n=t.map.offset,r=t.map.repeat;e.offsetRepeat.value.set(n.x,n.y,r.x,r.y)}}function C(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}function O(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function P(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.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 A(e,t){P(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function R(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.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 L(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,R(e,t)}function I(e,t){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 D(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function z(e){for(var t=0,n=0,r=e.length;n=$e.maxTextures&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+$e.maxTextures),we+=1,e}function F(e){var t;if(e===sa)return Ke.REPEAT;if(e===la)return Ke.CLAMP_TO_EDGE;if(e===ua)return Ke.MIRRORED_REPEAT;if(e===ca)return Ke.NEAREST;if(e===da)return Ke.NEAREST_MIPMAP_NEAREST;if(e===ha)return Ke.NEAREST_MIPMAP_LINEAR;if(e===fa)return Ke.LINEAR;if(e===pa)return Ke.LINEAR_MIPMAP_NEAREST;if(e===ma)return Ke.LINEAR_MIPMAP_LINEAR;if(e===ga)return Ke.UNSIGNED_BYTE;if(e===Sa)return Ke.UNSIGNED_SHORT_4_4_4_4;if(e===Ea)return Ke.UNSIGNED_SHORT_5_5_5_1;if(e===Ta)return Ke.UNSIGNED_SHORT_5_6_5;if(e===va)return Ke.BYTE;if(e===ya)return Ke.SHORT;if(e===ba)return Ke.UNSIGNED_SHORT;if(e===xa)return Ke.INT;if(e===wa)return Ke.UNSIGNED_INT;if(e===_a)return Ke.FLOAT;if(e===Ma&&null!==(t=Qe.get("OES_texture_half_float")))return t.HALF_FLOAT_OES;if(e===Ca)return Ke.ALPHA;if(e===Oa)return Ke.RGB;if(e===Pa)return Ke.RGBA;if(e===Aa)return Ke.LUMINANCE;if(e===Ra)return Ke.LUMINANCE_ALPHA;if(e===Ia)return Ke.DEPTH_COMPONENT;if(e===Da)return Ke.DEPTH_STENCIL;if(e===wo)return Ke.FUNC_ADD;if(e===_o)return Ke.FUNC_SUBTRACT;if(e===Mo)return Ke.FUNC_REVERSE_SUBTRACT;if(e===To)return Ke.ZERO;if(e===ko)return Ke.ONE;if(e===Co)return Ke.SRC_COLOR;if(e===Oo)return Ke.ONE_MINUS_SRC_COLOR;if(e===Po)return Ke.SRC_ALPHA;if(e===Ao)return Ke.ONE_MINUS_SRC_ALPHA;if(e===Ro)return Ke.DST_ALPHA;if(e===Lo)return Ke.ONE_MINUS_DST_ALPHA;if(e===Io)return Ke.DST_COLOR;if(e===Do)return Ke.ONE_MINUS_DST_COLOR;if(e===zo)return Ke.SRC_ALPHA_SATURATE;if((e===za||e===Na||e===Ba||e===Fa)&&null!==(t=Qe.get("WEBGL_compressed_texture_s3tc"))){if(e===za)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Na)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===Ba)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Fa)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((e===Ua||e===ja||e===Wa||e===Va)&&null!==(t=Qe.get("WEBGL_compressed_texture_pvrtc"))){if(e===Ua)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===ja)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===Wa)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===Va)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===Ga&&null!==(t=Qe.get("WEBGL_compressed_texture_etc1")))return t.COMPRESSED_RGB_ETC1_WEBGL;if((e===So||e===Eo)&&null!==(t=Qe.get("EXT_blend_minmax"))){if(e===So)return t.MIN_EXT;if(e===Eo)return t.MAX_EXT}return e===ka&&null!==(t=Qe.get("WEBGL_depth_texture"))?t.UNSIGNED_INT_24_8_WEBGL:0}console.log("THREE.WebGLRenderer",Zi),e=e||{};var U=void 0!==e.canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),j=void 0!==e.context?e.context:null,W=void 0!==e.alpha&&e.alpha,V=void 0===e.depth||e.depth,G=void 0===e.stencil||e.stencil,H=void 0!==e.antialias&&e.antialias,X=void 0===e.premultipliedAlpha||e.premultipliedAlpha,Z=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,Q=[],ee=[],te=-1,re=[],ie=-1,se=new Float32Array(8),le=[],ue=[];this.domElement=U,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=Zo,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var ce=this,de=null,he=null,fe=null,me=-1,ge="",ve=null,ye=new a,be=null,xe=new a,we=0,_e=new q(0),Me=0,Se=U.width,Ee=U.height,Te=1,ke=new a(0,0,Se,Ee),Ce=!1,Ae=new a(0,0,Se,Ee),Le=new oe,De=new ut,je=!1,We=!1,Ve=new ne,Ge=new d,He=new c,Ye=new d,qe=new d,Xe={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},Ze={calls:0,vertices:0,faces:0,points:0};this.info={render:Ze,memory:{geometries:0,textures:0},programs:null};var Ke;try{var Je={alpha:W,depth:V,stencil:G,antialias:H,premultipliedAlpha:X,preserveDrawingBuffer:Z};if(null===(Ke=j||U.getContext("webgl",Je)||U.getContext("experimental-webgl",Je)))throw null!==U.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===Ke.getShaderPrecisionFormat&&(Ke.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),U.addEventListener("webglcontextlost",i,!1)}catch(e){console.error("THREE.WebGLRenderer: "+e)}var Qe=new lt(Ke);Qe.get("WEBGL_depth_texture"),Qe.get("OES_texture_float"),Qe.get("OES_texture_float_linear"),Qe.get("OES_texture_half_float"),Qe.get("OES_texture_half_float_linear"),Qe.get("OES_standard_derivatives"),Qe.get("ANGLE_instanced_arrays"),Qe.get("OES_element_index_uint")&&(Oe.MaxIndex=4294967296);var $e=new st(Ke,Qe,e),et=new at(Ke,Qe,F),nt=new ot,ct=new it(Ke,Qe,et,nt,$e,F,this.info),dt=new rt(Ke,nt,this.info),ht=new tt(this,$e),ft=new Ue;this.info.programs=ht.programs;var pt,mt,gt,vt,yt=new Fe(Ke,Qe,Ze),bt=new Be(Ke,Qe,Ze);n(),this.context=Ke,this.capabilities=$e,this.extensions=Qe,this.properties=nt,this.state=et;var xt=new ae(this,Xe,dt,$e);this.shadowMap=xt;var wt=new J(this,le),_t=new K(this,ue);this.getContext=function(){return Ke},this.getContextAttributes=function(){return Ke.getContextAttributes()},this.forceContextLoss=function(){Qe.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){return $e.getMaxAnisotropy()},this.getPrecision=function(){return $e.precision},this.getPixelRatio=function(){return Te},this.setPixelRatio=function(e){void 0!==e&&(Te=e,this.setSize(Ae.z,Ae.w,!1))},this.getSize=function(){return{width:Se,height:Ee}},this.setSize=function(e,t,n){Se=e,Ee=t,U.width=e*Te,U.height=t*Te,!1!==n&&(U.style.width=e+"px",U.style.height=t+"px"),this.setViewport(0,0,e,t)},this.setViewport=function(e,t,n,r){et.viewport(Ae.set(e,t,n,r))},this.setScissor=function(e,t,n,r){et.scissor(ke.set(e,t,n,r))},this.setScissorTest=function(e){et.setScissorTest(Ce=e)},this.getClearColor=function(){return _e},this.setClearColor=function(e,t){_e.set(e),Me=void 0!==t?t:1,et.buffers.color.setClear(_e.r,_e.g,_e.b,Me,X)},this.getClearAlpha=function(){return Me},this.setClearAlpha=function(e){Me=e,et.buffers.color.setClear(_e.r,_e.g,_e.b,Me,X)},this.clear=function(e,t,n){var r=0;(void 0===e||e)&&(r|=Ke.COLOR_BUFFER_BIT),(void 0===t||t)&&(r|=Ke.DEPTH_BUFFER_BIT),(void 0===n||n)&&(r|=Ke.STENCIL_BUFFER_BIT),Ke.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,n,r){this.setRenderTarget(e),this.clear(t,n,r)},this.resetGLState=r,this.dispose=function(){re=[],ie=-1,ee=[],te=-1,U.removeEventListener("webglcontextlost",i,!1)},this.renderBufferImmediate=function(e,t,n){et.initAttributes();var r=nt.get(e);e.hasPositions&&!r.position&&(r.position=Ke.createBuffer()),e.hasNormals&&!r.normal&&(r.normal=Ke.createBuffer()),e.hasUvs&&!r.uv&&(r.uv=Ke.createBuffer()),e.hasColors&&!r.color&&(r.color=Ke.createBuffer());var i=t.getAttributes();if(e.hasPositions&&(Ke.bindBuffer(Ke.ARRAY_BUFFER,r.position),Ke.bufferData(Ke.ARRAY_BUFFER,e.positionArray,Ke.DYNAMIC_DRAW),et.enableAttribute(i.position),Ke.vertexAttribPointer(i.position,3,Ke.FLOAT,!1,0,0)),e.hasNormals){if(Ke.bindBuffer(Ke.ARRAY_BUFFER,r.normal),!n.isMeshPhongMaterial&&!n.isMeshStandardMaterial&&!n.isMeshNormalMaterial&&n.shading===uo)for(var o=0,a=3*e.count;o8&&(f.length=8);for(var v=r.morphAttributes,p=0,m=f.length;p0&&S.renderInstances(r,P,R):S.render(P,R)}},this.render=function(e,t,n,r){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");ge="",me=-1,ve=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),Ge.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),Le.setFromMatrix(Ge),Q.length=0,te=-1,ie=-1,le.length=0,ue.length=0,We=this.localClippingEnabled,je=De.init(this.clippingPlanes,We,t),b(e,t),ee.length=te+1,re.length=ie+1,!0===ce.sortObjects&&(ee.sort(f),re.sort(p)),je&&De.beginShadows(),z(Q),xt.render(e,t),N(Q,t),je&&De.endShadows(),Ze.calls=0,Ze.vertices=0,Ze.faces=0,Ze.points=0,void 0===n&&(n=null),this.setRenderTarget(n);var i=e.background;if(null===i?et.buffers.color.setClear(_e.r,_e.g,_e.b,Me,X):i&&i.isColor&&(et.buffers.color.setClear(i.r,i.g,i.b,1,X),r=!0),(this.autoClear||r)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),i&&i.isCubeTexture?(void 0===gt&&(gt=new ze,vt=new Pe(new Re(5,5,5),new $({uniforms:Ss.cube.uniforms,vertexShader:Ss.cube.vertexShader,fragmentShader:Ss.cube.fragmentShader,side:so,depthTest:!1,depthWrite:!1,fog:!1}))),gt.projectionMatrix.copy(t.projectionMatrix),gt.matrixWorld.extractRotation(t.matrixWorld),gt.matrixWorldInverse.getInverse(gt.matrixWorld),vt.material.uniforms.tCube.value=i,vt.modelViewMatrix.multiplyMatrices(gt.matrixWorldInverse,vt.matrixWorld),dt.update(vt),ce.renderBufferDirect(gt,null,vt.geometry,vt.material,vt,null)):i&&i.isTexture&&(void 0===pt&&(pt=new Ne(-1,1,1,-1,0,1),mt=new Pe(new Ie(2,2),new pe({depthTest:!1,depthWrite:!1,fog:!1}))),mt.material.map=i,dt.update(mt),ce.renderBufferDirect(pt,null,mt.geometry,mt.material,mt,null)),e.overrideMaterial){var o=e.overrideMaterial;x(ee,e,t,o),x(re,e,t,o)}else et.setBlending(mo),x(ee,e,t),x(re,e,t);wt.render(e,t),_t.render(e,t,xe),n&&ct.updateRenderTargetMipmap(n),et.setDepthTest(!0),et.setDepthWrite(!0),et.setColorWrite(!0)},this.setFaceCulling=function(e,t){et.setCullFace(e),et.setFlipSided(t===to)},this.allocTextureUnit=B,this.setTexture2D=function(){var e=!1;return function(t,n){t&&t.isWebGLRenderTarget&&(e||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),ct.setTexture2D(t,n)}}(),this.setTexture=function(){var e=!1;return function(t,n){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),ct.setTexture2D(t,n)}}(),this.setTextureCube=function(){var e=!1;return function(t,n){t&&t.isWebGLRenderTargetCube&&(e||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?ct.setTextureCube(t,n):ct.setTextureCubeDynamic(t,n)}}(),this.getCurrentRenderTarget=function(){return he},this.setRenderTarget=function(e){he=e,e&&void 0===nt.get(e).__webglFramebuffer&&ct.setupRenderTarget(e);var t,n=e&&e.isWebGLRenderTargetCube;if(e){var r=nt.get(e);t=n?r.__webglFramebuffer[e.activeCubeFace]:r.__webglFramebuffer,ye.copy(e.scissor),be=e.scissorTest,xe.copy(e.viewport)}else t=null,ye.copy(ke).multiplyScalar(Te),be=Ce,xe.copy(Ae).multiplyScalar(Te);if(fe!==t&&(Ke.bindFramebuffer(Ke.FRAMEBUFFER,t),fe=t),et.scissor(ye),et.setScissorTest(be),et.viewport(xe),n){var i=nt.get(e.texture);Ke.framebufferTexture2D(Ke.FRAMEBUFFER,Ke.COLOR_ATTACHMENT0,Ke.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,i.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,n,r,i,o){if(!1===(e&&e.isWebGLRenderTarget))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");var a=nt.get(e).__webglFramebuffer;if(a){var s=!1;a!==fe&&(Ke.bindFramebuffer(Ke.FRAMEBUFFER,a),s=!0);try{var l=e.texture,u=l.format,c=l.type;if(u!==Pa&&F(u)!==Ke.getParameter(Ke.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(c===ga||F(c)===Ke.getParameter(Ke.IMPLEMENTATION_COLOR_READ_TYPE)||c===_a&&(Qe.get("OES_texture_float")||Qe.get("WEBGL_color_buffer_float"))||c===Ma&&Qe.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");Ke.checkFramebufferStatus(Ke.FRAMEBUFFER)===Ke.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&Ke.readPixels(t,n,r,i,F(u),F(c),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&Ke.bindFramebuffer(Ke.FRAMEBUFFER,fe)}}}}function dt(e,t){this.name="",this.color=new q(e),this.density=void 0!==t?t:25e-5}function ht(e,t,n){this.name="",this.color=new q(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function ft(){ce.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function pt(e,t,n,r,i){ce.call(this),this.lensFlares=[],this.positionScreen=new c,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,n,r,i)}function mt(e){Q.call(this),this.type="SpriteMaterial",this.color=new q(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function gt(e){ce.call(this),this.type="Sprite",this.material=void 0!==e?e:new mt}function vt(){ce.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function yt(e,t,n){if(this.useVertexTexture=void 0===n||n,this.identityMatrix=new d,e=e||[],this.bones=e.slice(0),this.useVertexTexture){var r=Math.sqrt(4*this.bones.length);r=fs.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 X(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,Pa,_a)}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 i=0,o=this.bones.length;i=e.HAVE_CURRENT_DATA&&(d.needsUpdate=!0)}o.call(this,e,t,n,r,i,a,s,l,u),this.generateMipmaps=!1;var d=this;c()}function Ct(e,t,n,r,i,a,s,l,u,c,d,h){o.call(this,null,a,s,l,u,c,r,i,d,h),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Ot(e,t,n,r,i,a,s,l,u){o.call(this,e,t,n,r,i,a,s,l,u),this.needsUpdate=!0}function Pt(e,t,n,r,i,a,s,l,u,c){if((c=void 0!==c?c:Ia)!==Ia&&c!==Da)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===Ia&&(n=ba),void 0===n&&c===Da&&(n=ka),o.call(this,null,r,i,a,s,l,c,n,u),this.image={width:e,height:t},this.magFilter=void 0!==s?s:ca,this.minFilter=void 0!==l?l:ca,this.flipY=!1,this.generateMipmaps=!1}function At(e){function t(e,t){return e-t}Oe.call(this),this.type="WireframeGeometry";var n,r,i,o,a,s,l,u,d=[],h=[0,0],f={},p=["a","b","c"];if(e&&e.isGeometry){var m=e.faces;for(n=0,i=m.length;n.9&&o<.1&&(t<.2&&(m[e+0]+=1),n<.2&&(m[e+2]+=1),r<.2&&(m[e+4]+=1))}}function s(e){p.push(e.x,e.y,e.z)}function l(t,n){var r=3*t;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function u(){for(var e=new c,t=new c,n=new c,r=new c,o=new i,a=new i,s=new i,l=0,u=0;l0)&&m.push(_,M,E),(l!==n-1||u0&&u(!0),t>0&&u(!1)),this.setIndex(h),this.addAttribute("position",new Me(f,3)),this.addAttribute("normal",new Me(p,3)),this.addAttribute("uv",new Me(m,2))}function cn(e,t,n,r,i,o,a){ln.call(this,0,e,t,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}function dn(e,t,n,r,i,o,a){un.call(this,0,e,t,n,r,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}function hn(e,t,n,r){Ce.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new fn(e,t,n,r))}function fn(e,t,n,r){Oe.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},e=e||50,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var o,a,s=[],l=[],u=[],d=[],h=new c,f=new i;for(l.push(0,0,0),u.push(0,0,1),d.push(.5,.5),a=0,o=3;a<=t;a++,o+=3){var p=n+a/t*r;h.x=e*Math.cos(p),h.y=e*Math.sin(p),l.push(h.x,h.y,h.z),u.push(0,0,1),f.x=(l[o]/e+1)/2,f.y=(l[o+1]/e+1)/2,d.push(f.x,f.y)}for(o=1;o<=t;o++)s.push(o,o+1,0);this.setIndex(s),this.addAttribute("position",new Me(l,3)),this.addAttribute("normal",new Me(u,3)),this.addAttribute("uv",new Me(d,2))}function pn(){$.call(this,{uniforms:xs.merge([Ms.lights,{opacity:{value:1}}]),vertexShader:ws.shadow_vert,fragmentShader:ws.shadow_frag}),this.lights=!0,this.transparent=!0,Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}}})}function mn(e){$.call(this,e),this.type="RawShaderMaterial"}function gn(e){this.uuid=fs.generateUUID(),this.type="MultiMaterial",this.materials=Array.isArray(e)?e:[],this.visible=!0}function vn(e){Q.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new q(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 q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new i(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function yn(e){vn.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)}function bn(e){Q.call(this),this.type="MeshPhongMaterial",this.color=new q(16777215),this.specular=new q(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new i(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ho,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function xn(e){bn.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function wn(e){Q.call(this,e),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new i(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function _n(e){Q.call(this),this.type="MeshLambertMaterial",this.color=new q(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ho,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Mn(e){Q.call(this),this.type="LineDashedMaterial",this.color=new q(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(e)}function Sn(e,t,n){var r=this,i=!1,o=0,a=0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){a++,!1===i&&void 0!==r.onStart&&r.onStart(e,o,a),i=!0},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,a),o===a&&(i=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)}}function En(e){this.manager=void 0!==e?e:Ls}function Tn(e){this.manager=void 0!==e?e:Ls,this._parser=null}function kn(e){this.manager=void 0!==e?e:Ls,this._parser=null}function Cn(e){this.manager=void 0!==e?e:Ls}function On(e){this.manager=void 0!==e?e:Ls}function Pn(e){this.manager=void 0!==e?e:Ls}function An(e,t){ce.call(this),this.type="Light",this.color=new q(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function Rn(e,t,n){An.call(this,e,n),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(ce.DefaultUp),this.updateMatrix(),this.groundColor=new q(t)}function Ln(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new i(512,512),this.map=null,this.matrix=new d}function In(){Ln.call(this,new ze(50,1,.5,500))}function Dn(e,t,n,r,i,o){An.call(this,e,t),this.type="SpotLight",this.position.copy(ce.DefaultUp),this.updateMatrix(),this.target=new ce,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==r?r:Math.PI/3,this.penumbra=void 0!==i?i:0,this.decay=void 0!==o?o:1,this.shadow=new In}function zn(e,t,n,r){An.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==r?r:1,this.shadow=new Ln(new ze(90,1,.5,500))}function Nn(){Ln.call(this,new Ne(-5,5,5,-5,.5,500))}function Bn(e,t){An.call(this,e,t),this.type="DirectionalLight",this.position.copy(ce.DefaultUp),this.updateMatrix(),this.target=new ce,this.shadow=new Nn}function Fn(e,t){An.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function Un(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function jn(e,t,n,r){Un.call(this,e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Wn(e,t,n,r){Un.call(this,e,t,n,r)}function Vn(e,t,n,r){Un.call(this,e,t,n,r)}function Gn(e,t,n,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=Is.convertArray(t,this.TimeBufferType),this.values=Is.convertArray(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()}function Hn(e,t,n,r){Gn.call(this,e,t,n,r)}function Yn(e,t,n,r){Un.call(this,e,t,n,r)}function qn(e,t,n,r){Gn.call(this,e,t,n,r)}function Xn(e,t,n,r){Gn.call(this,e,t,n,r)}function Zn(e,t,n,r){Gn.call(this,e,t,n,r)}function Kn(e,t,n){Gn.call(this,e,t,n)}function Jn(e,t,n,r){Gn.call(this,e,t,n,r)}function Qn(e,t,n,r){Gn.apply(this,arguments)}function $n(e,t,n){this.name=e,this.tracks=n,this.duration=void 0!==t?t:-1,this.uuid=fs.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function er(e){this.manager=void 0!==e?e:Ls,this.textures={}}function tr(e){this.manager=void 0!==e?e:Ls}function nr(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function rr(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:Ls,this.withCredentials=!1}function ir(e){this.manager=void 0!==e?e:Ls,this.texturePath=""}function or(e,t,n,r,i){var o=.5*(r-t),a=.5*(i-n),s=e*e;return(2*n-2*r+o+a)*(e*s)+(-3*n+3*r-2*o-a)*s+o*e+n}function ar(e,t){var n=1-e;return n*n*t}function sr(e,t){return 2*(1-e)*e*t}function lr(e,t){return e*e*t}function ur(e,t,n,r){return ar(e,t)+sr(e,n)+lr(e,r)}function cr(e,t){var n=1-e;return n*n*n*t}function dr(e,t){var n=1-e;return 3*n*n*e*t}function hr(e,t){return 3*(1-e)*e*e*t}function fr(e,t){return e*e*e*t}function pr(e,t,n,r,i){return cr(e,t)+dr(e,n)+hr(e,r)+fr(e,i)}function mr(){}function gr(e,t){this.v1=e,this.v2=t}function vr(){this.curves=[],this.autoClose=!1}function yr(e,t,n,r,i,o,a,s){this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function br(e){this.points=void 0===e?[]:e}function xr(e,t,n,r){this.v0=e,this.v1=t,this.v2=n,this.v3=r}function wr(e,t,n){this.v0=e,this.v1=t,this.v2=n}function _r(e){vr.call(this),this.currentPoint=new i,e&&this.fromPoints(e)}function Mr(){_r.apply(this,arguments),this.holes=[]}function Sr(){this.subPaths=[],this.currentPath=null}function Er(e){this.data=e}function Tr(e){this.manager=void 0!==e?e:Ls}function kr(e){this.manager=void 0!==e?e:Ls}function Cr(e,t,n,r){An.call(this,e,t),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==n?n:10,this.height=void 0!==r?r:10}function Or(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ze,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ze,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Pr(e,t,n){ce.call(this),this.type="CubeCamera";var r=new ze(90,1,e,t);r.up.set(0,-1,0),r.lookAt(new c(1,0,0)),this.add(r);var i=new ze(90,1,e,t);i.up.set(0,-1,0),i.lookAt(new c(-1,0,0)),this.add(i);var o=new ze(90,1,e,t);o.up.set(0,0,1),o.lookAt(new c(0,1,0)),this.add(o);var a=new ze(90,1,e,t);a.up.set(0,0,-1),a.lookAt(new c(0,-1,0)),this.add(a);var s=new ze(90,1,e,t);s.up.set(0,-1,0),s.lookAt(new c(0,0,1)),this.add(s);var u=new ze(90,1,e,t);u.up.set(0,-1,0),u.lookAt(new c(0,0,-1)),this.add(u);var d={format:Oa,magFilter:fa,minFilter:fa};this.renderTarget=new l(n,n,d),this.updateCubeMap=function(e,t){null===this.parent&&this.updateMatrixWorld();var n=this.renderTarget,l=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,n.activeCubeFace=0,e.render(t,r,n),n.activeCubeFace=1,e.render(t,i,n),n.activeCubeFace=2,e.render(t,o,n),n.activeCubeFace=3,e.render(t,a,n),n.activeCubeFace=4,e.render(t,s,n),n.texture.generateMipmaps=l,n.activeCubeFace=5,e.render(t,u,n),e.setRenderTarget(null)}}function Ar(){ce.call(this),this.type="AudioListener",this.context=Bs.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Rr(e){ce.call(this),this.type="Audio",this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Lr(e){Rr.call(this,e),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Ir(e,t){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=void 0!==t?t:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}function Dr(e,t,n){this.binding=e,this.valueSize=n;var r,i=Float64Array;switch(t){case"quaternion":r=this._slerp;break;case"string":case"bool":i=Array,r=this._select;break;default:r=this._lerp}this.buffer=new i(4*n),this._mixBufferRegion=r,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function zr(e,t,n){this.path=t,this.parsedPath=n||zr.parseTrackName(t),this.node=zr.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function Nr(e){this.uuid=fs.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var n=0,r=arguments.length;n!==r;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function Br(e,t,n){this._mixer=e,this._clip=t,this._localRoot=n||null;for(var r=t.tracks,i=r.length,o=new Array(i),a={endingStart:Ja,endingEnd:Ja},s=0;s!==i;++s){var l=r[s].createInterpolant(null);o[s]=l,l.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Ya,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Fr(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Ur(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function jr(){Oe.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Wr(e,t,n,r){this.uuid=fs.generateUUID(),this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}function Vr(e,t){this.uuid=fs.generateUUID(),this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Gr(e,t,n){Vr.call(this,e,t),this.meshPerAttribute=n||1}function Hr(e,t,n){me.call(this,e,t),this.meshPerAttribute=n||1}function Yr(e,t,n,r){this.ray=new se(e,t),this.near=n||0,this.far=r||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}}})}function qr(e,t){return e.distance-t.distance}function Xr(e,t,n,r){if(!1!==e.visible&&(e.raycast(t,n),!0===r))for(var i=e.children,o=0,a=i.length;o0?1:+e}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&function(){Object.assign=function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n>=4,n[i]=t[19===i?3&e|8:e]);return n.join("")}}(),clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*fs.DEG2RAD},radToDeg:function(e){return e*fs.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},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}};i.prototype={constructor:i,isVector2:!0,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)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("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(n,r){return void 0===e&&(e=new i,t=new i),e.set(n,n),t.set(r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,n))/n)},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 e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},distanceToManhattan:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},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,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,o=this.y-e.y;return this.x=i*n-o*r+e.x,this.y=i*r+o*n+e.y,this}};var ps=0;o.DEFAULT_IMAGE=void 0,o.DEFAULT_MAPPING=$o,o.prototype={constructor:o,isTexture:!0,set needsUpdate(e){!0===e&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){if(void 0!==e.textures[this.uuid])return e.textures[this.uuid];var t={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,flipY:this.flipY};if(void 0!==this.image){var n=this.image;void 0===n.uuid&&(n.uuid=fs.generateUUID()),void 0===e.images[n.uuid]&&(e.images[n.uuid]={uuid:n.uuid,url:function(e){var t;return void 0!==e.toDataURL?t=e:(t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),t.width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0,e.width,e.height)),t.width>2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}(n)}),t.image=n.uuid}return e.textures[this.uuid]=t,t},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(this.mapping===$o){if(e.multiply(this.repeat),e.add(this.offset),e.x<0||e.x>1)switch(this.wrapS){case sa:e.x=e.x-Math.floor(e.x);break;case la:e.x=e.x<0?0:1;break;case ua:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case sa:e.y=e.y-Math.floor(e.y);break;case la:e.y=e.y<0?0:1;break;case ua:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}},Object.assign(o.prototype,r.prototype),a.prototype={constructor:a,isVector4:!0,set:function(e,t,n,r){return this.x=e,this.y=t,this.z=n,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)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("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,n=this.y,r=this.z,i=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*i,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,n,r,i,o=e.elements,a=o[0],s=o[4],l=o[8],u=o[1],c=o[5],d=o[9],h=o[2],f=o[6],p=o[10];if(Math.abs(s-u)<.01&&Math.abs(l-h)<.01&&Math.abs(d-f)<.01){if(Math.abs(s+u)<.1&&Math.abs(l+h)<.1&&Math.abs(d+f)<.1&&Math.abs(a+c+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(a+1)/2,g=(c+1)/2,v=(p+1)/2,y=(s+u)/4,b=(l+h)/4,x=(d+f)/4;return m>g&&m>v?m<.01?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(m),r=y/n,i=b/n):g>v?g<.01?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(g),n=y/r,i=x/r):v<.01?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(v),n=b/i,r=x/i),this.set(n,r,i,t),this}var w=Math.sqrt((f-d)*(f-d)+(l-h)*(l-h)+(u-s)*(u-s));return Math.abs(w)<.001&&(w=1),this.x=(f-d)/w,this.y=(l-h)/w,this.z=(u-s)/w,this.w=Math.acos((a+c+p-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(n,r){return void 0===e&&(e=new a,t=new a),e.set(n,n,n,n),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,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}},s.prototype={constructor:s,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(s.prototype,r.prototype),l.prototype=Object.create(s.prototype),l.prototype.constructor=l,l.prototype.isWebGLRenderTargetCube=!0,u.prototype={constructor:u,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,n,r){return this._x=e,this._y=t,this._z=n,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(!1===(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=Math.cos(e._x/2),r=Math.cos(e._y/2),i=Math.cos(e._z/2),o=Math.sin(e._x/2),a=Math.sin(e._y/2),s=Math.sin(e._z/2),l=e.order;return"XYZ"===l?(this._x=o*r*i+n*a*s,this._y=n*a*i-o*r*s,this._z=n*r*s+o*a*i,this._w=n*r*i-o*a*s):"YXZ"===l?(this._x=o*r*i+n*a*s,this._y=n*a*i-o*r*s,this._z=n*r*s-o*a*i,this._w=n*r*i+o*a*s):"ZXY"===l?(this._x=o*r*i-n*a*s,this._y=n*a*i+o*r*s,this._z=n*r*s+o*a*i,this._w=n*r*i-o*a*s):"ZYX"===l?(this._x=o*r*i-n*a*s,this._y=n*a*i+o*r*s,this._z=n*r*s-o*a*i,this._w=n*r*i+o*a*s):"YZX"===l?(this._x=o*r*i+n*a*s,this._y=n*a*i+o*r*s,this._z=n*r*s-o*a*i,this._w=n*r*i-o*a*s):"XZY"===l&&(this._x=o*r*i-n*a*s,this._y=n*a*i-o*r*s,this._z=n*r*s+o*a*i,this._w=n*r*i+o*a*s),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,r=n[0],i=n[4],o=n[8],a=n[1],s=n[5],l=n[9],u=n[2],c=n[6],d=n[10],h=r+s+d;return h>0?(t=.5/Math.sqrt(h+1),this._w=.25/t,this._x=(c-l)*t,this._y=(o-u)*t,this._z=(a-i)*t):r>s&&r>d?(t=2*Math.sqrt(1+r-s-d),this._w=(c-l)/t,this._x=.25*t,this._y=(i+a)/t,this._z=(o+u)/t):s>d?(t=2*Math.sqrt(1+s-r-d),this._w=(o-u)/t,this._x=(i+a)/t,this._y=.25*t,this._z=(l+c)/t):(t=2*Math.sqrt(1+d-r-s),this._w=(a-i)/t,this._x=(o+u)/t,this._y=(l+c)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t;return function(n,r){return void 0===e&&(e=new c),t=n.dot(r)+1,t<1e-6?(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,r),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},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)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var n=e._x,r=e._y,i=e._z,o=e._w,a=t._x,s=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+r*l-i*s,this._y=r*u+o*s+i*a-n*l,this._z=i*u+o*l+n*s-r*a,this._w=o*u-n*a-r*s-i*l,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,r=this._y,i=this._z,o=this._w,a=o*e._w+n*e._x+r*e._y+i*e._z;if(a<0?(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=n,this._y=r,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(n+this._x),this._y=.5*(r+this._y),this._z=.5*(i+this._z),this;var l=Math.atan2(s,a),u=Math.sin((1-t)*l)/s,c=Math.sin(t*l)/s;return this._w=o*u+this._w*c,this._x=n*u+this._x*c,this._y=r*u+this._y*c,this._z=i*u+this._z*c,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(u,{slerp:function(e,t,n,r){return n.copy(e).slerp(t,r)},slerpFlat:function(e,t,n,r,i,o,a){var s=n[r+0],l=n[r+1],u=n[r+2],c=n[r+3],d=i[o+0],h=i[o+1],f=i[o+2],p=i[o+3];if(c!==p||s!==d||l!==h||u!==f){var m=1-a,g=s*d+l*h+u*f+c*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,g*v);m=Math.sin(m*x)/b,a=Math.sin(a*x)/b}var w=a*v;if(s=s*m+d*w,l=l*m+h*w,u=u*m+f*w,c=c*m+p*w,m===1-a){var _=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=_,l*=_,u*=_,c*=_}}e[t]=s,e[t+1]=l,e[t+2]=u,e[t+3]=c}}),c.prototype={constructor:c,isVector3:!0,set:function(e,t,n){return this.x=e,this.y=t,this.z=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("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!1===(t&&t.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===e&&(e=new u),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e;return function(t,n){return void 0===e&&(e=new u),this.applyQuaternion(e.setFromAxisAngle(t,n))}}(),applyMatrix3:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this},applyMatrix4:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;this.x=i[0]*t+i[4]*n+i[8]*r+i[12],this.y=i[1]*t+i[5]*n+i[9]*r+i[13],this.z=i[2]*t+i[6]*n+i[10]*r+i[14];var o=i[3]*t+i[7]*n+i[11]*r+i[15];return this.divideScalar(o)},applyQuaternion:function(e){var t=this.x,n=this.y,r=this.z,i=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*r-a*n,u=s*n+a*t-i*r,c=s*r+i*n-o*t,d=-i*t-o*n-a*r;return this.x=l*s+d*-i+u*-a-c*-o,this.y=u*s+d*-o+c*-i-l*-a,this.z=c*s+d*-a+l*-o-u*-i,this},project:function(){var e;return function(t){return void 0===e&&(e=new d),e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e;return function(t){return void 0===e&&(e=new d),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e,t;return function(n,r){return void 0===e&&(e=new c,t=new c),e.set(n,n,n),t.set(r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,n))/n)},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,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},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 n=this.x,r=this.y,i=this.z;return this.x=r*e.z-i*e.y,this.y=i*e.x-n*e.z,this.z=n*e.y-r*e.x,this},crossVectors:function(e,t){var n=e.x,r=e.y,i=e.z,o=t.x,a=t.y,s=t.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e;return function(t){return void 0===e&&(e=new c),e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e;return function(t){return void 0===e&&(e=new c),this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(fs.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r},distanceToManhattan:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},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},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){return this.setFromMatrixColumn(e,3)},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this},setFromMatrixColumn:function(e,t){if("number"==typeof e){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var n=e;e=t,t=n}return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}},d.prototype={constructor:d,isMatrix4:!0,set:function(e,t,n,r,i,o,a,s,l,u,c,d,h,f,p,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=l,g[6]=u,g[10]=c,g[14]=d,g[3]=h,g[7]=f,g[11]=p,g[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 d).fromArray(this.elements)},copy:function(e){return this.elements.set(e.elements),this},copyPosition:function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},extractBasis:function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},extractRotation:function(){var e;return function(t){void 0===e&&(e=new c);var n=this.elements,r=t.elements,i=1/e.setFromMatrixColumn(t,0).length(),o=1/e.setFromMatrixColumn(t,1).length(),a=1/e.setFromMatrixColumn(t,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[4]=r[4]*o,n[5]=r[5]*o,n[6]=r[6]*o,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,this}}(),makeRotationFromEuler:function(e){!1===(e&&e.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,n=e.x,r=e.y,i=e.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),l=Math.sin(r),u=Math.cos(i),c=Math.sin(i);if("XYZ"===e.order){var d=o*u,h=o*c,f=a*u,p=a*c;t[0]=s*u,t[4]=-s*c,t[8]=l,t[1]=h+f*l,t[5]=d-p*l,t[9]=-a*s,t[2]=p-d*l,t[6]=f+h*l,t[10]=o*s}else if("YXZ"===e.order){var m=s*u,g=s*c,v=l*u,y=l*c;t[0]=m+y*a,t[4]=v*a-g,t[8]=o*l,t[1]=o*c,t[5]=o*u,t[9]=-a,t[2]=g*a-v,t[6]=y+m*a,t[10]=o*s}else if("ZXY"===e.order){var m=s*u,g=s*c,v=l*u,y=l*c;t[0]=m-y*a,t[4]=-o*c,t[8]=v+g*a,t[1]=g+v*a,t[5]=o*u,t[9]=y-m*a,t[2]=-o*l,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){var d=o*u,h=o*c,f=a*u,p=a*c;t[0]=s*u,t[4]=f*l-h,t[8]=d*l+p,t[1]=s*c,t[5]=p*l+d,t[9]=h*l-f,t[2]=-l,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){var b=o*s,x=o*l,w=a*s,_=a*l;t[0]=s*u,t[4]=_-b*c,t[8]=w*c+x,t[1]=c,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=x*c+w,t[10]=b-_*c}else if("XZY"===e.order){var b=o*s,x=o*l,w=a*s,_=a*l;t[0]=s*u,t[4]=-c,t[8]=l*u,t[1]=b*c+_,t[5]=o*u,t[9]=x*c-w,t[2]=w*c-x,t[6]=a*u,t[10]=_*c+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,n=e.x,r=e.y,i=e.z,o=e.w,a=n+n,s=r+r,l=i+i,u=n*a,c=n*s,d=n*l,h=r*s,f=r*l,p=i*l,m=o*a,g=o*s,v=o*l;return t[0]=1-(h+p),t[4]=c-v,t[8]=d+g,t[1]=c+v,t[5]=1-(u+p),t[9]=f-m,t[2]=d-g,t[6]=f+m,t[10]=1-(u+h),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,n;return function(r,i,o){void 0===e&&(e=new c,t=new c,n=new c);var a=this.elements;return n.subVectors(r,i).normalize(),0===n.lengthSq()&&(n.z=1),e.crossVectors(o,n).normalize(),0===e.lengthSq()&&(n.z+=1e-4,e.crossVectors(o,n).normalize()),t.crossVectors(n,e),a[0]=e.x,a[4]=t.x,a[8]=n.x,a[1]=e.y,a[5]=t.y,a[9]=n.y,a[2]=e.z,a[6]=t.z,a[10]=n.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)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var n=e.elements,r=t.elements,i=this.elements,o=n[0],a=n[4],s=n[8],l=n[12],u=n[1],c=n[5],d=n[9],h=n[13],f=n[2],p=n[6],m=n[10],g=n[14],v=n[3],y=n[7],b=n[11],x=n[15],w=r[0],_=r[4],M=r[8],S=r[12],E=r[1],T=r[5],k=r[9],C=r[13],O=r[2],P=r[6],A=r[10],R=r[14],L=r[3],I=r[7],D=r[11],z=r[15];return i[0]=o*w+a*E+s*O+l*L,i[4]=o*_+a*T+s*P+l*I,i[8]=o*M+a*k+s*A+l*D,i[12]=o*S+a*C+s*R+l*z,i[1]=u*w+c*E+d*O+h*L,i[5]=u*_+c*T+d*P+h*I,i[9]=u*M+c*k+d*A+h*D,i[13]=u*S+c*C+d*R+h*z,i[2]=f*w+p*E+m*O+g*L,i[6]=f*_+p*T+m*P+g*I,i[10]=f*M+p*k+m*A+g*D,i[14]=f*S+p*C+m*R+g*z,i[3]=v*w+y*E+b*O+x*L,i[7]=v*_+y*T+b*P+x*I,i[11]=v*M+y*k+b*A+x*D,i[15]=v*S+y*C+b*R+x*z,this},multiplyToArray:function(e,t,n){var r=this.elements;return this.multiplyMatrices(e,t),n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[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},applyToBufferAttribute:function(){var e;return function(t){void 0===e&&(e=new c);for(var n=0,r=t.count;n 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 ltcTextureCoords( const in GeometricContext geometry, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE;\n\tconst float LUT_BIAS = 0.5/LUT_SIZE;\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nvoid clipQuadToHorizon( inout vec3 L[5], out int n ) {\n\tint config = 0;\n\tif ( L[0].z > 0.0 ) config += 1;\n\tif ( L[1].z > 0.0 ) config += 2;\n\tif ( L[2].z > 0.0 ) config += 4;\n\tif ( L[3].z > 0.0 ) config += 8;\n\tn = 0;\n\tif ( config == 0 ) {\n\t} else if ( config == 1 ) {\n\t\tn = 3;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 2 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 3 ) {\n\t\tn = 4;\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t\tL[3] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 4 ) {\n\t\tn = 3;\n\t\tL[0] = -L[3].z * L[2] + L[2].z * L[3];\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t} else if ( config == 5 ) {\n\t\tn = 0;\n\t} else if ( config == 6 ) {\n\t\tn = 4;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 7 ) {\n\t\tn = 5;\n\t\tL[4] = -L[3].z * L[0] + L[0].z * L[3];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 8 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[1] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = L[3];\n\t} else if ( config == 9 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[2].z * L[3] + L[3].z * L[2];\n\t} else if ( config == 10 ) {\n\t\tn = 0;\n\t} else if ( config == 11 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 12 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t} else if ( config == 13 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = L[2];\n\t\tL[2] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t} else if ( config == 14 ) {\n\t\tn = 5;\n\t\tL[4] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t} else if ( config == 15 ) {\n\t\tn = 4;\n\t}\n\tif ( n == 3 )\n\t\tL[3] = L[0];\n\tif ( n == 4 )\n\t\tL[4] = L[0];\n}\nfloat integrateLtcBrdfOverRectEdge( vec3 v1, vec3 v2 ) {\n\tfloat cosTheta = dot( v1, v2 );\n\tfloat theta = acos( cosTheta );\n\tfloat res = cross( v1, v2 ).z * ( ( theta > 0.001 ) ? theta / sin( theta ) : 1.0 );\n\treturn res;\n}\nvoid initRectPoints( const in vec3 pos, const in vec3 halfWidth, const in vec3 halfHeight, out vec3 rectPoints[4] ) {\n\trectPoints[0] = pos - halfWidth - halfHeight;\n\trectPoints[1] = pos + halfWidth - halfHeight;\n\trectPoints[2] = pos + halfWidth + halfHeight;\n\trectPoints[3] = pos - halfWidth + halfHeight;\n}\nvec3 integrateLtcBrdfOverRect( const in GeometricContext geometry, const in mat3 brdfMat, const in vec3 rectPoints[4] ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot( V, N ));\n\tT2 = - cross( N, T1 );\n\tmat3 brdfWrtSurface = brdfMat * transpose( mat3( T1, T2, N ) );\n\tvec3 clippedRect[5];\n\tclippedRect[0] = brdfWrtSurface * ( rectPoints[0] - P );\n\tclippedRect[1] = brdfWrtSurface * ( rectPoints[1] - P );\n\tclippedRect[2] = brdfWrtSurface * ( rectPoints[2] - P );\n\tclippedRect[3] = brdfWrtSurface * ( rectPoints[3] - P );\n\tint n;\n\tclipQuadToHorizon(clippedRect, n);\n\tif ( n == 0 )\n\t\treturn vec3( 0, 0, 0 );\n\tclippedRect[0] = normalize( clippedRect[0] );\n\tclippedRect[1] = normalize( clippedRect[1] );\n\tclippedRect[2] = normalize( clippedRect[2] );\n\tclippedRect[3] = normalize( clippedRect[3] );\n\tclippedRect[4] = normalize( clippedRect[4] );\n\tfloat sum = 0.0;\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[0], clippedRect[1] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[1], clippedRect[2] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[2], clippedRect[3] );\n\tif (n >= 4)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[3], clippedRect[4] );\n\tif (n == 5)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[4], clippedRect[0] );\n\tsum = max( 0.0, sum );\n\tvec3 Lo_i = vec3( sum, sum, sum );\n\treturn Lo_i;\n}\nvec3 Rect_Area_Light_Specular_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight,\n\t\tconst in float roughness,\n\t\tconst in sampler2D ltcMat, const in sampler2D ltcMag ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tvec2 uv = ltcTextureCoords( geometry, roughness );\n\tvec4 brdfLtcApproxParams, t;\n\tbrdfLtcApproxParams = texture2D( ltcMat, uv );\n\tt = texture2D( ltcMat, uv );\n\tfloat brdfLtcScalar = texture2D( ltcMag, uv ).a;\n\tmat3 brdfLtcApproxMat = mat3(\n\t\tvec3( 1, 0, t.y ),\n\t\tvec3( 0, t.z, 0 ),\n\t\tvec3( t.w, 0, t.x )\n\t);\n\tvec3 specularReflectance = integrateLtcBrdfOverRect( geometry, brdfLtcApproxMat, rectPoints );\n\tspecularReflectance *= brdfLtcScalar;\n\treturn specularReflectance;\n}\nvec3 Rect_Area_Light_Diffuse_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tmat3 diffuseBrdfMat = mat3(1);\n\tvec3 diffuseReflectance = integrateLtcBrdfOverRect( geometry, diffuseBrdfMat, rectPoints );\n\treturn diffuseReflectance;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n\t}\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff;\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",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\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",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\tvarying vec2 vUv;\n#endif",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\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",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\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};q.prototype={constructor:q,isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,n){return this.r=e,this.g=t,this.b=n,this},setHSL:function(){function e(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}return function(t,n,r){if(t=fs.euclideanModulo(t,1),n=fs.clamp(n,0,1),r=fs.clamp(r,0,1),0===n)this.r=this.g=this.b=r;else{var i=r<=.5?r*(1+n):r+n-r*n,o=2*r-i;this.r=e(o,i,t+1/3),this.g=e(o,i,t),this.b=e(o,i,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 n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,i=n[1],o=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))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(o))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(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,l=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(a,s,l)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(e)){var u=n[1],c=u.length;if(3===c)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===c)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(e&&e.length>0){var u=_s[e];void 0!==u?this.setHex(u):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 n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},convertGammaToLinear:function(){var e=this.r,t=this.g,n=this.b;return this.r=e*e,this.g=t*t,this.b=n*n,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,n,r=e||{h:0,s:0,l:0},i=this.r,o=this.g,a=this.b,s=Math.max(i,o,a),l=Math.min(i,o,a),u=(l+s)/2;if(l===s)t=0,n=0;else{var c=s-l;switch(n=u<=.5?c/(s+l):c/(2-s-l),s){case i:t=(o-a)/c+(othis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return(t||new 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)},clampPoint:function(e,t){return(t||new i).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new i;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};var Es=0;Q.prototype={constructor:Q,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(e){!0===e&&this.update(),this._needsUpdate=e},setValues:function(e){if(void 0!==e)for(var t in e){var n=e[t];if(void 0!==n){var r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]="overdraw"===t?Number(n):n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}else console.warn("THREE.Material: '"+t+"' parameter is undefined.")}},toJSON:function(e){function t(e){var t=[];for(var n in e){var r=e[n];delete r.metadata,t.push(r)}return t}var n=void 0===e;n&&(e={textures:{},images:{}});var r={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearCoat&&(r.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(r.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,r.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(r.size=this.size),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==go&&(r.blending=this.blending),this.shading!==co&&(r.shading=this.shading),this.side!==ao&&(r.side=this.side),this.vertexColors!==ho&&(r.vertexColors=this.vertexColors),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),r.skinning=this.skinning,r.morphTargets=this.morphTargets,n){var i=t(e.textures),o=t(e.images);i.length>0&&(r.textures=i),o.length>0&&(r.images=o)}return r},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.shading=e.shading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,n=null;if(null!==t){var r=t.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(Q.prototype,r.prototype),$.prototype=Object.create(Q.prototype),$.prototype.constructor=$,$.prototype.isShaderMaterial=!0,$.prototype.copy=function(e){return Q.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=xs.clone(e.uniforms),this.defines=e.defines,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},$.prototype.toJSON=function(e){var t=Q.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},ee.prototype=Object.create(Q.prototype),ee.prototype.constructor=ee,ee.prototype.isMeshDepthMaterial=!0,ee.prototype.copy=function(e){return Q.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},te.prototype={constructor:te,isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=e.length;si&&(i=u),c>o&&(o=c),d>a&&(a=d)}return this.min.set(t,n,r),this.max.set(i,o,a),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,l=e.count;si&&(i=u),c>o&&(o=c),d>a&&(a=d)}return this.min.set(t,n,r),this.max.set(i,o,a),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return(t||new c).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)},intersectsSphere:function(){var e;return function(t){return void 0===e&&(e=new c),this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=e.constant&&n>=e.constant},clampPoint:function(e,t){return(t||new c).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new c;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new c;return function(t){var n=t||new ne;return this.getCenter(n.center),n.radius=.5*this.getSize(e).length(),n}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new c,new c,new c,new c,new c,new c,new c,new c];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},ne.prototype={constructor:ne,set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e;return function(t,n){void 0===e&&(e=new te);var r=this.center;void 0!==n?r.copy(n):e.setFromPoints(t).getCenter(r);for(var i=0,o=0,a=t.length;othis.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},getBoundingBox:function(e){var t=e||new te;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}},re.prototype={constructor:re,isMatrix3:!0,set:function(e,t,n,r,i,o,a,s,l){var u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=i,u[5]=s,u[6]=n,u[7]=o,u[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=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},applyToBufferAttribute:function(){var e;return function(t){void 0===e&&(e=new c);for(var n=0,r=t.count;n1))return r.copy(i).multiplyScalar(a).add(t.start)}else if(0===this.distanceToPoint(t.start))return r.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return(e||new c).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new c,t=new re;return function(n,r){var i=this.coplanarPoint(e).applyMatrix4(n),o=r||t.getNormalMatrix(n),a=this.normal.applyMatrix3(o).normalize();return this.constant=-i.dot(a),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}},oe.prototype={constructor:oe,set:function(e,t,n,r,i,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromMatrix:function(e){var t=this.planes,n=e.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],u=n[6],c=n[7],d=n[8],h=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(a-r,c-s,p-d,y-m).normalize(),t[1].setComponents(a+r,c+s,p+d,y+m).normalize(),t[2].setComponents(a+i,c+l,p+h,y+g).normalize(),t[3].setComponents(a-i,c-l,p-h,y-g).normalize(),t[4].setComponents(a-o,c-u,p-f,y-v).normalize(),t[5].setComponents(a+o,c+u,p+f,y+v).normalize(),this},intersectsObject:function(){var e=new ne;return function(t){var n=t.geometry;return null===n.boundingSphere&&n.computeBoundingSphere(),e.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new ne;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,n=e.center,r=-e.radius,i=0;i<6;i++){if(t[i].distanceToPoint(n)0?n.min.x:n.max.x,t.x=o.normal.x>0?n.max.x:n.min.x,e.y=o.normal.y>0?n.min.y:n.max.y,t.y=o.normal.y>0?n.max.y:n.min.y,e.z=o.normal.z>0?n.min.z:n.max.z,t.z=o.normal.z>0?n.max.z:n.min.z;var a=o.distanceToPoint(e),s=o.distanceToPoint(t);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}},se.prototype={constructor:se,set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return(t||new c).copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new c;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var n=t||new c;n.subVectors(e,this.origin);var r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(r).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new c;return function(t){var n=e.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(n).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new c,t=new c,n=new c;return function(r,i,o,a){e.copy(r).add(i).multiplyScalar(.5),t.copy(i).sub(r).normalize(),n.copy(this.origin).sub(e);var s,l,u,c,d=.5*r.distanceTo(i),h=-this.direction.dot(t),f=n.dot(this.direction),p=-n.dot(t),m=n.lengthSq(),g=Math.abs(1-h*h);if(g>0)if(s=h*p-f,l=h*f-p,c=d*g,s>=0)if(l>=-c)if(l<=c){var v=1/g;s*=v,l*=v,u=s*(s+h*l+2*f)+l*(h*s+l+2*p)+m}else l=d,s=Math.max(0,-(h*l+f)),u=-s*s+l*(l+2*p)+m;else l=-d,s=Math.max(0,-(h*l+f)),u=-s*s+l*(l+2*p)+m;else l<=-c?(s=Math.max(0,-(-h*d+f)),l=s>0?-d:Math.min(Math.max(-d,-p),d),u=-s*s+l*(l+2*p)+m):l<=c?(s=0,l=Math.min(Math.max(-d,-p),d),u=l*(l+2*p)+m):(s=Math.max(0,-(h*d+f)),l=s>0?d:Math.min(Math.max(-d,-p),d),u=-s*s+l*(l+2*p)+m);else l=h>0?-d:d,s=Math.max(0,-(h*l+f)),u=-s*s+l*(l+2*p)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(t).multiplyScalar(l).add(e),u}}(),intersectSphere:function(){var e=new c;return function(t,n){e.subVectors(t.center,this.origin);var r=e.dot(this.direction),i=e.dot(e)-r*r,o=t.radius*t.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=r-a,l=r+a;return s<0&&l<0?null:s<0?this.at(l,n):this.at(s,n)}}(),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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null},intersectPlane:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var n,r,i,o,a,s,l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),u>=0?(i=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(i=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||i>r?null:((i>n||n!==n)&&(n=i),(o=0?(a=(e.min.z-d.z)*c,s=(e.max.z-d.z)*c):(a=(e.max.z-d.z)*c,s=(e.min.z-d.z)*c),n>s||a>r?null:((a>n||n!==n)&&(n=a),(s=0?n:r,t)))},intersectsBox:function(){var e=new c;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new c,t=new c,n=new c,r=new c;return function(i,o,a,s,l){t.subVectors(o,i),n.subVectors(a,i),r.crossVectors(t,n);var u,c=this.direction.dot(r);if(c>0){if(s)return null;u=1}else{if(!(c<0))return null;u=-1,c=-c}e.subVectors(this.origin,i);var d=u*this.direction.dot(n.crossVectors(e,n));if(d<0)return null;var h=u*this.direction.dot(t.cross(e));if(h<0)return null;if(d+h>c)return null;var f=-u*e.dot(r);return f<0?null:this.at(f/c,l)}}(),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)}},le.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],le.DefaultOrder="XYZ",le.prototype={constructor:le,isEuler:!0,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,n,r){return this._x=e,this._y=t,this._z=n,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,n){var r=fs.clamp,i=e.elements,o=i[0],a=i[4],s=i[8],l=i[1],u=i[5],c=i[9],d=i[2],h=i[6],f=i[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(h,u),this._z=0)):"YXZ"===t?(this._x=Math.asin(-r(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(s,f),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-d,o),this._z=0)):"ZXY"===t?(this._x=Math.asin(r(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,o))):"ZYX"===t?(this._y=Math.asin(-r(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(h,f),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===t?(this._z=Math.asin(r(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-d,o)):(this._x=0,this._y=Math.atan2(s,f))):"XZY"===t?(this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(h,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-c,f),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,!1!==n&&this.onChangeCallback(),this},setFromQuaternion:function(){var e;return function(t,n,r){return void 0===e&&(e=new d),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,n,r)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new u;return function(t){return e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new c(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},ue.prototype={constructor:ue,set:function(e){this.mask=1<1){for(var t=0;t1)for(var t=0;t0){i.children=[];for(var o=0;o0&&(r.geometries=a),s.length>0&&(r.materials=s),l.length>0&&(r.textures=l),u.length>0&&(r.images=u)}return r.object=i,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.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n0?o.multiplyScalar(1/Math.sqrt(a)):o.set(0,0,0)}}(),he.barycoordFromPoint=function(){var e=new c,t=new c,n=new c;return function(r,i,o,a,s){e.subVectors(a,i),t.subVectors(o,i),n.subVectors(r,i);var l=e.dot(e),u=e.dot(t),d=e.dot(n),h=t.dot(t),f=t.dot(n),p=l*h-u*u,m=s||new c;if(0===p)return m.set(-2,-1,-1);var g=1/p,v=(h*d-u*f)*g,y=(l*f-u*d)*g;return m.set(1-v-y,y,v)}}(),he.containsPoint=function(){var e=new c;return function(t,n,r,i){var o=he.barycoordFromPoint(t,n,r,i,e);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),he.prototype={constructor:he,set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),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 c,t=new c;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){return(e||new c).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return he.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new ie).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return he.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return he.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e,t,n,r;return function(i,o){void 0===e&&(e=new ie,t=[new de,new de,new de],n=new c,r=new c);var a=o||new c,s=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(i,n),!0===this.containsPoint(n))a.copy(n);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var l=0;l0,s=o[1]&&o[1].length>0,l=e.morphTargets,u=l.length;if(u>0){t=[];for(var c=0;c0){d=[];for(var c=0;c0)for(var m=0;m0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,n;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,n,r,i;for(n=0,r=this.faces.length;n0&&(e+=t[n].distanceTo(t[n-1])),this.lineDistances[n]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new te),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new ne),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,n){if(!1===(e&&e.isGeometry))return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);var r,i=this.vertices.length,o=this.vertices,a=e.vertices,s=this.faces,l=e.faces,u=this.faceVertexUvs[0],c=e.faceVertexUvs[0],d=this.colors,h=e.colors;void 0===n&&(n=0),void 0!==t&&(r=(new re).getNormalMatrix(t));for(var f=0,p=a.length;f=0;n--){var p=h[n];for(this.faces.splice(p,1),a=0,s=this.faceVertexUvs.length;a0,x=v.vertexNormals.length>0,w=1!==v.color.r||1!==v.color.g||1!==v.color.b,_=v.vertexColors.length>0,M=0;if(M=e(M,0,0),M=e(M,1,!0),M=e(M,2,!1),M=e(M,3,y),M=e(M,4,b),M=e(M,5,x),M=e(M,6,w),M=e(M,7,_),c.push(M),c.push(v.a,v.b,v.c),c.push(v.materialIndex),y){var S=this.faceVertexUvs[0][l];c.push(r(S[0]),r(S[1]),r(S[2]))}if(b&&c.push(t(v.normal)),x){var E=v.vertexNormals;c.push(t(E[0]),t(E[1]),t(E[2]))}if(w&&c.push(n(v.color)),_){var T=v.vertexColors;c.push(n(T[0]),n(T[1]),n(T[2]))}}return i.data={},i.data.vertices=s,i.data.normals=d,f.length>0&&(i.data.colors=f),m.length>0&&(i.data.uvs=[m]),i.data.faces=c,i},clone:function(){return(new Ce).copy(this)},copy:function(e){var t,n,r,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,n=s.length;t65535?_e:xe)(e,1):this.index=e},addAttribute:function(e,t){return!1===(t&&t.isBufferAttribute)&&!1===(t&&t.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(e,new me(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,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var n=this.attributes.normal;if(void 0!==n){(new re).getNormalMatrix(e).applyToBufferAttribute(n),n.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 d),e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e;return function(t){return void 0===e&&(e=new d),e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e;return function(t){return void 0===e&&(e=new d),e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e;return function(t,n,r){return void 0===e&&(e=new d),e.makeTranslation(t,n,r),this.applyMatrix(e),this}}(),scale:function(){var e;return function(t,n,r){return void 0===e&&(e=new d),e.makeScale(t,n,r),this.applyMatrix(e),this}}(),lookAt:function(){var e;return function(t){void 0===e&&(e=new ce),e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){this.computeBoundingBox();var e=this.boundingBox.getCenter().negate();return this.translate(e.x,e.y,e.z),e},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var n=new Me(3*t.vertices.length,3),r=new Me(3*t.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(t.vertices)),this.addAttribute("color",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var i=new Me(t.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},updateFromObject:function(e){var t=e.geometry;if(e.isMesh){var n=t.__directGeometry;if(!0===t.elementsNeedUpdate&&(n=void 0,t.elementsNeedUpdate=!1),void 0===n)return this.fromGeometry(t);n.verticesNeedUpdate=t.verticesNeedUpdate,n.normalsNeedUpdate=t.normalsNeedUpdate,n.colorsNeedUpdate=t.colorsNeedUpdate,n.uvsNeedUpdate=t.uvsNeedUpdate,n.groupsNeedUpdate=t.groupsNeedUpdate,t.verticesNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.groupsNeedUpdate=!1,t=n}var r;return!0===t.verticesNeedUpdate&&(r=this.attributes.position,void 0!==r&&(r.copyVector3sArray(t.vertices),r.needsUpdate=!0),t.verticesNeedUpdate=!1),!0===t.normalsNeedUpdate&&(r=this.attributes.normal,void 0!==r&&(r.copyVector3sArray(t.normals),r.needsUpdate=!0),t.normalsNeedUpdate=!1),!0===t.colorsNeedUpdate&&(r=this.attributes.color,void 0!==r&&(r.copyColorsArray(t.colors),r.needsUpdate=!0),t.colorsNeedUpdate=!1),t.uvsNeedUpdate&&(r=this.attributes.uv,void 0!==r&&(r.copyVector2sArray(t.uvs),r.needsUpdate=!0),t.uvsNeedUpdate=!1),t.lineDistancesNeedUpdate&&(r=this.attributes.lineDistance,void 0!==r&&(r.copyArray(t.lineDistances),r.needsUpdate=!0),t.lineDistancesNeedUpdate=!1),t.groupsNeedUpdate&&(t.computeGroups(e.geometry),this.groups=t.groups,t.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new Ee).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(3*e.vertices.length);if(this.addAttribute("position",new me(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){var n=new Float32Array(3*e.normals.length);this.addAttribute("normal",new me(n,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.addAttribute("color",new me(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var i=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new me(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new me(o,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var a=Te(e.indices)>65535?Uint32Array:Uint16Array,s=new a(3*e.indices.length);this.setIndex(new me(s,1).copyIndicesArray(e.indices))}this.groups=e.groups;for(var l in e.morphTargets){for(var u=[],c=e.morphTargets[l],d=0,h=c.length;d0){var m=new Me(4*e.skinIndices.length,4);this.addAttribute("skinIndex",m.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var g=new Me(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(){null===this.boundingBox&&(this.boundingBox=new te);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new te,t=new c;return function(){null===this.boundingSphere&&(this.boundingSphere=new ne);var n=this.attributes.position;if(n){var r=this.boundingSphere.center;e.setFromBufferAttribute(n),e.getCenter(r);for(var i=0,o=0,a=n.count;o0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var l=this.boundingSphere;return null!==l&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e},clone:function(){return(new Oe).copy(this)},copy:function(e){var t,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var i=e.index;null!==i&&this.setIndex(i.clone());var o=e.attributes;for(t in o){var a=o[t];this.addAttribute(t,a.clone())}var s=e.morphAttributes;for(t in s){var l=[],u=s[t];for(n=0,r=u.length;n0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var t=0,n=e.length;tt.far?null:{distance:l,point:x.clone(),object:e}}function n(n,r,i,o,a,c,d,h){s.fromBufferAttribute(o,c),l.fromBufferAttribute(o,d),u.fromBufferAttribute(o,h);var f=t(n,r,i,s,l,u,b);return f&&(a&&(m.fromBufferAttribute(a,c),g.fromBufferAttribute(a,d),v.fromBufferAttribute(a,h),f.uv=e(b,s,l,u,m,g,v)),f.face=new fe(c,d,h,he.normal(s,l,u)),f.faceIndex=c),f}var r=new d,o=new se,a=new ne,s=new c,l=new c,u=new c,h=new c,f=new c,p=new c,m=new i,g=new i,v=new i,y=new c,b=new c,x=new c;return function(i,c){var d=this.geometry,y=this.material,x=this.matrixWorld;if(void 0!==y&&(null===d.boundingSphere&&d.computeBoundingSphere(),a.copy(d.boundingSphere),a.applyMatrix4(x),!1!==i.ray.intersectsSphere(a)&&(r.getInverse(x),o.copy(i.ray).applyMatrix4(r),null===d.boundingBox||!1!==o.intersectsBox(d.boundingBox)))){var w;if(d.isBufferGeometry){var _,M,S,E,T,k=d.index,C=d.attributes.position,O=d.attributes.uv;if(null!==k)for(E=0,T=k.count;E0&&(L=B);for(var F=0,U=N.length;Fthis.scale.x*this.scale.y/4||n.push({distance:Math.sqrt(r),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),vt.prototype=Object.assign(Object.create(ce.prototype),{constructor:vt,copy:function(e){ce.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,r=t.length;n1){e.setFromMatrixPosition(n.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var i=e.distanceTo(t);r[0].object.visible=!0;for(var o=1,a=r.length;o=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;oa)){f.applyMatrix4(this.matrixWorld);var S=r.ray.origin.distanceTo(f);Sr.far||i.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else for(var b=0,x=v.length/3-1;ba)){f.applyMatrix4(this.matrixWorld);var S=r.ray.origin.distanceTo(f);Sr.far||i.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}else if(s.isGeometry)for(var E=s.vertices,T=E.length,b=0;ba)){f.applyMatrix4(this.matrixWorld);var S=r.ray.origin.distanceTo(f);Sr.far||i.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Mt.prototype=Object.assign(Object.create(_t.prototype),{constructor:Mt,isLineSegments:!0}),St.prototype=Object.create(Q.prototype),St.prototype.constructor=St,St.prototype.isPointsMaterial=!0,St.prototype.copy=function(e){return Q.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},Et.prototype=Object.assign(Object.create(ce.prototype),{constructor:Et,isPoints:!0,raycast:function(){var e=new d,t=new se,n=new ne;return function(r,i){function o(e,n){var o=t.distanceSqToPoint(e);if(or.far)return;i.push({distance:u,distanceToRay:Math.sqrt(o),point:s.clone(),index:n,face:null,object:a})}}var a=this,s=this.geometry,l=this.matrixWorld,u=r.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),n.copy(s.boundingSphere),n.applyMatrix4(l),!1!==r.ray.intersectsSphere(n)){e.getInverse(l),t.copy(r.ray).applyMatrix4(e);var d=u/((this.scale.x+this.scale.y+this.scale.z)/3),h=d*d,f=new c;if(s.isBufferGeometry){var p=s.index,m=s.attributes,g=m.position.array;if(null!==p)for(var v=p.array,y=0,b=v.length;y=-Number.EPSILON&&C>=-Number.EPSILON&&k>=-Number.EPSILON))return!1;return!0}return function(t,n){var r=t.length;if(r<3)return null;var i,o,a,s=[],l=[],u=[];if(Os.area(t)>0)for(o=0;o2;){if(d--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),n?u:s;if(i=o,c<=i&&(i=0),o=i+1,c<=o&&(o=0),a=o+1,c<=a&&(a=0),e(t,i,o,a,c,l)){var h,f,p,m,g;for(h=l[i],f=l[o],p=l[a],s.push([t[h],t[f],t[p]]),u.push([l[i],l[o],l[a]]),m=o,g=o+1;g2&&e[t-1].equals(e[0])&&e.pop()}function r(e,t,n){return e.x!==t.x?e.xNumber.EPSILON){var p;if(h>0){if(f<0||f>h)return[];if((p=u*c-l*d)<0||p>h)return[]}else{if(f>0||f0||pE?[]:x===E?o?[]:[y]:w<=E?[y,b]:[y,M]}function o(e,t,n,r){var i=t.x-e.x,o=t.y-e.y,a=n.x-e.x,s=n.y-e.y,l=r.x-e.x,u=r.y-e.y,c=i*s-o*a,d=i*u-o*l;if(Math.abs(c)>Number.EPSILON){var h=l*s-u*a;return c>0?d>=0&&h>=0:d>=0||h>=0}return d>0}n(e),t.forEach(n);for(var a,s,l,u,c,d,h={},f=e.concat(),p=0,m=t.length;p0;){if(--w<0){console.log("Infinite Loop! Holes left:"+g.length+", Probably Hole outside Shape!");break}for(a=x;ar&&(a=0);var s=o(m[e],m[i],m[a],n[t]);if(!s)return!1;var l=n.length-1,u=t-1;u<0&&(u=l);var c=t+1;return c>l&&(c=0),!!(s=o(n[t],n[u],n[c],m[e]))}(a,_)&&!function(e,t){var n,r,o;for(n=0;n0)return!0;return!1}(s,l)&&!function(e,n){var r,o,a,s,l;for(r=0;r0)return!0;return!1}(s,l)){r=_,g.splice(y,1),d=m.slice(0,a+1),h=m.slice(a),f=n.slice(r),p=n.slice(0,r+1),m=d.concat(f).concat(p).concat(h),x=a;break}if(r>=0)break;v[c]=!0}if(r>=0)break}}return m}(e,t),v=Os.triangulate(g,!1);for(a=0,s=v.length;aNumber.EPSILON){var f=Math.sqrt(d),p=Math.sqrt(u*u+c*c),m=t.x-l/f,g=t.y+s/f,v=n.x-c/p,y=n.y+u/p,b=((v-m)*c-(y-g)*u)/(s*c-l*u);r=m+s*b-e.x,o=g+l*b-e.y;var x=r*r+o*o;if(x<=2)return new i(r,o);a=Math.sqrt(x/2)}else{var w=!1;s>Number.EPSILON?u>Number.EPSILON&&(w=!0):s<-Number.EPSILON?u<-Number.EPSILON&&(w=!0):Math.sign(l)===Math.sign(c)&&(w=!0),w?(r=-l,o=s,a=Math.sqrt(d)):(r=s,o=l,a=Math.sqrt(d/2))}return new i(r/a,o/a)}function o(e,t){var n,r;for(H=e.length;--H>=0;){n=H,r=H-1,r<0&&(r=e.length-1);var i=0,o=w+2*y;for(i=0;i=0;z--){for(B=z/y,F=g*Math.cos(B*Math.PI/2),N=v*Math.sin(B*Math.PI/2),H=0,Y=D.length;H0||0===e.search(/^data\:image\/jpeg/);i.format=r?Oa:Pa,i.image=n,i.needsUpdate=!0,void 0!==t&&t(i)},n,r),i},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),An.prototype=Object.assign(Object.create(ce.prototype),{constructor:An,isLight:!0,copy:function(e){return ce.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=ce.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Rn.prototype=Object.assign(Object.create(An.prototype),{constructor:Rn,isHemisphereLight:!0,copy:function(e){return An.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(Ln.prototype,{copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),In.prototype=Object.assign(Object.create(Ln.prototype),{constructor:In,isSpotLightShadow:!0,update:function(e){var t=2*fs.RAD2DEG*e.angle,n=this.mapSize.width/this.mapSize.height,r=e.distance||500,i=this.camera;t===i.fov&&n===i.aspect&&r===i.far||(i.fov=t,i.aspect=n,i.far=r,i.updateProjectionMatrix())}}),Dn.prototype=Object.assign(Object.create(An.prototype),{constructor:Dn,isSpotLight:!0,copy:function(e){return An.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),zn.prototype=Object.assign(Object.create(An.prototype),{constructor:zn,isPointLight:!0,copy:function(e){return An.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),Nn.prototype=Object.assign(Object.create(Ln.prototype),{constructor:Nn}),Bn.prototype=Object.assign(Object.create(An.prototype),{constructor:Bn,isDirectionalLight:!0,copy:function(e){return An.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Fn.prototype=Object.assign(Object.create(An.prototype),{constructor:Fn,isAmbientLight:!0});var Is={arraySlice:function(e,t,n){return Is.isTypedArray(e)?new e.constructor(e.subarray(t,n)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&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,n){return e[t]-e[n]}for(var n=e.length,r=new Array(n),i=0;i!==n;++i)r[i]=i;return r.sort(t),r},sortedArray:function(e,t,n){for(var r=e.length,i=new e.constructor(r),o=0,a=0;a!==r;++o)for(var s=n[o]*t,l=0;l!==t;++l)i[a++]=e[s+l];return i},flattenJSON:function(e,t,n,r){for(var i=1,o=e[0];void 0!==o&&void 0===o[r];)o=e[i++];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),n.push.apply(n,a)),o=e[i++]}while(void 0!==o);else if(void 0!==a.toArray)do{a=o[r],void 0!==a&&(t.push(o.time),a.toArray(n,n.length)),o=e[i++]}while(void 0!==o);else do{a=o[r],void 0!==a&&(t.push(o.time),n.push(a)),o=e[i++]}while(void 0!==o)}}};Un.prototype={constructor:Un,evaluate:function(e){var t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];e:{t:{var o;n:{r:if(!(e=i)break e;var s=t[1];e=i)break t}o=n,n=0}}for(;n>>1;et;)--o;if(++o,0!==i||o!==r){i>=o&&(o=Math.max(o,1),i=o-1);var a=this.getValueSize();this.times=Is.arraySlice(n,i,o),this.values=Is.arraySlice(this.values,i*a,o*a)}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 n=this.times,r=this.values,i=n.length;0===i&&(console.error("track is empty",this),e=!1);for(var o=null,a=0;a!==i;a++){var s=n[a];if("number"==typeof s&&isNaN(s)){console.error("time is not a valid number",this,a,s),e=!1;break}if(null!==o&&o>s){console.error("out of order keys",this,a,s,o),e=!1;break}o=s}if(void 0!==r&&Is.isTypedArray(r))for(var a=0,l=r.length;a!==l;++a){var u=r[a];if(isNaN(u)){console.error("value is not a valid number",this,a,u),e=!1;break}}return e},optimize:function(){for(var e=this.times,t=this.values,n=this.getValueSize(),r=this.getInterpolation()===Ka,i=1,o=e.length-1,a=1;a0){e[i]=e[o];for(var p=o*n,m=i*n,h=0;h!==n;++h)t[m+h]=t[p+h];++i}return i!==e.length&&(this.times=Is.arraySlice(e,0,i),this.values=Is.arraySlice(t,0,i*n)),this}},Hn.prototype=Object.assign(Object.create(Ds),{constructor:Hn,ValueTypeName:"vector"}),Yn.prototype=Object.assign(Object.create(Un.prototype),{constructor:Yn,interpolate_:function(e,t,n,r){for(var i=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=(n-t)/(r-t),c=s+a;s!==c;s+=4)u.slerpFlat(i,0,o,s-a,o,s,l);return i}}),qn.prototype=Object.assign(Object.create(Ds),{constructor:qn,ValueTypeName:"quaternion",DefaultInterpolation:Za,InterpolantFactoryMethodLinear:function(e){return new Yn(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),Xn.prototype=Object.assign(Object.create(Ds),{constructor:Xn,ValueTypeName:"number"}),Zn.prototype=Object.assign(Object.create(Ds),{constructor:Zn,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Xa,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Kn.prototype=Object.assign(Object.create(Ds),{constructor:Kn,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Xa,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Jn.prototype=Object.assign(Object.create(Ds),{constructor:Jn,ValueTypeName:"color"}),Qn.prototype=Ds,Ds.constructor=Qn,Object.assign(Qn,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=Qn._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){var n=[],r=[];Is.flattenJSON(e.keys,n,r,"value"),e.times=n,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,n=e.constructor;if(void 0!==n.toJSON)t=n.toJSON(e);else{t={name:e.name,times:Is.convertArray(e.times,Array),values:Is.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 Xn;case"vector":case"vector2":case"vector3":case"vector4":return Hn;case"color":return Jn;case"quaternion":return qn;case"bool":case"boolean":return Kn;case"string":return Zn}throw new Error("Unsupported typeName: "+e)}}),$n.prototype={constructor:$n,resetDuration:function(){for(var e=this.tracks,t=0,n=0,r=e.length;n!==r;++n){var i=this.tracks[n];t=Math.max(t,i.times[i.times.length-1])}this.duration=t},trim:function(){for(var e=0;e1){var u=l[1],c=r[u];c||(r[u]=c=[]),c.push(s)}}var d=[];for(var u in r)d.push($n.CreateFromMorphTargetSequence(u,r[u],t,n));return d},parseAnimation:function(e,t){if(!e)return console.error(" no animation in JSONLoader data"),null;for(var n=function(e,t,n,r,i){if(0!==n.length){var o=[],a=[];Is.flattenJSON(n,o,a,r),0!==o.length&&i.push(new e(t,o,a))}},r=[],i=e.name||"default",o=e.length||-1,a=e.fps||30,s=e.hierarchy||[],l=0;l1?e.skinWeights[r+1]:0,l=t>2?e.skinWeights[r+2]:0,u=t>3?e.skinWeights[r+3]:0;n.skinWeights.push(new a(o,s,l,u))}if(e.skinIndices)for(var r=0,i=e.skinIndices.length;r1?e.skinIndices[r+1]:0,h=t>2?e.skinIndices[r+2]:0,f=t>3?e.skinIndices[r+3]:0;n.skinIndices.push(new a(c,d,h,f))}n.bones=e.bones,n.bones&&n.bones.length>0&&(n.skinWeights.length!==n.skinIndices.length||n.skinIndices.length!==n.vertices.length)&&console.warn("When skinning, number of vertices ("+n.vertices.length+"), skinIndices ("+n.skinIndices.length+"), and skinWeights ("+n.skinWeights.length+") should match.")}(),function(t){if(void 0!==e.morphTargets)for(var r=0,i=e.morphTargets.length;r0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var d=n.faces,h=e.morphColors[0].colors,r=0,i=d.length;r0&&(n.animations=t)}(),n.computeFaceNormals(),n.computeBoundingSphere(),void 0===e.materials||0===e.materials.length)return{geometry:n};var o=nr.prototype.initMaterials(e.materials,t,this.crossOrigin);return{geometry:n,materials:o}}}),Object.assign(ir.prototype,{load:function(e,t,n,r){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var i=this;new En(i.manager).load(e,function(n){var o=null;try{o=JSON.parse(n)}catch(t){return void 0!==r&&r(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var a=o.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead.");i.parse(o,t)},n,r)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var n=this.parseGeometries(e.geometries),r=this.parseImages(e.images,function(){void 0!==t&&t(a)}),i=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,i),a=this.parseObject(e.object,n,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 n=new rr,r=new tr,i=0,o=e.length;i0){var i=new Sn(t),o=new Cn(i);o.setCrossOrigin(this.crossOrigin);for(var a=0,s=e.length;a0?new xt(s,l):new Pe(s,l);break;case"LOD":a=new vt;break;case"Line":a=new _t(i(t.geometry),o(t.material),t.mode);break;case"LineSegments":a=new Mt(i(t.geometry),o(t.material));break;case"PointCloud":case"Points":a=new Et(i(t.geometry),o(t.material));break;case"Sprite":a=new gt(o(t.material));break;case"Group":a=new Tt;break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh type. Instantiates Object3D instead.");default:a=new ce}if(a.uuid=t.uuid,void 0!==t.name&&(a.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(a.position,a.quaternion,a.scale)):(void 0!==t.position&&a.position.fromArray(t.position),void 0!==t.rotation&&a.rotation.fromArray(t.rotation),void 0!==t.quaternion&&a.quaternion.fromArray(t.quaternion),void 0!==t.scale&&a.scale.fromArray(t.scale)),void 0!==t.castShadow&&(a.castShadow=t.castShadow),void 0!==t.receiveShadow&&(a.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(a.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(a.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&a.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(a.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(a.visible=t.visible),void 0!==t.userData&&(a.userData=t.userData),void 0!==t.children)for(var u in t.children)a.add(this.parseObject(t.children[u],n,r));if("LOD"===t.type)for(var c=t.levels,d=0;d0)){l=i;break}l=i-1}if(i=l,r[i]===n){var u=i/(o-1);return u}var c=r[i],d=r[i+1],h=d-c,f=(n-c)/h,u=(i+f)/(o-1);return u},getTangent:function(e){var t=e-1e-4,n=e+1e-4;t<0&&(t=0),n>1&&(n=1);var r=this.getPoint(t);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,r,i,o=new c,a=[],s=[],l=[],u=new c,h=new d;for(n=0;n<=e;n++)r=n/e,a[n]=this.getTangentAt(r),a[n].normalize();s[0]=new c,l[0]=new c;var f=Number.MAX_VALUE,p=Math.abs(a[0].x),m=Math.abs(a[0].y),g=Math.abs(a[0].z);for(p<=f&&(f=p,o.set(1,0,0)),m<=f&&(f=m,o.set(0,1,0)),g<=f&&o.set(0,0,1),u.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],u),l[0].crossVectors(a[0],s[0]),n=1;n<=e;n++)s[n]=s[n-1].clone(),l[n]=l[n-1].clone(),u.crossVectors(a[n-1],a[n]),u.length()>Number.EPSILON&&(u.normalize(),i=Math.acos(fs.clamp(a[n-1].dot(a[n]),-1,1)),s[n].applyMatrix4(h.makeRotationAxis(u,i))),l[n].crossVectors(a[n],s[n]);if(!0===t)for(i=Math.acos(fs.clamp(s[0].dot(s[e]),-1,1)),i/=e,a[0].dot(u.crossVectors(s[0],s[e]))>0&&(i=-i),n=1;n<=e;n++)s[n].applyMatrix4(h.makeRotationAxis(a[n],i*n)),l[n].crossVectors(a[n],s[n]);return{tangents:a,normals:s,binormals:l}}},gr.prototype=Object.create(mr.prototype),gr.prototype.constructor=gr,gr.prototype.isLineCurve=!0,gr.prototype.getPoint=function(e){if(1===e)return this.v2.clone();var t=this.v2.clone().sub(this.v1);return t.multiplyScalar(e).add(this.v1),t},gr.prototype.getPointAt=function(e){return this.getPoint(e)},gr.prototype.getTangent=function(e){return this.v2.clone().sub(this.v1).normalize()},vr.prototype=Object.assign(Object.create(mr.prototype),{constructor:vr,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new gr(t,e))},getPoint:function(e){for(var t=e*this.getLength(),n=this.getCurveLengths(),r=0;r=t){var i=n[r]-t,o=this.curves[r],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},createPointsGeometry:function(e){var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){for(var t=new Ce,n=0,r=e.length;nt;)n-=t;nt.length-2?t.length-1:r+1],u=t[r>t.length-3?t.length-1:r+2];return new i(or(o,a.x,s.x,l.x,u.x),or(o,a.y,s.y,l.y,u.y))},xr.prototype=Object.create(mr.prototype),xr.prototype.constructor=xr,xr.prototype.getPoint=function(e){var t=this.v0,n=this.v1,r=this.v2,o=this.v3;return new i(pr(e,t.x,n.x,r.x,o.x),pr(e,t.y,n.y,r.y,o.y))},wr.prototype=Object.create(mr.prototype),wr.prototype.constructor=wr,wr.prototype.getPoint=function(e){var t=this.v0,n=this.v1,r=this.v2;return new i(ur(e,t.x,n.x,r.x),ur(e,t.y,n.y,r.y))};var zs=Object.assign(Object.create(vr.prototype),{fromPoints:function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,n=e.length;t0){var u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);var c=l.getPoint(1);this.currentPoint.copy(c)}});_r.prototype=zs,zs.constructor=_r,Mr.prototype=Object.assign(Object.create(zs),{constructor:Mr,getPointsHoles:function(e){for(var t=[],n=0,r=this.holes.length;n1){for(var v=!1,y=[],b=0,x=h.length;bNumber.EPSILON){if(u<0&&(a=t[o],l=-l,s=t[i],u=-u),e.ys.y)continue;if(e.y===a.y){if(e.x===a.x)return!0}else{var c=u*(e.x-a.x)-l*(e.y-a.y);if(0===c)return!0;if(c<0)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})(M.p,h[E].p)&&(b!==E&&y.push({froms:b,tos:E,hole:_}),S?(S=!1,d[E].push(M)):v=!0);S&&d[b].push(M)}y.length>0&&(v||(f=d))}for(var T,m=0,k=h.length;m0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var o=0;o!==i;++o)e[t+o]=e[n+o]},_slerp:function(e,t,n,r,i){u.slerpFlat(e,t,e,t,e,n,r)},_lerp:function(e,t,n,r,i){for(var o=1-r,a=0;a!==i;++a){var s=t+a;e[s]=e[s]*o+e[n+a]*r}}},zr.prototype={constructor:zr,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,n=t.objectName,r=t.propertyName,i=t.propertyIndex;if(e||(e=zr.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(n){var o=t.objectIndex;switch(n){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 a=0;a=n){var d=n++,h=t[d];r[h.uuid]=c,t[c]=h,r[u]=d,t[d]=l;for(var f=0,p=o;f!==p;++f){var m=i[f],g=m[d],v=m[c];m[c]=g,m[d]=v}}}this.nCachedObjects_=n},uncache:function(e){for(var t=this._objects,n=t.length,r=this.nCachedObjects_,i=this._indicesByUUID,o=this._bindings,a=o.length,s=0,l=arguments.length;s!==l;++s){var u=arguments[s],c=u.uuid,d=i[c];if(void 0!==d)if(delete i[c],d0)for(var l=this._interpolants,u=this._propertyBindings,c=0,d=l.length;c!==d;++c)l[c].evaluate(a),u[c].accumulate(r,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(e)[0];t*=r,e>n.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 n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var n=this._clip.duration,r=this.loop,i=this._loopCount;if(r===Ha){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=n)t=n;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{var o=r===qa;if(-1===i&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),t>=n||t<0){var a=Math.floor(t/n);t-=n*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?n:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(0===s){var l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=t,n-t}return this.time=t,t},_setEndings:function(e,t,n){var r=this._interpolantSettings;n?(r.endingStart=Qa,r.endingEnd=Qa):(r.endingStart=e?this.zeroSlopeAtStart?Qa:Ja:$a,r.endingEnd=t?this.zeroSlopeAtEnd?Qa:Ja:$a)},_scheduleFading:function(e,t,n){var r=this._mixer,i=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=t,a[1]=i+e,s[1]=n,this}},Fr.prototype={constructor:Fr,clipAction:function(e,t){var n=t||this._root,r=n.uuid,i="string"==typeof e?$n.findByName(n,e):e,o=null!==i?i.uuid:e,a=this._actionsByClip[o],s=null;if(void 0!==a){var l=a.actionByRoot[r];if(void 0!==l)return l;s=a.knownActions[0],null===i&&(i=s._clip)}if(null===i)return null;var u=new Br(this,i,t);return this._bindAction(u,s),this._addInactiveAction(u,o,r),u},existingAction:function(e,t){var n=t||this._root,r=n.uuid,i="string"==typeof e?$n.findByName(n,e):e,o=i?i.uuid:e,a=this._actionsByClip[o];return void 0!==a?a.actionByRoot[r]||null:null},stopAllAction:function(){var e=this._actions,t=this._nActiveActions,n=this._bindings,r=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var i=0;i!==t;++i)e[i].reset();for(var i=0;i!==r;++i)n[i].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),o=this._accuIndex^=1,a=0;a!==n;++a){var s=t[a];s.enabled&&s._update(r,e,i,o)}for(var l=this._bindings,u=this._nActiveBindings,a=0;a!==u;++a)l[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(e){var t=this._actions,n=e.uuid,r=this._actionsByClip,i=r[n];if(void 0!==i){for(var o=i.knownActions,a=0,s=o.length;a!==s;++a){var l=o[a];this._deactivateAction(l);var u=l._cacheIndex,c=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=u,t[u]=c,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[n]}},uncacheRoot:function(e){var t=e.uuid,n=this._actionsByClip;for(var r in n){var i=n[r].actionByRoot,o=i[t];void 0!==o&&(this._deactivateAction(o),this._removeInactiveAction(o))}var a=this._bindingsByRootAndName,s=a[t];if(void 0!==s)for(var l in s){var u=s[l];u.restoreOriginalState(),this._removeInactiveBinding(u)}},uncacheAction:function(e,t){var n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Object.assign(Fr.prototype,{_bindAction:function(e,t){var n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,o=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName,u=l[s];void 0===u&&(u={},l[s]=u);for(var c=0;c!==i;++c){var d=r[c],h=d.name,f=u[h];if(void 0!==f)o[c]=f;else{if(void 0!==(f=o[c])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,h));continue}var p=t&&t._propertyBindings[c].binding.parsedPath;f=new Dr(zr.create(n,h,p),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,s,h),o[c]=f}a[c].resultBuffer=f.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}for(var i=e._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,r=t.length;n!==r;++n){var i=t[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}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&&t1){var u=l[1];r[u]||(r[u]={start:1/0,end:-1/0});var c=r[u];oc.end&&(c.end=o),t||(t=u)}}for(var u in r){var c=r[u];this.createAnimation(u,c.start,c.end,e)}this.firstAnimation=t},Qr.prototype.setAnimationDirectionForward=function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},Qr.prototype.setAnimationDirectionBackward=function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},Qr.prototype.setAnimationFPS=function(e,t){var n=this.animationsMap[e];n&&(n.fps=t,n.duration=(n.end-n.start)/n.fps)},Qr.prototype.setAnimationDuration=function(e,t){var n=this.animationsMap[e];n&&(n.duration=t,n.fps=(n.end-n.start)/n.duration)},Qr.prototype.setAnimationWeight=function(e,t){var n=this.animationsMap[e];n&&(n.weight=t)},Qr.prototype.setAnimationTime=function(e,t){var n=this.animationsMap[e];n&&(n.time=t)},Qr.prototype.getAnimationTime=function(e){var t=0,n=this.animationsMap[e];return n&&(t=n.time),t},Qr.prototype.getAnimationDuration=function(e){var t=-1,n=this.animationsMap[e];return n&&(t=n.duration),t},Qr.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()")},Qr.prototype.stopAnimation=function(e){var t=this.animationsMap[e];t&&(t.active=!1)},Qr.prototype.update=function(e){for(var t=0,n=this.animationsList.length;tr.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 o=r.start+fs.clamp(Math.floor(r.time/i),0,r.length-1),a=r.weight;o!==r.currentFrame&&(this.morphTargetInfluences[r.lastFrame]=0,this.morphTargetInfluences[r.currentFrame]=1*a,this.morphTargetInfluences[o]=0,r.lastFrame=r.currentFrame,r.currentFrame=o);var s=r.time%i/i;r.directionBackwards&&(s=1-s),r.currentFrame!==r.lastFrame?(this.morphTargetInfluences[r.currentFrame]=s*a,this.morphTargetInfluences[r.lastFrame]=(1-s)*a):this.morphTargetInfluences[r.currentFrame]=a}}},$r.prototype=Object.create(ce.prototype),$r.prototype.constructor=$r,$r.prototype.isImmediateRenderObject=!0,ei.prototype=Object.create(Mt.prototype),ei.prototype.constructor=ei,ei.prototype.update=function(){var e=new c,t=new c,n=new re;return function(){var r=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,l=a.faces,u=0,c=0,d=l.length;c.99999?this.quaternion.set(0,0,0,1):n.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(n.z,0,-n.x).normalize(),e=Math.acos(n.y),this.quaternion.setFromAxisAngle(t,e))}}(),hi.prototype.setLength=function(e,t,n){void 0===t&&(t=.2*e),void 0===n&&(n=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()},hi.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},fi.prototype=Object.create(Mt.prototype),fi.prototype.constructor=fi;var js=new c,Ws=new pi,Vs=new pi,Gs=new pi;mi.prototype=Object.create(mr.prototype),mi.prototype.constructor=mi,mi.prototype.getPoint=function(e){var t=this.points,n=t.length;n<2&&console.log("duh, you need at least 2 points");var r=(n-(this.closed?0:1))*e,i=Math.floor(r),o=r-i;this.closed?i+=i>0?0:(Math.floor(Math.abs(i)/t.length)+1)*t.length:0===o&&i===n-1&&(i=n-2,o=1);var a,s,l,u;if(this.closed||i>0?a=t[(i-1)%n]:(js.subVectors(t[0],t[1]).add(t[0]),a=js),s=t[i%n],l=t[(i+1)%n],this.closed||i+26?l-6:0),c=6;c>",s=s||r,null==i[r]){if(e){var n=null===i[r]?"null":"undefined";return new Error("The "+o+" `"+s+"` is marked as required in `"+a+"`, but its value is `"+n+"`.")}return null}return t.apply(void 0,[i,r,a,o,s].concat(u))})}var i=e.bind(null,!1);return i.isRequired=e.bind(null,!0),i}function r(t,e){return"symbol"===t||("Symbol"===e["@@toStringTag"]||"function"==typeof Symbol&&e instanceof Symbol)}function a(t){var e=void 0===t?"undefined":k(t);return Array.isArray(t)?"array":t instanceof RegExp?"object":r(e,t)?"symbol":e}function o(t){var e=a(t);if("object"===e){if(t instanceof Date)return"date";if(t instanceof RegExp)return"regexp"}return e}function s(t,e){return i(function(i,r,s,l,u){return n.i(w.untracked)(function(){if(t&&a(i[r])===e.toLowerCase())return null;var n=void 0;switch(e){case"Array":n=w.isObservableArray;break;case"Object":n=w.isObservableObject;break;case"Map":n=w.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+e)}var l=i[r];if(!n(l)){var c=o(l),h=t?" or javascript `"+e.toLowerCase()+"`":"";return new Error("Invalid prop `"+u+"` of type `"+c+"` supplied to `"+s+"`, expected `mobx.Observable"+e+"`"+h+".")}return null})})}function l(t,e){return i(function(i,r,a,o,l){for(var u=arguments.length,c=Array(u>5?u-5:0),h=5;h2&&void 0!==arguments[2]&&arguments[2],i=t[e],r=it[e],a=i?!0===n?function(){r.apply(this,arguments),i.apply(this,arguments)}:function(){i.apply(this,arguments),r.apply(this,arguments)}:r;t[e]=a}function y(t,e){if(b(t,e))return!0;if("object"!==(void 0===t?"undefined":k(t))||null===t||"object"!==(void 0===e?"undefined":k(e))||null===e)return!1;var n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(var r=0;r",i=this._reactInternalInstance&&this._reactInternalInstance._rootNodeID||this._reactInternalFiber&&this._reactInternalFiber._debugID,r=!1,a=!1;t.call(this,"props"),t.call(this,"state");var o=this.render.bind(this),s=null,l=!1,u=function(){return s=new w.Reaction(n+"#"+i+".render()",function(){if(!l&&(l=!0,"function"==typeof e.componentWillReact&&e.componentWillReact(),!0!==e.__$mobxIsUnmounted)){var t=!0;try{a=!0,r||M.Component.prototype.forceUpdate.call(e),t=!1}finally{a=!1,t&&s.dispose()}}}),s.reactComponent=e,c.$mobx=s,e.render=c,c()},c=function(){l=!1;var t=void 0,n=void 0;if(s.track(function(){Q&&(e.__$mobRenderStart=Date.now());try{n=w.extras.allowStateChanges(!1,o)}catch(e){t=e}Q&&(e.__$mobRenderEnd=Date.now())}),t)throw nt.emit(t),t;return n};this.render=u}},componentWillUnmount:function(){if(!0!==J&&(this.render.$mobx&&this.render.$mobx.dispose(),this.__$mobxIsUnmounted=!0,Q)){var t=f(this);t&&tt&&tt.delete(t),et.emit({event:"destroy",component:this,node:t})}},componentDidMount:function(){Q&&p(this)},componentDidUpdate:function(){Q&&p(this)},shouldComponentUpdate:function(t,e){return J&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==e||!y(this.props,t)}},rt=x(function(t){var e=t.children,n=t.inject,i=t.render,r=e||i;if(void 0===r)return null;if(!n)return r();var a=d(n)(r);return S.a.createElement(a,null)});rt.displayName="Observer";var at=function(t,e,n,i,r){var a="children"===e?"render":"children";if("function"==typeof t[e]&&"function"==typeof t[a])return new Error("Invalid prop,do not use children and render in the same time in`"+n);if("function"!=typeof t[e]&&"function"!=typeof t[a])return new Error("Invalid prop `"+r+"` of type `"+k(t[e])+"` supplied to `"+n+"`, expected `function`.")};rt.propTypes={render:at,children:at};var ot,st,lt={children:!0,key:!0,ref:!0},ut=(st=ot=function(t){function e(){return T(this,e),P(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return O(e,t),C(e,[{key:"render",value:function(){return M.Children.only(this.props.children)}},{key:"getChildContext",value:function(){var t={},e=this.context.mobxStores;if(e)for(var n in e)t[n]=e[n];for(var i in this.props)lt[i]||"suppressChangedStoreWarning"===i||(t[i]=this.props[i]);return{mobxStores:t}}},{key:"componentWillReceiveProps",value:function(t){if(Object.keys(t).length!==Object.keys(this.props).length&&console.warn("MobX Provider: The set of provided stores has changed. Please avoid changing stores as the change might not propagate to all children"),!t.suppressChangedStoreWarning)for(var e in t)lt[e]||this.props[e]===t[e]||console.warn("MobX Provider: Provided store '"+e+"' has changed. Please avoid replacing stores as the change might not propagate to all children")}}]),e}(M.Component),ot.contextTypes={mobxStores:q},ot.childContextTypes={mobxStores:q.isRequired},st);if(!M.Component)throw new Error("mobx-react requires React to be available");if(!w.extras)throw new Error("mobx-react requires mobx to be available");"function"==typeof E.unstable_batchedUpdates&&w.extras.setReactionScheduler(E.unstable_batchedUpdates);var ct=function(t){return nt.on(t)};if("object"===("undefined"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__?"undefined":k(__MOBX_DEVTOOLS_GLOBAL_HOOK__))){var ht={spy:w.spy,extras:w.extras},dt={renderReporter:et,componentByNodeRegistery:tt,trackComponents:m};__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobxReact(dt,ht)}},function(t,e,n){"use strict";var i=n(6);t.exports={_set:function(t,e){return i.merge(this[t]||(this[t]={}),e)}}},function(t,e,n){"use strict";var i=n(7),r=n(57);e.a=function(t){return Math.abs(t)<=i.c?t:t-n.i(r.a)(t)*i.e}},function(t,e){var n=t.exports={version:"2.5.3"};"number"==typeof __e&&(__e=n)},function(t,e,n){"use strict";function i(){}function r(t,e){this.x=t||0,this.y=e||0}function a(t,e,n,i,o,s,l,u,c,h){Object.defineProperty(this,"id",{value:ps++}),this.uuid=fs.generateUUID(),this.name="",this.image=void 0!==t?t:a.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:a.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:so,this.wrapT=void 0!==i?i:so,this.magFilter=void 0!==o?o:fo,this.minFilter=void 0!==s?s:mo,this.anisotropy=void 0!==c?c:1,this.format=void 0!==l?l:Po,this.type=void 0!==u?u:go,this.offset=new r(0,0),this.repeat=new r(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:is,this.version=0,this.onUpdate=null}function o(t,e,n,i){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==i?i:1}function s(t,e,n){this.uuid=fs.generateUUID(),this.width=t,this.height=e,this.scissor=new o(0,0,t,e),this.scissorTest=!1,this.viewport=new o(0,0,t,e),n=n||{},void 0===n.minFilter&&(n.minFilter=fo),this.texture=new a(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function l(t,e,n){s.call(this,t,e,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function u(t,e,n,i){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==i?i:1}function c(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}function h(){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.")}function d(t,e,n,i,r,o,s,l,u,c){t=void 0!==t?t:[],e=void 0!==e?e:$a,a.call(this,t,e,n,i,r,o,s,l,u,c),this.flipY=!1}function f(){this.seq=[],this.map={}}function p(t,e,n){var i=t[0];if(i<=0||i>0)return t;var r=e*n,a=vs[r];if(void 0===a&&(a=new Float32Array(r),vs[r]=a),0!==e){i.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function m(t,e){var n=ys[e];void 0===n&&(n=new Int32Array(e),ys[e]=n);for(var i=0;i!==e;++i)n[i]=t.allocTextureUnit();return n}function g(t,e){t.uniform1f(this.addr,e)}function v(t,e){t.uniform1i(this.addr,e)}function y(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function b(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function x(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function _(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function w(t,e){t.uniformMatrix3fv(this.addr,!1,e.elements||e)}function M(t,e){t.uniformMatrix4fv(this.addr,!1,e.elements||e)}function S(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTexture2D(e||ms,i)}function E(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTextureCube(e||gs,i)}function k(t,e){t.uniform2iv(this.addr,e)}function T(t,e){t.uniform3iv(this.addr,e)}function C(t,e){t.uniform4iv(this.addr,e)}function O(t){switch(t){case 5126:return g;case 35664:return y;case 35665:return b;case 35666:return x;case 35674:return _;case 35675:return w;case 35676:return M;case 35678:return S;case 35680:return E;case 5124:case 35670:return v;case 35667:case 35671:return k;case 35668:case 35672:return T;case 35669:case 35673:return C}}function P(t,e){t.uniform1fv(this.addr,e)}function A(t,e){t.uniform1iv(this.addr,e)}function R(t,e){t.uniform2fv(this.addr,p(e,this.size,2))}function L(t,e){t.uniform3fv(this.addr,p(e,this.size,3))}function I(t,e){t.uniform4fv(this.addr,p(e,this.size,4))}function D(t,e){t.uniformMatrix2fv(this.addr,!1,p(e,this.size,4))}function N(t,e){t.uniformMatrix3fv(this.addr,!1,p(e,this.size,9))}function z(t,e){t.uniformMatrix4fv(this.addr,!1,p(e,this.size,16))}function B(t,e,n){var i=e.length,r=m(n,i);t.uniform1iv(this.addr,r);for(var a=0;a!==i;++a)n.setTexture2D(e[a]||ms,r[a])}function F(t,e,n){var i=e.length,r=m(n,i);t.uniform1iv(this.addr,r);for(var a=0;a!==i;++a)n.setTextureCube(e[a]||gs,r[a])}function U(t){switch(t){case 5126:return P;case 35664:return R;case 35665:return L;case 35666:return I;case 35674:return D;case 35675:return N;case 35676:return z;case 35678:return B;case 35680:return F;case 5124:case 35670:return A;case 35667:case 35671:return k;case 35668:case 35672:return T;case 35669:case 35673:return C}}function j(t,e,n){this.id=t,this.addr=n,this.setValue=O(e.type)}function W(t,e,n){this.id=t,this.addr=n,this.size=e.size,this.setValue=U(e.type)}function G(t){this.id=t,f.call(this)}function V(t,e){t.seq.push(e),t.map[e.id]=e}function H(t,e,n){var i=t.name,r=i.length;for(bs.lastIndex=0;;){var a=bs.exec(i),o=bs.lastIndex,s=a[1],l="]"===a[2],u=a[3];if(l&&(s|=0),void 0===u||"["===u&&o+2===r){V(n,void 0===u?new j(s,t,e):new W(s,t,e));break}var c=n.map,h=c[s];void 0===h&&(h=new G(s),V(n,h)),n=h}}function Y(t,e,n){f.call(this),this.renderer=n;for(var i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r.001&&A.scale>.001&&(M.x=A.x,M.y=A.y,M.z=A.z,_=A.size*A.scale/g.w,w.x=_*y,w.y=_,p.uniform3f(h.screenPosition,M.x,M.y,M.z),p.uniform2f(h.scale,w.x,w.y),p.uniform1f(h.rotation,A.rotation),p.uniform1f(h.opacity,A.opacity),p.uniform3f(h.color,A.color.r,A.color.g,A.color.b),m.setBlending(A.blending,A.blendEquation,A.blendSrc,A.blendDst),t.setTexture2D(A.texture,1),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0))}}}m.enable(p.CULL_FACE),m.enable(p.DEPTH_TEST),m.setDepthWrite(!0),t.resetGLState()}}}function Q(t,e){function n(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),e=new Uint16Array([0,1,2,0,2,3]);o=p.createBuffer(),s=p.createBuffer(),p.bindBuffer(p.ARRAY_BUFFER,o),p.bufferData(p.ARRAY_BUFFER,t,p.STATIC_DRAW),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,s),p.bufferData(p.ELEMENT_ARRAY_BUFFER,e,p.STATIC_DRAW),l=i(),h={position:p.getAttribLocation(l,"position"),uv:p.getAttribLocation(l,"uv")},d={uvOffset:p.getUniformLocation(l,"uvOffset"),uvScale:p.getUniformLocation(l,"uvScale"),rotation:p.getUniformLocation(l,"rotation"),scale:p.getUniformLocation(l,"scale"),color:p.getUniformLocation(l,"color"),map:p.getUniformLocation(l,"map"),opacity:p.getUniformLocation(l,"opacity"),modelViewMatrix:p.getUniformLocation(l,"modelViewMatrix"),projectionMatrix:p.getUniformLocation(l,"projectionMatrix"),fogType:p.getUniformLocation(l,"fogType"),fogDensity:p.getUniformLocation(l,"fogDensity"),fogNear:p.getUniformLocation(l,"fogNear"),fogFar:p.getUniformLocation(l,"fogFar"),fogColor:p.getUniformLocation(l,"fogColor"),alphaTest:p.getUniformLocation(l,"alphaTest")};var n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");n.width=8,n.height=8;var r=n.getContext("2d");r.fillStyle="white",r.fillRect(0,0,8,8),f=new a(n),f.needsUpdate=!0}function i(){var e=p.createProgram(),n=p.createShader(p.VERTEX_SHADER),i=p.createShader(p.FRAGMENT_SHADER);return p.shaderSource(n,["precision "+t.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")),p.shaderSource(i,["precision "+t.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")),p.compileShader(n),p.compileShader(i),p.attachShader(e,n),p.attachShader(e,i),p.linkProgram(e),e}function r(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}var o,s,l,h,d,f,p=t.context,m=t.state,g=new c,v=new u,y=new c;this.render=function(i,a){if(0!==e.length){void 0===l&&n(),p.useProgram(l),m.initAttributes(),m.enableAttribute(h.position),m.enableAttribute(h.uv),m.disableUnusedAttributes(),m.disable(p.CULL_FACE),m.enable(p.BLEND),p.bindBuffer(p.ARRAY_BUFFER,o),p.vertexAttribPointer(h.position,2,p.FLOAT,!1,16,0),p.vertexAttribPointer(h.uv,2,p.FLOAT,!1,16,8),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,s),p.uniformMatrix4fv(d.projectionMatrix,!1,a.projectionMatrix.elements),m.activeTexture(p.TEXTURE0),p.uniform1i(d.map,0);var u=0,c=0,b=i.fog;b?(p.uniform3f(d.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(p.uniform1f(d.fogNear,b.near),p.uniform1f(d.fogFar,b.far),p.uniform1i(d.fogType,1),u=1,c=1):b.isFogExp2&&(p.uniform1f(d.fogDensity,b.density),p.uniform1i(d.fogType,2),u=2,c=2)):(p.uniform1i(d.fogType,0),u=0,c=0);for(var x=0,_=e.length;x<_;x++){var w=e[x];w.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,w.matrixWorld),w.z=-w.modelViewMatrix.elements[14]}e.sort(r);for(var M=[],x=0,_=e.length;x<_;x++){var w=e[x],S=w.material;if(!1!==S.visible){p.uniform1f(d.alphaTest,S.alphaTest),p.uniformMatrix4fv(d.modelViewMatrix,!1,w.modelViewMatrix.elements),w.matrixWorld.decompose(g,v,y),M[0]=y.x,M[1]=y.y;var E=0;i.fog&&S.fog&&(E=c),u!==E&&(p.uniform1i(d.fogType,E),u=E),null!==S.map?(p.uniform2f(d.uvOffset,S.map.offset.x,S.map.offset.y),p.uniform2f(d.uvScale,S.map.repeat.x,S.map.repeat.y)):(p.uniform2f(d.uvOffset,0,0),p.uniform2f(d.uvScale,1,1)),p.uniform1f(d.opacity,S.opacity),p.uniform3f(d.color,S.color.r,S.color.g,S.color.b),p.uniform1f(d.rotation,S.rotation),p.uniform2fv(d.scale,M),m.setBlending(S.blending,S.blendEquation,S.blendSrc,S.blendDst),m.setDepthTest(S.depthTest),m.setDepthWrite(S.depthWrite),S.map?t.setTexture2D(S.map,0):t.setTexture2D(f,0),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0)}}m.enable(p.CULL_FACE),t.resetGLState()}}}function J(){Object.defineProperty(this,"id",{value:Es++}),this.uuid=fs.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=ma,this.side=oa,this.shading=ca,this.vertexColors=ha,this.opacity=1,this.transparent=!1,this.blendSrc=Oa,this.blendDst=Pa,this.blendEquation=xa,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Fa,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this._needsUpdate=!0}function $(t){J.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function tt(t){J.call(this),this.type="MeshDepthMaterial",this.depthPacking=hs,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function et(t,e){this.min=void 0!==t?t:new c(1/0,1/0,1/0),this.max=void 0!==e?e:new c(-1/0,-1/0,-1/0)}function nt(t,e){this.center=void 0!==t?t:new c,this.radius=void 0!==e?e:0}function it(){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.")}function rt(t,e){this.normal=void 0!==t?t:new c(1,0,0),this.constant=void 0!==e?e:0}function at(t,e,n,i,r,a){this.planes=[void 0!==t?t:new rt,void 0!==e?e:new rt,void 0!==n?n:new rt,void 0!==i?i:new rt,void 0!==r?r:new rt,void 0!==a?a:new rt]}function ot(t,e,n,i){function a(e,n,i,r){var a=e.geometry,o=null,s=S,l=e.customDepthMaterial;if(i&&(s=E,l=e.customDistanceMaterial),l)o=l;else{var u=!1;n.morphTargets&&(a&&a.isBufferGeometry?u=a.morphAttributes&&a.morphAttributes.position&&a.morphAttributes.position.length>0:a&&a.isGeometry&&(u=a.morphTargets&&a.morphTargets.length>0));var c=e.isSkinnedMesh&&n.skinning,h=0;u&&(h|=_),c&&(h|=w),o=s[h]}if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var d=o.uuid,f=n.uuid,p=k[d];void 0===p&&(p={},k[d]=p);var m=p[f];void 0===m&&(m=o.clone(),p[f]=m),o=m}o.visible=n.visible,o.wireframe=n.wireframe;var g=n.side;return B.renderSingleSided&&g==la&&(g=oa),B.renderReverseSided&&(g===oa?g=sa:g===sa&&(g=oa)),o.side=g,o.clipShadows=n.clipShadows,o.clippingPlanes=n.clippingPlanes,o.wireframeLinewidth=n.wireframeLinewidth,o.linewidth=n.linewidth,i&&void 0!==o.uniforms.lightPos&&o.uniforms.lightPos.value.copy(r),o}function l(t,e,n){if(!1!==t.visible){if(0!=(t.layers.mask&e.layers.mask)&&(t.isMesh||t.isLine||t.isPoints)&&t.castShadow&&(!1===t.frustumCulled||!0===f.intersectsObject(t))){!0===t.material.visible&&(t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),x.push(t))}for(var i=t.children,r=0,a=i.length;rn&&(n=t[e]);return n}function Tt(){return Ts++}function Ct(){Object.defineProperty(this,"id",{value:Tt()}),this.uuid=fs.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Ot(){Object.defineProperty(this,"id",{value:Tt()}),this.uuid=fs.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function Pt(t,e){ct.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Ot,this.material=void 0!==e?e:new pt({color:16777215*Math.random()}),this.drawMode=ts,this.updateMorphTargets()}function At(t,e,n,i,r,a){Ct.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a},this.fromBufferGeometry(new Rt(t,e,n,i,r,a)),this.mergeVertices()}function Rt(t,e,n,i,r,a){function o(t,e,n,i,r,a,o,m,g,v,y){var b,x,_=a/g,w=o/v,M=a/2,S=o/2,E=m/2,k=g+1,T=v+1,C=0,O=0,P=new c;for(x=0;x0?1:-1,h.push(P.x,P.y,P.z),d.push(b/g),d.push(1-x/v),C+=1}}for(x=0;x");return Jt(n)}var n=/#include +<([\w\d.]+)>/g;return t.replace(n,e)}function $t(t){function e(t,e,n,i){for(var r="",a=parseInt(e);a0?t.gammaFactor:1,g=qt(a,i,t.extensions),v=Xt(o),y=r.createProgram();n.isRawShaderMaterial?(f=[v,"\n"].filter(Kt).join("\n"),p=[g,v,"\n"].filter(Kt).join("\n")):(f=["precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,v,i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+m,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexColors?"#define USE_COLOR":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+i.numClippingPlanes,i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&t.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","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Kt).join("\n"),p=[g,"precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,v,i.alphaTest?"#define ALPHATEST "+i.alphaTest:"","#define GAMMA_FACTOR "+m,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.envMap?"#define "+h:"",i.envMap?"#define "+d:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexColors?"#define USE_COLOR":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+i.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(i.numClippingPlanes-i.numClipIntersection),i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+u:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&t.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",i.envMap&&t.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",i.toneMapping!==qa?"#define TONE_MAPPING":"",i.toneMapping!==qa?_s.tonemapping_pars_fragment:"",i.toneMapping!==qa?Yt("toneMapping",i.toneMapping):"",i.outputEncoding||i.mapEncoding||i.envMapEncoding||i.emissiveMapEncoding?_s.encodings_pars_fragment:"",i.mapEncoding?Vt("mapTexelToLinear",i.mapEncoding):"",i.envMapEncoding?Vt("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Vt("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.outputEncoding?Ht("linearToOutputTexel",i.outputEncoding):"",i.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Kt).join("\n")),s=Jt(s,i),s=Qt(s,i),l=Jt(l,i),l=Qt(l,i),n.isShaderMaterial||(s=$t(s),l=$t(l));var b=f+s,x=p+l,_=Wt(r,r.VERTEX_SHADER,b),w=Wt(r,r.FRAGMENT_SHADER,x);r.attachShader(y,_),r.attachShader(y,w),void 0!==n.index0AttributeName?r.bindAttribLocation(y,0,n.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);var M=r.getProgramInfoLog(y),S=r.getShaderInfoLog(_),E=r.getShaderInfoLog(w),k=!0,T=!0;!1===r.getProgramParameter(y,r.LINK_STATUS)?(k=!1,console.error("THREE.WebGLProgram: shader error: ",r.getError(),"gl.VALIDATE_STATUS",r.getProgramParameter(y,r.VALIDATE_STATUS),"gl.getProgramInfoLog",M,S,E)):""!==M?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",M):""!==S&&""!==E||(T=!1),T&&(this.diagnostics={runnable:k,material:n,programLog:M,vertexShader:{log:S,prefix:f},fragmentShader:{log:E,prefix:p}}),r.deleteShader(_),r.deleteShader(w);var C;this.getUniforms=function(){return void 0===C&&(C=new Y(r,y,t)),C};var O;return this.getAttributes=function(){return void 0===O&&(O=Zt(r,y)),O},this.destroy=function(){r.deleteProgram(y),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=Cs++,this.code=e,this.usedTimes=1,this.program=y,this.vertexShader=_,this.fragmentShader=w,this}function ee(t,e){function n(t){if(e.floatVertexTextures&&t&&t.skeleton&&t.skeleton.useVertexTexture)return 1024;var n=e.maxVertexUniforms,i=Math.floor((n-20)/4),r=i;return void 0!==t&&t&&t.isSkinnedMesh&&(r=Math.min(t.skeleton.bones.length,r))0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:r.side===la,flipSided:r.side===sa,depthPacking:void 0!==r.depthPacking&&r.depthPacking}},this.getProgramCode=function(t,e){var n=[];if(e.shaderID?n.push(e.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),void 0!==t.defines)for(var i in t.defines)n.push(i),n.push(t.defines[i]);for(var r=0;r65535?wt:xt)(a,1);return r(p,t.ELEMENT_ARRAY_BUFFER),i.wireframe=p,p}var c=new ne(t,e,n);return{getAttributeBuffer:s,getAttributeProperties:l,getWireframeAttribute:u,update:i}}function re(t,e,n,i,r,a,o){function s(t,e){if(t.width>e||t.height>e){var n=e/Math.max(t.width,t.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=Math.floor(t.width*n),i.height=Math.floor(t.height*n);return i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height,t),i}return t}function l(t){return fs.isPowerOfTwo(t.width)&&fs.isPowerOfTwo(t.height)}function u(t){if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement){var e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");e.width=fs.nearestPowerOfTwo(t.width),e.height=fs.nearestPowerOfTwo(t.height);return e.getContext("2d").drawImage(t,0,0,e.width,e.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+e.width+"x"+e.height,t),e}return t}function c(t){return t.wrapS!==so||t.wrapT!==so||t.minFilter!==uo&&t.minFilter!==fo}function h(e){return e===uo||e===co||e===ho?t.NEAREST:t.LINEAR}function d(t){var e=t.target;e.removeEventListener("dispose",d),p(e),T.textures--}function f(t){var e=t.target;e.removeEventListener("dispose",f),m(e),T.textures--}function p(e){var n=i.get(e);if(e.image&&n.__image__webglTextureCube)t.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture)}i.delete(e)}function m(e){var n=i.get(e),r=i.get(e.texture);if(e){if(void 0!==r.__webglTexture&&t.deleteTexture(r.__webglTexture),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[a]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);i.delete(e.texture),i.delete(e)}}function g(e,r){var a=i.get(e);if(e.version>0&&a.__version!==e.version){var o=e.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==o.complete)return void x(a,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}n.activeTexture(t.TEXTURE0+r),n.bindTexture(t.TEXTURE_2D,a.__webglTexture)}function v(e,o){var u=i.get(e);if(6===e.image.length)if(e.version>0&&u.__version!==e.version){u.__image__webglTextureCube||(e.addEventListener("dispose",d),u.__image__webglTextureCube=t.createTexture(),T.textures++),n.activeTexture(t.TEXTURE0+o),n.bindTexture(t.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var c=e&&e.isCompressedTexture,h=e.image[0]&&e.image[0].isDataTexture,f=[],p=0;p<6;p++)f[p]=c||h?h?e.image[p].image:e.image[p]:s(e.image[p],r.maxCubemapSize);var m=f[0],g=l(m),v=a(e.format),y=a(e.type);b(t.TEXTURE_CUBE_MAP,e,g);for(var p=0;p<6;p++)if(c)for(var x,_=f[p].mipmaps,w=0,M=_.length;w-1?n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,w,v,x.width,x.height,0,x.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,w,v,x.width,x.height,0,v,y,x.data);else h?n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,v,f[p].width,f[p].height,0,v,y,f[p].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,v,v,y,f[p]);e.generateMipmaps&&g&&t.generateMipmap(t.TEXTURE_CUBE_MAP),u.__version=e.version,e.onUpdate&&e.onUpdate(e)}else n.activeTexture(t.TEXTURE0+o),n.bindTexture(t.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)}function y(e,r){n.activeTexture(t.TEXTURE0+r),n.bindTexture(t.TEXTURE_CUBE_MAP,i.get(e).__webglTexture)}function b(n,o,s){var l;if(s?(t.texParameteri(n,t.TEXTURE_WRAP_S,a(o.wrapS)),t.texParameteri(n,t.TEXTURE_WRAP_T,a(o.wrapT)),t.texParameteri(n,t.TEXTURE_MAG_FILTER,a(o.magFilter)),t.texParameteri(n,t.TEXTURE_MIN_FILTER,a(o.minFilter))):(t.texParameteri(n,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(n,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),o.wrapS===so&&o.wrapT===so||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",o),t.texParameteri(n,t.TEXTURE_MAG_FILTER,h(o.magFilter)),t.texParameteri(n,t.TEXTURE_MIN_FILTER,h(o.minFilter)),o.minFilter!==uo&&o.minFilter!==fo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",o)),l=e.get("EXT_texture_filter_anisotropic")){if(o.type===wo&&null===e.get("OES_texture_float_linear"))return;if(o.type===Mo&&null===e.get("OES_texture_half_float_linear"))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(t.texParameterf(n,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function x(e,i,o){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",d),e.__webglTexture=t.createTexture(),T.textures++),n.activeTexture(t.TEXTURE0+o),n.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,i.unpackAlignment);var h=s(i.image,r.maxTextureSize);c(i)&&!1===l(h)&&(h=u(h));var f=l(h),p=a(i.format),m=a(i.type);b(t.TEXTURE_2D,i,f);var g,v=i.mipmaps;if(i.isDepthTexture){var y=t.DEPTH_COMPONENT;if(i.type===wo){if(!C)throw new Error("Float Depth Texture only supported in WebGL2.0");y=t.DEPTH_COMPONENT32F}else C&&(y=t.DEPTH_COMPONENT16);i.format===Io&&y===t.DEPTH_COMPONENT&&i.type!==bo&&i.type!==_o&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=bo,m=a(i.type)),i.format===Do&&(y=t.DEPTH_STENCIL,i.type!==To&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=To,m=a(i.type))),n.texImage2D(t.TEXTURE_2D,0,y,h.width,h.height,0,p,m,null)}else if(i.isDataTexture)if(v.length>0&&f){for(var x=0,_=v.length;x<_;x++)g=v[x],n.texImage2D(t.TEXTURE_2D,x,p,g.width,g.height,0,p,m,g.data);i.generateMipmaps=!1}else n.texImage2D(t.TEXTURE_2D,0,p,h.width,h.height,0,p,m,h.data);else if(i.isCompressedTexture)for(var x=0,_=v.length;x<_;x++)g=v[x],i.format!==Po&&i.format!==Oo?n.getCompressedTextureFormats().indexOf(p)>-1?n.compressedTexImage2D(t.TEXTURE_2D,x,p,g.width,g.height,0,g.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(t.TEXTURE_2D,x,p,g.width,g.height,0,p,m,g.data);else if(v.length>0&&f){for(var x=0,_=v.length;x<_;x++)g=v[x],n.texImage2D(t.TEXTURE_2D,x,p,p,m,g);i.generateMipmaps=!1}else n.texImage2D(t.TEXTURE_2D,0,p,p,m,h);i.generateMipmaps&&f&&t.generateMipmap(t.TEXTURE_2D),e.__version=i.version,i.onUpdate&&i.onUpdate(i)}function _(e,r,o,s){var l=a(r.texture.format),u=a(r.texture.type);n.texImage2D(s,0,l,r.width,r.height,0,l,u,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,o,s,i.get(r.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function w(e,n){t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer&&!n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):n.depthBuffer&&n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,n.width,n.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function M(e,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),g(n.depthTexture,0);var r=i.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===Io)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0);else{if(n.depthTexture.format!==Do)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0)}}function S(e){var n=i.get(e),r=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");M(n.__webglFramebuffer,e)}else if(r){n.__webglDepthbuffer=[];for(var a=0;a<6;a++)t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer[a]),n.__webglDepthbuffer[a]=t.createRenderbuffer(),w(n.__webglDepthbuffer[a],e)}else t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=t.createRenderbuffer(),w(n.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}function E(e){var r=i.get(e),a=i.get(e.texture);e.addEventListener("dispose",f),a.__webglTexture=t.createTexture(),T.textures++;var o=!0===e.isWebGLRenderTargetCube,s=l(e);if(o){r.__webglFramebuffer=[];for(var u=0;u<6;u++)r.__webglFramebuffer[u]=t.createFramebuffer()}else r.__webglFramebuffer=t.createFramebuffer();if(o){n.bindTexture(t.TEXTURE_CUBE_MAP,a.__webglTexture),b(t.TEXTURE_CUBE_MAP,e.texture,s);for(var u=0;u<6;u++)_(r.__webglFramebuffer[u],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+u);e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_CUBE_MAP),n.bindTexture(t.TEXTURE_CUBE_MAP,null)}else n.bindTexture(t.TEXTURE_2D,a.__webglTexture),b(t.TEXTURE_2D,e.texture,s),_(r.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),e.texture.generateMipmaps&&s&&t.generateMipmap(t.TEXTURE_2D),n.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&S(e)}function k(e){var r=e.texture;if(r.generateMipmaps&&l(e)&&r.minFilter!==uo&&r.minFilter!==fo){var a=e&&e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,o=i.get(r).__webglTexture;n.bindTexture(a,o),t.generateMipmap(a),n.bindTexture(a,null)}}var T=o.memory,C="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext;this.setTexture2D=g,this.setTextureCube=v,this.setTextureCubeDynamic=y,this.setupRenderTarget=E,this.updateRenderTargetMipmap=k}function ae(){var t={};return{get:function(e){var n=e.uuid,i=t[n];return void 0===i&&(i={},t[n]=i),i},delete:function(e){delete t[e.uuid]},clear:function(){t={}}}}function oe(t,e,n){function i(){var e=!1,n=new o,i=null,r=new o;return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,a,o,s){!0===s&&(e*=o,i*=o,a*=o),n.set(e,i,a,o),!1===r.equals(n)&&(t.clearColor(e,i,a,o),r.copy(n))},reset:function(){e=!1,i=null,r.set(0,0,0,1)}}}function r(){var e=!1,n=null,i=null,r=null;return{setTest:function(e){e?f(t.DEPTH_TEST):p(t.DEPTH_TEST)},setMask:function(i){n===i||e||(t.depthMask(i),n=i)},setFunc:function(e){if(i!==e){if(e)switch(e){case Na:t.depthFunc(t.NEVER);break;case za:t.depthFunc(t.ALWAYS);break;case Ba:t.depthFunc(t.LESS);break;case Fa:t.depthFunc(t.LEQUAL);break;case Ua:t.depthFunc(t.EQUAL);break;case ja:t.depthFunc(t.GEQUAL);break;case Wa:t.depthFunc(t.GREATER);break;case Ga:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);i=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,n=null,i=null,r=null}}}function a(){var e=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,u=null;return{setTest:function(e){e?f(t.STENCIL_TEST):p(t.STENCIL_TEST)},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,o){i===e&&r===n&&a===o||(t.stencilFunc(e,n,o),i=e,r=n,a=o)},setOp:function(e,n,i){o===e&&s===n&&l===i||(t.stencilOp(e,n,i),o=e,s=n,l=i)},setLocked:function(t){e=t},setClear:function(e){u!==e&&(t.clearStencil(e),u=e)},reset:function(){e=!1,n=null,i=null,r=null,a=null,o=null,s=null,l=null,u=null}}}function s(e,n,i){var r=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var o=0;o=1,ct=null,ht={},dt=new o,ft=new o,pt={};return pt[t.TEXTURE_2D]=s(t.TEXTURE_2D,t.TEXTURE_2D,1),pt[t.TEXTURE_CUBE_MAP]=s(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),{buffers:{color:B,depth:F,stencil:U},init:l,initAttributes:u,enableAttribute:c,enableAttributeAndDivisor:h,disableUnusedAttributes:d,enable:f,disable:p,getCompressedTextureFormats:m,setBlending:g,setColorWrite:v,setDepthTest:y,setDepthWrite:b,setDepthFunc:x,setStencilTest:_,setStencilWrite:w,setStencilFunc:M,setStencilOp:S,setFlipSided:E,setCullFace:k,setLineWidth:T,setPolygonOffset:C,getScissorTest:O,setScissorTest:P,activeTexture:A,bindTexture:R,compressedTexImage2D:L,texImage2D:I,scissor:D,viewport:N,reset:z}}function se(t,e,n){function i(){if(void 0!==a)return a;var n=e.get("EXT_texture_filter_anisotropic");return a=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a,o=void 0!==n.precision?n.precision:"highp",s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var l=!0===n.logarithmicDepthBuffer&&!!e.get("EXT_frag_depth"),u=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),c=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=t.getParameter(t.MAX_TEXTURE_SIZE),d=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),f=t.getParameter(t.MAX_VERTEX_ATTRIBS),p=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),m=t.getParameter(t.MAX_VARYING_VECTORS),g=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=c>0,y=!!e.get("OES_texture_float");return{getMaxAnisotropy:i,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:c,maxTextureSize:h,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:p,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y}}function le(t){var e={};return{get:function(n){if(void 0!==e[n])return e[n];var i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":i=t.getExtension("WEBGL_compressed_texture_etc1");break;default:i=t.getExtension(n)}return null===i&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),e[n]=i,i}}}function ue(){function t(){u.value!==i&&(u.value=i,u.needsUpdate=r>0),n.numPlanes=r,n.numIntersection=0}function e(t,e,i,r){var a=null!==t?t.length:0,o=null;if(0!==a){if(o=u.value,!0!==r||null===o){var c=i+4*a,h=e.matrixWorldInverse;l.getNormalMatrix(h),(null===o||o.length=0){var c=a[l];if(void 0!==c){var h=c.normalized,d=c.itemSize,f=he.getAttributeProperties(c),p=f.__webglBuffer,m=f.type,g=f.bytesPerElement;if(c.isInterleavedBufferAttribute){var v=c.data,y=v.stride,b=c.offset;v&&v.isInstancedInterleavedBuffer?(te.enableAttributeAndDivisor(u,v.meshPerAttribute,r),void 0===n.maxInstancedCount&&(n.maxInstancedCount=v.meshPerAttribute*v.count)):te.enableAttribute(u),Kt.bindBuffer(Kt.ARRAY_BUFFER,p),Kt.vertexAttribPointer(u,d,m,h,y*g,(i*y+b)*g)}else c.isInstancedBufferAttribute?(te.enableAttributeAndDivisor(u,c.meshPerAttribute,r),void 0===n.maxInstancedCount&&(n.maxInstancedCount=c.meshPerAttribute*c.count)):te.enableAttribute(u),Kt.bindBuffer(Kt.ARRAY_BUFFER,p),Kt.vertexAttribPointer(u,d,m,h,0,i*d*g)}else if(void 0!==s){var x=s[l];if(void 0!==x)switch(x.length){case 2:Kt.vertexAttrib2fv(u,x);break;case 3:Kt.vertexAttrib3fv(u,x);break;case 4:Kt.vertexAttrib4fv(u,x);break;default:Kt.vertexAttrib1fv(u,x)}}}}te.disableUnusedAttributes()}function d(t,e){return Math.abs(e[0])-Math.abs(t[0])}function f(t,e){return t.object.renderOrder!==e.object.renderOrder?t.object.renderOrder-e.object.renderOrder:t.material.program&&e.material.program&&t.material.program!==e.material.program?t.material.program.id-e.material.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function p(t,e){return t.object.renderOrder!==e.object.renderOrder?t.object.renderOrder-e.object.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function m(t,e,n,i,r){var a,o;n.transparent?(a=it,o=++rt):(a=tt,o=++et);var s=a[o];void 0!==s?(s.id=t.id,s.object=t,s.geometry=e,s.material=n,s.z=Ht.z,s.group=r):(s={id:t.id,object:t,geometry:e,material:n,z:Ht.z,group:r},a.push(s))}function g(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),Gt.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),y(Gt)}function v(t){return Gt.center.set(0,0,0),Gt.radius=.7071067811865476,Gt.applyMatrix4(t.matrixWorld),y(Gt)}function y(t){if(!Lt.intersectsSphere(t))return!1;var e=Dt.numPlanes;if(0===e)return!0;var n=ct.clippingPlanes,i=t.center,r=-t.radius,a=0;do{if(n[a].distanceToPoint(i)=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(var d=0;d=0&&t.numSupportedMorphNormals++}var f=i.__webglShader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(i.numClippingPlanes=Dt.numPlanes,i.numIntersection=Dt.numIntersection,f.clippingPlanes=Dt.uniform),i.fog=e,i.lightsHash=Xt.hash,t.lights&&(f.ambientLightColor.value=Xt.ambient,f.directionalLights.value=Xt.directional,f.spotLights.value=Xt.spot,f.rectAreaLights.value=Xt.rectArea,f.pointLights.value=Xt.point,f.hemisphereLights.value=Xt.hemi,f.directionalShadowMap.value=Xt.directionalShadowMap,f.directionalShadowMatrix.value=Xt.directionalShadowMatrix,f.spotShadowMap.value=Xt.spotShadowMap,f.spotShadowMatrix.value=Xt.spotShadowMatrix,f.pointShadowMap.value=Xt.pointShadowMap,f.pointShadowMatrix.value=Xt.pointShadowMatrix);var p=i.program.getUniforms(),m=Y.seqWithValue(p.seq,f);i.uniformsList=m}function w(t){t.side===la?te.disable(Kt.CULL_FACE):te.enable(Kt.CULL_FACE),te.setFlipSided(t.side===sa),!0===t.transparent?te.setBlending(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha):te.setBlending(pa),te.setDepthFunc(t.depthFunc),te.setDepthTest(t.depthTest),te.setDepthWrite(t.depthWrite),te.setColorWrite(t.colorWrite),te.setPolygonOffset(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)}function M(t,e,n,i){_t=0;var r=ne.get(n);if(jt&&(Wt||t!==vt)){var a=t===vt&&n.id===mt;Dt.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,r,a)}!1===n.needsUpdate&&(void 0===r.program?n.needsUpdate=!0:n.fog&&r.fog!==e?n.needsUpdate=!0:n.lights&&r.lightsHash!==Xt.hash?n.needsUpdate=!0:void 0===r.numClippingPlanes||r.numClippingPlanes===Dt.numPlanes&&r.numIntersection===Dt.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(_(n,e,i),n.needsUpdate=!1);var o=!1,s=!1,l=!1,u=r.program,c=u.getUniforms(),h=r.__webglShader.uniforms;if(u.id!==ht&&(Kt.useProgram(u.program),ht=u.id,o=!0,s=!0,l=!0),n.id!==mt&&(mt=n.id,s=!0),o||t!==vt){if(c.set(Kt,t,"projectionMatrix"),$t.logarithmicDepthBuffer&&c.setValue(Kt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),t!==vt&&(vt=t,s=!0,l=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var d=c.map.cameraPosition;void 0!==d&&d.setValue(Kt,Ht.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&c.setValue(Kt,"viewMatrix",t.matrixWorldInverse),c.set(Kt,ct,"toneMappingExposure"),c.set(Kt,ct,"toneMappingWhitePoint")}if(n.skinning){c.setOptional(Kt,i,"bindMatrix"),c.setOptional(Kt,i,"bindMatrixInverse");var f=i.skeleton;f&&($t.floatVertexTextures&&f.useVertexTexture?(c.set(Kt,f,"boneTexture"),c.set(Kt,f,"boneTextureWidth"),c.set(Kt,f,"boneTextureHeight")):c.setOptional(Kt,f,"boneMatrices"))}return s&&(n.lights&&D(h,l),e&&n.fog&&C(h,e),(n.isMeshBasicMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.isMeshNormalMaterial||n.isMeshDepthMaterial)&&S(h,n),n.isLineBasicMaterial?E(h,n):n.isLineDashedMaterial?(E(h,n),k(h,n)):n.isPointsMaterial?T(h,n):n.isMeshLambertMaterial?O(h,n):n.isMeshToonMaterial?A(h,n):n.isMeshPhongMaterial?P(h,n):n.isMeshPhysicalMaterial?L(h,n):n.isMeshStandardMaterial?R(h,n):n.isMeshDepthMaterial?n.displacementMap&&(h.displacementMap.value=n.displacementMap,h.displacementScale.value=n.displacementScale,h.displacementBias.value=n.displacementBias):n.isMeshNormalMaterial&&I(h,n),void 0!==h.ltcMat&&(h.ltcMat.value=THREE.UniformsLib.LTC_MAT_TEXTURE),void 0!==h.ltcMag&&(h.ltcMag.value=THREE.UniformsLib.LTC_MAG_TEXTURE),Y.upload(Kt,r.uniformsList,h,ct)),c.set(Kt,i,"modelViewMatrix"),c.set(Kt,i,"normalMatrix"),c.setValue(Kt,"modelMatrix",i.matrixWorld),u}function S(t,e){t.opacity.value=e.opacity,t.diffuse.value=e.color,e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),t.map.value=e.map,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity);var n;if(e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n){n.isWebGLRenderTarget&&(n=n.texture);var i=n.offset,r=n.repeat;t.offsetRepeat.value.set(i.x,i.y,r.x,r.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio}function E(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function k(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}function T(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*kt,t.scale.value=.5*Et,t.map.value=e.map,null!==e.map){var n=e.map.offset,i=e.map.repeat;t.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}}function C(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}function O(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}function P(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function A(t,e){P(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}function R(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}function L(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,R(t,e)}function I(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function D(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}function N(t){for(var e=0,n=0,i=t.length;n=$t.maxTextures&&console.warn("WebGLRenderer: trying to use "+t+" texture units while this GPU supports only "+$t.maxTextures),_t+=1,t}function F(t){var e;if(t===oo)return Kt.REPEAT;if(t===so)return Kt.CLAMP_TO_EDGE;if(t===lo)return Kt.MIRRORED_REPEAT;if(t===uo)return Kt.NEAREST;if(t===co)return Kt.NEAREST_MIPMAP_NEAREST;if(t===ho)return Kt.NEAREST_MIPMAP_LINEAR;if(t===fo)return Kt.LINEAR;if(t===po)return Kt.LINEAR_MIPMAP_NEAREST;if(t===mo)return Kt.LINEAR_MIPMAP_LINEAR;if(t===go)return Kt.UNSIGNED_BYTE;if(t===So)return Kt.UNSIGNED_SHORT_4_4_4_4;if(t===Eo)return Kt.UNSIGNED_SHORT_5_5_5_1;if(t===ko)return Kt.UNSIGNED_SHORT_5_6_5;if(t===vo)return Kt.BYTE;if(t===yo)return Kt.SHORT;if(t===bo)return Kt.UNSIGNED_SHORT;if(t===xo)return Kt.INT;if(t===_o)return Kt.UNSIGNED_INT;if(t===wo)return Kt.FLOAT;if(t===Mo&&null!==(e=Jt.get("OES_texture_half_float")))return e.HALF_FLOAT_OES;if(t===Co)return Kt.ALPHA;if(t===Oo)return Kt.RGB;if(t===Po)return Kt.RGBA;if(t===Ao)return Kt.LUMINANCE;if(t===Ro)return Kt.LUMINANCE_ALPHA;if(t===Io)return Kt.DEPTH_COMPONENT;if(t===Do)return Kt.DEPTH_STENCIL;if(t===xa)return Kt.FUNC_ADD;if(t===_a)return Kt.FUNC_SUBTRACT;if(t===wa)return Kt.FUNC_REVERSE_SUBTRACT;if(t===Ea)return Kt.ZERO;if(t===ka)return Kt.ONE;if(t===Ta)return Kt.SRC_COLOR;if(t===Ca)return Kt.ONE_MINUS_SRC_COLOR;if(t===Oa)return Kt.SRC_ALPHA;if(t===Pa)return Kt.ONE_MINUS_SRC_ALPHA;if(t===Aa)return Kt.DST_ALPHA;if(t===Ra)return Kt.ONE_MINUS_DST_ALPHA;if(t===La)return Kt.DST_COLOR;if(t===Ia)return Kt.ONE_MINUS_DST_COLOR;if(t===Da)return Kt.SRC_ALPHA_SATURATE;if((t===No||t===zo||t===Bo||t===Fo)&&null!==(e=Jt.get("WEBGL_compressed_texture_s3tc"))){if(t===No)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===zo)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===Bo)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===Fo)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((t===Uo||t===jo||t===Wo||t===Go)&&null!==(e=Jt.get("WEBGL_compressed_texture_pvrtc"))){if(t===Uo)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===jo)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===Wo)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===Go)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t===Vo&&null!==(e=Jt.get("WEBGL_compressed_texture_etc1")))return e.COMPRESSED_RGB_ETC1_WEBGL;if((t===Ma||t===Sa)&&null!==(e=Jt.get("EXT_blend_minmax"))){if(t===Ma)return e.MIN_EXT;if(t===Sa)return e.MAX_EXT}return t===To&&null!==(e=Jt.get("WEBGL_depth_texture"))?e.UNSIGNED_INT_24_8_WEBGL:0}console.log("THREE.WebGLRenderer",Zr),t=t||{};var U=void 0!==t.canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),j=void 0!==t.context?t.context:null,W=void 0!==t.alpha&&t.alpha,G=void 0===t.depth||t.depth,V=void 0===t.stencil||t.stencil,H=void 0!==t.antialias&&t.antialias,X=void 0===t.premultipliedAlpha||t.premultipliedAlpha,Z=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,J=[],tt=[],et=-1,it=[],rt=-1,st=new Float32Array(8),lt=[],ut=[];this.domElement=U,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=Xa,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var ct=this,ht=null,dt=null,ft=null,mt=-1,gt="",vt=null,yt=new o,bt=null,xt=new o,_t=0,wt=new q(0),Mt=0,St=U.width,Et=U.height,kt=1,Tt=new o(0,0,St,Et),Ct=!1,At=new o(0,0,St,Et),Lt=new at,Dt=new ue,jt=!1,Wt=!1,Gt=new nt,Vt=new h,Ht=new c,Yt=new h,qt=new h,Xt={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},Zt={calls:0,vertices:0,faces:0,points:0};this.info={render:Zt,memory:{geometries:0,textures:0},programs:null};var Kt;try{var Qt={alpha:W,depth:G,stencil:V,antialias:H,premultipliedAlpha:X,preserveDrawingBuffer:Z};if(null===(Kt=j||U.getContext("webgl",Qt)||U.getContext("experimental-webgl",Qt)))throw null!==U.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context.";void 0===Kt.getShaderPrecisionFormat&&(Kt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}}),U.addEventListener("webglcontextlost",r,!1)}catch(t){console.error("THREE.WebGLRenderer: "+t)}var Jt=new le(Kt);Jt.get("WEBGL_depth_texture"),Jt.get("OES_texture_float"),Jt.get("OES_texture_float_linear"),Jt.get("OES_texture_half_float"),Jt.get("OES_texture_half_float_linear"),Jt.get("OES_standard_derivatives"),Jt.get("ANGLE_instanced_arrays"),Jt.get("OES_element_index_uint")&&(Ot.MaxIndex=4294967296);var $t=new se(Kt,Jt,t),te=new oe(Kt,Jt,F),ne=new ae,ce=new re(Kt,Jt,te,ne,$t,F,this.info),he=new ie(Kt,ne,this.info),de=new ee(this,$t),fe=new Ut;this.info.programs=de.programs;var pe,me,ge,ve,ye=new Ft(Kt,Jt,Zt),be=new Bt(Kt,Jt,Zt);n(),this.context=Kt,this.capabilities=$t,this.extensions=Jt,this.properties=ne,this.state=te;var xe=new ot(this,Xt,he,$t);this.shadowMap=xe;var _e=new Q(this,lt),we=new K(this,ut);this.getContext=function(){return Kt},this.getContextAttributes=function(){return Kt.getContextAttributes()},this.forceContextLoss=function(){Jt.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){return $t.getMaxAnisotropy()},this.getPrecision=function(){return $t.precision},this.getPixelRatio=function(){return kt},this.setPixelRatio=function(t){void 0!==t&&(kt=t,this.setSize(At.z,At.w,!1))},this.getSize=function(){return{width:St,height:Et}},this.setSize=function(t,e,n){St=t,Et=e,U.width=t*kt,U.height=e*kt,!1!==n&&(U.style.width=t+"px",U.style.height=e+"px"),this.setViewport(0,0,t,e)},this.setViewport=function(t,e,n,i){te.viewport(At.set(t,e,n,i))},this.setScissor=function(t,e,n,i){te.scissor(Tt.set(t,e,n,i))},this.setScissorTest=function(t){te.setScissorTest(Ct=t)},this.getClearColor=function(){return wt},this.setClearColor=function(t,e){wt.set(t),Mt=void 0!==e?e:1,te.buffers.color.setClear(wt.r,wt.g,wt.b,Mt,X)},this.getClearAlpha=function(){return Mt},this.setClearAlpha=function(t){Mt=t,te.buffers.color.setClear(wt.r,wt.g,wt.b,Mt,X)},this.clear=function(t,e,n){var i=0;(void 0===t||t)&&(i|=Kt.COLOR_BUFFER_BIT),(void 0===e||e)&&(i|=Kt.DEPTH_BUFFER_BIT),(void 0===n||n)&&(i|=Kt.STENCIL_BUFFER_BIT),Kt.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,n,i){this.setRenderTarget(t),this.clear(e,n,i)},this.resetGLState=i,this.dispose=function(){it=[],rt=-1,tt=[],et=-1,U.removeEventListener("webglcontextlost",r,!1)},this.renderBufferImmediate=function(t,e,n){te.initAttributes();var i=ne.get(t);t.hasPositions&&!i.position&&(i.position=Kt.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=Kt.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=Kt.createBuffer()),t.hasColors&&!i.color&&(i.color=Kt.createBuffer());var r=e.getAttributes();if(t.hasPositions&&(Kt.bindBuffer(Kt.ARRAY_BUFFER,i.position),Kt.bufferData(Kt.ARRAY_BUFFER,t.positionArray,Kt.DYNAMIC_DRAW),te.enableAttribute(r.position),Kt.vertexAttribPointer(r.position,3,Kt.FLOAT,!1,0,0)),t.hasNormals){if(Kt.bindBuffer(Kt.ARRAY_BUFFER,i.normal),!n.isMeshPhongMaterial&&!n.isMeshStandardMaterial&&!n.isMeshNormalMaterial&&n.shading===ua)for(var a=0,o=3*t.count;a8&&(f.length=8);for(var v=i.morphAttributes,p=0,m=f.length;p0&&S.renderInstances(i,P,R):S.render(P,R)}},this.render=function(t,e,n,i){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");gt="",mt=-1,vt=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),e.matrixWorldInverse.getInverse(e.matrixWorld),Vt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),Lt.setFromMatrix(Vt),J.length=0,et=-1,rt=-1,lt.length=0,ut.length=0,Wt=this.localClippingEnabled,jt=Dt.init(this.clippingPlanes,Wt,e),b(t,e),tt.length=et+1,it.length=rt+1,!0===ct.sortObjects&&(tt.sort(f),it.sort(p)),jt&&Dt.beginShadows(),N(J),xe.render(t,e),z(J,e),jt&&Dt.endShadows(),Zt.calls=0,Zt.vertices=0,Zt.faces=0,Zt.points=0,void 0===n&&(n=null),this.setRenderTarget(n);var r=t.background;if(null===r?te.buffers.color.setClear(wt.r,wt.g,wt.b,Mt,X):r&&r.isColor&&(te.buffers.color.setClear(r.r,r.g,r.b,1,X),i=!0),(this.autoClear||i)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil),r&&r.isCubeTexture?(void 0===ge&&(ge=new Nt,ve=new Pt(new Rt(5,5,5),new $({uniforms:Ss.cube.uniforms,vertexShader:Ss.cube.vertexShader,fragmentShader:Ss.cube.fragmentShader,side:sa,depthTest:!1,depthWrite:!1,fog:!1}))),ge.projectionMatrix.copy(e.projectionMatrix),ge.matrixWorld.extractRotation(e.matrixWorld),ge.matrixWorldInverse.getInverse(ge.matrixWorld),ve.material.uniforms.tCube.value=r,ve.modelViewMatrix.multiplyMatrices(ge.matrixWorldInverse,ve.matrixWorld),he.update(ve),ct.renderBufferDirect(ge,null,ve.geometry,ve.material,ve,null)):r&&r.isTexture&&(void 0===pe&&(pe=new zt(-1,1,1,-1,0,1),me=new Pt(new It(2,2),new pt({depthTest:!1,depthWrite:!1,fog:!1}))),me.material.map=r,he.update(me),ct.renderBufferDirect(pe,null,me.geometry,me.material,me,null)),t.overrideMaterial){var a=t.overrideMaterial;x(tt,t,e,a),x(it,t,e,a)}else te.setBlending(pa),x(tt,t,e),x(it,t,e);_e.render(t,e),we.render(t,e,xt),n&&ce.updateRenderTargetMipmap(n),te.setDepthTest(!0),te.setDepthWrite(!0),te.setColorWrite(!0)},this.setFaceCulling=function(t,e){te.setCullFace(t),te.setFlipSided(e===ea)},this.allocTextureUnit=B,this.setTexture2D=function(){var t=!1;return function(e,n){e&&e.isWebGLRenderTarget&&(t||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),ce.setTexture2D(e,n)}}(),this.setTexture=function(){var t=!1;return function(e,n){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),ce.setTexture2D(e,n)}}(),this.setTextureCube=function(){var t=!1;return function(e,n){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?ce.setTextureCube(e,n):ce.setTextureCubeDynamic(e,n)}}(),this.getCurrentRenderTarget=function(){return dt},this.setRenderTarget=function(t){dt=t,t&&void 0===ne.get(t).__webglFramebuffer&&ce.setupRenderTarget(t);var e,n=t&&t.isWebGLRenderTargetCube;if(t){var i=ne.get(t);e=n?i.__webglFramebuffer[t.activeCubeFace]:i.__webglFramebuffer,yt.copy(t.scissor),bt=t.scissorTest,xt.copy(t.viewport)}else e=null,yt.copy(Tt).multiplyScalar(kt),bt=Ct,xt.copy(At).multiplyScalar(kt);if(ft!==e&&(Kt.bindFramebuffer(Kt.FRAMEBUFFER,e),ft=e),te.scissor(yt),te.setScissorTest(bt),te.viewport(xt),n){var r=ne.get(t.texture);Kt.framebufferTexture2D(Kt.FRAMEBUFFER,Kt.COLOR_ATTACHMENT0,Kt.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,r.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,n,i,r,a){if(!1===(t&&t.isWebGLRenderTarget))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");var o=ne.get(t).__webglFramebuffer;if(o){var s=!1;o!==ft&&(Kt.bindFramebuffer(Kt.FRAMEBUFFER,o),s=!0);try{var l=t.texture,u=l.format,c=l.type;if(u!==Po&&F(u)!==Kt.getParameter(Kt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(c===go||F(c)===Kt.getParameter(Kt.IMPLEMENTATION_COLOR_READ_TYPE)||c===wo&&(Jt.get("OES_texture_float")||Jt.get("WEBGL_color_buffer_float"))||c===Mo&&Jt.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");Kt.checkFramebufferStatus(Kt.FRAMEBUFFER)===Kt.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&Kt.readPixels(e,n,i,r,F(u),F(c),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&Kt.bindFramebuffer(Kt.FRAMEBUFFER,ft)}}}}function he(t,e){this.name="",this.color=new q(t),this.density=void 0!==e?e:25e-5}function de(t,e,n){this.name="",this.color=new q(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function fe(){ct.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function pe(t,e,n,i,r){ct.call(this),this.lensFlares=[],this.positionScreen=new c,this.customUpdateCallback=void 0,void 0!==t&&this.add(t,e,n,i,r)}function me(t){J.call(this),this.type="SpriteMaterial",this.color=new q(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function ge(t){ct.call(this),this.type="Sprite",this.material=void 0!==t?t:new me}function ve(){ct.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ye(t,e,n){if(this.useVertexTexture=void 0===n||n,this.identityMatrix=new h,t=t||[],this.bones=t.slice(0),this.useVertexTexture){var i=Math.sqrt(4*this.bones.length);i=fs.nextPowerOfTwo(Math.ceil(i)),i=Math.max(i,4),this.boneTextureWidth=i,this.boneTextureHeight=i,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new X(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,Po,wo)}else this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[];for(var r=0,a=this.bones.length;r=t.HAVE_CURRENT_DATA&&(h.needsUpdate=!0)}a.call(this,t,e,n,i,r,o,s,l,u),this.generateMipmaps=!1;var h=this;c()}function Ce(t,e,n,i,r,o,s,l,u,c,h,d){a.call(this,null,o,s,l,u,c,i,r,h,d),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function Oe(t,e,n,i,r,o,s,l,u){a.call(this,t,e,n,i,r,o,s,l,u),this.needsUpdate=!0}function Pe(t,e,n,i,r,o,s,l,u,c){if((c=void 0!==c?c:Io)!==Io&&c!==Do)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===Io&&(n=bo),void 0===n&&c===Do&&(n=To),a.call(this,null,i,r,o,s,l,c,n,u),this.image={width:t,height:e},this.magFilter=void 0!==s?s:uo,this.minFilter=void 0!==l?l:uo,this.flipY=!1,this.generateMipmaps=!1}function Ae(t){function e(t,e){return t-e}Ot.call(this),this.type="WireframeGeometry";var n,i,r,a,o,s,l,u,h=[],d=[0,0],f={},p=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(n=0,r=m.length;n.9&&a<.1&&(e<.2&&(m[t+0]+=1),n<.2&&(m[t+2]+=1),i<.2&&(m[t+4]+=1))}}function s(t){p.push(t.x,t.y,t.z)}function l(e,n){var i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function u(){for(var t=new c,e=new c,n=new c,i=new c,a=new r,o=new r,s=new r,l=0,u=0;l0)&&m.push(w,M,E),(l!==n-1||u0&&u(!0),e>0&&u(!1)),this.setIndex(d),this.addAttribute("position",new Mt(f,3)),this.addAttribute("normal",new Mt(p,3)),this.addAttribute("uv",new Mt(m,2))}function cn(t,e,n,i,r,a,o){ln.call(this,0,t,e,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function hn(t,e,n,i,r,a,o){un.call(this,0,t,e,n,i,r,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function dn(t,e,n,i){Ct.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new fn(t,e,n,i))}function fn(t,e,n,i){Ot.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var a,o,s=[],l=[],u=[],h=[],d=new c,f=new r;for(l.push(0,0,0),u.push(0,0,1),h.push(.5,.5),o=0,a=3;o<=e;o++,a+=3){var p=n+o/e*i;d.x=t*Math.cos(p),d.y=t*Math.sin(p),l.push(d.x,d.y,d.z),u.push(0,0,1),f.x=(l[a]/t+1)/2,f.y=(l[a+1]/t+1)/2,h.push(f.x,f.y)}for(a=1;a<=e;a++)s.push(a,a+1,0);this.setIndex(s),this.addAttribute("position",new Mt(l,3)),this.addAttribute("normal",new Mt(u,3)),this.addAttribute("uv",new Mt(h,2))}function pn(){$.call(this,{uniforms:xs.merge([Ms.lights,{opacity:{value:1}}]),vertexShader:_s.shadow_vert,fragmentShader:_s.shadow_frag}),this.lights=!0,this.transparent=!0,Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}}})}function mn(t){$.call(this,t),this.type="RawShaderMaterial"}function gn(t){this.uuid=fs.generateUUID(),this.type="MultiMaterial",this.materials=Array.isArray(t)?t:[],this.visible=!0}function vn(t){J.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new q(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 q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function yn(t){vn.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function bn(t){J.call(this),this.type="MeshPhongMaterial",this.color=new q(16777215),this.specular=new q(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Va,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function xn(t){bn.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function _n(t){J.call(this,t),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new r(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function wn(t){J.call(this),this.type="MeshLambertMaterial",this.color=new q(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Va,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Mn(t){J.call(this),this.type="LineDashedMaterial",this.color=new q(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.lights=!1,this.setValues(t)}function Sn(t,e,n){var i=this,r=!1,a=0,o=0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){o++,!1===r&&void 0!==i.onStart&&i.onStart(t,a,o),r=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)}}function En(t){this.manager=void 0!==t?t:Ls}function kn(t){this.manager=void 0!==t?t:Ls,this._parser=null}function Tn(t){this.manager=void 0!==t?t:Ls,this._parser=null}function Cn(t){this.manager=void 0!==t?t:Ls}function On(t){this.manager=void 0!==t?t:Ls}function Pn(t){this.manager=void 0!==t?t:Ls}function An(t,e){ct.call(this),this.type="Light",this.color=new q(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function Rn(t,e,n){An.call(this,t,n),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(ct.DefaultUp),this.updateMatrix(),this.groundColor=new q(e)}function Ln(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new r(512,512),this.map=null,this.matrix=new h}function In(){Ln.call(this,new Nt(50,1,.5,500))}function Dn(t,e,n,i,r,a){An.call(this,t,e),this.type="SpotLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.target=new ct,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==a?a:1,this.shadow=new In}function Nn(t,e,n,i){An.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==i?i:1,this.shadow=new Ln(new Nt(90,1,.5,500))}function zn(){Ln.call(this,new zt(-5,5,5,-5,.5,500))}function Bn(t,e){An.call(this,t,e),this.type="DirectionalLight",this.position.copy(ct.DefaultUp),this.updateMatrix(),this.target=new ct,this.shadow=new zn}function Fn(t,e){An.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function Un(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n}function jn(t,e,n,i){Un.call(this,t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Wn(t,e,n,i){Un.call(this,t,e,n,i)}function Gn(t,e,n,i){Un.call(this,t,e,n,i)}function Vn(t,e,n,i){if(void 0===t)throw new Error("track name is undefined");if(void 0===e||0===e.length)throw new Error("no keyframes in track named "+t);this.name=t,this.times=Is.convertArray(e,this.TimeBufferType),this.values=Is.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation),this.validate(),this.optimize()}function Hn(t,e,n,i){Vn.call(this,t,e,n,i)}function Yn(t,e,n,i){Un.call(this,t,e,n,i)}function qn(t,e,n,i){Vn.call(this,t,e,n,i)}function Xn(t,e,n,i){Vn.call(this,t,e,n,i)}function Zn(t,e,n,i){Vn.call(this,t,e,n,i)}function Kn(t,e,n){Vn.call(this,t,e,n)}function Qn(t,e,n,i){Vn.call(this,t,e,n,i)}function Jn(t,e,n,i){Vn.apply(this,arguments)}function $n(t,e,n){this.name=t,this.tracks=n,this.duration=void 0!==e?e:-1,this.uuid=fs.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function ti(t){this.manager=void 0!==t?t:Ls,this.textures={}}function ei(t){this.manager=void 0!==t?t:Ls}function ni(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function ii(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:Ls,this.withCredentials=!1}function ri(t){this.manager=void 0!==t?t:Ls,this.texturePath=""}function ai(t,e,n,i,r){var a=.5*(i-e),o=.5*(r-n),s=t*t;return(2*n-2*i+a+o)*(t*s)+(-3*n+3*i-2*a-o)*s+a*t+n}function oi(t,e){var n=1-t;return n*n*e}function si(t,e){return 2*(1-t)*t*e}function li(t,e){return t*t*e}function ui(t,e,n,i){return oi(t,e)+si(t,n)+li(t,i)}function ci(t,e){var n=1-t;return n*n*n*e}function hi(t,e){var n=1-t;return 3*n*n*t*e}function di(t,e){return 3*(1-t)*t*t*e}function fi(t,e){return t*t*t*e}function pi(t,e,n,i,r){return ci(t,e)+hi(t,n)+di(t,i)+fi(t,r)}function mi(){}function gi(t,e){this.v1=t,this.v2=e}function vi(){this.curves=[],this.autoClose=!1}function yi(t,e,n,i,r,a,o,s){this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s||0}function bi(t){this.points=void 0===t?[]:t}function xi(t,e,n,i){this.v0=t,this.v1=e,this.v2=n,this.v3=i}function _i(t,e,n){this.v0=t,this.v1=e,this.v2=n}function wi(t){vi.call(this),this.currentPoint=new r,t&&this.fromPoints(t)}function Mi(){wi.apply(this,arguments),this.holes=[]}function Si(){this.subPaths=[],this.currentPath=null}function Ei(t){this.data=t}function ki(t){this.manager=void 0!==t?t:Ls}function Ti(t){this.manager=void 0!==t?t:Ls}function Ci(t,e,n,i){An.call(this,t,e),this.type="RectAreaLight",this.position.set(0,1,0),this.updateMatrix(),this.width=void 0!==n?n:10,this.height=void 0!==i?i:10}function Oi(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Nt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Nt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function Pi(t,e,n){ct.call(this),this.type="CubeCamera";var i=new Nt(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new c(1,0,0)),this.add(i);var r=new Nt(90,1,t,e);r.up.set(0,-1,0),r.lookAt(new c(-1,0,0)),this.add(r);var a=new Nt(90,1,t,e);a.up.set(0,0,1),a.lookAt(new c(0,1,0)),this.add(a);var o=new Nt(90,1,t,e);o.up.set(0,0,-1),o.lookAt(new c(0,-1,0)),this.add(o);var s=new Nt(90,1,t,e);s.up.set(0,-1,0),s.lookAt(new c(0,0,1)),this.add(s);var u=new Nt(90,1,t,e);u.up.set(0,-1,0),u.lookAt(new c(0,0,-1)),this.add(u);var h={format:Oo,magFilter:fo,minFilter:fo};this.renderTarget=new l(n,n,h),this.updateCubeMap=function(t,e){null===this.parent&&this.updateMatrixWorld();var n=this.renderTarget,l=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,n.activeCubeFace=0,t.render(e,i,n),n.activeCubeFace=1,t.render(e,r,n),n.activeCubeFace=2,t.render(e,a,n),n.activeCubeFace=3,t.render(e,o,n),n.activeCubeFace=4,t.render(e,s,n),n.texture.generateMipmaps=l,n.activeCubeFace=5,t.render(e,u,n),t.setRenderTarget(null)}}function Ai(){ct.call(this),this.type="AudioListener",this.context=Bs.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Ri(t){ct.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Li(t){Ri.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Ii(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function Di(t,e,n){this.binding=t,this.valueSize=n;var i,r=Float64Array;switch(e){case"quaternion":i=this._slerp;break;case"string":case"bool":r=Array,i=this._select;break;default:i=this._lerp}this.buffer=new r(4*n),this._mixBufferRegion=i,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}function Ni(t,e,n){this.path=e,this.parsedPath=n||Ni.parseTrackName(e),this.node=Ni.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function zi(t){this.uuid=fs.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function Bi(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var i=e.tracks,r=i.length,a=new Array(r),o={endingStart:Qo,endingEnd:Qo},s=0;s!==r;++s){var l=i[s].createInterpolant(null);a[s]=l,l.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Yo,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Fi(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Ui(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function ji(){Ot.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Wi(t,e,n,i){this.uuid=fs.generateUUID(),this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===i}function Gi(t,e){this.uuid=fs.generateUUID(),this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Vi(t,e,n){Gi.call(this,t,e),this.meshPerAttribute=n||1}function Hi(t,e,n){mt.call(this,t,e),this.meshPerAttribute=n||1}function Yi(t,e,n,i){this.ray=new st(t,e),this.near=n||0,this.far=i||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function qi(t,e){return t.distance-e.distance}function Xi(t,e,n,i){if(!1!==t.visible&&(t.raycast(e,n),!0===i))for(var r=t.children,a=0,o=r.length;a0?1:+t}),void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&function(){Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n>=4,n[r]=e[19===r?3&t|8:t]);return n.join("")}}(),clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*fs.DEG2RAD},radToDeg:function(t){return t*fs.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t}};r.prototype={constructor:r,isVector2:!0,get width(){return this.x},set width(t){this.x=t},get height(){return this.y},set height(t){this.y=t},set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t,e;return function(n,i){return void 0===t&&(t=new r,e=new r),t.set(n,n),e.set(i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var n=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,n))/n)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},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 t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}};var ps=0;a.DEFAULT_IMAGE=void 0,a.DEFAULT_MAPPING=Ja,a.prototype={constructor:a,isTexture:!0,set needsUpdate(t){!0===t&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){if(void 0!==t.textures[this.uuid])return t.textures[this.uuid];var e={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,flipY:this.flipY};if(void 0!==this.image){var n=this.image;void 0===n.uuid&&(n.uuid=fs.generateUUID()),void 0===t.images[n.uuid]&&(t.images[n.uuid]={uuid:n.uuid,url:function(t){var e;return void 0!==t.toDataURL?e=t:(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0,t.width,t.height)),e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(n)}),e.image=n.uuid}return t.textures[this.uuid]=e,e},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping===Ja){if(t.multiply(this.repeat),t.add(this.offset),t.x<0||t.x>1)switch(this.wrapS){case oo:t.x=t.x-Math.floor(t.x);break;case so:t.x=t.x<0?0:1;break;case lo:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case oo:t.y=t.y-Math.floor(t.y);break;case so:t.y=t.y<0?0:1;break;case lo:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}},Object.assign(a.prototype,i.prototype),o.prototype={constructor:o,isVector4:!0,set:function(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(t){var e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,i,r,a=t.elements,o=a[0],s=a[4],l=a[8],u=a[1],c=a[5],h=a[9],d=a[2],f=a[6],p=a[10];if(Math.abs(s-u)<.01&&Math.abs(l-d)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+u)<.1&&Math.abs(l+d)<.1&&Math.abs(h+f)<.1&&Math.abs(o+c+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,g=(c+1)/2,v=(p+1)/2,y=(s+u)/4,b=(l+d)/4,x=(h+f)/4;return m>g&&m>v?m<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(m),i=y/n,r=b/n):g>v?g<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(g),n=y/i,r=x/i):v<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=b/r,i=x/r),this.set(n,i,r,e),this}var _=Math.sqrt((f-h)*(f-h)+(l-d)*(l-d)+(u-s)*(u-s));return Math.abs(_)<.001&&(_=1),this.x=(f-h)/_,this.y=(l-d)/_,this.z=(u-s)/_,this.w=Math.acos((o+c+p-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(n,i){return void 0===t&&(t=new o,e=new o),t.set(n,n,n,n),e.set(i,i,i,i),this.clamp(t,e)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},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(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}},s.prototype={constructor:s,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(s.prototype,i.prototype),l.prototype=Object.create(s.prototype),l.prototype.constructor=l,l.prototype.isWebGLRenderTargetCube=!0,u.prototype={constructor:u,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get w(){return this._w},set w(t){this._w=t,this.onChangeCallback()},set:function(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!1===(t&&t.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=Math.cos(t._x/2),i=Math.cos(t._y/2),r=Math.cos(t._z/2),a=Math.sin(t._x/2),o=Math.sin(t._y/2),s=Math.sin(t._z/2),l=t.order;return"XYZ"===l?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"YXZ"===l?(this._x=a*i*r+n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"ZXY"===l?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r-a*o*s):"ZYX"===l?(this._x=a*i*r-n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r+a*o*s):"YZX"===l?(this._x=a*i*r+n*o*s,this._y=n*o*r+a*i*s,this._z=n*i*s-a*o*r,this._w=n*i*r-a*o*s):"XZY"===l&&(this._x=a*i*r-n*o*s,this._y=n*o*r-a*i*s,this._z=n*i*s+a*o*r,this._w=n*i*r+a*o*s),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],l=n[9],u=n[2],c=n[6],h=n[10],d=i+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(c-l)*e,this._y=(a-u)*e,this._z=(o-r)*e):i>s&&i>h?(e=2*Math.sqrt(1+i-s-h),this._w=(c-l)/e,this._x=.25*e,this._y=(r+o)/e,this._z=(a+u)/e):s>h?(e=2*Math.sqrt(1+s-i-h),this._w=(a-u)/e,this._x=(r+o)/e,this._y=.25*e,this._z=(l+c)/e):(e=2*Math.sqrt(1+h-i-s),this._w=(o-r)/e,this._x=(a+u)/e,this._y=(l+c)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e;return function(n,i){return void 0===t&&(t=new c),e=n.dot(i)+1,e<1e-6?(e=0,Math.abs(n.x)>Math.abs(n.z)?t.set(-n.y,n.x,0):t.set(0,-n.z,n.y)):t.crossVectors(n,i),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,s=e._y,l=e._z,u=e._w;return this._x=n*u+a*o+i*l-r*s,this._y=i*u+a*s+r*o-n*l,this._z=r*u+a*l+n*s-i*o,this._w=a*u-n*o-i*s-r*l,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,i=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+i*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(n+this._x),this._y=.5*(i+this._y),this._z=.5*(r+this._z),this;var l=Math.atan2(s,o),u=Math.sin((1-e)*l)/s,c=Math.sin(e*l)/s;return this._w=a*u+this._w*c,this._x=n*u+this._x*c,this._y=i*u+this._y*c,this._z=r*u+this._z*c,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},Object.assign(u,{slerp:function(t,e,n,i){return n.copy(t).slerp(e,i)},slerpFlat:function(t,e,n,i,r,a,o){var s=n[i+0],l=n[i+1],u=n[i+2],c=n[i+3],h=r[a+0],d=r[a+1],f=r[a+2],p=r[a+3];if(c!==p||s!==h||l!==d||u!==f){var m=1-o,g=s*h+l*d+u*f+c*p,v=g>=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,g*v);m=Math.sin(m*x)/b,o=Math.sin(o*x)/b}var _=o*v;if(s=s*m+h*_,l=l*m+d*_,u=u*m+f*_,c=c*m+p*_,m===1-o){var w=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=w,l*=w,u*=w,c*=w}}t[e]=s,t[e+1]=l,t[e+2]=u,t[e+3]=c}}),c.prototype={constructor:c,isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t;return function(e){return!1===(e&&e.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===t&&(t=new u),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t;return function(e,n){return void 0===t&&(t=new u),this.applyQuaternion(t.setFromAxisAngle(e,n))}}(),applyMatrix3:function(t){var e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this},applyMatrix4:function(t){var e=this.x,n=this.y,i=this.z,r=t.elements;this.x=r[0]*e+r[4]*n+r[8]*i+r[12],this.y=r[1]*e+r[5]*n+r[9]*i+r[13],this.z=r[2]*e+r[6]*n+r[10]*i+r[14];var a=r[3]*e+r[7]*n+r[11]*i+r[15];return this.divideScalar(a)},applyQuaternion:function(t){var e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,s=t.w,l=s*e+a*i-o*n,u=s*n+o*e-r*i,c=s*i+r*n-a*e,h=-r*e-a*n-o*i;return this.x=l*s+h*-r+u*-o-c*-a,this.y=u*s+h*-a+c*-r-l*-o,this.z=c*s+h*-o+l*-a-u*-r,this},project:function(){var t;return function(e){return void 0===t&&(t=new h),t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t;return function(e){return void 0===t&&(t=new h),t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t,e;return function(n,i){return void 0===t&&(t=new c,e=new c),t.set(n,n,n),e.set(i,i,i),this.clamp(t,e)}}(),clampLength:function(t,e){var n=this.length();return this.multiplyScalar(Math.max(t,Math.min(e,n))/n)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(t){return this.multiplyScalar(t/this.length())},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var n=this.x,i=this.y,r=this.z;return this.x=i*t.z-r*t.y,this.y=r*t.x-n*t.z,this.z=n*t.y-i*t.x,this},crossVectors:function(t,e){var n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,s=e.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t;return function(e){return void 0===t&&(t=new c),t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t;return function(e){return void 0===t&&(t=new c),this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(fs.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i},distanceToManhattan:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){return this.setFromMatrixColumn(t,3)},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this},setFromMatrixColumn:function(t,e){if("number"==typeof t){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var n=t;t=e,e=n}return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}},h.prototype={constructor:h,isMatrix4:!0,set:function(t,e,n,i,r,a,o,s,l,u,c,h,d,f,p,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=d,g[7]=f,g[11]=p,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new h).fromArray(this.elements)},copy:function(t){return this.elements.set(t.elements),this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:function(){var t;return function(e){void 0===t&&(t=new c);var n=this.elements,i=e.elements,r=1/t.setFromMatrixColumn(e,0).length(),a=1/t.setFromMatrixColumn(e,1).length(),o=1/t.setFromMatrixColumn(e,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[4]=i[4]*a,n[5]=i[5]*a,n[6]=i[6]*a,n[8]=i[8]*o,n[9]=i[9]*o,n[10]=i[10]*o,this}}(),makeRotationFromEuler:function(t){!1===(t&&t.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),l=Math.sin(i),u=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){var h=a*u,d=a*c,f=o*u,p=o*c;e[0]=s*u,e[4]=-s*c,e[8]=l,e[1]=d+f*l,e[5]=h-p*l,e[9]=-o*s,e[2]=p-h*l,e[6]=f+d*l,e[10]=a*s}else if("YXZ"===t.order){var m=s*u,g=s*c,v=l*u,y=l*c;e[0]=m+y*o,e[4]=v*o-g,e[8]=a*l,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=g*o-v,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){var m=s*u,g=s*c,v=l*u,y=l*c;e[0]=m-y*o,e[4]=-a*c,e[8]=v+g*o,e[1]=g+v*o,e[5]=a*u,e[9]=y-m*o,e[2]=-a*l,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){var h=a*u,d=a*c,f=o*u,p=o*c;e[0]=s*u,e[4]=f*l-d,e[8]=h*l+p,e[1]=s*c,e[5]=p*l+h,e[9]=d*l-f,e[2]=-l,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var b=a*s,x=a*l,_=o*s,w=o*l;e[0]=s*u,e[4]=w-b*c,e[8]=_*c+x,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-l*u,e[6]=x*c+_,e[10]=b-w*c}else if("XZY"===t.order){var b=a*s,x=a*l,_=o*s,w=o*l;e[0]=s*u,e[4]=-c,e[8]=l*u,e[1]=b*c+w,e[5]=a*u,e[9]=x*c-_,e[2]=_*c-x,e[6]=o*u,e[10]=w*c+b}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,n=t.x,i=t.y,r=t.z,a=t.w,o=n+n,s=i+i,l=r+r,u=n*o,c=n*s,h=n*l,d=i*s,f=i*l,p=r*l,m=a*o,g=a*s,v=a*l;return e[0]=1-(d+p),e[4]=c-v,e[8]=h+g,e[1]=c+v,e[5]=1-(u+p),e[9]=f-m,e[2]=h-g,e[6]=f+m,e[10]=1-(u+d),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t,e,n;return function(i,r,a){void 0===t&&(t=new c,e=new c,n=new c);var o=this.elements;return n.subVectors(i,r).normalize(),0===n.lengthSq()&&(n.z=1),t.crossVectors(a,n).normalize(),0===t.lengthSq()&&(n.z+=1e-4,t.crossVectors(a,n).normalize()),e.crossVectors(n,t),o[0]=t.x,o[4]=e.x,o[8]=n.x,o[1]=t.y,o[5]=e.y,o[9]=n.y,o[2]=t.z,o[6]=e.z,o[10]=n.z,this}}(),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],u=n[1],c=n[5],h=n[9],d=n[13],f=n[2],p=n[6],m=n[10],g=n[14],v=n[3],y=n[7],b=n[11],x=n[15],_=i[0],w=i[4],M=i[8],S=i[12],E=i[1],k=i[5],T=i[9],C=i[13],O=i[2],P=i[6],A=i[10],R=i[14],L=i[3],I=i[7],D=i[11],N=i[15];return r[0]=a*_+o*E+s*O+l*L,r[4]=a*w+o*k+s*P+l*I,r[8]=a*M+o*T+s*A+l*D,r[12]=a*S+o*C+s*R+l*N,r[1]=u*_+c*E+h*O+d*L,r[5]=u*w+c*k+h*P+d*I,r[9]=u*M+c*T+h*A+d*D,r[13]=u*S+c*C+h*R+d*N,r[2]=f*_+p*E+m*O+g*L,r[6]=f*w+p*k+m*P+g*I,r[10]=f*M+p*T+m*A+g*D,r[14]=f*S+p*C+m*R+g*N,r[3]=v*_+y*E+b*O+x*L,r[7]=v*w+y*k+b*P+x*I,r[11]=v*M+y*T+b*A+x*D,r[15]=v*S+y*C+b*R+x*N,this},multiplyToArray:function(t,e,n){var i=this.elements;return this.multiplyMatrices(t,e),n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(){var t;return function(e){void 0===t&&(t=new c);for(var n=0,i=e.count;n 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 ltcTextureCoords( const in GeometricContext geometry, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE;\n\tconst float LUT_BIAS = 0.5/LUT_SIZE;\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nvoid clipQuadToHorizon( inout vec3 L[5], out int n ) {\n\tint config = 0;\n\tif ( L[0].z > 0.0 ) config += 1;\n\tif ( L[1].z > 0.0 ) config += 2;\n\tif ( L[2].z > 0.0 ) config += 4;\n\tif ( L[3].z > 0.0 ) config += 8;\n\tn = 0;\n\tif ( config == 0 ) {\n\t} else if ( config == 1 ) {\n\t\tn = 3;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 2 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 3 ) {\n\t\tn = 4;\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t\tL[3] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 4 ) {\n\t\tn = 3;\n\t\tL[0] = -L[3].z * L[2] + L[2].z * L[3];\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t} else if ( config == 5 ) {\n\t\tn = 0;\n\t} else if ( config == 6 ) {\n\t\tn = 4;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 7 ) {\n\t\tn = 5;\n\t\tL[4] = -L[3].z * L[0] + L[0].z * L[3];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 8 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[1] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = L[3];\n\t} else if ( config == 9 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[2].z * L[3] + L[3].z * L[2];\n\t} else if ( config == 10 ) {\n\t\tn = 0;\n\t} else if ( config == 11 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 12 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t} else if ( config == 13 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = L[2];\n\t\tL[2] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t} else if ( config == 14 ) {\n\t\tn = 5;\n\t\tL[4] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t} else if ( config == 15 ) {\n\t\tn = 4;\n\t}\n\tif ( n == 3 )\n\t\tL[3] = L[0];\n\tif ( n == 4 )\n\t\tL[4] = L[0];\n}\nfloat integrateLtcBrdfOverRectEdge( vec3 v1, vec3 v2 ) {\n\tfloat cosTheta = dot( v1, v2 );\n\tfloat theta = acos( cosTheta );\n\tfloat res = cross( v1, v2 ).z * ( ( theta > 0.001 ) ? theta / sin( theta ) : 1.0 );\n\treturn res;\n}\nvoid initRectPoints( const in vec3 pos, const in vec3 halfWidth, const in vec3 halfHeight, out vec3 rectPoints[4] ) {\n\trectPoints[0] = pos - halfWidth - halfHeight;\n\trectPoints[1] = pos + halfWidth - halfHeight;\n\trectPoints[2] = pos + halfWidth + halfHeight;\n\trectPoints[3] = pos - halfWidth + halfHeight;\n}\nvec3 integrateLtcBrdfOverRect( const in GeometricContext geometry, const in mat3 brdfMat, const in vec3 rectPoints[4] ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot( V, N ));\n\tT2 = - cross( N, T1 );\n\tmat3 brdfWrtSurface = brdfMat * transpose( mat3( T1, T2, N ) );\n\tvec3 clippedRect[5];\n\tclippedRect[0] = brdfWrtSurface * ( rectPoints[0] - P );\n\tclippedRect[1] = brdfWrtSurface * ( rectPoints[1] - P );\n\tclippedRect[2] = brdfWrtSurface * ( rectPoints[2] - P );\n\tclippedRect[3] = brdfWrtSurface * ( rectPoints[3] - P );\n\tint n;\n\tclipQuadToHorizon(clippedRect, n);\n\tif ( n == 0 )\n\t\treturn vec3( 0, 0, 0 );\n\tclippedRect[0] = normalize( clippedRect[0] );\n\tclippedRect[1] = normalize( clippedRect[1] );\n\tclippedRect[2] = normalize( clippedRect[2] );\n\tclippedRect[3] = normalize( clippedRect[3] );\n\tclippedRect[4] = normalize( clippedRect[4] );\n\tfloat sum = 0.0;\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[0], clippedRect[1] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[1], clippedRect[2] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[2], clippedRect[3] );\n\tif (n >= 4)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[3], clippedRect[4] );\n\tif (n == 5)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[4], clippedRect[0] );\n\tsum = max( 0.0, sum );\n\tvec3 Lo_i = vec3( sum, sum, sum );\n\treturn Lo_i;\n}\nvec3 Rect_Area_Light_Specular_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight,\n\t\tconst in float roughness,\n\t\tconst in sampler2D ltcMat, const in sampler2D ltcMag ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tvec2 uv = ltcTextureCoords( geometry, roughness );\n\tvec4 brdfLtcApproxParams, t;\n\tbrdfLtcApproxParams = texture2D( ltcMat, uv );\n\tt = texture2D( ltcMat, uv );\n\tfloat brdfLtcScalar = texture2D( ltcMag, uv ).a;\n\tmat3 brdfLtcApproxMat = mat3(\n\t\tvec3( 1, 0, t.y ),\n\t\tvec3( 0, t.z, 0 ),\n\t\tvec3( t.w, 0, t.x )\n\t);\n\tvec3 specularReflectance = integrateLtcBrdfOverRect( geometry, brdfLtcApproxMat, rectPoints );\n\tspecularReflectance *= brdfLtcScalar;\n\treturn specularReflectance;\n}\nvec3 Rect_Area_Light_Diffuse_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tmat3 diffuseBrdfMat = mat3(1);\n\tvec3 diffuseReflectance = integrateLtcBrdfOverRect( geometry, diffuseBrdfMat, rectPoints );\n\treturn diffuseReflectance;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n\t}\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 matDiffColor = material.diffuseColor;\n\t\tvec3 matSpecColor = material.specularColor;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 spec = Rect_Area_Light_Specular_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n\t\t\t\troughness,\n\t\t\t\tltcMat, ltcMag );\n\t\tvec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n\t\t\t\tgeometry,\n\t\t\t\trectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n\t\treflectedLight.directSpecular += lightColor * matSpecColor * spec;\n\t\treflectedLight.directDiffuse += lightColor * matDiffColor * diff;\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",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\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 1.0 - 2.0 * rgb.xyz;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",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\tvarying vec2 vUv;\n#endif",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\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n",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\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include \n#include \n#include \nvoid main () {\n\t#include \n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};q.prototype={constructor:q,isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,n){return this.r=t,this.g=e,this.b=n,this},setHSL:function(){function t(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}return function(e,n,i){if(e=fs.euclideanModulo(e,1),n=fs.clamp(n,0,1),i=fs.clamp(i,0,1),0===n)this.r=this.g=this.b=i;else{var r=i<=.5?i*(1+n):i+n-i*n,a=2*i-r;this.r=t(a,r,e+1/3),this.g=t(a,r,e),this.b=t(a,r,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var i,r=n[1],a=n[2];switch(r){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,e(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,e(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return e(i[5]),this.setHSL(o,s,l)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var u=n[1],c=u.length;if(3===c)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===c)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(t&&t.length>0){var u=ws[t];void 0!==u?this.setHex(u):console.warn("THREE.Color: Unknown color "+t)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},convertGammaToLinear:function(){var t=this.r,e=this.g,n=this.b;return this.r=t*t,this.g=e*e,this.b=n*n,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(t){var e,n,i=t||{h:0,s:0,l:0},r=this.r,a=this.g,o=this.b,s=Math.max(r,a,o),l=Math.min(r,a,o),u=(l+s)/2;if(l===s)e=0,n=0;else{var c=s-l;switch(n=u<=.5?c/(s+l):c/(2-s-l),s){case r:e=(a-o)/c+(athis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new r).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return(e||new r).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new r;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}};var Es=0;J.prototype={constructor:J,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(t){!0===t&&this.update(),this._needsUpdate=t},setValues:function(t){if(void 0!==t)for(var e in t){var n=t[e];if(void 0!==n){var i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]="overdraw"===e?Number(n):n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){function e(t){var e=[];for(var n in t){var i=t[n];delete i.metadata,e.push(i)}return e}var n=void 0===t;n&&(t={textures:{},images:{}});var i={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearCoat&&(i.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(i.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==ma&&(i.blending=this.blending),this.shading!==ca&&(i.shading=this.shading),this.side!==oa&&(i.side=this.side),this.vertexColors!==ha&&(i.vertexColors=this.vertexColors),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),i.skinning=this.skinning,i.morphTargets=this.morphTargets,n){var r=e(t.textures),a=e(t.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.shading=t.shading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,n=null;if(null!==e){var i=e.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(J.prototype,i.prototype),$.prototype=Object.create(J.prototype),$.prototype.constructor=$,$.prototype.isShaderMaterial=!0,$.prototype.copy=function(t){return J.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=xs.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},$.prototype.toJSON=function(t){var e=J.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},tt.prototype=Object.create(J.prototype),tt.prototype.constructor=tt,tt.prototype.isMeshDepthMaterial=!0,tt.prototype.copy=function(t){return J.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},et.prototype={constructor:et,isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,l=t.length;sr&&(r=u),c>a&&(a=c),h>o&&(o=h)}return this.min.set(e,n,i),this.max.set(r,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,l=t.count;sr&&(r=u),c>a&&(a=c),h>o&&(o=h)}return this.min.set(e,n,i),this.max.set(r,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new c).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t;return function(e){return void 0===t&&(t=new c),this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=t.constant&&n>=t.constant},clampPoint:function(t,e){return(e||new c).copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new c;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new c;return function(e){var n=e||new nt;return this.getCenter(n.center),n.radius=.5*this.getSize(t).length(),n}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new c,new c,new c,new c,new c,new c,new c,new c];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},nt.prototype={constructor:nt,set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t;return function(e,n){void 0===t&&(t=new et);var i=this.center;void 0!==n?i.copy(n):t.setFromPoints(e).getCenter(i);for(var r=0,a=0,o=e.length;athis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(t){var e=t||new et;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}},it.prototype={constructor:it,isMatrix3:!0,set:function(t,e,n,i,r,a,o,s,l){var u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=r,u[5]=s,u[6]=n,u[7]=a,u[8]=l,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=t.elements;return this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]),this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var t;return function(e){void 0===t&&(t=new c);for(var n=0,i=e.count;n1))return i.copy(r).multiplyScalar(o).add(e.start)}else if(0===this.distanceToPoint(e.start))return i.copy(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return(t||new c).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new c,e=new it;return function(n,i){var r=this.coplanarPoint(t).applyMatrix4(n),a=i||e.getNormalMatrix(n),o=this.normal.applyMatrix3(a).normalize();return this.constant=-r.dot(o),this}}(),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}},at.prototype={constructor:at,set:function(t,e,n,i,r,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],u=n[6],c=n[7],h=n[8],d=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return e[0].setComponents(o-i,c-s,p-h,y-m).normalize(),e[1].setComponents(o+i,c+s,p+h,y+m).normalize(),e[2].setComponents(o+r,c+l,p+d,y+g).normalize(),e[3].setComponents(o-r,c-l,p-d,y-g).normalize(),e[4].setComponents(o-a,c-u,p-f,y-v).normalize(),e[5].setComponents(o+a,c+u,p+f,y+v).normalize(),this},intersectsObject:function(){var t=new nt;return function(e){var n=e.geometry;return null===n.boundingSphere&&n.computeBoundingSphere(),t.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new nt;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,n=t.center,i=-t.radius,r=0;r<6;r++){if(e[r].distanceToPoint(n)0?n.min.x:n.max.x,e.x=a.normal.x>0?n.max.x:n.min.x,t.y=a.normal.y>0?n.min.y:n.max.y,e.y=a.normal.y>0?n.max.y:n.min.y,t.z=a.normal.z>0?n.min.z:n.max.z,e.z=a.normal.z>0?n.max.z:n.min.z;var o=a.distanceToPoint(t),s=a.distanceToPoint(e);if(o<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}},st.prototype={constructor:st,set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new c).copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new c;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){var n=e||new c;n.subVectors(t,this.origin);var i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new c;return function(e){var n=t.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(n).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new c,e=new c,n=new c;return function(i,r,a,o){t.copy(i).add(r).multiplyScalar(.5),e.copy(r).sub(i).normalize(),n.copy(this.origin).sub(t);var s,l,u,c,h=.5*i.distanceTo(r),d=-this.direction.dot(e),f=n.dot(this.direction),p=-n.dot(e),m=n.lengthSq(),g=Math.abs(1-d*d);if(g>0)if(s=d*p-f,l=d*f-p,c=h*g,s>=0)if(l>=-c)if(l<=c){var v=1/g;s*=v,l*=v,u=s*(s+d*l+2*f)+l*(d*s+l+2*p)+m}else l=h,s=Math.max(0,-(d*l+f)),u=-s*s+l*(l+2*p)+m;else l=-h,s=Math.max(0,-(d*l+f)),u=-s*s+l*(l+2*p)+m;else l<=-c?(s=Math.max(0,-(-d*h+f)),l=s>0?-h:Math.min(Math.max(-h,-p),h),u=-s*s+l*(l+2*p)+m):l<=c?(s=0,l=Math.min(Math.max(-h,-p),h),u=l*(l+2*p)+m):(s=Math.max(0,-(d*h+f)),l=s>0?h:Math.min(Math.max(-h,-p),h),u=-s*s+l*(l+2*p)+m);else l=d>0?-h:h,s=Math.max(0,-(d*l+f)),u=-s*s+l*(l+2*p)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(e).multiplyScalar(l).add(t),u}}(),intersectSphere:function(){var t=new c;return function(e,n){t.subVectors(e.center,this.origin);var i=t.dot(this.direction),r=t.dot(t)-i*i,a=e.radius*e.radius;if(r>a)return null;var o=Math.sqrt(a-r),s=i-o,l=i+o;return s<0&&l<0?null:s<0?this.at(l,n):this.at(s,n)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,i,r,a,o,s,l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return l>=0?(n=(t.min.x-h.x)*l,i=(t.max.x-h.x)*l):(n=(t.max.x-h.x)*l,i=(t.min.x-h.x)*l),u>=0?(r=(t.min.y-h.y)*u,a=(t.max.y-h.y)*u):(r=(t.max.y-h.y)*u,a=(t.min.y-h.y)*u),n>a||r>i?null:((r>n||n!==n)&&(n=r),(a=0?(o=(t.min.z-h.z)*c,s=(t.max.z-h.z)*c):(o=(t.max.z-h.z)*c,s=(t.min.z-h.z)*c),n>s||o>i?null:((o>n||n!==n)&&(n=o),(s=0?n:i,e)))},intersectsBox:function(){var t=new c;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new c,e=new c,n=new c,i=new c;return function(r,a,o,s,l){e.subVectors(a,r),n.subVectors(o,r),i.crossVectors(e,n);var u,c=this.direction.dot(i);if(c>0){if(s)return null;u=1}else{if(!(c<0))return null;u=-1,c=-c}t.subVectors(this.origin,r);var h=u*this.direction.dot(n.crossVectors(t,n));if(h<0)return null;var d=u*this.direction.dot(e.cross(t));if(d<0)return null;if(h+d>c)return null;var f=-u*t.dot(i);return f<0?null:this.at(f/c,l)}}(),applyMatrix4:function(t){return this.direction.add(this.origin).applyMatrix4(t),this.origin.applyMatrix4(t),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}},lt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],lt.DefaultOrder="XYZ",lt.prototype={constructor:lt,isEuler:!0,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get order(){return this._order},set order(t){this._order=t,this.onChangeCallback()},set:function(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._order=i||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,n){var i=fs.clamp,r=t.elements,a=r[0],o=r[4],s=r[8],l=r[1],u=r[5],c=r[9],h=r[2],d=r[6],f=r[10];return e=e||this._order,"XYZ"===e?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(d,u),this._z=0)):"YXZ"===e?(this._x=Math.asin(-i(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(s,f),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-h,a),this._z=0)):"ZXY"===e?(this._x=Math.asin(i(d,-1,1)),Math.abs(d)<.99999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(l,a))):"ZYX"===e?(this._y=Math.asin(-i(h,-1,1)),Math.abs(h)<.99999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-o,u))):"YZX"===e?(this._z=Math.asin(i(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(s,f))):"XZY"===e?(this._z=Math.asin(-i(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(d,u),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-c,f),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==n&&this.onChangeCallback(),this},setFromQuaternion:function(){var t;return function(e,n,i){return void 0===t&&(t=new h),t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,n,i)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:function(){var t=new u;return function(e){return t.setFromEuler(this),this.setFromQuaternion(t,e)}}(),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new c(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}},ut.prototype={constructor:ut,set:function(t){this.mask=1<1){for(var e=0;e1)for(var e=0;e0){r.children=[];for(var a=0;a0&&(i.geometries=o),s.length>0&&(i.materials=s),l.length>0&&(i.textures=l),u.length>0&&(i.images=u)}return i.object=r,i},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;n0?a.multiplyScalar(1/Math.sqrt(o)):a.set(0,0,0)}}(),dt.barycoordFromPoint=function(){var t=new c,e=new c,n=new c;return function(i,r,a,o,s){t.subVectors(o,r),e.subVectors(a,r),n.subVectors(i,r);var l=t.dot(t),u=t.dot(e),h=t.dot(n),d=e.dot(e),f=e.dot(n),p=l*d-u*u,m=s||new c;if(0===p)return m.set(-2,-1,-1);var g=1/p,v=(d*h-u*f)*g,y=(l*f-u*h)*g;return m.set(1-v-y,y,v)}}(),dt.containsPoint=function(){var t=new c;return function(e,n,i,r){var a=dt.barycoordFromPoint(e,n,i,r,t);return a.x>=0&&a.y>=0&&a.x+a.y<=1}}(),dt.prototype={constructor:dt,set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:function(){var t=new c,e=new c;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),midpoint:function(t){return(t||new c).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return dt.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new rt).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return dt.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return dt.containsPoint(t,this.a,this.b,this.c)},closestPointToPoint:function(){var t,e,n,i;return function(r,a){void 0===t&&(t=new rt,e=[new ht,new ht,new ht],n=new c,i=new c);var o=a||new c,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(r,n),!0===this.containsPoint(n))o.copy(n);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var l=0;l0,s=a[1]&&a[1].length>0,l=t.morphTargets,u=l.length;if(u>0){e=[];for(var c=0;c0){h=[];for(var c=0;c0)for(var m=0;m0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,i,r;for(n=0,i=this.faces.length;n0&&(t+=e[n].distanceTo(e[n-1])),this.lineDistances[n]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new nt),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,n){if(!1===(t&&t.isGeometry))return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);var i,r=this.vertices.length,a=this.vertices,o=t.vertices,s=this.faces,l=t.faces,u=this.faceVertexUvs[0],c=t.faceVertexUvs[0],h=this.colors,d=t.colors;void 0===n&&(n=0),void 0!==e&&(i=(new it).getNormalMatrix(e));for(var f=0,p=o.length;f=0;n--){var p=d[n];for(this.faces.splice(p,1),o=0,s=this.faceVertexUvs.length;o0,x=v.vertexNormals.length>0,_=1!==v.color.r||1!==v.color.g||1!==v.color.b,w=v.vertexColors.length>0,M=0;if(M=t(M,0,0),M=t(M,1,!0),M=t(M,2,!1),M=t(M,3,y),M=t(M,4,b),M=t(M,5,x),M=t(M,6,_),M=t(M,7,w),c.push(M),c.push(v.a,v.b,v.c),c.push(v.materialIndex),y){var S=this.faceVertexUvs[0][l];c.push(i(S[0]),i(S[1]),i(S[2]))}if(b&&c.push(e(v.normal)),x){var E=v.vertexNormals;c.push(e(E[0]),e(E[1]),e(E[2]))}if(_&&c.push(n(v.color)),w){var k=v.vertexColors;c.push(n(k[0]),n(k[1]),n(k[2]))}}return r.data={},r.data.vertices=s,r.data.normals=h,f.length>0&&(r.data.colors=f),m.length>0&&(r.data.uvs=[m]),r.data.faces=c,r},clone:function(){return(new Ct).copy(this)},copy:function(t){var e,n,i,r,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e65535?wt:xt)(t,1):this.index=t},addAttribute:function(t,e){return!1===(e&&e.isBufferAttribute)&&!1===(e&&e.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(t,new mt(arguments[1],arguments[2]))):"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(e)):(this.attributes[t]=e,this)},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,n){this.groups.push({start:t,count:e,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var n=this.attributes.normal;if(void 0!==n){(new it).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t;return function(e){return void 0===t&&(t=new h),t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t;return function(e){return void 0===t&&(t=new h),t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t;return function(e){return void 0===t&&(t=new h),t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t;return function(e,n,i){return void 0===t&&(t=new h),t.makeTranslation(e,n,i),this.applyMatrix(t),this}}(),scale:function(){var t;return function(e,n,i){return void 0===t&&(t=new h),t.makeScale(e,n,i),this.applyMatrix(t),this}}(),lookAt:function(){var t;return function(e){void 0===t&&(t=new ct),t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new Mt(3*e.vertices.length,3),i=new Mt(3*e.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(e.vertices)),this.addAttribute("color",i.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var r=new Mt(e.lineDistances.length,1);this.addAttribute("lineDistance",r.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},updateFromObject:function(t){var e=t.geometry;if(t.isMesh){var n=e.__directGeometry;if(!0===e.elementsNeedUpdate&&(n=void 0,e.elementsNeedUpdate=!1),void 0===n)return this.fromGeometry(e);n.verticesNeedUpdate=e.verticesNeedUpdate,n.normalsNeedUpdate=e.normalsNeedUpdate,n.colorsNeedUpdate=e.colorsNeedUpdate,n.uvsNeedUpdate=e.uvsNeedUpdate,n.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=n}var i;return!0===e.verticesNeedUpdate&&(i=this.attributes.position,void 0!==i&&(i.copyVector3sArray(e.vertices),i.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(i=this.attributes.normal,void 0!==i&&(i.copyVector3sArray(e.normals),i.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(i=this.attributes.color,void 0!==i&&(i.copyColorsArray(e.colors),i.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(i=this.attributes.uv,void 0!==i&&(i.copyVector2sArray(e.uvs),i.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(i=this.attributes.lineDistance,void 0!==i&&(i.copyArray(e.lineDistances),i.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Et).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new mt(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var n=new Float32Array(3*t.normals.length);this.addAttribute("normal",new mt(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var i=new Float32Array(3*t.colors.length);this.addAttribute("color",new mt(i,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var r=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new mt(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new mt(a,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var o=kt(t.indices)>65535?Uint32Array:Uint16Array,s=new o(3*t.indices.length);this.setIndex(new mt(s,1).copyIndicesArray(t.indices))}this.groups=t.groups;for(var l in t.morphTargets){for(var u=[],c=t.morphTargets[l],h=0,d=c.length;h0){var m=new Mt(4*t.skinIndices.length,4);this.addAttribute("skinIndex",m.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var g=new Mt(4*t.skinWeights.length,4);this.addAttribute("skinWeight",g.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new et);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(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 t=new et,e=new c;return function(){null===this.boundingSphere&&(this.boundingSphere=new nt);var n=this.attributes.position;if(n){var i=this.boundingSphere.center;t.setFromBufferAttribute(n),t.getCenter(i);for(var r=0,a=0,o=n.count;a0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var l=this.boundingSphere;return null!==l&&(t.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),t},clone:function(){return(new Ot).copy(this)},copy:function(t){var e,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var r=t.index;null!==r&&this.setIndex(r.clone());var a=t.attributes;for(e in a){var o=a[e];this.addAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var l=[],u=s[e];for(n=0,i=u.length;n0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var e=0,n=t.length;ee.far?null:{distance:l,point:x.clone(),object:t}}function n(n,i,r,a,o,c,h,d){s.fromBufferAttribute(a,c),l.fromBufferAttribute(a,h),u.fromBufferAttribute(a,d);var f=e(n,i,r,s,l,u,b);return f&&(o&&(m.fromBufferAttribute(o,c),g.fromBufferAttribute(o,h),v.fromBufferAttribute(o,d),f.uv=t(b,s,l,u,m,g,v)),f.face=new ft(c,h,d,dt.normal(s,l,u)),f.faceIndex=c),f}var i=new h,a=new st,o=new nt,s=new c,l=new c,u=new c,d=new c,f=new c,p=new c,m=new r,g=new r,v=new r,y=new c,b=new c,x=new c;return function(r,c){var h=this.geometry,y=this.material,x=this.matrixWorld;if(void 0!==y&&(null===h.boundingSphere&&h.computeBoundingSphere(),o.copy(h.boundingSphere),o.applyMatrix4(x),!1!==r.ray.intersectsSphere(o)&&(i.getInverse(x),a.copy(r.ray).applyMatrix4(i),null===h.boundingBox||!1!==a.intersectsBox(h.boundingBox)))){var _;if(h.isBufferGeometry){var w,M,S,E,k,T=h.index,C=h.attributes.position,O=h.attributes.uv;if(null!==T)for(E=0,k=T.count;E0&&(L=B);for(var F=0,U=z.length;Fthis.scale.x*this.scale.y/4||n.push({distance:Math.sqrt(i),point:this.position,face:null,object:this})}}(),clone:function(){return new this.constructor(this.material).copy(this)}}),ve.prototype=Object.assign(Object.create(ct.prototype),{constructor:ve,copy:function(t){ct.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,i=e.length;n1){t.setFromMatrixPosition(n.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var r=t.distanceTo(e);i[0].object.visible=!0;for(var a=1,o=i.length;a=i[a].distance;a++)i[a-1].object.visible=!1,i[a].object.visible=!0;for(;ao)){f.applyMatrix4(this.matrixWorld);var S=i.ray.origin.distanceTo(f);Si.far||r.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else for(var b=0,x=v.length/3-1;bo)){f.applyMatrix4(this.matrixWorld);var S=i.ray.origin.distanceTo(f);Si.far||r.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}else if(s.isGeometry)for(var E=s.vertices,k=E.length,b=0;bo)){f.applyMatrix4(this.matrixWorld);var S=i.ray.origin.distanceTo(f);Si.far||r.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Me.prototype=Object.assign(Object.create(we.prototype),{constructor:Me,isLineSegments:!0}),Se.prototype=Object.create(J.prototype),Se.prototype.constructor=Se,Se.prototype.isPointsMaterial=!0,Se.prototype.copy=function(t){return J.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},Ee.prototype=Object.assign(Object.create(ct.prototype),{constructor:Ee,isPoints:!0,raycast:function(){var t=new h,e=new st,n=new nt;return function(i,r){function a(t,n){var a=e.distanceSqToPoint(t);if(ai.far)return;r.push({distance:u,distanceToRay:Math.sqrt(a),point:s.clone(),index:n,face:null,object:o})}}var o=this,s=this.geometry,l=this.matrixWorld,u=i.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),n.copy(s.boundingSphere),n.applyMatrix4(l),!1!==i.ray.intersectsSphere(n)){t.getInverse(l),e.copy(i.ray).applyMatrix4(t);var h=u/((this.scale.x+this.scale.y+this.scale.z)/3),d=h*h,f=new c;if(s.isBufferGeometry){var p=s.index,m=s.attributes,g=m.position.array;if(null!==p)for(var v=p.array,y=0,b=v.length;y=-Number.EPSILON&&C>=-Number.EPSILON&&T>=-Number.EPSILON))return!1;return!0}return function(e,n){var i=e.length;if(i<3)return null;var r,a,o,s=[],l=[],u=[];if(Os.area(e)>0)for(a=0;a2;){if(h--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),n?u:s;if(r=a,c<=r&&(r=0),a=r+1,c<=a&&(a=0),o=a+1,c<=o&&(o=0),t(e,r,a,o,c,l)){var d,f,p,m,g;for(d=l[r],f=l[a],p=l[o],s.push([e[d],e[f],e[p]]),u.push([l[r],l[a],l[o]]),m=a,g=a+1;g2&&t[e-1].equals(t[0])&&t.pop()}function i(t,e,n){return t.x!==e.x?t.xNumber.EPSILON){var p;if(d>0){if(f<0||f>d)return[];if((p=u*c-l*h)<0||p>d)return[]}else{if(f>0||f0||pE?[]:x===E?a?[]:[y]:_<=E?[y,b]:[y,M]}function a(t,e,n,i){var r=e.x-t.x,a=e.y-t.y,o=n.x-t.x,s=n.y-t.y,l=i.x-t.x,u=i.y-t.y,c=r*s-a*o,h=r*u-a*l;if(Math.abs(c)>Number.EPSILON){var d=l*s-u*o;return c>0?h>=0&&d>=0:h>=0||d>=0}return h>0}n(t),e.forEach(n);for(var o,s,l,u,c,h,d={},f=t.concat(),p=0,m=e.length;p0;){if(--_<0){console.log("Infinite Loop! Holes left:"+g.length+", Probably Hole outside Shape!");break}for(o=x;oi&&(o=0);var s=a(m[t],m[r],m[o],n[e]);if(!s)return!1;var l=n.length-1,u=e-1;u<0&&(u=l);var c=e+1;return c>l&&(c=0),!!(s=a(n[e],n[u],n[c],m[t]))}(o,w)&&!function(t,e){var n,i,a;for(n=0;n0)return!0;return!1}(s,l)&&!function(t,n){var i,a,o,s,l;for(i=0;i0)return!0;return!1}(s,l)){i=w,g.splice(y,1),h=m.slice(0,o+1),d=m.slice(o),f=n.slice(i),p=n.slice(0,i+1),m=h.concat(f).concat(p).concat(d),x=o;break}if(i>=0)break;v[c]=!0}if(i>=0)break}}return m}(t,e),v=Os.triangulate(g,!1);for(o=0,s=v.length;oNumber.EPSILON){var f=Math.sqrt(h),p=Math.sqrt(u*u+c*c),m=e.x-l/f,g=e.y+s/f,v=n.x-c/p,y=n.y+u/p,b=((v-m)*c-(y-g)*u)/(s*c-l*u);i=m+s*b-t.x,a=g+l*b-t.y;var x=i*i+a*a;if(x<=2)return new r(i,a);o=Math.sqrt(x/2)}else{var _=!1;s>Number.EPSILON?u>Number.EPSILON&&(_=!0):s<-Number.EPSILON?u<-Number.EPSILON&&(_=!0):Math.sign(l)===Math.sign(c)&&(_=!0),_?(i=-l,a=s,o=Math.sqrt(h)):(i=s,a=l,o=Math.sqrt(h/2))}return new r(i/o,a/o)}function a(t,e){var n,i;for(H=t.length;--H>=0;){n=H,i=H-1,i<0&&(i=t.length-1);var r=0,a=_+2*y;for(r=0;r=0;N--){for(B=N/y,F=g*Math.cos(B*Math.PI/2),z=v*Math.sin(B*Math.PI/2),H=0,Y=D.length;H0||0===t.search(/^data\:image\/jpeg/);r.format=i?Oo:Po,r.image=n,r.needsUpdate=!0,void 0!==e&&e(r)},n,i),r},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),An.prototype=Object.assign(Object.create(ct.prototype),{constructor:An,isLight:!0,copy:function(t){return ct.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=ct.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),Rn.prototype=Object.assign(Object.create(An.prototype),{constructor:Rn,isHemisphereLight:!0,copy:function(t){return An.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Ln.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),In.prototype=Object.assign(Object.create(Ln.prototype),{constructor:In,isSpotLightShadow:!0,update:function(t){var e=2*fs.RAD2DEG*t.angle,n=this.mapSize.width/this.mapSize.height,i=t.distance||500,r=this.camera;e===r.fov&&n===r.aspect&&i===r.far||(r.fov=e,r.aspect=n,r.far=i,r.updateProjectionMatrix())}}),Dn.prototype=Object.assign(Object.create(An.prototype),{constructor:Dn,isSpotLight:!0,copy:function(t){return An.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Nn.prototype=Object.assign(Object.create(An.prototype),{constructor:Nn,isPointLight:!0,copy:function(t){return An.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),zn.prototype=Object.assign(Object.create(Ln.prototype),{constructor:zn}),Bn.prototype=Object.assign(Object.create(An.prototype),{constructor:Bn,isDirectionalLight:!0,copy:function(t){return An.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Fn.prototype=Object.assign(Object.create(An.prototype),{constructor:Fn,isAmbientLight:!0});var Is={arraySlice:function(t,e,n){return Is.isTypedArray(t)?new t.constructor(t.subarray(e,n)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){function e(e,n){return t[e]-t[n]}for(var n=t.length,i=new Array(n),r=0;r!==n;++r)i[r]=r;return i.sort(e),i},sortedArray:function(t,e,n){for(var i=t.length,r=new t.constructor(i),a=0,o=0;o!==i;++a)for(var s=n[a]*e,l=0;l!==e;++l)r[o++]=t[s+l];return r},flattenJSON:function(t,e,n,i){for(var r=1,a=t[0];void 0!==a&&void 0===a[i];)a=t[r++];if(void 0!==a){var o=a[i];if(void 0!==o)if(Array.isArray(o))do{o=a[i],void 0!==o&&(e.push(a.time),n.push.apply(n,o)),a=t[r++]}while(void 0!==a);else if(void 0!==o.toArray)do{o=a[i],void 0!==o&&(e.push(a.time),o.toArray(n,n.length)),a=t[r++]}while(void 0!==a);else do{o=a[i],void 0!==o&&(e.push(a.time),n.push(o)),a=t[r++]}while(void 0!==a)}}};Un.prototype={constructor:Un,evaluate:function(t){var e=this.parameterPositions,n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{var a;n:{i:if(!(t=r)break t;var s=e[1];t=r)break e}a=n,n=0}}for(;n>>1;te;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);var o=this.getValueSize();this.times=Is.arraySlice(n,r,a),this.values=Is.arraySlice(this.values,r*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("invalid value size in track",this),t=!1);var n=this.times,i=this.values,r=n.length;0===r&&(console.error("track is empty",this),t=!1);for(var a=null,o=0;o!==r;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("time is not a valid number",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("out of order keys",this,o,s,a),t=!1;break}a=s}if(void 0!==i&&Is.isTypedArray(i))for(var o=0,l=i.length;o!==l;++o){var u=i[o];if(isNaN(u)){console.error("value is not a valid number",this,o,u),t=!1;break}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),i=this.getInterpolation()===Ko,r=1,a=t.length-1,o=1;o0){t[r]=t[a];for(var p=a*n,m=r*n,d=0;d!==n;++d)e[m+d]=e[p+d];++r}return r!==t.length&&(this.times=Is.arraySlice(t,0,r),this.values=Is.arraySlice(e,0,r*n)),this}},Hn.prototype=Object.assign(Object.create(Ds),{constructor:Hn,ValueTypeName:"vector"}),Yn.prototype=Object.assign(Object.create(Un.prototype),{constructor:Yn,interpolate_:function(t,e,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,l=(n-e)/(i-e),c=s+o;s!==c;s+=4)u.slerpFlat(r,0,a,s-o,a,s,l);return r}}),qn.prototype=Object.assign(Object.create(Ds),{constructor:qn,ValueTypeName:"quaternion",DefaultInterpolation:Zo,InterpolantFactoryMethodLinear:function(t){return new Yn(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Xn.prototype=Object.assign(Object.create(Ds),{constructor:Xn,ValueTypeName:"number"}),Zn.prototype=Object.assign(Object.create(Ds),{constructor:Zn,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Xo,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Kn.prototype=Object.assign(Object.create(Ds),{constructor:Kn,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Xo,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Qn.prototype=Object.assign(Object.create(Ds),{constructor:Qn,ValueTypeName:"color"}),Jn.prototype=Ds,Ds.constructor=Jn,Object.assign(Jn,{parse:function(t){if(void 0===t.type)throw new Error("track type undefined, can not parse");var e=Jn._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var n=[],i=[];Is.flattenJSON(t.keys,n,i,"value"),t.times=n,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,n=t.constructor;if(void 0!==n.toJSON)e=n.toJSON(t);else{e={name:t.name,times:Is.convertArray(t.times,Array),values:Is.convertArray(t.values,Array)};var i=t.getInterpolation();i!==t.DefaultInterpolation&&(e.interpolation=i)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Xn;case"vector":case"vector2":case"vector3":case"vector4":return Hn;case"color":return Qn;case"quaternion":return qn;case"bool":case"boolean":return Kn;case"string":return Zn}throw new Error("Unsupported typeName: "+t)}}),$n.prototype={constructor:$n,resetDuration:function(){for(var t=this.tracks,e=0,n=0,i=t.length;n!==i;++n){var r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}this.duration=e},trim:function(){for(var t=0;t1){var u=l[1],c=i[u];c||(i[u]=c=[]),c.push(s)}}var h=[];for(var u in i)h.push($n.CreateFromMorphTargetSequence(u,i[u],e,n));return h},parseAnimation:function(t,e){if(!t)return console.error(" no animation in JSONLoader data"),null;for(var n=function(t,e,n,i,r){if(0!==n.length){var a=[],o=[];Is.flattenJSON(n,a,o,i),0!==a.length&&r.push(new t(e,a,o))}},i=[],r=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],l=0;l1?t.skinWeights[i+1]:0,l=e>2?t.skinWeights[i+2]:0,u=e>3?t.skinWeights[i+3]:0;n.skinWeights.push(new o(a,s,l,u))}if(t.skinIndices)for(var i=0,r=t.skinIndices.length;i1?t.skinIndices[i+1]:0,d=e>2?t.skinIndices[i+2]:0,f=e>3?t.skinIndices[i+3]:0;n.skinIndices.push(new o(c,h,d,f))}n.bones=t.bones,n.bones&&n.bones.length>0&&(n.skinWeights.length!==n.skinIndices.length||n.skinIndices.length!==n.vertices.length)&&console.warn("When skinning, number of vertices ("+n.vertices.length+"), skinIndices ("+n.skinIndices.length+"), and skinWeights ("+n.skinWeights.length+") should match.")}(),function(e){if(void 0!==t.morphTargets)for(var i=0,r=t.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=n.faces,d=t.morphColors[0].colors,i=0,r=h.length;i0&&(n.animations=e)}(),n.computeFaceNormals(),n.computeBoundingSphere(),void 0===t.materials||0===t.materials.length)return{geometry:n};var a=ni.prototype.initMaterials(t.materials,e,this.crossOrigin);return{geometry:n,materials:a}}}),Object.assign(ri.prototype,{load:function(t,e,n,i){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var r=this;new En(r.manager).load(t,function(n){var a=null;try{a=JSON.parse(n)}catch(e){return void 0!==i&&i(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var o=a.metadata;if(void 0===o||void 0===o.type||"geometry"===o.type.toLowerCase())return void console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.");r.parse(a,e)},n,i)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var n=this.parseGeometries(t.geometries),i=this.parseImages(t.images,function(){void 0!==e&&e(o)}),r=this.parseTextures(t.textures,i),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,n,a);return t.animations&&(o.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(o),o},parseGeometries:function(t){var e={};if(void 0!==t)for(var n=new ii,i=new ei,r=0,a=t.length;r0){var r=new Sn(e),a=new Cn(r);a.setCrossOrigin(this.crossOrigin);for(var o=0,s=t.length;o0?new xe(s,l):new Pt(s,l);break;case"LOD":o=new ve;break;case"Line":o=new we(r(e.geometry),a(e.material),e.mode);break;case"LineSegments":o=new Me(r(e.geometry),a(e.material));break;case"PointCloud":case"Points":o=new Ee(r(e.geometry),a(e.material));break;case"Sprite":o=new ge(a(e.material));break;case"Group":o=new ke;break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh type. Instantiates Object3D instead.");default:o=new ct}if(o.uuid=e.uuid,void 0!==e.name&&(o.name=e.name),void 0!==e.matrix?(t.fromArray(e.matrix),t.decompose(o.position,o.quaternion,o.scale)):(void 0!==e.position&&o.position.fromArray(e.position),void 0!==e.rotation&&o.rotation.fromArray(e.rotation),void 0!==e.quaternion&&o.quaternion.fromArray(e.quaternion),void 0!==e.scale&&o.scale.fromArray(e.scale)),void 0!==e.castShadow&&(o.castShadow=e.castShadow),void 0!==e.receiveShadow&&(o.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(o.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(o.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&o.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(o.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(o.visible=e.visible),void 0!==e.userData&&(o.userData=e.userData),void 0!==e.children)for(var u in e.children)o.add(this.parseObject(e.children[u],n,i));if("LOD"===e.type)for(var c=e.levels,h=0;h0)){l=r;break}l=r-1}if(r=l,i[r]===n){var u=r/(a-1);return u}var c=i[r],h=i[r+1],d=h-c,f=(n-c)/d,u=(r+f)/(a-1);return u},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var i=this.getPoint(e);return this.getPoint(n).clone().sub(i).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,i,r,a=new c,o=[],s=[],l=[],u=new c,d=new h;for(n=0;n<=t;n++)i=n/t,o[n]=this.getTangentAt(i),o[n].normalize();s[0]=new c,l[0]=new c;var f=Number.MAX_VALUE,p=Math.abs(o[0].x),m=Math.abs(o[0].y),g=Math.abs(o[0].z);for(p<=f&&(f=p,a.set(1,0,0)),m<=f&&(f=m,a.set(0,1,0)),g<=f&&a.set(0,0,1),u.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],u),l[0].crossVectors(o[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),l[n]=l[n-1].clone(),u.crossVectors(o[n-1],o[n]),u.length()>Number.EPSILON&&(u.normalize(),r=Math.acos(fs.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(d.makeRotationAxis(u,r))),l[n].crossVectors(o[n],s[n]);if(!0===e)for(r=Math.acos(fs.clamp(s[0].dot(s[t]),-1,1)),r/=t,o[0].dot(u.crossVectors(s[0],s[t]))>0&&(r=-r),n=1;n<=t;n++)s[n].applyMatrix4(d.makeRotationAxis(o[n],r*n)),l[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:l}}},gi.prototype=Object.create(mi.prototype),gi.prototype.constructor=gi,gi.prototype.isLineCurve=!0,gi.prototype.getPoint=function(t){if(1===t)return this.v2.clone();var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},gi.prototype.getPointAt=function(t){return this.getPoint(t)},gi.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},vi.prototype=Object.assign(Object.create(mi.prototype),{constructor:vi,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new gi(e,t))},getPoint:function(t){for(var e=t*this.getLength(),n=this.getCurveLengths(),i=0;i=e){var r=n[i]-e,a=this.curves[i],o=a.getLength(),s=0===o?0:1-r/o;return a.getPointAt(s)}i++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},createPointsGeometry:function(t){var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){for(var e=new Ct,n=0,i=t.length;ne;)n-=e;ne.length-2?e.length-1:i+1],u=e[i>e.length-3?e.length-1:i+2];return new r(ai(a,o.x,s.x,l.x,u.x),ai(a,o.y,s.y,l.y,u.y))},xi.prototype=Object.create(mi.prototype),xi.prototype.constructor=xi,xi.prototype.getPoint=function(t){var e=this.v0,n=this.v1,i=this.v2,a=this.v3;return new r(pi(t,e.x,n.x,i.x,a.x),pi(t,e.y,n.y,i.y,a.y))},_i.prototype=Object.create(mi.prototype),_i.prototype.constructor=_i,_i.prototype.getPoint=function(t){var e=this.v0,n=this.v1,i=this.v2;return new r(ui(t,e.x,n.x,i.x),ui(t,e.y,n.y,i.y))};var Ns=Object.assign(Object.create(vi.prototype),{fromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,n=t.length;e0){var u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);var c=l.getPoint(1);this.currentPoint.copy(c)}});wi.prototype=Ns,Ns.constructor=wi,Mi.prototype=Object.assign(Object.create(Ns),{constructor:Mi,getPointsHoles:function(t){for(var e=[],n=0,i=this.holes.length;n1){for(var v=!1,y=[],b=0,x=d.length;bNumber.EPSILON){if(u<0&&(o=e[a],l=-l,s=e[r],u=-u),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var c=u*(t.x-o.x)-l*(t.y-o.y);if(0===c)return!0;if(c<0)continue;i=!i}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return i})(M.p,d[E].p)&&(b!==E&&y.push({froms:b,tos:E,hole:w}),S?(S=!1,h[E].push(M)):v=!0);S&&h[b].push(M)}y.length>0&&(v||(f=h))}for(var k,m=0,T=d.length;m0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==r;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,i,r){u.slerpFlat(t,e,t,e,t,n,i)},_lerp:function(t,e,n,i,r){for(var a=1-i,o=0;o!==r;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*i}}},Ni.prototype={constructor:Ni,getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,r=e.propertyIndex;if(t||(t=Ni.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error(" trying to update node for track: "+this.path+" but it wasn't found.");if(n){var a=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error(" can not bind to material as node does not have a material",this);if(!t.material.materials)return void console.error(" can not bind to material.materials as node.material does not have a materials array",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error(" can not bind to bones as node does not have a skeleton",this);t=t.skeleton.bones;for(var o=0;o=n){var h=n++,d=e[h];i[d.uuid]=c,e[c]=d,i[u]=h,e[h]=l;for(var f=0,p=a;f!==p;++f){var m=r[f],g=m[h],v=m[c];m[c]=g,m[h]=v}}}this.nCachedObjects_=n},uncache:function(t){for(var e=this._objects,n=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,a=this._bindings,o=a.length,s=0,l=arguments.length;s!==l;++s){var u=arguments[s],c=u.uuid,h=r[c];if(void 0!==h)if(delete r[c],h0)for(var l=this._interpolants,u=this._propertyBindings,c=0,h=l.length;c!==h;++c)l[c].evaluate(o),u[c].accumulate(i,s)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n){e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var n=this._clip.duration,i=this.loop,r=this._loopCount;if(i===Ho){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var a=i===qo;if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=n||e<0){var o=Math.floor(e/n);e-=n*o,r+=Math.abs(o);var s=this.repetitions-r;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(0===s){var l=t<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&1==(1&r))return this.time=e,n-e}return this.time=e,e},_setEndings:function(t,e,n){var i=this._interpolantSettings;n?(i.endingStart=Jo,i.endingEnd=Jo):(i.endingStart=t?this.zeroSlopeAtStart?Jo:Qo:$o,i.endingEnd=e?this.zeroSlopeAtEnd?Jo:Qo:$o)},_scheduleFading:function(t,e,n){var i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=e,o[1]=r+t,s[1]=n,this}},Fi.prototype={constructor:Fi,clipAction:function(t,e){var n=e||this._root,i=n.uuid,r="string"==typeof t?$n.findByName(n,t):t,a=null!==r?r.uuid:t,o=this._actionsByClip[a],s=null;if(void 0!==o){var l=o.actionByRoot[i];if(void 0!==l)return l;s=o.knownActions[0],null===r&&(r=s._clip)}if(null===r)return null;var u=new Bi(this,r,e);return this._bindAction(u,s),this._addInactiveAction(u,a,i),u},existingAction:function(t,e){var n=e||this._root,i=n.uuid,r="string"==typeof t?$n.findByName(n,t):t,a=r?r.uuid:t,o=this._actionsByClip[a];return void 0!==o?o.actionByRoot[i]||null:null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,n=this._bindings,i=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var r=0;r!==e;++r)t[r].reset();for(var r=0;r!==i;++r)n[r].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),a=this._accuIndex^=1,o=0;o!==n;++o){var s=e[o];s.enabled&&s._update(i,t,r,a)}for(var l=this._bindings,u=this._nActiveBindings,o=0;o!==u;++o)l[o].apply(a);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){for(var a=r.knownActions,o=0,s=a.length;o!==s;++o){var l=a[o];this._deactivateAction(l);var u=l._cacheIndex,c=e[e.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,c._cacheIndex=u,e[u]=c,e.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}},uncacheRoot:function(t){var e=t.uuid,n=this._actionsByClip;for(var i in n){var r=n[i].actionByRoot,a=r[e];void 0!==a&&(this._deactivateAction(a),this._removeInactiveAction(a))}var o=this._bindingsByRootAndName,s=o[e];if(void 0!==s)for(var l in s){var u=s[l];u.restoreOriginalState(),this._removeInactiveBinding(u)}},uncacheAction:function(t,e){var n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Object.assign(Fi.prototype,{_bindAction:function(t,e){var n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,a=t._propertyBindings,o=t._interpolants,s=n.uuid,l=this._bindingsByRootAndName,u=l[s];void 0===u&&(u={},l[s]=u);for(var c=0;c!==r;++c){var h=i[c],d=h.name,f=u[d];if(void 0!==f)a[c]=f;else{if(void 0!==(f=a[c])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,d));continue}var p=e&&e._propertyBindings[c].binding.parsedPath;f=new Di(Ni.create(n,d,p),h.ValueTypeName,h.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,s,d),a[c]=f}o[c].resultBuffer=f.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}for(var r=t._propertyBindings,a=0,o=r.length;a!==o;++a){var s=r[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,i=e.length;n!==i;++n){var r=e[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&e1){var u=l[1];i[u]||(i[u]={start:1/0,end:-1/0});var c=i[u];ac.end&&(c.end=a),e||(e=u)}}for(var u in i){var c=i[u];this.createAnimation(u,c.start,c.end,t)}this.firstAnimation=e},Ji.prototype.setAnimationDirectionForward=function(t){var e=this.animationsMap[t];e&&(e.direction=1,e.directionBackwards=!1)},Ji.prototype.setAnimationDirectionBackward=function(t){var e=this.animationsMap[t];e&&(e.direction=-1,e.directionBackwards=!0)},Ji.prototype.setAnimationFPS=function(t,e){var n=this.animationsMap[t];n&&(n.fps=e,n.duration=(n.end-n.start)/n.fps)},Ji.prototype.setAnimationDuration=function(t,e){var n=this.animationsMap[t];n&&(n.duration=e,n.fps=(n.end-n.start)/n.duration)},Ji.prototype.setAnimationWeight=function(t,e){var n=this.animationsMap[t];n&&(n.weight=e)},Ji.prototype.setAnimationTime=function(t,e){var n=this.animationsMap[t];n&&(n.time=e)},Ji.prototype.getAnimationTime=function(t){var e=0,n=this.animationsMap[t];return n&&(e=n.time),e},Ji.prototype.getAnimationDuration=function(t){var e=-1,n=this.animationsMap[t];return n&&(e=n.duration),e},Ji.prototype.playAnimation=function(t){var e=this.animationsMap[t];e?(e.time=0,e.active=!0):console.warn("THREE.MorphBlendMesh: animation["+t+"] undefined in .playAnimation()")},Ji.prototype.stopAnimation=function(t){var e=this.animationsMap[t];e&&(e.active=!1)},Ji.prototype.update=function(t){for(var e=0,n=this.animationsList.length;ei.duration||i.time<0)&&(i.direction*=-1,i.time>i.duration&&(i.time=i.duration,i.directionBackwards=!0),i.time<0&&(i.time=0,i.directionBackwards=!1)):(i.time=i.time%i.duration,i.time<0&&(i.time+=i.duration));var a=i.start+fs.clamp(Math.floor(i.time/r),0,i.length-1),o=i.weight;a!==i.currentFrame&&(this.morphTargetInfluences[i.lastFrame]=0,this.morphTargetInfluences[i.currentFrame]=1*o,this.morphTargetInfluences[a]=0,i.lastFrame=i.currentFrame,i.currentFrame=a);var s=i.time%r/r;i.directionBackwards&&(s=1-s),i.currentFrame!==i.lastFrame?(this.morphTargetInfluences[i.currentFrame]=s*o,this.morphTargetInfluences[i.lastFrame]=(1-s)*o):this.morphTargetInfluences[i.currentFrame]=o}}},$i.prototype=Object.create(ct.prototype),$i.prototype.constructor=$i,$i.prototype.isImmediateRenderObject=!0,tr.prototype=Object.create(Me.prototype),tr.prototype.constructor=tr,tr.prototype.update=function(){var t=new c,e=new c,n=new it;return function(){var i=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var r=this.object.matrixWorld,a=this.geometry.attributes.position,o=this.object.geometry;if(o&&o.isGeometry)for(var s=o.vertices,l=o.faces,u=0,c=0,h=l.length;c.99999?this.quaternion.set(0,0,0,1):n.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(n.z,0,-n.x).normalize(),t=Math.acos(n.y),this.quaternion.setFromAxisAngle(e,t))}}(),dr.prototype.setLength=function(t,e,n){void 0===e&&(e=.2*t),void 0===n&&(n=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},dr.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},fr.prototype=Object.create(Me.prototype),fr.prototype.constructor=fr;var js=new c,Ws=new pr,Gs=new pr,Vs=new pr;mr.prototype=Object.create(mi.prototype),mr.prototype.constructor=mr,mr.prototype.getPoint=function(t){var e=this.points,n=e.length;n<2&&console.log("duh, you need at least 2 points");var i=(n-(this.closed?0:1))*t,r=Math.floor(i),a=i-r;this.closed?r+=r>0?0:(Math.floor(Math.abs(r)/e.length)+1)*e.length:0===a&&r===n-1&&(r=n-2,a=1);var o,s,l,u;if(this.closed||r>0?o=e[(r-1)%n]:(js.subVectors(e[0],e[1]).add(e[0]),o=js),s=e[r%n],l=e[(r+1)%n],this.closed||r+20}function o(e,t){var n=e.interceptors||(e.interceptors=[]);return n.push(t),Se(function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)})}function a(e,t){var n=Mt();try{var r=e.interceptors;if(r)for(var i=0,o=r.length;i0}function l(e,t){var n=e.changeListeners||(e.changeListeners=[]);return n.push(t),Se(function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)})}function u(e,t){var n=Mt(),r=e.changeListeners;if(r){r=r.slice();for(var i=0,o=r.length;i=this.length,value:t0,"actions should have valid names, got: '"+e+"'");var n=function(){return S(e,t,this,arguments)};return n.originalFn=t,n.isMobxAction=!0,n}function S(e,t,n,r){var i=E(e,t,n,r);try{return t.apply(n,r)}finally{T(i)}}function E(e,t,n,r){var i=c()&&!!e,o=0;if(i){o=Date.now();var a=r&&r.length||0,s=new Array(a);if(a>0)for(var l=0;l",i="function"==typeof e?e:t,o="function"==typeof e?t:n;return _e("function"==typeof i,_("m002")),_e(0===i.length,_("m003")),_e("string"==typeof r&&r.length>0,"actions should have valid names, got: '"+r+"'"),S(r,i,o,void 0)}function B(e){return"function"==typeof e&&!0===e.isMobxAction}function F(e,t,n){var r=function(){return S(t,n,e,arguments)};r.isMobxAction=!0,Ae(e,t,r)}function U(e,t){return e===t}function j(e,t){return ze(e,t)}function W(e,t){return Be(e,t)||U(e,t)}function V(e,t,n){function r(){o(s)}var i,o,a;"string"==typeof e?(i=e,o=t,a=n):(i=e.name||"Autorun@"+xe(),o=e,a=t),_e("function"==typeof o,_("m004")),_e(!1===B(o),_("m005")),a&&(o=o.bind(a));var s=new Kn(i,function(){this.track(r)});return s.schedule(),s.getDisposer()}function G(e,t,n,r){var i,o,a,s;return"string"==typeof e?(i=e,o=t,a=n,s=r):(i="When@"+xe(),o=e,a=t,s=n),V(i,function(e){if(o.call(s)){e.dispose();var t=Mt();a.call(s),St(t)}})}function H(e,t,n,r){function i(){a(c)}var o,a,s,l;"string"==typeof e?(o=e,a=t,s=n,l=r):(o=e.name||"AutorunAsync@"+xe(),a=e,s=t,l=n),_e(!1===B(a),_("m006")),void 0===s&&(s=1),l&&(a=a.bind(l));var u=!1,c=new Kn(o,function(){u||(u=!0,setTimeout(function(){u=!1,c.isDisposed||c.track(i)},s))});return c.schedule(),c.getDisposer()}function Y(e,t,n){function r(){if(!u.isDisposed){var n=!1;u.track(function(){var t=e(u);n=a||!l(o,t),o=t}),a&&i.fireImmediately&&t(o,u),a||!0!==n||t(o,u),a&&(a=!1)}}arguments.length>3&&we(_("m007")),ce(e)&&we(_("m008"));var i;i="object"==typeof n?n:{},i.name=i.name||e.name||t.name||"Reaction@"+xe(),i.fireImmediately=!0===n||!0===i.fireImmediately,i.delay=i.delay||0,i.compareStructural=i.compareStructural||i.struct||!1,t=yn(i.name,i.context?t.bind(i.context):t),i.context&&(e=e.bind(i.context));var o,a=!0,s=!1,l=i.equals?i.equals:i.compareStructural||i.struct?bn.structural:bn.default,u=new Kn(i.name,function(){a||i.delay<1?r():s||(s=!0,setTimeout(function(){s=!1,r()},i.delay))});return u.schedule(),u.getDisposer()}function q(e,t){if(ne(e)&&e.hasOwnProperty("$mobx"))return e.$mobx;_e(Object.isExtensible(e),_("m035")),Ce(e)||(t=(e.constructor.name||"ObservableObject")+"@"+xe()),t||(t="ObservableObject@"+xe());var n=new _n(e,t);return Re(e,"$mobx",n),n}function X(e,t,n,r){if(e.values[t]&&!wn(e.values[t]))return _e("value"in n,"The property "+t+" in "+e.name+" is already observable, cannot redefine it as computed property"),void(e.target[t]=n.value);if("value"in n)if(ce(n.value)){var i=n.value;Z(e,t,i.initialValue,i.enhancer)}else B(n.value)&&!0===n.value.autoBind?F(e.target,t,n.value.originalFn):wn(n.value)?J(e,t,n.value):Z(e,t,n.value,r);else K(e,t,n.get,n.set,bn.default,!0)}function Z(e,t,n,r){if(Ie(e.target,t),i(e)){var o=a(e,{object:e.target,name:t,type:"add",newValue:n});if(!o)return;n=o.newValue}n=(e.values[t]=new fn(n,r,e.name+"."+t,!1)).value,Object.defineProperty(e.target,t,Q(t)),te(e,e.target,t,n)}function K(e,t,n,r,i,o){o&&Ie(e.target,t),e.values[t]=new xn(n,e.target,i,e.name+"."+t,r),o&&Object.defineProperty(e.target,t,$(t))}function J(e,t,n){var r=e.name+"."+t;n.name=r,n.scope||(n.scope=e.target),e.values[t]=n,Object.defineProperty(e.target,t,$(t))}function Q(e){return Mn[e]||(Mn[e]={configurable:!0,enumerable:!0,get:function(){return this.$mobx.values[e].get()},set:function(t){ee(this,e,t)}})}function $(e){return Sn[e]||(Sn[e]={configurable:!0,enumerable:!1,get:function(){return this.$mobx.values[e].get()},set:function(t){return this.$mobx.values[e].set(t)}})}function ee(e,t,n){var r=e.$mobx,o=r.values[t];if(i(r)){var l=a(r,{type:"update",object:e,name:t,newValue:n});if(!l)return;n=l.newValue}if((n=o.prepareNewValue(n))!==hn){var d=s(r),p=c(),l=d||p?{type:"update",object:e,oldValue:o.value,name:t,newValue:n}:null;p&&h(l),o.setNewValue(n),d&&u(r,l),p&&f()}}function te(e,t,n,r){var i=s(e),o=c(),a=i||o?{type:"add",object:t,name:n,newValue:r}:null;o&&h(a),i&&u(e,a),o&&f()}function ne(e){return!!ke(e)&&(I(e),En(e.$mobx))}function re(e,t){if(null===e||void 0===e)return!1;if(void 0!==t){if(w(e)||Dn(e))throw new Error(_("m019"));if(ne(e)){var n=e.$mobx;return n.values&&!!n.values[t]}return!1}return ne(e)||!!e.$mobx||tn(e)||$n(e)||wn(e)}function ie(e){return _e(!!e,":("),R(function(t,n,r,i,o){Ie(t,n),_e(!o||!o.get,_("m022")),Z(q(t,void 0),n,r,e)},function(e){var t=this.$mobx.values[e];if(void 0!==t)return t.get()},function(e,t){ee(this,e,t)},!0,!1)}function oe(e){for(var t=[],n=1;n=2,_("m014")),_e("object"==typeof e,_("m015")),_e(!Dn(e),_("m016")),n.forEach(function(e){_e("object"==typeof e,_("m017")),_e(!re(e),_("m018"))});for(var r=q(e),i={},o=n.length-1;o>=0;o--){var a=n[o];for(var s in a)if(!0!==i[s]&&Pe(a,s)){if(i[s]=!0,e===a&&!Le(e,s))continue;var l=Object.getOwnPropertyDescriptor(a,s);X(r,s,l,t)}}return e}function le(e){if(void 0===e&&(e=void 0),"string"==typeof arguments[1])return Tn.apply(null,arguments);if(_e(arguments.length<=1,_("m021")),_e(!ce(e),_("m020")),re(e))return e;var t=he(e,void 0,void 0);return t!==e?t:Rn.box(e)}function ue(e){we("Expected one or two arguments to observable."+e+". Did you accidentally try to use observable."+e+" as decorator?")}function ce(e){return"object"==typeof e&&null!==e&&!0===e.isMobxModifierDescriptor}function de(e,t){return _e(!ce(t),"Modifiers cannot be nested"),{isMobxModifierDescriptor:!0,initialValue:t,enhancer:e}}function he(e,t,n){return ce(e)&&we("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),re(e)?e:Array.isArray(e)?Rn.array(e,n):Ce(e)?Rn.object(e,n):je(e)?Rn.map(e,n):e}function fe(e,t,n){return ce(e)&&we("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),void 0===e||null===e?e:ne(e)||w(e)||Dn(e)?e:Array.isArray(e)?Rn.shallowArray(e,n):Ce(e)?Rn.shallowObject(e,n):je(e)?Rn.shallowMap(e,n):we("The shallow modifier / decorator can only used in combination with arrays, objects and maps")}function pe(e){return e}function me(e,t,n){if(ze(e,t))return t;if(re(e))return e;if(Array.isArray(e))return new un(e,me,n);if(je(e))return new In(e,me,n);if(Ce(e)){var r={};return q(r,n),se(r,me,[e]),r}return e}function ge(e,t,n){return ze(e,t)?t:e}function ve(e,t){void 0===t&&(t=void 0),st();try{return e.apply(t)}finally{lt()}}function ye(e){return Me("`mobx.map` is deprecated, use `new ObservableMap` or `mobx.observable.map` instead"),Rn.map(e)}function be(){return"undefined"!=typeof window?window:e}function xe(){return++Wn.mobxGuid}function we(e,t){throw _e(!1,e,t),"X"}function _e(e,t,n){if(!e)throw new Error("[mobx] Invariant failed: "+t+(n?" in '"+n+"'":""))}function Me(e){return-1===Nn.indexOf(e)&&(Nn.push(e),console.error("[mobx] Deprecated: "+e),!0)}function Se(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}function Ee(e){var t=[];return e.forEach(function(e){-1===t.indexOf(e)&&t.push(e)}),t}function Te(e,t,n){return void 0===t&&(t=100),void 0===n&&(n=" - "),e?e.slice(0,t).join(n)+(e.length>t?" (... and "+(e.length-t)+"more)":""):""}function ke(e){return null!==e&&"object"==typeof e}function Ce(e){if(null===e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Oe(){for(var e=arguments[0],t=1,n=arguments.length;t=0;i--)if(!ze(e[i],t[i]))return!1;return!0}if(r){if(e.size!==t.size)return!1;var o=!0;return e.forEach(function(e,n){o=o&&ze(t.get(n),e)}),o}if("object"==typeof e&&"object"==typeof t){if(null===e||null===t)return!1;if(Ue(e)&&Ue(t))return e.size===t.size&&ze(Rn.shallowMap(e).entries(),Rn.shallowMap(t).entries());if(De(e).length!==De(t).length)return!1;for(var a in e){if(!(a in t))return!1;if(!ze(e[a],t[a]))return!1}return!0}return!1}function Ne(e,t){var n="isMobX"+e;return t.prototype[n]=!0,function(e){return ke(e)&&!0===e[n]}}function Be(e,t){return"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)}function Fe(e){return Array.isArray(e)||w(e)}function Ue(e){return je(e)||Dn(e)}function je(e){return void 0!==be().Map&&e instanceof be().Map}function We(e){var t;return Ce(e)?t=Object.keys(e):Array.isArray(e)?t=e.map(function(e){return e[0]}):Ue(e)?t=Array.from(e.keys()):we("Cannot get keys from "+e),t}function Ve(){return"function"==typeof Symbol&&Symbol.toPrimitive||"@@toPrimitive"}function Ge(e){return null===e?null:"object"==typeof e?""+e:e}function He(){Gn=!0,be().__mobxInstanceCount--}function Ye(){Me("Using `shareGlobalState` is not recommended, use peer dependencies instead. See https://github.com/mobxjs/mobx/issues/1082 for details."),Vn=!0;var e=be(),t=Wn;if(e.__mobservableTrackingStack||e.__mobservableViewStack)throw new Error("[mobx] An incompatible version of mobservable is already loaded.");if(e.__mobxGlobal&&e.__mobxGlobal.version!==t.version)throw new Error("[mobx] An incompatible version of mobx is already loaded.");e.__mobxGlobal?Wn=e.__mobxGlobal:e.__mobxGlobal=t}function qe(){return Wn}function Xe(){Wn.resetId++;var e=new jn;for(var t in e)-1===Un.indexOf(t)&&(Wn[t]=e[t]);Wn.allowStateChanges=!Wn.strictMode}function Ze(e,t){if("object"==typeof e&&null!==e){if(w(e))return _e(void 0===t,_("m036")),e.$mobx.atom;if(Dn(e)){var n=e;if(void 0===t)return Ze(n._keys);var r=n._data[t]||n._hasMap[t];return _e(!!r,"the entry '"+t+"' does not exist in the observable map '"+Je(e)+"'"),r}if(I(e),t&&!e.$mobx&&e[t],ne(e)){if(!t)return we("please specify a property");var r=e.$mobx.values[t];return _e(!!r,"no observable property '"+t+"' found on the observable object '"+Je(e)+"'"),r}if(tn(e)||wn(e)||$n(e))return e}else if("function"==typeof e&&$n(e.$mobx))return e.$mobx;return we("Cannot obtain atom from "+e)}function Ke(e,t){return _e(e,"Expecting some object"),void 0!==t?Ke(Ze(e,t)):tn(e)||wn(e)||$n(e)?e:Dn(e)?e:(I(e),e.$mobx?e.$mobx:void _e(!1,"Cannot obtain administration from "+e))}function Je(e,t){var n;return n=void 0!==t?Ze(e,t):ne(e)||Dn(e)?Ke(e):Ze(e),n.name}function Qe(e,t){return $e(Ze(e,t))}function $e(e){var t={name:e.name};return e.observing&&e.observing.length>0&&(t.dependencies=Ee(e.observing).map($e)),t}function et(e,t){return tt(Ze(e,t))}function tt(e){var t={name:e.name};return nt(e)&&(t.observers=rt(e).map(tt)),t}function nt(e){return e.observers&&e.observers.length>0}function rt(e){return e.observers}function it(e,t){var n=e.observers.length;n&&(e.observersIndexes[t.__mapid]=n),e.observers[n]=t,e.lowestObserverState>t.dependenciesState&&(e.lowestObserverState=t.dependenciesState)}function ot(e,t){if(1===e.observers.length)e.observers.length=0,at(e);else{var n=e.observers,r=e.observersIndexes,i=n.pop();if(i!==t){var o=r[t.__mapid]||0;o?r[i.__mapid]=o:delete r[i.__mapid],n[o]=i}delete r[t.__mapid]}}function at(e){e.isPendingUnobservation||(e.isPendingUnobservation=!0,Wn.pendingUnobservations.push(e))}function st(){Wn.inBatch++}function lt(){if(0==--Wn.inBatch){Rt();for(var e=Wn.pendingUnobservations,t=0;t=1e3)return void t.push("(and many more)");t.push(""+new Array(n).join("\t")+e.name),e.dependencies&&e.dependencies.forEach(function(e){return pt(e,t,n+1)})}function mt(e){return e instanceof Zn}function gt(e){switch(e.dependenciesState){case qn.UP_TO_DATE:return!1;case qn.NOT_TRACKING:case qn.STALE:return!0;case qn.POSSIBLY_STALE:for(var t=Mt(),n=e.observing,r=n.length,i=0;i0;Wn.computationDepth>0&&t&&we(_("m031")+e.name),!Wn.allowStateChanges&&t&&we(_(Wn.strictMode?"m030a":"m030b")+e.name)}function bt(e,t,n){Et(e),e.newObserving=new Array(e.observing.length+100),e.unboundDepsCount=0,e.runId=++Wn.runId;var r=Wn.trackingDerivation;Wn.trackingDerivation=e;var i;try{i=t.call(n)}catch(e){i=new Zn(e)}return Wn.trackingDerivation=r,xt(e),i}function xt(e){for(var t=e.observing,n=e.observing=e.newObserving,r=qn.UP_TO_DATE,i=0,o=e.unboundDepsCount,a=0;ar&&(r=s.dependenciesState)}for(n.length=i,e.newObserving=null,o=t.length;o--;){var s=t[o];0===s.diffValue&&ot(s,e),s.diffValue=0}for(;i--;){var s=n[i];1===s.diffValue&&(s.diffValue=0,it(s,e))}r!==qn.UP_TO_DATE&&(e.dependenciesState=r,e.onBecomeStale())}function wt(e){var t=e.observing;e.observing=[];for(var n=t.length;n--;)ot(t[n],e);e.dependenciesState=qn.NOT_TRACKING}function _t(e){var t=Mt(),n=e();return St(t),n}function Mt(){var e=Wn.trackingDerivation;return Wn.trackingDerivation=null,e}function St(e){Wn.trackingDerivation=e}function Et(e){if(e.dependenciesState!==qn.UP_TO_DATE){e.dependenciesState=qn.UP_TO_DATE;for(var t=e.observing,n=t.length;n--;)t[n].lowestObserverState=qn.UP_TO_DATE}}function Tt(e){return console.log(e),e}function kt(e,t){return Me("`whyRun` is deprecated in favor of `trace`"),e=Ot(arguments),e?wn(e)||$n(e)?Tt(e.whyRun()):we(_("m025")):Tt(_("m024"))}function Ct(){for(var e=[],t=0;t=0&&Wn.globalReactionErrorHandlers.splice(t,1)}}function Rt(){Wn.inBatch>0||Wn.isRunningReactions||Qn(Lt)}function Lt(){Wn.isRunningReactions=!0;for(var e=Wn.pendingReactions,t=0;e.length>0;){++t===Jn&&(console.error("Reaction doesn't converge to a stable state after "+Jn+" iterations. Probably there is a cycle in the reactive function: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r0}function a(t,e){var n=t.interceptors||(t.interceptors=[]);return n.push(e),St(function(){var t=n.indexOf(e);-1!==t&&n.splice(t,1)})}function o(t,e){var n=Me();try{var i=t.interceptors;if(i)for(var r=0,a=i.length;r0}function l(t,e){var n=t.changeListeners||(t.changeListeners=[]);return n.push(e),St(function(){var t=n.indexOf(e);-1!==t&&n.splice(t,1)})}function u(t,e){var n=Me(),i=t.changeListeners;if(i){i=i.slice();for(var r=0,a=i.length;r=this.length,value:e0,"actions should have valid names, got: '"+t+"'");var n=function(){return S(t,e,this,arguments)};return n.originalFn=e,n.isMobxAction=!0,n}function S(t,e,n,i){var r=E(t,e,n,i);try{return e.apply(n,i)}finally{k(r)}}function E(t,e,n,i){var r=c()&&!!t,a=0;if(r){a=Date.now();var o=i&&i.length||0,s=new Array(o);if(o>0)for(var l=0;l",r="function"==typeof t?t:e,a="function"==typeof t?e:n;return wt("function"==typeof r,w("m002")),wt(0===r.length,w("m003")),wt("string"==typeof i&&i.length>0,"actions should have valid names, got: '"+i+"'"),S(i,r,a,void 0)}function B(t){return"function"==typeof t&&!0===t.isMobxAction}function F(t,e,n){var i=function(){return S(e,n,t,arguments)};i.isMobxAction=!0,At(t,e,i)}function U(t,e){return t===e}function j(t,e){return Nt(t,e)}function W(t,e){return Bt(t,e)||U(t,e)}function G(t,e,n){function i(){a(s)}var r,a,o;"string"==typeof t?(r=t,a=e,o=n):(r=t.name||"Autorun@"+xt(),a=t,o=e),wt("function"==typeof a,w("m004")),wt(!1===B(a),w("m005")),o&&(a=a.bind(o));var s=new Kn(r,function(){this.track(i)});return s.schedule(),s.getDisposer()}function V(t,e,n,i){var r,a,o,s;return"string"==typeof t?(r=t,a=e,o=n,s=i):(r="When@"+xt(),a=t,o=e,s=n),G(r,function(t){if(a.call(s)){t.dispose();var e=Me();o.call(s),Se(e)}})}function H(t,e,n,i){function r(){o(c)}var a,o,s,l;"string"==typeof t?(a=t,o=e,s=n,l=i):(a=t.name||"AutorunAsync@"+xt(),o=t,s=e,l=n),wt(!1===B(o),w("m006")),void 0===s&&(s=1),l&&(o=o.bind(l));var u=!1,c=new Kn(a,function(){u||(u=!0,setTimeout(function(){u=!1,c.isDisposed||c.track(r)},s))});return c.schedule(),c.getDisposer()}function Y(t,e,n){function i(){if(!u.isDisposed){var n=!1;u.track(function(){var e=t(u);n=o||!l(a,e),a=e}),o&&r.fireImmediately&&e(a,u),o||!0!==n||e(a,u),o&&(o=!1)}}arguments.length>3&&_t(w("m007")),ct(t)&&_t(w("m008"));var r;r="object"==typeof n?n:{},r.name=r.name||t.name||e.name||"Reaction@"+xt(),r.fireImmediately=!0===n||!0===r.fireImmediately,r.delay=r.delay||0,r.compareStructural=r.compareStructural||r.struct||!1,e=yn(r.name,r.context?e.bind(r.context):e),r.context&&(t=t.bind(r.context));var a,o=!0,s=!1,l=r.equals?r.equals:r.compareStructural||r.struct?bn.structural:bn.default,u=new Kn(r.name,function(){o||r.delay<1?i():s||(s=!0,setTimeout(function(){s=!1,i()},r.delay))});return u.schedule(),u.getDisposer()}function q(t,e){if(nt(t)&&t.hasOwnProperty("$mobx"))return t.$mobx;wt(Object.isExtensible(t),w("m035")),Ct(t)||(e=(t.constructor.name||"ObservableObject")+"@"+xt()),e||(e="ObservableObject@"+xt());var n=new wn(t,e);return Rt(t,"$mobx",n),n}function X(t,e,n,i){if(t.values[e]&&!_n(t.values[e]))return wt("value"in n,"The property "+e+" in "+t.name+" is already observable, cannot redefine it as computed property"),void(t.target[e]=n.value);if("value"in n)if(ct(n.value)){var r=n.value;Z(t,e,r.initialValue,r.enhancer)}else B(n.value)&&!0===n.value.autoBind?F(t.target,e,n.value.originalFn):_n(n.value)?Q(t,e,n.value):Z(t,e,n.value,i);else K(t,e,n.get,n.set,bn.default,!0)}function Z(t,e,n,i){if(It(t.target,e),r(t)){var a=o(t,{object:t.target,name:e,type:"add",newValue:n});if(!a)return;n=a.newValue}n=(t.values[e]=new fn(n,i,t.name+"."+e,!1)).value,Object.defineProperty(t.target,e,J(e)),et(t,t.target,e,n)}function K(t,e,n,i,r,a){a&&It(t.target,e),t.values[e]=new xn(n,t.target,r,t.name+"."+e,i),a&&Object.defineProperty(t.target,e,$(e))}function Q(t,e,n){var i=t.name+"."+e;n.name=i,n.scope||(n.scope=t.target),t.values[e]=n,Object.defineProperty(t.target,e,$(e))}function J(t){return Mn[t]||(Mn[t]={configurable:!0,enumerable:!0,get:function(){return this.$mobx.values[t].get()},set:function(e){tt(this,t,e)}})}function $(t){return Sn[t]||(Sn[t]={configurable:!0,enumerable:!1,get:function(){return this.$mobx.values[t].get()},set:function(e){return this.$mobx.values[t].set(e)}})}function tt(t,e,n){var i=t.$mobx,a=i.values[e];if(r(i)){var l=o(i,{type:"update",object:t,name:e,newValue:n});if(!l)return;n=l.newValue}if((n=a.prepareNewValue(n))!==dn){var h=s(i),p=c(),l=h||p?{type:"update",object:t,oldValue:a.value,name:e,newValue:n}:null;p&&d(l),a.setNewValue(n),h&&u(i,l),p&&f()}}function et(t,e,n,i){var r=s(t),a=c(),o=r||a?{type:"add",object:e,name:n,newValue:i}:null;a&&d(o),r&&u(t,o),a&&f()}function nt(t){return!!Tt(t)&&(I(t),En(t.$mobx))}function it(t,e){if(null===t||void 0===t)return!1;if(void 0!==e){if(_(t)||Dn(t))throw new Error(w("m019"));if(nt(t)){var n=t.$mobx;return n.values&&!!n.values[e]}return!1}return nt(t)||!!t.$mobx||en(t)||$n(t)||_n(t)}function rt(t){return wt(!!t,":("),R(function(e,n,i,r,a){It(e,n),wt(!a||!a.get,w("m022")),Z(q(e,void 0),n,i,t)},function(t){var e=this.$mobx.values[t];if(void 0!==e)return e.get()},function(t,e){tt(this,t,e)},!0,!1)}function at(t){for(var e=[],n=1;n=2,w("m014")),wt("object"==typeof t,w("m015")),wt(!Dn(t),w("m016")),n.forEach(function(t){wt("object"==typeof t,w("m017")),wt(!it(t),w("m018"))});for(var i=q(t),r={},a=n.length-1;a>=0;a--){var o=n[a];for(var s in o)if(!0!==r[s]&&Pt(o,s)){if(r[s]=!0,t===o&&!Lt(t,s))continue;var l=Object.getOwnPropertyDescriptor(o,s);X(i,s,l,e)}}return t}function lt(t){if(void 0===t&&(t=void 0),"string"==typeof arguments[1])return kn.apply(null,arguments);if(wt(arguments.length<=1,w("m021")),wt(!ct(t),w("m020")),it(t))return t;var e=dt(t,void 0,void 0);return e!==t?e:Rn.box(t)}function ut(t){_t("Expected one or two arguments to observable."+t+". Did you accidentally try to use observable."+t+" as decorator?")}function ct(t){return"object"==typeof t&&null!==t&&!0===t.isMobxModifierDescriptor}function ht(t,e){return wt(!ct(e),"Modifiers cannot be nested"),{isMobxModifierDescriptor:!0,initialValue:e,enhancer:t}}function dt(t,e,n){return ct(t)&&_t("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),it(t)?t:Array.isArray(t)?Rn.array(t,n):Ct(t)?Rn.object(t,n):jt(t)?Rn.map(t,n):t}function ft(t,e,n){return ct(t)&&_t("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),void 0===t||null===t?t:nt(t)||_(t)||Dn(t)?t:Array.isArray(t)?Rn.shallowArray(t,n):Ct(t)?Rn.shallowObject(t,n):jt(t)?Rn.shallowMap(t,n):_t("The shallow modifier / decorator can only used in combination with arrays, objects and maps")}function pt(t){return t}function mt(t,e,n){if(Nt(t,e))return e;if(it(t))return t;if(Array.isArray(t))return new un(t,mt,n);if(jt(t))return new In(t,mt,n);if(Ct(t)){var i={};return q(i,n),st(i,mt,[t]),i}return t}function gt(t,e,n){return Nt(t,e)?e:t}function vt(t,e){void 0===e&&(e=void 0),se();try{return t.apply(e)}finally{le()}}function yt(t){return Mt("`mobx.map` is deprecated, use `new ObservableMap` or `mobx.observable.map` instead"),Rn.map(t)}function bt(){return"undefined"!=typeof window?window:t}function xt(){return++Wn.mobxGuid}function _t(t,e){throw wt(!1,t,e),"X"}function wt(t,e,n){if(!t)throw new Error("[mobx] Invariant failed: "+e+(n?" in '"+n+"'":""))}function Mt(t){return-1===zn.indexOf(t)&&(zn.push(t),console.error("[mobx] Deprecated: "+t),!0)}function St(t){var e=!1;return function(){if(!e)return e=!0,t.apply(this,arguments)}}function Et(t){var e=[];return t.forEach(function(t){-1===e.indexOf(t)&&e.push(t)}),e}function kt(t,e,n){return void 0===e&&(e=100),void 0===n&&(n=" - "),t?t.slice(0,e).join(n)+(t.length>e?" (... and "+(t.length-e)+"more)":""):""}function Tt(t){return null!==t&&"object"==typeof t}function Ct(t){if(null===t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function Ot(){for(var t=arguments[0],e=1,n=arguments.length;e=0;r--)if(!Nt(t[r],e[r]))return!1;return!0}if(i){if(t.size!==e.size)return!1;var a=!0;return t.forEach(function(t,n){a=a&&Nt(e.get(n),t)}),a}if("object"==typeof t&&"object"==typeof e){if(null===t||null===e)return!1;if(Ut(t)&&Ut(e))return t.size===e.size&&Nt(Rn.shallowMap(t).entries(),Rn.shallowMap(e).entries());if(Dt(t).length!==Dt(e).length)return!1;for(var o in t){if(!(o in e))return!1;if(!Nt(t[o],e[o]))return!1}return!0}return!1}function zt(t,e){var n="isMobX"+t;return e.prototype[n]=!0,function(t){return Tt(t)&&!0===t[n]}}function Bt(t,e){return"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)}function Ft(t){return Array.isArray(t)||_(t)}function Ut(t){return jt(t)||Dn(t)}function jt(t){return void 0!==bt().Map&&t instanceof bt().Map}function Wt(t){var e;return Ct(t)?e=Object.keys(t):Array.isArray(t)?e=t.map(function(t){return t[0]}):Ut(t)?e=Array.from(t.keys()):_t("Cannot get keys from "+t),e}function Gt(){return"function"==typeof Symbol&&Symbol.toPrimitive||"@@toPrimitive"}function Vt(t){return null===t?null:"object"==typeof t?""+t:t}function Ht(){Vn=!0,bt().__mobxInstanceCount--}function Yt(){Mt("Using `shareGlobalState` is not recommended, use peer dependencies instead. See https://github.com/mobxjs/mobx/issues/1082 for details."),Gn=!0;var t=bt(),e=Wn;if(t.__mobservableTrackingStack||t.__mobservableViewStack)throw new Error("[mobx] An incompatible version of mobservable is already loaded.");if(t.__mobxGlobal&&t.__mobxGlobal.version!==e.version)throw new Error("[mobx] An incompatible version of mobx is already loaded.");t.__mobxGlobal?Wn=t.__mobxGlobal:t.__mobxGlobal=e}function qt(){return Wn}function Xt(){Wn.resetId++;var t=new jn;for(var e in t)-1===Un.indexOf(e)&&(Wn[e]=t[e]);Wn.allowStateChanges=!Wn.strictMode}function Zt(t,e){if("object"==typeof t&&null!==t){if(_(t))return wt(void 0===e,w("m036")),t.$mobx.atom;if(Dn(t)){var n=t;if(void 0===e)return Zt(n._keys);var i=n._data[e]||n._hasMap[e];return wt(!!i,"the entry '"+e+"' does not exist in the observable map '"+Qt(t)+"'"),i}if(I(t),e&&!t.$mobx&&t[e],nt(t)){if(!e)return _t("please specify a property");var i=t.$mobx.values[e];return wt(!!i,"no observable property '"+e+"' found on the observable object '"+Qt(t)+"'"),i}if(en(t)||_n(t)||$n(t))return t}else if("function"==typeof t&&$n(t.$mobx))return t.$mobx;return _t("Cannot obtain atom from "+t)}function Kt(t,e){return wt(t,"Expecting some object"),void 0!==e?Kt(Zt(t,e)):en(t)||_n(t)||$n(t)?t:Dn(t)?t:(I(t),t.$mobx?t.$mobx:void wt(!1,"Cannot obtain administration from "+t))}function Qt(t,e){var n;return n=void 0!==e?Zt(t,e):nt(t)||Dn(t)?Kt(t):Zt(t),n.name}function Jt(t,e){return $t(Zt(t,e))}function $t(t){var e={name:t.name};return t.observing&&t.observing.length>0&&(e.dependencies=Et(t.observing).map($t)),e}function te(t,e){return ee(Zt(t,e))}function ee(t){var e={name:t.name};return ne(t)&&(e.observers=ie(t).map(ee)),e}function ne(t){return t.observers&&t.observers.length>0}function ie(t){return t.observers}function re(t,e){var n=t.observers.length;n&&(t.observersIndexes[e.__mapid]=n),t.observers[n]=e,t.lowestObserverState>e.dependenciesState&&(t.lowestObserverState=e.dependenciesState)}function ae(t,e){if(1===t.observers.length)t.observers.length=0,oe(t);else{var n=t.observers,i=t.observersIndexes,r=n.pop();if(r!==e){var a=i[e.__mapid]||0;a?i[r.__mapid]=a:delete i[r.__mapid],n[a]=r}delete i[e.__mapid]}}function oe(t){t.isPendingUnobservation||(t.isPendingUnobservation=!0,Wn.pendingUnobservations.push(t))}function se(){Wn.inBatch++}function le(){if(0==--Wn.inBatch){Re();for(var t=Wn.pendingUnobservations,e=0;e=1e3)return void e.push("(and many more)");e.push(""+new Array(n).join("\t")+t.name),t.dependencies&&t.dependencies.forEach(function(t){return pe(t,e,n+1)})}function me(t){return t instanceof Zn}function ge(t){switch(t.dependenciesState){case qn.UP_TO_DATE:return!1;case qn.NOT_TRACKING:case qn.STALE:return!0;case qn.POSSIBLY_STALE:for(var e=Me(),n=t.observing,i=n.length,r=0;r0;Wn.computationDepth>0&&e&&_t(w("m031")+t.name),!Wn.allowStateChanges&&e&&_t(w(Wn.strictMode?"m030a":"m030b")+t.name)}function be(t,e,n){Ee(t),t.newObserving=new Array(t.observing.length+100),t.unboundDepsCount=0,t.runId=++Wn.runId;var i=Wn.trackingDerivation;Wn.trackingDerivation=t;var r;try{r=e.call(n)}catch(t){r=new Zn(t)}return Wn.trackingDerivation=i,xe(t),r}function xe(t){for(var e=t.observing,n=t.observing=t.newObserving,i=qn.UP_TO_DATE,r=0,a=t.unboundDepsCount,o=0;oi&&(i=s.dependenciesState)}for(n.length=r,t.newObserving=null,a=e.length;a--;){var s=e[a];0===s.diffValue&&ae(s,t),s.diffValue=0}for(;r--;){var s=n[r];1===s.diffValue&&(s.diffValue=0,re(s,t))}i!==qn.UP_TO_DATE&&(t.dependenciesState=i,t.onBecomeStale())}function _e(t){var e=t.observing;t.observing=[];for(var n=e.length;n--;)ae(e[n],t);t.dependenciesState=qn.NOT_TRACKING}function we(t){var e=Me(),n=t();return Se(e),n}function Me(){var t=Wn.trackingDerivation;return Wn.trackingDerivation=null,t}function Se(t){Wn.trackingDerivation=t}function Ee(t){if(t.dependenciesState!==qn.UP_TO_DATE){t.dependenciesState=qn.UP_TO_DATE;for(var e=t.observing,n=e.length;n--;)e[n].lowestObserverState=qn.UP_TO_DATE}}function ke(t){return console.log(t),t}function Te(t,e){return Mt("`whyRun` is deprecated in favor of `trace`"),t=Oe(arguments),t?_n(t)||$n(t)?ke(t.whyRun()):_t(w("m025")):ke(w("m024"))}function Ce(){for(var t=[],e=0;e=0&&Wn.globalReactionErrorHandlers.splice(e,1)}}function Re(){Wn.inBatch>0||Wn.isRunningReactions||Jn(Le)}function Le(){Wn.isRunningReactions=!0;for(var t=Wn.pendingReactions,e=0;t.length>0;){++e===Qn&&(console.error("Reaction doesn't converge to a stable state after "+Qn+" iterations. Probably there is a cycle in the reactive function: "+t[0]),t.splice(0));for(var n=t.splice(0),i=0,r=n.length;it){for(var n=new Array(e-t),r=0;r0&&e+t+1>an&&x(e+t+1)},e.prototype.spliceWithArray=function(e,t,n){var r=this;yt(this.atom);var o=this.values.length;if(void 0===e?e=0:e>o?e=o:e<0&&(e=Math.max(0,o+e)),t=1===arguments.length?o-e:void 0===t||null===t?0:Math.max(0,Math.min(t,o-e)),void 0===n&&(n=[]),i(this)){var s=a(this,{object:this.array,type:"splice",index:e,removedCount:t,added:n});if(!s)return zn;t=s.removedCount,n=s.added}n=n.map(function(e){return r.enhancer(e,void 0)});var l=n.length-t;this.updateArrayLength(o,l);var u=this.spliceItemsIntoValues(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice(e,n,u),this.dehanceValues(u)},e.prototype.spliceItemsIntoValues=function(e,t,n){if(n.length<1e4)return(i=this.values).splice.apply(i,[e,t].concat(n));var r=this.values.slice(e,e+t);return this.values=this.values.slice(0,e).concat(n,this.values.slice(e+t)),r;var i},e.prototype.notifyArrayChildUpdate=function(e,t,n){var r=!this.owned&&c(),i=s(this),o=i||r?{object:this.array,type:"update",index:e,newValue:t,oldValue:n}:null;r&&h(o),this.atom.reportChanged(),i&&u(this,o),r&&f()},e.prototype.notifyArraySplice=function(e,t,n){var r=!this.owned&&c(),i=s(this),o=i||r?{object:this.array,type:"splice",index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&h(o),this.atom.reportChanged(),i&&u(this,o),r&&f()},e}(),un=function(e){function t(t,n,r,i){void 0===r&&(r="ObservableArray@"+xe()),void 0===i&&(i=!1);var o=e.call(this)||this,a=new ln(r,n,o,i);return Re(o,"$mobx",a),t&&t.length&&o.spliceWithArray(0,0,t),on&&Object.defineProperty(a.array,"0",cn),o}return r(t,e),t.prototype.intercept=function(e){return this.$mobx.intercept(e)},t.prototype.observe=function(e,t){return void 0===t&&(t=!1),this.$mobx.observe(e,t)},t.prototype.clear=function(){return this.splice(0)},t.prototype.concat=function(){for(var e=[],t=0;t-1&&(this.splice(t,1),!0)},t.prototype.move=function(e,t){function n(e){if(e<0)throw new Error("[mobx.array] Index out of bounds: "+e+" is negative");var t=this.$mobx.values.length;if(e>=t)throw new Error("[mobx.array] Index out of bounds: "+e+" is not smaller than "+t)}if(n.call(this,e),n.call(this,t),e!==t){var r,i=this.$mobx.values;r=e";Ae(e,t,yn(o,n))},function(e){return this[e]},function(){_e(!1,_("m001"))},!1,!0),vn=R(function(e,t,n){F(e,t,n)},function(e){return this[e]},function(){_e(!1,_("m001"))},!1,!1),yn=function(e,t,n,r){return 1===arguments.length&&"function"==typeof e?M(e.name||"",e):2===arguments.length&&"function"==typeof t?M(e,t):1===arguments.length&&"string"==typeof e?z(e):z(t).apply(null,arguments)};yn.bound=function(e,t,n){if("function"==typeof e){var r=M("",e);return r.autoBind=!0,r}return vn.apply(null,arguments)};var bn={identity:U,structural:j,default:W},xn=function(){function e(e,t,n,r,i){this.derivation=e,this.scope=t,this.equals=n,this.dependenciesState=qn.NOT_TRACKING,this.observing=[],this.newObserving=null,this.isPendingUnobservation=!1,this.observers=[],this.observersIndexes={},this.diffValue=0,this.runId=0,this.lastAccessedBy=0,this.lowestObserverState=qn.UP_TO_DATE,this.unboundDepsCount=0,this.__mapid="#"+xe(),this.value=new Zn(null),this.isComputing=!1,this.isRunningSetter=!1,this.isTracing=Xn.NONE,this.name=r||"ComputedValue@"+xe(),i&&(this.setter=M(r+"-setter",i))}return e.prototype.onBecomeStale=function(){ht(this)},e.prototype.onBecomeUnobserved=function(){wt(this),this.value=void 0},e.prototype.get=function(){_e(!this.isComputing,"Cycle detected in computation "+this.name,this.derivation),0===Wn.inBatch?(st(),gt(this)&&(this.isTracing!==Xn.NONE&&console.log("[mobx.trace] '"+this.name+"' is being read outside a reactive context and doing a full recompute"),this.value=this.computeValue(!1)),lt()):(ut(this),gt(this)&&this.trackAndCompute()&&dt(this));var e=this.value;if(mt(e))throw e.cause;return e},e.prototype.peek=function(){var e=this.computeValue(!1);if(mt(e))throw e.cause;return e},e.prototype.set=function(e){if(this.setter){_e(!this.isRunningSetter,"The setter of computed value '"+this.name+"' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"),this.isRunningSetter=!0;try{this.setter.call(this.scope,e)}finally{this.isRunningSetter=!1}}else _e(!1,"[ComputedValue '"+this.name+"'] It is not possible to assign a new value to a computed value.")},e.prototype.trackAndCompute=function(){c()&&d({object:this.scope,type:"compute",fn:this.derivation});var e=this.value,t=this.dependenciesState===qn.NOT_TRACKING,n=this.value=this.computeValue(!0);return t||mt(e)||mt(n)||!this.equals(e,n)},e.prototype.computeValue=function(e){this.isComputing=!0,Wn.computationDepth++;var t;if(e)t=bt(this,this.derivation,this.scope);else try{t=this.derivation.call(this.scope)}catch(e){t=new Zn(e)}return Wn.computationDepth--,this.isComputing=!1,t},e.prototype.observe=function(e,t){var n=this,r=!0,i=void 0;return V(function(){var o=n.get();if(!r||t){var a=Mt();e({type:"update",object:n,newValue:o,oldValue:i}),St(a)}r=!1,i=o})},e.prototype.toJSON=function(){return this.get()},e.prototype.toString=function(){return this.name+"["+this.derivation.toString()+"]"},e.prototype.valueOf=function(){return Ge(this.get())},e.prototype.whyRun=function(){var e=Boolean(Wn.trackingDerivation),t=Ee(this.isComputing?this.newObserving:this.observing).map(function(e){return e.name}),n=Ee(rt(this).map(function(e){return e.name}));return"\nWhyRun? computation '"+this.name+"':\n * Running because: "+(e?"[active] the value of this computation is needed by a reaction":this.isComputing?"[get] The value of this computed was requested outside a reaction":"[idle] not running at the moment")+"\n"+(this.dependenciesState===qn.NOT_TRACKING?_("m032"):" * This computation will re-run if any of the following observables changes:\n "+Te(t)+"\n "+(this.isComputing&&e?" (... or any observable accessed during the remainder of the current run)":"")+"\n "+_("m038")+"\n\n * If the outcome of this computation changes, the following observers will be re-run:\n "+Te(n)+"\n")},e}();xn.prototype[Ve()]=xn.prototype.valueOf;var wn=Ne("ComputedValue",xn),_n=function(){function e(e,t){this.target=e,this.name=t,this.values={},this.changeListeners=null,this.interceptors=null}return e.prototype.observe=function(e,t){return _e(!0!==t,"`observe` doesn't support the fire immediately property for observable objects."),l(this,e)},e.prototype.intercept=function(e){return o(this,e)},e}(),Mn={},Sn={},En=Ne("ObservableObjectAdministration",_n),Tn=ie(he),kn=ie(fe),Cn=ie(pe),On=ie(me),Pn=ie(ge),An={box:function(e,t){return arguments.length>2&&ue("box"),new fn(e,he,t)},shallowBox:function(e,t){return arguments.length>2&&ue("shallowBox"),new fn(e,pe,t)},array:function(e,t){return arguments.length>2&&ue("array"),new un(e,he,t)},shallowArray:function(e,t){return arguments.length>2&&ue("shallowArray"),new un(e,pe,t)},map:function(e,t){return arguments.length>2&&ue("map"),new In(e,he,t)},shallowMap:function(e,t){return arguments.length>2&&ue("shallowMap"),new In(e,pe,t)},object:function(e,t){arguments.length>2&&ue("object");var n={};return q(n,t),oe(n,e),n},shallowObject:function(e,t){arguments.length>2&&ue("shallowObject");var n={};return q(n,t),ae(n,e),n},ref:function(){return arguments.length<2?de(pe,arguments[0]):Cn.apply(null,arguments)},shallow:function(){return arguments.length<2?de(fe,arguments[0]):kn.apply(null,arguments)},deep:function(){return arguments.length<2?de(he,arguments[0]):Tn.apply(null,arguments)},struct:function(){return arguments.length<2?de(me,arguments[0]):On.apply(null,arguments)}},Rn=le;Object.keys(An).forEach(function(e){return Rn[e]=An[e]}),Rn.deep.struct=Rn.struct,Rn.ref.struct=function(){return arguments.length<2?de(ge,arguments[0]):Pn.apply(null,arguments)};var Ln={},In=function(){function e(e,t,n){void 0===t&&(t=he),void 0===n&&(n="ObservableMap@"+xe()),this.enhancer=t,this.name=n,this.$mobx=Ln,this._data=Object.create(null),this._hasMap=Object.create(null),this._keys=new un(void 0,pe,this.name+".keys()",!0),this.interceptors=null,this.changeListeners=null,this.dehancer=void 0,this.merge(e)}return e.prototype._has=function(e){return void 0!==this._data[e]},e.prototype.has=function(e){return!!this.isValidKey(e)&&(e=""+e,this._hasMap[e]?this._hasMap[e].get():this._updateHasMapEntry(e,!1).get())},e.prototype.set=function(e,t){this.assertValidKey(e),e=""+e;var n=this._has(e);if(i(this)){var r=a(this,{type:n?"update":"add",object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this._updateValue(e,t):this._addValue(e,t),this},e.prototype.delete=function(e){var t=this;if(this.assertValidKey(e),e=""+e,i(this)){var n=a(this,{type:"delete",object:this,name:e});if(!n)return!1}if(this._has(e)){var r=c(),o=s(this),n=o||r?{type:"delete",object:this,oldValue:this._data[e].value,name:e}:null;return r&&h(n),ve(function(){t._keys.remove(e),t._updateHasMapEntry(e,!1),t._data[e].setNewValue(void 0),t._data[e]=void 0}),o&&u(this,n),r&&f(),!0}return!1},e.prototype._updateHasMapEntry=function(e,t){var n=this._hasMap[e];return n?n.setNewValue(t):n=this._hasMap[e]=new fn(t,pe,this.name+"."+e+"?",!1),n},e.prototype._updateValue=function(e,t){var n=this._data[e];if((t=n.prepareNewValue(t))!==hn){var r=c(),i=s(this),o=i||r?{type:"update",object:this,oldValue:n.value,name:e,newValue:t}:null;r&&h(o),n.setNewValue(t),i&&u(this,o),r&&f()}},e.prototype._addValue=function(e,t){var n=this;ve(function(){var r=n._data[e]=new fn(t,n.enhancer,n.name+"."+e,!1);t=r.value,n._updateHasMapEntry(e,!0),n._keys.push(e)});var r=c(),i=s(this),o=i||r?{type:"add",object:this,name:e,newValue:t}:null;r&&h(o),i&&u(this,o),r&&f()},e.prototype.get=function(e){return e=""+e,this.has(e)?this.dehanceValue(this._data[e].get()):this.dehanceValue(void 0)},e.prototype.dehanceValue=function(e){return void 0!==this.dehancer?this.dehancer(e):e},e.prototype.keys=function(){return g(this._keys.slice())},e.prototype.values=function(){return g(this._keys.map(this.get,this))},e.prototype.entries=function(){var e=this;return g(this._keys.map(function(t){return[t,e.get(t)]}))},e.prototype.forEach=function(e,t){var n=this;this.keys().forEach(function(r){return e.call(t,n.get(r),r,n)})},e.prototype.merge=function(e){var t=this;return Dn(e)&&(e=e.toJS()),ve(function(){Ce(e)?Object.keys(e).forEach(function(n){return t.set(n,e[n])}):Array.isArray(e)?e.forEach(function(e){var n=e[0],r=e[1];return t.set(n,r)}):je(e)?e.forEach(function(e,n){return t.set(n,e)}):null!==e&&void 0!==e&&we("Cannot initialize map from "+e)}),this},e.prototype.clear=function(){var e=this;ve(function(){_t(function(){e.keys().forEach(e.delete,e)})})},e.prototype.replace=function(e){var t=this;return ve(function(){var n=We(e);t.keys().filter(function(e){return-1===n.indexOf(e)}).forEach(function(e){return t.delete(e)}),t.merge(e)}),this},Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.toJS=function(){var e=this,t={};return this.keys().forEach(function(n){return t[n]=e.get(n)}),t},e.prototype.toJSON=function(){return this.toJS()},e.prototype.isValidKey=function(e){return null!==e&&void 0!==e&&("string"==typeof e||"number"==typeof e||"boolean"==typeof e)},e.prototype.assertValidKey=function(e){if(!this.isValidKey(e))throw new Error("[mobx.map] Invalid key: '"+e+"', only strings, numbers and booleans are accepted as key in observable maps.")},e.prototype.toString=function(){var e=this;return this.name+"[{ "+this.keys().map(function(t){return t+": "+e.get(t)}).join(", ")+" }]"},e.prototype.observe=function(e,t){return _e(!0!==t,_("m033")),l(this,e)},e.prototype.intercept=function(e){return o(this,e)},e}();v(In.prototype,function(){return this.entries()});var Dn=Ne("ObservableMap",In),zn=[];Object.freeze(zn);var Nn=[],Bn=function(){},Fn=Object.prototype.hasOwnProperty,Un=["mobxGuid","resetId","spyListeners","strictMode","runId"],jn=function(){function e(){this.version=5,this.trackingDerivation=null,this.computationDepth=0,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!0,this.strictMode=!1,this.resetId=0,this.spyListeners=[],this.globalReactionErrorHandlers=[]}return e}(),Wn=new jn,Vn=!1,Gn=!1,Hn=!1,Yn=be();Yn.__mobxInstanceCount?(Yn.__mobxInstanceCount++,setTimeout(function(){Vn||Gn||Hn||(Hn=!0,console.warn("[mobx] Warning: there are multiple mobx instances active. This might lead to unexpected results. See https://github.com/mobxjs/mobx/issues/1082 for details."))})):Yn.__mobxInstanceCount=1;var qn;!function(e){e[e.NOT_TRACKING=-1]="NOT_TRACKING",e[e.UP_TO_DATE=0]="UP_TO_DATE",e[e.POSSIBLY_STALE=1]="POSSIBLY_STALE",e[e.STALE=2]="STALE"}(qn||(qn={}));var Xn;!function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(Xn||(Xn={}));var Zn=function(){function e(e){this.cause=e}return e}(),Kn=function(){function e(e,t){void 0===e&&(e="Reaction@"+xe()),this.name=e,this.onInvalidate=t,this.observing=[],this.newObserving=[],this.dependenciesState=qn.NOT_TRACKING,this.diffValue=0,this.runId=0,this.unboundDepsCount=0,this.__mapid="#"+xe(),this.isDisposed=!1,this._isScheduled=!1,this._isTrackPending=!1,this._isRunning=!1,this.isTracing=Xn.NONE}return e.prototype.onBecomeStale=function(){this.schedule()},e.prototype.schedule=function(){this._isScheduled||(this._isScheduled=!0,Wn.pendingReactions.push(this),Rt())},e.prototype.isScheduled=function(){return this._isScheduled},e.prototype.runReaction=function(){this.isDisposed||(st(),this._isScheduled=!1,gt(this)&&(this._isTrackPending=!0,this.onInvalidate(),this._isTrackPending&&c()&&d({object:this,type:"scheduled-reaction"})),lt())},e.prototype.track=function(e){st();var t,n=c();n&&(t=Date.now(),h({object:this,type:"reaction",fn:e})),this._isRunning=!0;var r=bt(this,e,void 0);this._isRunning=!1,this._isTrackPending=!1,this.isDisposed&&wt(this),mt(r)&&this.reportExceptionInDerivation(r.cause),n&&f({time:Date.now()-t}),lt()},e.prototype.reportExceptionInDerivation=function(e){var t=this;if(this.errorHandler)return void this.errorHandler(e,this);var n="[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '"+this,r=_("m037");console.error(n||r,e),c()&&d({type:"error",message:n,error:e,object:this}),Wn.globalReactionErrorHandlers.forEach(function(n){return n(e,t)})},e.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this._isRunning||(st(),wt(this),lt()))},e.prototype.getDisposer=function(){var e=this.dispose.bind(this);return e.$mobx=this,e.onError=Pt,e},e.prototype.toString=function(){return"Reaction["+this.name+"]"},e.prototype.whyRun=function(){var e=Ee(this._isRunning?this.newObserving:this.observing).map(function(e){return e.name});return"\nWhyRun? reaction '"+this.name+"':\n * Status: ["+(this.isDisposed?"stopped":this._isRunning?"running":this.isScheduled()?"scheduled":"idle")+"]\n * This reaction will re-run if any of the following observables changes:\n "+Te(e)+"\n "+(this._isRunning?" (... or any observable accessed during the remainder of the current run)":"")+"\n\t"+_("m038")+"\n"},e.prototype.trace=function(e){void 0===e&&(e=!1),Ct(this,e)},e}(),Jn=100,Qn=function(e){return e()},$n=Ne("Reaction",Kn),er=Ft(bn.default),tr=Ft(bn.structural),nr=function(e,t,n){if("string"==typeof t)return er.apply(null,arguments);_e("function"==typeof e,_("m011")),_e(arguments.length<3,_("m012"));var r="object"==typeof t?t:{};r.setter="function"==typeof t?t:r.setter;var i=r.equals?r.equals:r.compareStructural||r.struct?bn.structural:bn.default;return new xn(e,r.context,i,r.name||e.name||"",r.setter)};nr.struct=tr,nr.equals=Ft;var rr={allowStateChanges:O,deepEqual:ze,getAtom:Ze,getDebugName:Je,getDependencyTree:Qe,getAdministration:Ke,getGlobalState:qe,getObserverTree:et,interceptReads:Jt,isComputingDerivation:vt,isSpyEnabled:c,onReactionError:At,reserveArrayBuffer:x,resetGlobalState:Xe,isolateGlobalState:He,shareGlobalState:Ye,spyReport:d,spyReportEnd:f,spyReportStart:h,setReactionScheduler:It},ir={Reaction:Kn,untracked:_t,Atom:en,BaseAtom:$t,useStrict:k,isStrictModeEnabled:C,spy:p,comparer:bn,asReference:Dt,asFlat:Nt,asStructure:zt,asMap:Bt,isModifierDescriptor:ce,isObservableObject:ne,isBoxedObservable:pn,isObservableArray:w,ObservableMap:In,isObservableMap:Dn,map:ye,transaction:ve,observable:Rn,computed:nr,isObservable:re,isComputed:Ut,extendObservable:oe,extendShallowObservable:ae,observe:jt,intercept:Gt,autorun:V,autorunAsync:H,when:G,reaction:Y,action:yn,isAction:B,runInAction:N,expr:qt,toJS:Xt,createTransformer:Zt,whyRun:kt,isArrayLike:Fe,extras:rr},or=!1;for(var ar in ir)!function(e){var t=ir[e];Object.defineProperty(ir,e,{get:function(){return or||(or=!0,console.warn("Using default export (`import mobx from 'mobx'`) is deprecated and won’t work in mobx@4.0.0\nUse `import * as mobx from 'mobx'` instead")),t}})}(ar);"object"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:p,extras:rr}),t.default=ir}.call(t,n(149))},function(e,t,n){e.exports=n(460)()},function(e,t,n){e.exports={default:n(328),__esModule:!0}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(81),i=n(54);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t,n){var r=n(17).f,i=n(22),o=n(11)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,o)&&r(e,o,{configurable:!0,value:t})}},function(e,t,n){var r=n(53);e.exports=function(e){return Object(r(e))}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+r).toString(36))}},function(e,t,n){"use strict";var r=n(126)(!0);n(65)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){"use strict";function r(e,t,n){return n?[e,t]:e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(t){var n=t*_;e.position.z+=n}}function o(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,a=new g.MeshBasicMaterial({map:E.load(e),transparent:!0,depthWrite:!1}),s=new g.Mesh(new g.PlaneGeometry(t,n),a);return s.material.side=g.DoubleSide,s.position.set(r,i,o),s.overdraw=!0,s}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16711680,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],l=new g.Path,u=l.createGeometry(e);u.computeLineDistances();var c=new g.LineDashedMaterial({color:t,dashSize:r,linewidth:n,gapSize:o}),d=new g.Line(u,c);return i(d,a),d.matrixAutoUpdate=s,s||d.updateMatrix(),d}function s(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:32,r=new g.CircleGeometry(e,n);return new g.Mesh(r,t)}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16777215,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=M(e.map(function(e){return[e.x,e.y]})),s=new g.ShaderMaterial(S({side:g.DoubleSide,diffuse:n,thickness:t,opacity:r,transparent:!0})),l=new g.Mesh(a,s);return i(l,o),l}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16711680,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1,l=new g.Path,u=l.createGeometry(e),c=new g.LineBasicMaterial({color:t,linewidth:n,transparent:a,opacity:s}),d=new g.Line(u,c);return i(d,r),d.matrixAutoUpdate=o,!1===o&&d.updateMatrix(),d}function c(e,t,n){var r=new g.CubeGeometry(e.x,e.y,e.z),i=new g.MeshBasicMaterial({color:t}),o=new g.Mesh(r,i),a=new g.BoxHelper(o);return a.material.linewidth=n,a}function d(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.01,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.02,o=new g.CubeGeometry(e.x,e.y,e.z);o=new g.EdgesGeometry(o),o=(new g.Geometry).fromBufferGeometry(o),o.computeLineDistances();var a=new g.LineDashedMaterial({color:t,linewidth:n,dashSize:r,gapSize:i});return new g.LineSegments(o,a)}function h(e,t,n,r,i){var o=new g.Vector3(0,e,0);return u([new g.Vector3(0,0,0),o,new g.Vector3(r/2,e-n,0),o,new g.Vector3(-r/2,e-n,0)],i,t,1)}function f(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new g.Shape;if(t){n.moveTo(e[0].x,e[0].y);for(var r=1;r1&&void 0!==arguments[1]?arguments[1]:new g.MeshBasicMaterial({color:16711680}),n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=f(e,n),s=new g.Mesh(a,t);return i(s,r),s.matrixAutoUpdate=o,!1===o&&s.updateMatrix(),s}Object.defineProperty(t,"__esModule",{value:!0}),t.addOffsetZ=i,t.drawImage=o,t.drawDashedLineFromPoints=a,t.drawCircle=s,t.drawThickBandFromPoints=l,t.drawSegmentsFromPoints=u,t.drawBox=c,t.drawDashedBox=d,t.drawArrow=h,t.getShapeGeometryFromPoints=f,t.drawShapeFromPoints=p;var m=n(15),g=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(m),v=n(481),y=r(v),b=n(482),x=r(b),w=n(61),_=.04,M=(0,y.default)(g),S=(0,x.default)(g),E=new g.TextureLoader},function(e,t,n){e.exports={default:n(329),__esModule:!0}},function(e,t,n){"use strict";e.exports={},e.exports.Arc=n(301),e.exports.Line=n(302),e.exports.Point=n(303),e.exports.Rectangle=n(304)},function(e,t){e.exports=!0},function(e,t,n){var r=n(20),i=n(122),o=n(54),a=n(55)("IE_PROTO"),s=function(){},l=function(){var e,t=n(64)("iframe"),r=o.length;for(t.style.display="none",n(91).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write(" - - - - -
- - - - \ No newline at end of file diff --git a/modules/dreamview/frontend/dist/index.html b/modules/dreamview/frontend/dist/index.html index 065ab7b4c2..aa4fda95b8 100644 --- a/modules/dreamview/frontend/dist/index.html +++ b/modules/dreamview/frontend/dist/index.html @@ -4,6 +4,8 @@ Dreamview + +
diff --git a/modules/dreamview/frontend/dist/navigation.bundle.js b/modules/dreamview/frontend/dist/navigation.bundle.js deleted file mode 100644 index ffd53357f0..0000000000 --- a/modules/dreamview/frontend/dist/navigation.bundle.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t){function i(s){if(a[s])return a[s].exports;var e=a[s]={i:s,l:!1,exports:{}};return t[s].call(e.exports,e,e.exports,i),e.l=!0,e.exports}var a={};i.m=t,i.c=a,i.i=function(t){return t},i.d=function(t,a,s){i.o(t,a)||Object.defineProperty(t,a,{configurable:!1,enumerable:!0,get:s})},i.n=function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(a,"a",a),a},i.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},i.p="/",i(i.s=207)}([function(t,i,a){"use strict";i.__esModule=!0,i.default=function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}},function(t,i,a){"use strict";i.__esModule=!0;var s=a(26),e=function(t){return t&&t.__esModule?t:{default:t}}(s);i.default=function(){function t(t,i){for(var a=0;a=i.length?{value:void 0,done:!0}:(t=s(i,a),this._i+=t.length,{value:t,done:!1})})},,,,,function(t,i){t.exports=!0},function(t,i,a){var s=a(20),e=a(122),n=a(54),r=a(55)("IE_PROTO"),h=function(){},o=function(){var t,i=a(64)("iframe"),s=n.length;for(i.style.display="none",a(91).appendChild(i),i.src="javascript:",t=i.contentWindow.document,t.open(),t.write(" +
diff --git a/modules/dreamview/frontend/src/store/index.js b/modules/dreamview/frontend/src/store/index.js index 4f47300d16..77319abf46 100644 --- a/modules/dreamview/frontend/src/store/index.js +++ b/modules/dreamview/frontend/src/store/index.js @@ -53,7 +53,7 @@ class DreamviewStore { @observable moduleDelay = observable.map(); @computed get enableHMIButtonsOnly() { - return !this.isInitialized || this.hmi.showNavigationMap; + return !this.isInitialized; } @action updateTimestamp(newTimestamp) { diff --git a/modules/dreamview/frontend/src/store/websocket/websocket_navigation.js b/modules/dreamview/frontend/src/store/websocket/websocket_navigation.js deleted file mode 100644 index 2227aa4034..0000000000 --- a/modules/dreamview/frontend/src/store/websocket/websocket_navigation.js +++ /dev/null @@ -1,64 +0,0 @@ -import Worker from "utils/webworker.js"; -import MAP_NAVIGATOR from "components/Navigation/MapNavigator"; - -export default class NavigationWebSocketEndpoint { - constructor(serverAddr) { - this.serverAddr = serverAddr; - this.websocket = null; - this.worker = new Worker(); - } - - initialize() { - try { - this.websocket = new WebSocket(this.serverAddr); - this.websocket.binaryType = "arraybuffer"; - } catch (error) { - console.error("Failed to establish a connection: " + error); - setTimeout(() => { - this.initialize(); - }, 1000); - return; - } - this.websocket.onmessage = event => { - this.worker.postMessage({ - source: "realtime", - data: event.data, - }); - }; - this.worker.onmessage = event => { - const message = event.data; - switch (message.type) { - case "SimWorldUpdate": - MAP_NAVIGATOR.update(message); - break; - default: - break; - } - }; - this.websocket.onclose = event => { - console.log("WebSocket connection closed, close_code: " + event.code); - this.initialize(); - }; - - // Request simulation world every 100ms. - clearInterval(this.timer); - this.timer = setInterval(() => { - if (this.websocket.readyState === this.websocket.OPEN) { - this.requestSimulationWorld(); - } - }, 100); - } - - requestSimulationWorld() { - this.websocket.send( - JSON.stringify({ - type: "RequestSimulationWorld", - planning: false, - }) - ); - } - - publishNavigationInfo(data) { - this.websocket.send(data); - } -} diff --git a/modules/dreamview/frontend/src/store/websocket/websocket_realtime.js b/modules/dreamview/frontend/src/store/websocket/websocket_realtime.js index 729e003dda..ce6a1432ee 100644 --- a/modules/dreamview/frontend/src/store/websocket/websocket_realtime.js +++ b/modules/dreamview/frontend/src/store/websocket/websocket_realtime.js @@ -1,5 +1,6 @@ import STORE from "store"; import RENDERER from "renderer"; +import MAP_NAVIGATOR from "components/Navigation/MapNavigator"; import Worker from 'utils/webworker.js'; export default class RosWebSocketEndpoint { @@ -74,6 +75,9 @@ export default class RosWebSocketEndpoint { this.requestRoutePath(); this.routingTime = message.routingTime; } + if (STORE.hmi.showNavigationMap && MAP_NAVIGATOR.isInitialized()) { + MAP_NAVIGATOR.update(message); + } this.counter += 1; break; case "MapElementIds": @@ -96,8 +100,7 @@ export default class RosWebSocketEndpoint { // Request simulation world every 100ms. clearInterval(this.timer); this.timer = setInterval(() => { - if (this.websocket.readyState === this.websocket.OPEN && - !STORE.hmi.showNavigationMap) { + if (this.websocket.readyState === this.websocket.OPEN) { // Load default routing end point. if (this.updatePOI) { this.requestDefaultRoutingEndPoint(); @@ -228,4 +231,8 @@ export default class RosWebSocketEndpoint { type: "RequestRoutePath", })); } + + publishNavigationInfo(data) { + this.websocket.send(data); + } } diff --git a/modules/dreamview/frontend/src/styles/main.scss b/modules/dreamview/frontend/src/styles/main.scss index dfb76198b7..5494253fe9 100644 --- a/modules/dreamview/frontend/src/styles/main.scss +++ b/modules/dreamview/frontend/src/styles/main.scss @@ -195,6 +195,7 @@ body { .main-view { flex: 0 0 auto; position: relative; + min-width: 600px; } } } @@ -1364,4 +1365,24 @@ body { } } } +} + +.navigation-view { + z-index: 20; + position: relative; + + #map_canvas { + width: 100%; + height: 100%; + + background: rgba(0, 0, 0, 0.8); + } + + .window-resize-control { + position: absolute; + bottom: 0px; + right: 0px; + width: 25px; + height: 25px; + } } \ No newline at end of file diff --git a/modules/dreamview/frontend/webpack.config.js b/modules/dreamview/frontend/webpack.config.js index 58a95ca247..0e38d73245 100644 --- a/modules/dreamview/frontend/webpack.config.js +++ b/modules/dreamview/frontend/webpack.config.js @@ -13,7 +13,6 @@ module.exports = { entry: { app: "./app.js", - navigation: "./components/Navigation/entry.js" }, output: { @@ -181,10 +180,6 @@ module.exports = { new FaviconsWebpackPlugin("./favicon.png"), new CopyWebpackPlugin([ { - from: 'components/Navigation/navigation_viewer.html', - to: 'components/Navigation/navigation_viewer.html', - toType: 'file', - }, { from: '../node_modules/three/examples/fonts', to: 'fonts', } -- GitLab