diff --git a/modules/dreamview/backend/simulation_world/simulation_world_service.cc b/modules/dreamview/backend/simulation_world/simulation_world_service.cc index 0fe143a384c..036cbe73ba0 100644 --- a/modules/dreamview/backend/simulation_world/simulation_world_service.cc +++ b/modules/dreamview/backend/simulation_world/simulation_world_service.cc @@ -970,10 +970,9 @@ void SimulationWorldService::UpdatePlanningData(const PlanningData &data) { } // Update pull over status - planning_data->clear_pull_over_status(); - if (data.has_pull_over_status()) { - planning_data->mutable_pull_over_status()->CopyFrom( - data.pull_over_status()); + planning_data->clear_pull_over(); + if (data.has_pull_over()) { + planning_data->mutable_pull_over()->CopyFrom(data.pull_over()); } // Update planning signal diff --git a/modules/dreamview/frontend/dist/app.bundle.js b/modules/dreamview/frontend/dist/app.bundle.js index 82ce239e8a5..f42c7c7a5eb 100644 --- a/modules/dreamview/frontend/dist/app.bundle.js +++ b/modules/dreamview/frontend/dist/app.bundle.js @@ -1,4 +1,4 @@ -!function(e){function t(t){for(var n,r,o=t[0],a=t[1],s=0,u=[];s6?l-6:0),c=6;c>",s=s||r,null==n[r]){if(t){var i=null===n[r]?"null":"undefined";return new Error("The "+a+" `"+s+"` is marked as required in `"+o+"`, but its value is `"+i+"`.")}return null}return e.apply(void 0,[n,r,o,a,s].concat(u))}))}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function M(e){var t=void 0===e?"undefined":s(e);return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function S(e,t){return w((function(n,r,o,a,s){return Object(i.untracked)((function(){if(e&&M(n[r])===t.toLowerCase())return null;var a=void 0;switch(t){case"Array":a=i.isObservableArray;break;case"Object":a=i.isObservableObject;break;case"Map":a=i.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+t)}var l=n[r];if(!a(l)){var u=function(e){var t=M(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}(l),c=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+s+"` of type `"+u+"` supplied to `"+o+"`, expected `mobx.Observable"+t+"`"+c+".")}return null}))}))}function E(e,t){return w((function(n,r,o,a,s){for(var l=arguments.length,u=Array(l>5?l-5:0),c=5;c2&&void 0!==arguments[2]&&arguments[2],i=e[t],r=J[t],o=i?!0===n?function(){r.apply(this,arguments),i.apply(this,arguments)}:function(){i.apply(this,arguments),r.apply(this,arguments)}:r;e[t]=o}function K(e,t){if(Z(e,t))return!0;if("object"!==(void 0===e?"undefined":s(e))||null===e||"object"!==(void 0===t?"undefined":s(t))||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r",n=this._reactInternalInstance&&this._reactInternalInstance._rootNodeID||this._reactInternalFiber&&this._reactInternalFiber._debugID,o=!1,a=!1;d.call(this,"props"),d.call(this,"state");var s=this.render.bind(this),l=null,u=!1,c=function(){u=!1;var t=void 0,n=void 0;if(l.track((function(){z&&(e.__$mobRenderStart=Date.now());try{n=i.extras.allowStateChanges(!1,s)}catch(e){t=e}z&&(e.__$mobRenderEnd=Date.now())})),t)throw q.emit(t),t;return n};this.render=function(){return(l=new i.Reaction(t+"#"+n+".render()",(function(){if(!u&&(u=!0,"function"==typeof e.componentWillReact&&e.componentWillReact(),!0!==e.__$mobxIsUnmounted)){var t=!0;try{a=!0,o||r.Component.prototype.forceUpdate.call(e),t=!1}finally{a=!1,t&&l.dispose()}}}))).reactComponent=e,c.$mobx=l,e.render=c,c()}}function d(e){var t=this[e],n=new i.Atom("reactive "+e);Object.defineProperty(this,e,{configurable:!0,enumerable:!0,get:function(){return n.reportObserved(),t},set:function(e){a||K(t,e)?t=e:(t=e,o=!0,n.reportChanged(),o=!1)}})}},componentWillUnmount:function(){if(!0!==B&&(this.render.$mobx&&this.render.$mobx.dispose(),this.__$mobxIsUnmounted=!0,z)){var e=G(this);e&&U&&U.delete(e),W.emit({event:"destroy",component:this,node:e})}},componentDidMount:function(){z&&V(this)},componentDidUpdate:function(){z&&V(this)},shouldComponentUpdate:function(e,t){return B&&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||!K(this.props,e)}};function $(e,t){if("string"==typeof e)throw new Error("Store names should be provided as array");if(Array.isArray(e))return j||(j=!0,console.warn('Mobx observer: Using observer to inject stores is deprecated since 4.0. Use `@inject("store1", "store2") @observer ComponentClass` or `inject("store1", "store2")(observer(componentClass))` instead of `@observer(["store1", "store2"]) ComponentClass`')),t?F.apply(null,e)($(t)):function(t){return $(e,t)};var n,i,o=e;if(!0===o.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),!("function"!=typeof o||o.prototype&&o.prototype.render||o.isReactClass||r.Component.isPrototypeOf(o)))return $((i=n=function(e){function t(){return l(this,t),d(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),u(t,[{key:"render",value:function(){return o.call(this,this.props,this.context)}}]),t}(r.Component),n.displayName=o.displayName||o.name,n.contextTypes=o.contextTypes,n.propTypes=o.propTypes,n.defaultProps=o.defaultProps,i));if(!o)throw new Error("Please pass a valid component to 'observer'");return function(e){X(e,"componentWillMount",!0),["componentDidMount","componentWillUnmount","componentDidUpdate"].forEach((function(t){X(e,t)})),e.shouldComponentUpdate||(e.shouldComponentUpdate=J.shouldComponentUpdate)}(o.prototype||o),o.isMobXReactObserver=!0,o}var Q=$((function(e){var t=e.children,n=e.inject,i=e.render,r=t||i;if(void 0===r)return null;if(!n)return r();var a=F(n)(r);return o.a.createElement(a,null)}));Q.displayName="Observer";var ee,te,ne=function(e,t,n,i,r){var o="children"===t?"render":"children";return"function"==typeof e[t]&&"function"==typeof e[o]?new Error("Invalid prop,do not use children and render in the same time in`"+n):"function"!=typeof e[t]&&"function"!=typeof e[o]?new Error("Invalid prop `"+r+"` of type `"+s(e[t])+"` supplied to `"+n+"`, expected `function`."):void 0};Q.propTypes={render:ne,children:ne};var ie={children:!0,key:!0,ref:!0},re=(te=ee=function(e){function t(){return l(this,t),d(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),u(t,[{key:"render",value:function(){return r.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 i in this.props)ie[i]||"suppressChangedStoreWarning"===i||(e[i]=this.props[i]);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)ie[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}(r.Component),ee.contextTypes={mobxStores:R},ee.childContextTypes={mobxStores:R.isRequired},te);if(!r.Component)throw new Error("mobx-react requires React to be available");if(!i.extras)throw new Error("mobx-react requires mobx to be available");"function"==typeof a.unstable_batchedUpdates&&i.extras.setReactionScheduler(a.unstable_batchedUpdates);var oe=function(e){return q.on(e)};if("object"===("undefined"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__?"undefined":s(__MOBX_DEVTOOLS_GLOBAL_HOOK__))){var ae={spy:i.spy,extras:i.extras},se={renderReporter:W,componentByNodeRegistery:U,trackComponents:H};__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobxReact(se,ae)}},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"extras",(function(){return Pn})),n.d(t,"Reaction",(function(){return un})),n.d(t,"untracked",(function(){return en})),n.d(t,"IDerivationState",(function(){return St})),n.d(t,"Atom",(function(){return a})),n.d(t,"BaseAtom",(function(){return o})),n.d(t,"useStrict",(function(){return G})),n.d(t,"isStrictModeEnabled",(function(){return V})),n.d(t,"spy",(function(){return b})),n.d(t,"comparer",(function(){return ce})),n.d(t,"asReference",(function(){return gn})),n.d(t,"asFlat",(function(){return vn})),n.d(t,"asStructure",(function(){return yn})),n.d(t,"asMap",(function(){return bn})),n.d(t,"isModifierDescriptor",(function(){return Ue})),n.d(t,"isObservableObject",(function(){return Ce})),n.d(t,"isBoxedObservable",(function(){return z})),n.d(t,"isObservableArray",(function(){return D})),n.d(t,"ObservableMap",(function(){return Ze})),n.d(t,"isObservableMap",(function(){return $e})),n.d(t,"map",(function(){return Je})),n.d(t,"transaction",(function(){return Xe})),n.d(t,"observable",(function(){return Be})),n.d(t,"computed",(function(){return Mn})),n.d(t,"isObservable",(function(){return Oe})),n.d(t,"isComputed",(function(){return Sn})),n.d(t,"extendObservable",(function(){return Pe})),n.d(t,"extendShallowObservable",(function(){return Ae})),n.d(t,"observe",(function(){return En})),n.d(t,"intercept",(function(){return Tn})),n.d(t,"autorun",(function(){return de})),n.d(t,"autorunAsync",(function(){return pe})),n.d(t,"when",(function(){return he})),n.d(t,"reaction",(function(){return fe})),n.d(t,"action",(function(){return Q})),n.d(t,"isAction",(function(){return ne})),n.d(t,"runInAction",(function(){return te})),n.d(t,"expr",(function(){return Cn})),n.d(t,"toJS",(function(){return On})),n.d(t,"createTransformer",(function(){return kn})),n.d(t,"whyRun",(function(){return an})),n.d(t,"trace",(function(){return sn})),n.d(t,"isArrayLike",(function(){return _t})); +!function(e){function t(t){for(var n,r,o=t[0],a=t[1],s=0,u=[];s6?l-6:0),c=6;c>",s=s||r,null==n[r]){if(t){var i=null===n[r]?"null":"undefined";return new Error("The "+a+" `"+s+"` is marked as required in `"+o+"`, but its value is `"+i+"`.")}return null}return e.apply(void 0,[n,r,o,a,s].concat(u))}))}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function M(e){var t=void 0===e?"undefined":s(e);return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function S(e,t){return w((function(n,r,o,a,s){return Object(i.untracked)((function(){if(e&&M(n[r])===t.toLowerCase())return null;var a=void 0;switch(t){case"Array":a=i.isObservableArray;break;case"Object":a=i.isObservableObject;break;case"Map":a=i.isObservableMap;break;default:throw new Error("Unexpected mobxType: "+t)}var l=n[r];if(!a(l)){var u=function(e){var t=M(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}(l),c=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+s+"` of type `"+u+"` supplied to `"+o+"`, expected `mobx.Observable"+t+"`"+c+".")}return null}))}))}function E(e,t){return w((function(n,r,o,a,s){for(var l=arguments.length,u=Array(l>5?l-5:0),c=5;c2&&void 0!==arguments[2]&&arguments[2],i=e[t],r=J[t],o=i?!0===n?function(){r.apply(this,arguments),i.apply(this,arguments)}:function(){i.apply(this,arguments),r.apply(this,arguments)}:r;e[t]=o}function K(e,t){if(Z(e,t))return!0;if("object"!==(void 0===e?"undefined":s(e))||null===e||"object"!==(void 0===t?"undefined":s(t))||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(var r=0;r",n=this._reactInternalInstance&&this._reactInternalInstance._rootNodeID||this._reactInternalFiber&&this._reactInternalFiber._debugID,o=!1,a=!1;d.call(this,"props"),d.call(this,"state");var s=this.render.bind(this),l=null,u=!1,c=function(){u=!1;var t=void 0,n=void 0;if(l.track((function(){z&&(e.__$mobRenderStart=Date.now());try{n=i.extras.allowStateChanges(!1,s)}catch(e){t=e}z&&(e.__$mobRenderEnd=Date.now())})),t)throw q.emit(t),t;return n};this.render=function(){return(l=new i.Reaction(t+"#"+n+".render()",(function(){if(!u&&(u=!0,"function"==typeof e.componentWillReact&&e.componentWillReact(),!0!==e.__$mobxIsUnmounted)){var t=!0;try{a=!0,o||r.Component.prototype.forceUpdate.call(e),t=!1}finally{a=!1,t&&l.dispose()}}}))).reactComponent=e,c.$mobx=l,e.render=c,c()}}function d(e){var t=this[e],n=new i.Atom("reactive "+e);Object.defineProperty(this,e,{configurable:!0,enumerable:!0,get:function(){return n.reportObserved(),t},set:function(e){a||K(t,e)?t=e:(t=e,o=!0,n.reportChanged(),o=!1)}})}},componentWillUnmount:function(){if(!0!==B&&(this.render.$mobx&&this.render.$mobx.dispose(),this.__$mobxIsUnmounted=!0,z)){var e=G(this);e&&j&&j.delete(e),W.emit({event:"destroy",component:this,node:e})}},componentDidMount:function(){z&&V(this)},componentDidUpdate:function(){z&&V(this)},shouldComponentUpdate:function(e,t){return B&&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||!K(this.props,e)}};function $(e,t){if("string"==typeof e)throw new Error("Store names should be provided as array");if(Array.isArray(e))return U||(U=!0,console.warn('Mobx observer: Using observer to inject stores is deprecated since 4.0. Use `@inject("store1", "store2") @observer ComponentClass` or `inject("store1", "store2")(observer(componentClass))` instead of `@observer(["store1", "store2"]) ComponentClass`')),t?F.apply(null,e)($(t)):function(t){return $(e,t)};var n,i,o=e;if(!0===o.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),!("function"!=typeof o||o.prototype&&o.prototype.render||o.isReactClass||r.Component.isPrototypeOf(o)))return $((i=n=function(e){function t(){return l(this,t),d(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),u(t,[{key:"render",value:function(){return o.call(this,this.props,this.context)}}]),t}(r.Component),n.displayName=o.displayName||o.name,n.contextTypes=o.contextTypes,n.propTypes=o.propTypes,n.defaultProps=o.defaultProps,i));if(!o)throw new Error("Please pass a valid component to 'observer'");return function(e){X(e,"componentWillMount",!0),["componentDidMount","componentWillUnmount","componentDidUpdate"].forEach((function(t){X(e,t)})),e.shouldComponentUpdate||(e.shouldComponentUpdate=J.shouldComponentUpdate)}(o.prototype||o),o.isMobXReactObserver=!0,o}var Q=$((function(e){var t=e.children,n=e.inject,i=e.render,r=t||i;if(void 0===r)return null;if(!n)return r();var a=F(n)(r);return o.a.createElement(a,null)}));Q.displayName="Observer";var ee,te,ne=function(e,t,n,i,r){var o="children"===t?"render":"children";return"function"==typeof e[t]&&"function"==typeof e[o]?new Error("Invalid prop,do not use children and render in the same time in`"+n):"function"!=typeof e[t]&&"function"!=typeof e[o]?new Error("Invalid prop `"+r+"` of type `"+s(e[t])+"` supplied to `"+n+"`, expected `function`."):void 0};Q.propTypes={render:ne,children:ne};var ie={children:!0,key:!0,ref:!0},re=(te=ee=function(e){function t(){return l(this,t),d(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return c(t,e),u(t,[{key:"render",value:function(){return r.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 i in this.props)ie[i]||"suppressChangedStoreWarning"===i||(e[i]=this.props[i]);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)ie[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}(r.Component),ee.contextTypes={mobxStores:R},ee.childContextTypes={mobxStores:R.isRequired},te);if(!r.Component)throw new Error("mobx-react requires React to be available");if(!i.extras)throw new Error("mobx-react requires mobx to be available");"function"==typeof a.unstable_batchedUpdates&&i.extras.setReactionScheduler(a.unstable_batchedUpdates);var oe=function(e){return q.on(e)};if("object"===("undefined"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__?"undefined":s(__MOBX_DEVTOOLS_GLOBAL_HOOK__))){var ae={spy:i.spy,extras:i.extras},se={renderReporter:W,componentByNodeRegistery:j,trackComponents:H};__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobxReact(se,ae)}},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"extras",(function(){return Pn})),n.d(t,"Reaction",(function(){return un})),n.d(t,"untracked",(function(){return en})),n.d(t,"IDerivationState",(function(){return St})),n.d(t,"Atom",(function(){return a})),n.d(t,"BaseAtom",(function(){return o})),n.d(t,"useStrict",(function(){return G})),n.d(t,"isStrictModeEnabled",(function(){return V})),n.d(t,"spy",(function(){return b})),n.d(t,"comparer",(function(){return ce})),n.d(t,"asReference",(function(){return gn})),n.d(t,"asFlat",(function(){return vn})),n.d(t,"asStructure",(function(){return yn})),n.d(t,"asMap",(function(){return bn})),n.d(t,"isModifierDescriptor",(function(){return je})),n.d(t,"isObservableObject",(function(){return Ce})),n.d(t,"isBoxedObservable",(function(){return z})),n.d(t,"isObservableArray",(function(){return D})),n.d(t,"ObservableMap",(function(){return Ze})),n.d(t,"isObservableMap",(function(){return $e})),n.d(t,"map",(function(){return Je})),n.d(t,"transaction",(function(){return Xe})),n.d(t,"observable",(function(){return Be})),n.d(t,"computed",(function(){return Mn})),n.d(t,"isObservable",(function(){return Oe})),n.d(t,"isComputed",(function(){return Sn})),n.d(t,"extendObservable",(function(){return Pe})),n.d(t,"extendShallowObservable",(function(){return Ae})),n.d(t,"observe",(function(){return En})),n.d(t,"intercept",(function(){return Tn})),n.d(t,"autorun",(function(){return de})),n.d(t,"autorunAsync",(function(){return pe})),n.d(t,"when",(function(){return he})),n.d(t,"reaction",(function(){return fe})),n.d(t,"action",(function(){return Q})),n.d(t,"isAction",(function(){return ne})),n.d(t,"runInAction",(function(){return te})),n.d(t,"expr",(function(){return Cn})),n.d(t,"toJS",(function(){return On})),n.d(t,"createTransformer",(function(){return kn})),n.d(t,"whyRun",(function(){return an})),n.d(t,"trace",(function(){return sn})),n.d(t,"isArrayLike",(function(){return _t})); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use @@ -13,12 +13,12 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ -var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function r(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){function e(e){void 0===e&&(e="Atom@"+tt()),this.name=e,this.isPendingUnobservation=!0,this.observers=[],this.observersIndexes={},this.diffValue=0,this.lastAccessedBy=0,this.lowestObserverState=St.NOT_TRACKING}return e.prototype.onBecomeUnobserved=function(){},e.prototype.reportObserved=function(){Ht(this)},e.prototype.reportChanged=function(){Gt(),function(e){if(e.lowestObserverState===St.STALE)return;e.lowestObserverState=St.STALE;var t=e.observers,n=t.length;for(;n--;){var i=t[n];i.dependenciesState===St.UP_TO_DATE&&(i.isTracing!==Et.NONE&&Yt(i,e),i.onBecomeStale()),i.dependenciesState=St.STALE}}(this),Vt()},e.prototype.toString=function(){return this.name},e}(),a=function(e){function t(t,n,i){void 0===t&&(t="Atom@"+tt()),void 0===n&&(n=st),void 0===i&&(i=st);var r=e.call(this,t)||this;return r.name=t,r.onBecomeObservedHandler=n,r.onBecomeUnobservedHandler=i,r.isPendingUnobservation=!1,r.isBeingTracked=!1,r}return r(t,e),t.prototype.reportObserved=function(){return Gt(),e.prototype.reportObserved.call(this),this.isBeingTracked||(this.isBeingTracked=!0,this.onBecomeObservedHandler()),Vt(),!!Ot.trackingDerivation},t.prototype.onBecomeUnobserved=function(){this.isBeingTracked=!1,this.onBecomeUnobservedHandler()},t}(o),s=bt("Atom",o);function l(e){return e.interceptors&&e.interceptors.length>0}function u(e,t){var n=e.interceptors||(e.interceptors=[]);return n.push(t),at((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function c(e,t){var n=tn();try{var i=e.interceptors;if(i)for(var r=0,o=i.length;r0}function h(e,t){var n=e.changeListeners||(e.changeListeners=[]);return n.push(t),at((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function p(e,t){var n=tn(),i=e.changeListeners;if(i){for(var r=0,o=(i=i.slice()).length;r=this.length,value:tt){for(var n=new Array(e-t),i=0;i0&&e+t+1>T&&L(e+t+1)},e.prototype.spliceWithArray=function(e,t,n){var i=this;Jt(this.atom);var r=this.values.length;if(void 0===e?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=1===arguments.length?r-e:null==t?0:Math.max(0,Math.min(t,r-e)),void 0===n&&(n=[]),l(this)){var o=c(this,{object:this.array,type:"splice",index:e,removedCount:t,added:n});if(!o)return Qe;t=o.removedCount,n=o.added}var a=(n=n.map((function(e){return i.enhancer(e,void 0)}))).length-t;this.updateArrayLength(r,a);var s=this.spliceItemsIntoValues(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice(e,n,s),this.dehanceValues(s)},e.prototype.spliceItemsIntoValues=function(e,t,n){if(n.length<1e4)return(i=this.values).splice.apply(i,[e,t].concat(n));var i,r=this.values.slice(e,e+t);return this.values=this.values.slice(0,e).concat(n,this.values.slice(e+t)),r},e.prototype.notifyArrayChildUpdate=function(e,t,n){var i=!this.owned&&f(),r=d(this),o=r||i?{object:this.array,type:"update",index:e,newValue:t,oldValue:n}:null;i&&g(o),this.atom.reportChanged(),r&&p(this,o),i&&v()},e.prototype.notifyArraySplice=function(e,t,n){var i=!this.owned&&f(),r=d(this),o=r||i?{object:this.array,type:"splice",index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;i&&g(o),this.atom.reportChanged(),r&&p(this,o),i&&v()},e}(),k=function(e){function t(t,n,i,r){void 0===i&&(i="ObservableArray@"+tt()),void 0===r&&(r=!1);var o=e.call(this)||this,a=new O(i,n,o,r);return gt(o,"$mobx",a),t&&t.length&&o.spliceWithArray(0,0,t),E&&Object.defineProperty(a.array,"0",P),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 i,r=this.$mobx.values;i=e0,"actions should have valid names, got: '"+e+"'");var n=function(){return W(e,t,this,arguments)};return n.originalFn=t,n.isMobxAction=!0,n}function W(e,t,n,i){var r=function(e,t,n,i){var r=f()&&!!e,o=0;if(r){o=Date.now();var a=i&&i.length||0,s=new Array(a);if(a>0)for(var l=0;l";mt(e,t,Q(o,n))}),(function(e){return this[e]}),(function(){it(!1,j("m001"))}),!1,!0),$=q((function(e,t,n){ie(e,t,n)}),(function(e){return this[e]}),(function(){it(!1,j("m001"))}),!1,!1),Q=function(e,t,n,i){return 1===arguments.length&&"function"==typeof e?U(e.name||"",e):2===arguments.length&&"function"==typeof t?U(e,t):1===arguments.length&&"string"==typeof e?ee(e):ee(t).apply(null,arguments)};function ee(e){return function(t,n,i){if(i&&"function"==typeof i.value)return i.value=U(e,i.value),i.enumerable=!1,i.configurable=!0,i;if(void 0!==i&&void 0!==i.get)throw new Error("[mobx] action is not expected to be used with getters");return J(e).apply(this,arguments)}}function te(e,t,n){var i="string"==typeof e?e:e.name||"",r="function"==typeof e?e:t,o="function"==typeof e?t:n;return it("function"==typeof r,j("m002")),it(0===r.length,j("m003")),it("string"==typeof i&&i.length>0,"actions should have valid names, got: '"+i+"'"),W(i,r,o,void 0)}function ne(e){return"function"==typeof e&&!0===e.isMobxAction}function ie(e,t,n){var i=function(){return W(t,n,e,arguments)};i.isMobxAction=!0,mt(e,t,i)}Q.bound=function(e,t,n){if("function"==typeof e){var i=U("",e);return i.autoBind=!0,i}return $.apply(null,arguments)};var re=Object.prototype.toString;function oe(e,t){return ae(e,t)}function ae(e,t,n,i){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return!1;if(e!=e)return t!=t;var r=typeof e;return("function"===r||"object"===r||"object"==typeof t)&&function(e,t,n,i){e=se(e),t=se(t);var r=re.call(e);if(r!==re.call(t))return!1;switch(r){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!=+e?+t!=+t:0==+e?1/+e==1/t:+e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object Symbol]":return"undefined"!=typeof Symbol&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t)}var o="[object Array]"===r;if(!o){if("object"!=typeof e||"object"!=typeof t)return!1;var a=e.constructor,s=t.constructor;if(a!==s&&!("function"==typeof a&&a instanceof a&&"function"==typeof s&&s instanceof s)&&"constructor"in e&&"constructor"in t)return!1}i=i||[];var l=(n=n||[]).length;for(;l--;)if(n[l]===e)return i[l]===t;if(n.push(e),i.push(t),o){if((l=e.length)!==t.length)return!1;for(;l--;)if(!ae(e[l],t[l],n,i))return!1}else{var u,c=Object.keys(e);if(l=c.length,Object.keys(t).length!==l)return!1;for(;l--;)if(u=c[l],!le(t,u)||!ae(e[u],t[u],n,i))return!1}return n.pop(),i.pop(),!0}(e,t,n,i)}function se(e){return D(e)?e.peek():$e(e)?e.entries():xt(e)?function(e){var t=[];for(;;){var n=e.next();if(n.done)break;t.push(n.value)}return t}(e.entries()):e}function le(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ue(e,t){return e===t}var ce={identity:ue,structural:function(e,t){return oe(e,t)},default:function(e,t){return function(e,t){return"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)}(e,t)||ue(e,t)}};function de(e,t,n){var i,r,o;"string"==typeof e?(i=e,r=t,o=n):(i=e.name||"Autorun@"+tt(),r=e,o=t),it("function"==typeof r,j("m004")),it(!1===ne(r),j("m005")),o&&(r=r.bind(o));var a=new un(i,(function(){this.track(s)}));function s(){r(a)}return a.schedule(),a.getDisposer()}function he(e,t,n,i){var r,o,a,s;return"string"==typeof e?(r=e,o=t,a=n,s=i):(r="When@"+tt(),o=e,a=t,s=n),de(r,(function(e){if(o.call(s)){e.dispose();var t=tn();a.call(s),nn(t)}}))}function pe(e,t,n,i){var r,o,a,s;"string"==typeof e?(r=e,o=t,a=n,s=i):(r=e.name||"AutorunAsync@"+tt(),o=e,a=t,s=n),it(!1===ne(o),j("m006")),void 0===a&&(a=1),s&&(o=o.bind(s));var l=!1,u=new un(r,(function(){l||(l=!0,setTimeout((function(){l=!1,u.isDisposed||u.track(c)}),a))}));function c(){o(u)}return u.schedule(),u.getDisposer()}function fe(e,t,n){var i;arguments.length>3&&nt(j("m007")),Ue(e)&&nt(j("m008")),(i="object"==typeof n?n:{}).name=i.name||e.name||t.name||"Reaction@"+tt(),i.fireImmediately=!0===n||!0===i.fireImmediately,i.delay=i.delay||0,i.compareStructural=i.compareStructural||i.struct||!1,t=Q(i.name,i.context?t.bind(i.context):t),i.context&&(e=e.bind(i.context));var r,o=!0,a=!1,s=i.equals?i.equals:i.compareStructural||i.struct?ce.structural:ce.default,l=new un(i.name,(function(){o||i.delay<1?u():a||(a=!0,setTimeout((function(){a=!1,u()}),i.delay))}));function u(){if(!l.isDisposed){var n=!1;l.track((function(){var t=e(l);n=o||!s(r,t),r=t})),o&&i.fireImmediately&&t(r,l),o||!0!==n||t(r,l),o&&(o=!1)}}return l.schedule(),l.getDisposer()}var me=function(){function e(e,t,n,i,r){this.derivation=e,this.scope=t,this.equals=n,this.dependenciesState=St.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=St.UP_TO_DATE,this.unboundDepsCount=0,this.__mapid="#"+tt(),this.value=new qt(null),this.isComputing=!1,this.isRunningSetter=!1,this.isTracing=Et.NONE,this.name=i||"ComputedValue@"+tt(),r&&(this.setter=U(i+"-setter",r))}return e.prototype.onBecomeStale=function(){!function(e){if(e.lowestObserverState!==St.UP_TO_DATE)return;e.lowestObserverState=St.POSSIBLY_STALE;var t=e.observers,n=t.length;for(;n--;){var i=t[n];i.dependenciesState===St.UP_TO_DATE&&(i.dependenciesState=St.POSSIBLY_STALE,i.isTracing!==Et.NONE&&Yt(i,e),i.onBecomeStale())}}(this)},e.prototype.onBecomeUnobserved=function(){Qt(this),this.value=void 0},e.prototype.get=function(){it(!this.isComputing,"Cycle detected in computation "+this.name,this.derivation),0===Ot.inBatch?(Gt(),Kt(this)&&(this.isTracing!==Et.NONE&&console.log("[mobx.trace] '"+this.name+"' is being read outside a reactive context and doing a full recompute"),this.value=this.computeValue(!1)),Vt()):(Ht(this),Kt(this)&&this.trackAndCompute()&&function(e){if(e.lowestObserverState===St.STALE)return;e.lowestObserverState=St.STALE;var t=e.observers,n=t.length;for(;n--;){var i=t[n];i.dependenciesState===St.POSSIBLY_STALE?i.dependenciesState=St.STALE:i.dependenciesState===St.UP_TO_DATE&&(e.lowestObserverState=St.UP_TO_DATE)}}(this));var e=this.value;if(Xt(e))throw e.cause;return e},e.prototype.peek=function(){var e=this.computeValue(!1);if(Xt(e))throw e.cause;return e},e.prototype.set=function(e){if(this.setter){it(!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 it(!1,"[ComputedValue '"+this.name+"'] It is not possible to assign a new value to a computed value.")},e.prototype.trackAndCompute=function(){f()&&m({object:this.scope,type:"compute",fn:this.derivation});var e=this.value,t=this.dependenciesState===St.NOT_TRACKING,n=this.value=this.computeValue(!0);return t||Xt(e)||Xt(n)||!this.equals(e,n)},e.prototype.computeValue=function(e){var t;if(this.isComputing=!0,Ot.computationDepth++,e)t=$t(this,this.derivation,this.scope);else try{t=this.derivation.call(this.scope)}catch(e){t=new qt(e)}return Ot.computationDepth--,this.isComputing=!1,t},e.prototype.observe=function(e,t){var n=this,i=!0,r=void 0;return de((function(){var o=n.get();if(!i||t){var a=tn();e({type:"update",object:n,newValue:o,oldValue:r}),nn(a)}i=!1,r=o}))},e.prototype.toJSON=function(){return this.get()},e.prototype.toString=function(){return this.name+"["+this.derivation.toString()+"]"},e.prototype.valueOf=function(){return Mt(this.get())},e.prototype.whyRun=function(){var e=Boolean(Ot.trackingDerivation),t=lt(this.isComputing?this.newObserving:this.observing).map((function(e){return e.name})),n=lt(Bt(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===St.NOT_TRACKING?j("m032"):" * This computation will re-run if any of the following observables changes:\n "+ut(t)+"\n "+(this.isComputing&&e?" (... or any observable accessed during the remainder of the current run)":"")+"\n "+j("m038")+"\n\n * If the outcome of this computation changes, the following observers will be re-run:\n "+ut(n)+"\n")},e}();me.prototype[wt()]=me.prototype.valueOf;var ge=bt("ComputedValue",me),ye=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 it(!0!==t,"`observe` doesn't support the fire immediately property for observable objects."),h(this,e)},e.prototype.intercept=function(e){return u(this,e)},e}();function ve(e,t){if(Ce(e)&&e.hasOwnProperty("$mobx"))return e.$mobx;it(Object.isExtensible(e),j("m035")),dt(e)||(t=(e.constructor.name||"ObservableObject")+"@"+tt()),t||(t="ObservableObject@"+tt());var n=new ye(e,t);return gt(e,"$mobx",n),n}function be(e,t,n,i){if(e.values[t]&&!ge(e.values[t]))return it("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(Ue(n.value)){var r=n.value;_e(e,t,r.initialValue,r.enhancer)}else ne(n.value)&&!0===n.value.autoBind?ie(e.target,t,n.value.originalFn):ge(n.value)?function(e,t,n){var i=e.name+"."+t;n.name=i,n.scope||(n.scope=e.target);e.values[t]=n,Object.defineProperty(e.target,t,Se(t))}(e,t,n.value):_e(e,t,n.value,i);else xe(e,t,n.get,n.set,ce.default,!0)}function _e(e,t,n,i){if(vt(e.target,t),l(e)){var r=c(e,{object:e.target,name:t,type:"add",newValue:n});if(!r)return;n=r.newValue}n=(e.values[t]=new F(n,i,e.name+"."+t,!1)).value,Object.defineProperty(e.target,t,function(e){return we[e]||(we[e]={configurable:!0,enumerable:!0,get:function(){return this.$mobx.values[e].get()},set:function(t){Ee(this,e,t)}})}(t)),function(e,t,n,i){var r=d(e),o=f(),a=r||o?{type:"add",object:t,name:n,newValue:i}:null;o&&g(a);r&&p(e,a);o&&v()}(e,e.target,t,n)}function xe(e,t,n,i,r,o){o&&vt(e.target,t),e.values[t]=new me(n,e.target,r,e.name+"."+t,i),o&&Object.defineProperty(e.target,t,Se(t))}var we={},Me={};function Se(e){return Me[e]||(Me[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 i=e.$mobx,r=i.values[t];if(l(i)){if(!(s=c(i,{type:"update",object:e,name:t,newValue:n})))return;n=s.newValue}if((n=r.prepareNewValue(n))!==N){var o=d(i),a=f(),s=o||a?{type:"update",object:e,oldValue:r.value,name:t,newValue:n}:null;a&&g(s),r.setNewValue(n),o&&p(i,s),a&&v()}}var Te=bt("ObservableObjectAdministration",ye);function Ce(e){return!!ct(e)&&(K(e),Te(e.$mobx))}function Oe(e,t){if(null==e)return!1;if(void 0!==t){if(D(e)||$e(e))throw new Error(j("m019"));if(Ce(e)){var n=e.$mobx;return n.values&&!!n.values[t]}return!1}return Ce(e)||!!e.$mobx||s(e)||mn(e)||ge(e)}function ke(e){return it(!!e,":("),q((function(t,n,i,r,o){vt(t,n),it(!o||!o.get,j("m022")),_e(ve(t,void 0),n,i,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 Pe(e){for(var t=[],n=1;n=2,j("m014")),it("object"==typeof e,j("m015")),it(!$e(e),j("m016")),n.forEach((function(e){it("object"==typeof e,j("m017")),it(!Oe(e),j("m018"))}));for(var i=ve(e),r={},o=n.length-1;o>=0;o--){var a=n[o];for(var s in a)if(!0!==r[s]&&ft(a,s)){if(r[s]=!0,e===a&&!yt(e,s))continue;be(i,s,Object.getOwnPropertyDescriptor(a,s),t)}}return e}var Le=ke(Ge),Ie=ke(Ve),De=ke(He),Ne=ke(Ye),Fe=ke(qe);var ze={box:function(e,t){return arguments.length>2&&je("box"),new F(e,Ge,t)},shallowBox:function(e,t){return arguments.length>2&&je("shallowBox"),new F(e,He,t)},array:function(e,t){return arguments.length>2&&je("array"),new k(e,Ge,t)},shallowArray:function(e,t){return arguments.length>2&&je("shallowArray"),new k(e,He,t)},map:function(e,t){return arguments.length>2&&je("map"),new Ze(e,Ge,t)},shallowMap:function(e,t){return arguments.length>2&&je("shallowMap"),new Ze(e,He,t)},object:function(e,t){arguments.length>2&&je("object");var n={};return ve(n,t),Pe(n,e),n},shallowObject:function(e,t){arguments.length>2&&je("shallowObject");var n={};return ve(n,t),Ae(n,e),n},ref:function(){return arguments.length<2?We(He,arguments[0]):De.apply(null,arguments)},shallow:function(){return arguments.length<2?We(Ve,arguments[0]):Ie.apply(null,arguments)},deep:function(){return arguments.length<2?We(Ge,arguments[0]):Le.apply(null,arguments)},struct:function(){return arguments.length<2?We(Ye,arguments[0]):Ne.apply(null,arguments)}},Be=function(e){if(void 0===e&&(e=void 0),"string"==typeof arguments[1])return Le.apply(null,arguments);if(it(arguments.length<=1,j("m021")),it(!Ue(e),j("m020")),Oe(e))return e;var t=Ge(e,void 0,void 0);return t!==e?t:Be.box(e)};function je(e){nt("Expected one or two arguments to observable."+e+". Did you accidentally try to use observable."+e+" as decorator?")}function Ue(e){return"object"==typeof e&&null!==e&&!0===e.isMobxModifierDescriptor}function We(e,t){return it(!Ue(t),"Modifiers cannot be nested"),{isMobxModifierDescriptor:!0,initialValue:t,enhancer:e}}function Ge(e,t,n){return Ue(e)&&nt("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),Oe(e)?e:Array.isArray(e)?Be.array(e,n):dt(e)?Be.object(e,n):xt(e)?Be.map(e,n):e}function Ve(e,t,n){return Ue(e)&&nt("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),null==e?e:Ce(e)||D(e)||$e(e)?e:Array.isArray(e)?Be.shallowArray(e,n):dt(e)?Be.shallowObject(e,n):xt(e)?Be.shallowMap(e,n):nt("The shallow modifier / decorator can only used in combination with arrays, objects and maps")}function He(e){return e}function Ye(e,t,n){if(oe(e,t))return t;if(Oe(e))return e;if(Array.isArray(e))return new k(e,Ye,n);if(xt(e))return new Ze(e,Ye,n);if(dt(e)){var i={};return ve(i,n),Re(i,Ye,[e]),i}return e}function qe(e,t,n){return oe(e,t)?t:e}function Xe(e,t){void 0===t&&(t=void 0),Gt();try{return e.apply(t)}finally{Vt()}}Object.keys(ze).forEach((function(e){return Be[e]=ze[e]})),Be.deep.struct=Be.struct,Be.ref.struct=function(){return arguments.length<2?We(qe,arguments[0]):Fe.apply(null,arguments)};var Ke={},Ze=function(){function e(e,t,n){void 0===t&&(t=Ge),void 0===n&&(n="ObservableMap@"+tt()),this.enhancer=t,this.name=n,this.$mobx=Ke,this._data=Object.create(null),this._hasMap=Object.create(null),this._keys=new k(void 0,He,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(l(this)){var i=c(this,{type:n?"update":"add",object:this,newValue:t,name:e});if(!i)return this;t=i.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,l(this))&&!(r=c(this,{type:"delete",object:this,name:e})))return!1;if(this._has(e)){var n=f(),i=d(this),r=i||n?{type:"delete",object:this,oldValue:this._data[e].value,name:e}:null;return n&&g(r),Xe((function(){t._keys.remove(e),t._updateHasMapEntry(e,!1),t._data[e].setNewValue(void 0),t._data[e]=void 0})),i&&p(this,r),n&&v(),!0}return!1},e.prototype._updateHasMapEntry=function(e,t){var n=this._hasMap[e];return n?n.setNewValue(t):n=this._hasMap[e]=new F(t,He,this.name+"."+e+"?",!1),n},e.prototype._updateValue=function(e,t){var n=this._data[e];if((t=n.prepareNewValue(t))!==N){var i=f(),r=d(this),o=r||i?{type:"update",object:this,oldValue:n.value,name:e,newValue:t}:null;i&&g(o),n.setNewValue(t),r&&p(this,o),i&&v()}},e.prototype._addValue=function(e,t){var n=this;Xe((function(){var i=n._data[e]=new F(t,n.enhancer,n.name+"."+e,!1);t=i.value,n._updateHasMapEntry(e,!0),n._keys.push(e)}));var i=f(),r=d(this),o=r||i?{type:"add",object:this,name:e,newValue:t}:null;i&&g(o),r&&p(this,o),i&&v()},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 x(this._keys.slice())},e.prototype.values=function(){return x(this._keys.map(this.get,this))},e.prototype.entries=function(){var e=this;return x(this._keys.map((function(t){return[t,e.get(t)]})))},e.prototype.forEach=function(e,t){var n=this;this.keys().forEach((function(i){return e.call(t,n.get(i),i,n)}))},e.prototype.merge=function(e){var t=this;return $e(e)&&(e=e.toJS()),Xe((function(){dt(e)?Object.keys(e).forEach((function(n){return t.set(n,e[n])})):Array.isArray(e)?e.forEach((function(e){var n=e[0],i=e[1];return t.set(n,i)})):xt(e)?e.forEach((function(e,n){return t.set(n,e)})):null!=e&&nt("Cannot initialize map from "+e)})),this},e.prototype.clear=function(){var e=this;Xe((function(){en((function(){e.keys().forEach(e.delete,e)}))}))},e.prototype.replace=function(e){var t=this;return Xe((function(){var n,i=dt(n=e)?Object.keys(n):Array.isArray(n)?n.map((function(e){return e[0]})):xt(n)?Array.from(n.keys()):$e(n)?n.keys():nt("Cannot get keys from "+n);t.keys().filter((function(e){return-1===i.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&&("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 it(!0!==t,j("m033")),h(this,e)},e.prototype.intercept=function(e){return u(this,e)},e}();function Je(e){return ot("`mobx.map` is deprecated, use `new ObservableMap` or `mobx.observable.map` instead"),Be.map(e)}w(Ze.prototype,(function(){return this.entries()}));var $e=bt("ObservableMap",Ze),Qe=[];function et(){return"undefined"!=typeof window?window:e}function tt(){return++Ot.mobxGuid}function nt(e,t){throw it(!1,e,t),"X"}function it(e,t,n){if(!e)throw new Error("[mobx] Invariant failed: "+t+(n?" in '"+n+"'":""))}Object.freeze(Qe);var rt=[];function ot(e){return-1===rt.indexOf(e)&&(rt.push(e),console.error("[mobx] Deprecated: "+e),!0)}function at(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var st=function(){};function lt(e){var t=[];return e.forEach((function(e){-1===t.indexOf(e)&&t.push(e)})),t}function ut(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 ct(e){return null!==e&&"object"==typeof e}function dt(e){if(null===e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ht(){for(var e=arguments[0],t=1,n=arguments.length;t0&&(t.dependencies=lt(e.observing).map(Ft)),t}function zt(e){var t={name:e.name};return function(e){return e.observers&&e.observers.length>0}(e)&&(t.observers=Bt(e).map(zt)),t}function Bt(e){return e.observers}function jt(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 Ut(e,t){if(1===e.observers.length)e.observers.length=0,Wt(e);else{var n=e.observers,i=e.observersIndexes,r=n.pop();if(r!==t){var o=i[t.__mapid]||0;o?i[r.__mapid]=o:delete i[r.__mapid],n[o]=r}delete i[t.__mapid]}}function Wt(e){e.isPendingUnobservation||(e.isPendingUnobservation=!0,Ot.pendingUnobservations.push(e))}function Gt(){Ot.inBatch++}function Vt(){if(0==--Ot.inBatch){pn();for(var e=Ot.pendingUnobservations,t=0;t=1e3)return void n.push("(and many more)");n.push(""+new Array(i).join("\t")+t.name);t.dependencies&&t.dependencies.forEach((function(t){return e(t,n,i+1)}))}(Nt(e),n,1),new Function("debugger;\n/*\nTracing '"+e.name+"'\n\nYou are entering this break point because derivation '"+e.name+"' is being traced and '"+t.name+"' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n"+(e instanceof me?e.derivation.toString():"")+"\n\nThe dependencies for this derivation are:\n\n"+n.join("\n")+"\n*/\n ")()}}Rt.__mobxInstanceCount?(Rt.__mobxInstanceCount++,setTimeout((function(){kt||Pt||At||(At=!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."))}),1)):Rt.__mobxInstanceCount=1,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"}(St||(St={})),function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(Et||(Et={}));var qt=function(e){this.cause=e};function Xt(e){return e instanceof qt}function Kt(e){switch(e.dependenciesState){case St.UP_TO_DATE:return!1;case St.NOT_TRACKING:case St.STALE:return!0;case St.POSSIBLY_STALE:for(var t=tn(),n=e.observing,i=n.length,r=0;r0;Ot.computationDepth>0&&t&&nt(j("m031")+e.name),!Ot.allowStateChanges&&t&&nt(j(Ot.strictMode?"m030a":"m030b")+e.name)}function $t(e,t,n){rn(e),e.newObserving=new Array(e.observing.length+100),e.unboundDepsCount=0,e.runId=++Ot.runId;var i,r=Ot.trackingDerivation;Ot.trackingDerivation=e;try{i=t.call(n)}catch(e){i=new qt(e)}return Ot.trackingDerivation=r,function(e){for(var t=e.observing,n=e.observing=e.newObserving,i=St.UP_TO_DATE,r=0,o=e.unboundDepsCount,a=0;ai&&(i=s.dependenciesState)}n.length=r,e.newObserving=null,o=t.length;for(;o--;){0===(s=t[o]).diffValue&&Ut(s,e),s.diffValue=0}for(;r--;){var s;1===(s=n[r]).diffValue&&(s.diffValue=0,jt(s,e))}i!==St.UP_TO_DATE&&(e.dependenciesState=i,e.onBecomeStale())}(e),i}function Qt(e){var t=e.observing;e.observing=[];for(var n=t.length;n--;)Ut(t[n],e);e.dependenciesState=St.NOT_TRACKING}function en(e){var t=tn(),n=e();return nn(t),n}function tn(){var e=Ot.trackingDerivation;return Ot.trackingDerivation=null,e}function nn(e){Ot.trackingDerivation=e}function rn(e){if(e.dependenciesState!==St.UP_TO_DATE){e.dependenciesState=St.UP_TO_DATE;for(var t=e.observing,n=t.length;n--;)t[n].lowestObserverState=St.UP_TO_DATE}}function on(e){return console.log(e),e}function an(e,t){return ot("`whyRun` is deprecated in favor of `trace`"),(e=ln(arguments))?ge(e)||mn(e)?on(e.whyRun()):nt(j("m025")):on(j("m024"))}function sn(){for(var e=[],t=0;t0||Ot.isRunningReactions||hn(fn)}function fn(){Ot.isRunningReactions=!0;for(var e=Ot.pendingReactions,t=0;e.length>0;){++t===dn&&(console.error("Reaction doesn't converge to a stable state after "+dn+" iterations. Probably there is a cycle in the reactive function: "+e[0]),e.splice(0));for(var n=e.splice(0),i=0,r=n.length;i=0&&Ot.globalReactionErrorHandlers.splice(t,1)}},reserveArrayBuffer:L,resetGlobalState:function(){Ot.resetId++;var e=new Ct;for(var t in e)-1===Tt.indexOf(t)&&(Ot[t]=e[t]);Ot.allowStateChanges=!Ot.strictMode},isolateGlobalState:function(){Pt=!0,et().__mobxInstanceCount--},shareGlobalState:function(){ot("Using `shareGlobalState` is not recommended, use peer dependencies instead. See https://github.com/mobxjs/mobx/issues/1082 for details."),kt=!0;var e=et(),t=Ot;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?Ot=e.__mobxGlobal:e.__mobxGlobal=t},spyReport:m,spyReportEnd:v,spyReportStart:g,setReactionScheduler:function(e){var t=hn;hn=function(n){return e((function(){return t(n)}))}}},An={Reaction:un,untracked:en,Atom:a,BaseAtom:o,useStrict:G,isStrictModeEnabled:V,spy:b,comparer:ce,asReference:gn,asFlat:vn,asStructure:yn,asMap:bn,isModifierDescriptor:Ue,isObservableObject:Ce,isBoxedObservable:z,isObservableArray:D,ObservableMap:Ze,isObservableMap:$e,map:Je,transaction:Xe,observable:Be,computed:Mn,isObservable:Oe,isComputed:Sn,extendObservable:Pe,extendShallowObservable:Ae,observe:En,intercept:Tn,autorun:de,autorunAsync:pe,when:he,reaction:fe,action:Q,isAction:ne,runInAction:te,expr:Cn,toJS:On,createTransformer:kn,whyRun:an,isArrayLike:_t,extras:Pn},Rn=!1,Ln=function(e){var t=An[e];Object.defineProperty(An,e,{get:function(){return Rn||(Rn=!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}})};for(var In in An)Ln(In);"object"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:b,extras:Pn}),t.default=An}.call(this,n(47))},function(e,t){var n=e.exports={version:"2.6.9"};"number"==typeof __e&&(__e=n)},function(e,t,n){var i; +var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};function r(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){function e(e){void 0===e&&(e="Atom@"+tt()),this.name=e,this.isPendingUnobservation=!0,this.observers=[],this.observersIndexes={},this.diffValue=0,this.lastAccessedBy=0,this.lowestObserverState=St.NOT_TRACKING}return e.prototype.onBecomeUnobserved=function(){},e.prototype.reportObserved=function(){Ht(this)},e.prototype.reportChanged=function(){Gt(),function(e){if(e.lowestObserverState===St.STALE)return;e.lowestObserverState=St.STALE;var t=e.observers,n=t.length;for(;n--;){var i=t[n];i.dependenciesState===St.UP_TO_DATE&&(i.isTracing!==Et.NONE&&Yt(i,e),i.onBecomeStale()),i.dependenciesState=St.STALE}}(this),Vt()},e.prototype.toString=function(){return this.name},e}(),a=function(e){function t(t,n,i){void 0===t&&(t="Atom@"+tt()),void 0===n&&(n=st),void 0===i&&(i=st);var r=e.call(this,t)||this;return r.name=t,r.onBecomeObservedHandler=n,r.onBecomeUnobservedHandler=i,r.isPendingUnobservation=!1,r.isBeingTracked=!1,r}return r(t,e),t.prototype.reportObserved=function(){return Gt(),e.prototype.reportObserved.call(this),this.isBeingTracked||(this.isBeingTracked=!0,this.onBecomeObservedHandler()),Vt(),!!Ot.trackingDerivation},t.prototype.onBecomeUnobserved=function(){this.isBeingTracked=!1,this.onBecomeUnobservedHandler()},t}(o),s=bt("Atom",o);function l(e){return e.interceptors&&e.interceptors.length>0}function u(e,t){var n=e.interceptors||(e.interceptors=[]);return n.push(t),at((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function c(e,t){var n=tn();try{var i=e.interceptors;if(i)for(var r=0,o=i.length;r0}function h(e,t){var n=e.changeListeners||(e.changeListeners=[]);return n.push(t),at((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function p(e,t){var n=tn(),i=e.changeListeners;if(i){for(var r=0,o=(i=i.slice()).length;r=this.length,value:tt){for(var n=new Array(e-t),i=0;i0&&e+t+1>T&&L(e+t+1)},e.prototype.spliceWithArray=function(e,t,n){var i=this;Jt(this.atom);var r=this.values.length;if(void 0===e?e=0:e>r?e=r:e<0&&(e=Math.max(0,r+e)),t=1===arguments.length?r-e:null==t?0:Math.max(0,Math.min(t,r-e)),void 0===n&&(n=[]),l(this)){var o=c(this,{object:this.array,type:"splice",index:e,removedCount:t,added:n});if(!o)return Qe;t=o.removedCount,n=o.added}var a=(n=n.map((function(e){return i.enhancer(e,void 0)}))).length-t;this.updateArrayLength(r,a);var s=this.spliceItemsIntoValues(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice(e,n,s),this.dehanceValues(s)},e.prototype.spliceItemsIntoValues=function(e,t,n){if(n.length<1e4)return(i=this.values).splice.apply(i,[e,t].concat(n));var i,r=this.values.slice(e,e+t);return this.values=this.values.slice(0,e).concat(n,this.values.slice(e+t)),r},e.prototype.notifyArrayChildUpdate=function(e,t,n){var i=!this.owned&&f(),r=d(this),o=r||i?{object:this.array,type:"update",index:e,newValue:t,oldValue:n}:null;i&&g(o),this.atom.reportChanged(),r&&p(this,o),i&&v()},e.prototype.notifyArraySplice=function(e,t,n){var i=!this.owned&&f(),r=d(this),o=r||i?{object:this.array,type:"splice",index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;i&&g(o),this.atom.reportChanged(),r&&p(this,o),i&&v()},e}(),k=function(e){function t(t,n,i,r){void 0===i&&(i="ObservableArray@"+tt()),void 0===r&&(r=!1);var o=e.call(this)||this,a=new O(i,n,o,r);return gt(o,"$mobx",a),t&&t.length&&o.spliceWithArray(0,0,t),E&&Object.defineProperty(a.array,"0",P),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 i,r=this.$mobx.values;i=e0,"actions should have valid names, got: '"+e+"'");var n=function(){return W(e,t,this,arguments)};return n.originalFn=t,n.isMobxAction=!0,n}function W(e,t,n,i){var r=function(e,t,n,i){var r=f()&&!!e,o=0;if(r){o=Date.now();var a=i&&i.length||0,s=new Array(a);if(a>0)for(var l=0;l";mt(e,t,Q(o,n))}),(function(e){return this[e]}),(function(){it(!1,U("m001"))}),!1,!0),$=q((function(e,t,n){ie(e,t,n)}),(function(e){return this[e]}),(function(){it(!1,U("m001"))}),!1,!1),Q=function(e,t,n,i){return 1===arguments.length&&"function"==typeof e?j(e.name||"",e):2===arguments.length&&"function"==typeof t?j(e,t):1===arguments.length&&"string"==typeof e?ee(e):ee(t).apply(null,arguments)};function ee(e){return function(t,n,i){if(i&&"function"==typeof i.value)return i.value=j(e,i.value),i.enumerable=!1,i.configurable=!0,i;if(void 0!==i&&void 0!==i.get)throw new Error("[mobx] action is not expected to be used with getters");return J(e).apply(this,arguments)}}function te(e,t,n){var i="string"==typeof e?e:e.name||"",r="function"==typeof e?e:t,o="function"==typeof e?t:n;return it("function"==typeof r,U("m002")),it(0===r.length,U("m003")),it("string"==typeof i&&i.length>0,"actions should have valid names, got: '"+i+"'"),W(i,r,o,void 0)}function ne(e){return"function"==typeof e&&!0===e.isMobxAction}function ie(e,t,n){var i=function(){return W(t,n,e,arguments)};i.isMobxAction=!0,mt(e,t,i)}Q.bound=function(e,t,n){if("function"==typeof e){var i=j("",e);return i.autoBind=!0,i}return $.apply(null,arguments)};var re=Object.prototype.toString;function oe(e,t){return ae(e,t)}function ae(e,t,n,i){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return!1;if(e!=e)return t!=t;var r=typeof e;return("function"===r||"object"===r||"object"==typeof t)&&function(e,t,n,i){e=se(e),t=se(t);var r=re.call(e);if(r!==re.call(t))return!1;switch(r){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!=+e?+t!=+t:0==+e?1/+e==1/t:+e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object Symbol]":return"undefined"!=typeof Symbol&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t)}var o="[object Array]"===r;if(!o){if("object"!=typeof e||"object"!=typeof t)return!1;var a=e.constructor,s=t.constructor;if(a!==s&&!("function"==typeof a&&a instanceof a&&"function"==typeof s&&s instanceof s)&&"constructor"in e&&"constructor"in t)return!1}i=i||[];var l=(n=n||[]).length;for(;l--;)if(n[l]===e)return i[l]===t;if(n.push(e),i.push(t),o){if((l=e.length)!==t.length)return!1;for(;l--;)if(!ae(e[l],t[l],n,i))return!1}else{var u,c=Object.keys(e);if(l=c.length,Object.keys(t).length!==l)return!1;for(;l--;)if(u=c[l],!le(t,u)||!ae(e[u],t[u],n,i))return!1}return n.pop(),i.pop(),!0}(e,t,n,i)}function se(e){return D(e)?e.peek():$e(e)?e.entries():xt(e)?function(e){var t=[];for(;;){var n=e.next();if(n.done)break;t.push(n.value)}return t}(e.entries()):e}function le(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ue(e,t){return e===t}var ce={identity:ue,structural:function(e,t){return oe(e,t)},default:function(e,t){return function(e,t){return"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)}(e,t)||ue(e,t)}};function de(e,t,n){var i,r,o;"string"==typeof e?(i=e,r=t,o=n):(i=e.name||"Autorun@"+tt(),r=e,o=t),it("function"==typeof r,U("m004")),it(!1===ne(r),U("m005")),o&&(r=r.bind(o));var a=new un(i,(function(){this.track(s)}));function s(){r(a)}return a.schedule(),a.getDisposer()}function he(e,t,n,i){var r,o,a,s;return"string"==typeof e?(r=e,o=t,a=n,s=i):(r="When@"+tt(),o=e,a=t,s=n),de(r,(function(e){if(o.call(s)){e.dispose();var t=tn();a.call(s),nn(t)}}))}function pe(e,t,n,i){var r,o,a,s;"string"==typeof e?(r=e,o=t,a=n,s=i):(r=e.name||"AutorunAsync@"+tt(),o=e,a=t,s=n),it(!1===ne(o),U("m006")),void 0===a&&(a=1),s&&(o=o.bind(s));var l=!1,u=new un(r,(function(){l||(l=!0,setTimeout((function(){l=!1,u.isDisposed||u.track(c)}),a))}));function c(){o(u)}return u.schedule(),u.getDisposer()}function fe(e,t,n){var i;arguments.length>3&&nt(U("m007")),je(e)&&nt(U("m008")),(i="object"==typeof n?n:{}).name=i.name||e.name||t.name||"Reaction@"+tt(),i.fireImmediately=!0===n||!0===i.fireImmediately,i.delay=i.delay||0,i.compareStructural=i.compareStructural||i.struct||!1,t=Q(i.name,i.context?t.bind(i.context):t),i.context&&(e=e.bind(i.context));var r,o=!0,a=!1,s=i.equals?i.equals:i.compareStructural||i.struct?ce.structural:ce.default,l=new un(i.name,(function(){o||i.delay<1?u():a||(a=!0,setTimeout((function(){a=!1,u()}),i.delay))}));function u(){if(!l.isDisposed){var n=!1;l.track((function(){var t=e(l);n=o||!s(r,t),r=t})),o&&i.fireImmediately&&t(r,l),o||!0!==n||t(r,l),o&&(o=!1)}}return l.schedule(),l.getDisposer()}var me=function(){function e(e,t,n,i,r){this.derivation=e,this.scope=t,this.equals=n,this.dependenciesState=St.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=St.UP_TO_DATE,this.unboundDepsCount=0,this.__mapid="#"+tt(),this.value=new qt(null),this.isComputing=!1,this.isRunningSetter=!1,this.isTracing=Et.NONE,this.name=i||"ComputedValue@"+tt(),r&&(this.setter=j(i+"-setter",r))}return e.prototype.onBecomeStale=function(){!function(e){if(e.lowestObserverState!==St.UP_TO_DATE)return;e.lowestObserverState=St.POSSIBLY_STALE;var t=e.observers,n=t.length;for(;n--;){var i=t[n];i.dependenciesState===St.UP_TO_DATE&&(i.dependenciesState=St.POSSIBLY_STALE,i.isTracing!==Et.NONE&&Yt(i,e),i.onBecomeStale())}}(this)},e.prototype.onBecomeUnobserved=function(){Qt(this),this.value=void 0},e.prototype.get=function(){it(!this.isComputing,"Cycle detected in computation "+this.name,this.derivation),0===Ot.inBatch?(Gt(),Kt(this)&&(this.isTracing!==Et.NONE&&console.log("[mobx.trace] '"+this.name+"' is being read outside a reactive context and doing a full recompute"),this.value=this.computeValue(!1)),Vt()):(Ht(this),Kt(this)&&this.trackAndCompute()&&function(e){if(e.lowestObserverState===St.STALE)return;e.lowestObserverState=St.STALE;var t=e.observers,n=t.length;for(;n--;){var i=t[n];i.dependenciesState===St.POSSIBLY_STALE?i.dependenciesState=St.STALE:i.dependenciesState===St.UP_TO_DATE&&(e.lowestObserverState=St.UP_TO_DATE)}}(this));var e=this.value;if(Xt(e))throw e.cause;return e},e.prototype.peek=function(){var e=this.computeValue(!1);if(Xt(e))throw e.cause;return e},e.prototype.set=function(e){if(this.setter){it(!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 it(!1,"[ComputedValue '"+this.name+"'] It is not possible to assign a new value to a computed value.")},e.prototype.trackAndCompute=function(){f()&&m({object:this.scope,type:"compute",fn:this.derivation});var e=this.value,t=this.dependenciesState===St.NOT_TRACKING,n=this.value=this.computeValue(!0);return t||Xt(e)||Xt(n)||!this.equals(e,n)},e.prototype.computeValue=function(e){var t;if(this.isComputing=!0,Ot.computationDepth++,e)t=$t(this,this.derivation,this.scope);else try{t=this.derivation.call(this.scope)}catch(e){t=new qt(e)}return Ot.computationDepth--,this.isComputing=!1,t},e.prototype.observe=function(e,t){var n=this,i=!0,r=void 0;return de((function(){var o=n.get();if(!i||t){var a=tn();e({type:"update",object:n,newValue:o,oldValue:r}),nn(a)}i=!1,r=o}))},e.prototype.toJSON=function(){return this.get()},e.prototype.toString=function(){return this.name+"["+this.derivation.toString()+"]"},e.prototype.valueOf=function(){return Mt(this.get())},e.prototype.whyRun=function(){var e=Boolean(Ot.trackingDerivation),t=lt(this.isComputing?this.newObserving:this.observing).map((function(e){return e.name})),n=lt(Bt(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===St.NOT_TRACKING?U("m032"):" * This computation will re-run if any of the following observables changes:\n "+ut(t)+"\n "+(this.isComputing&&e?" (... or any observable accessed during the remainder of the current run)":"")+"\n "+U("m038")+"\n\n * If the outcome of this computation changes, the following observers will be re-run:\n "+ut(n)+"\n")},e}();me.prototype[wt()]=me.prototype.valueOf;var ge=bt("ComputedValue",me),ye=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 it(!0!==t,"`observe` doesn't support the fire immediately property for observable objects."),h(this,e)},e.prototype.intercept=function(e){return u(this,e)},e}();function ve(e,t){if(Ce(e)&&e.hasOwnProperty("$mobx"))return e.$mobx;it(Object.isExtensible(e),U("m035")),dt(e)||(t=(e.constructor.name||"ObservableObject")+"@"+tt()),t||(t="ObservableObject@"+tt());var n=new ye(e,t);return gt(e,"$mobx",n),n}function be(e,t,n,i){if(e.values[t]&&!ge(e.values[t]))return it("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(je(n.value)){var r=n.value;_e(e,t,r.initialValue,r.enhancer)}else ne(n.value)&&!0===n.value.autoBind?ie(e.target,t,n.value.originalFn):ge(n.value)?function(e,t,n){var i=e.name+"."+t;n.name=i,n.scope||(n.scope=e.target);e.values[t]=n,Object.defineProperty(e.target,t,Se(t))}(e,t,n.value):_e(e,t,n.value,i);else xe(e,t,n.get,n.set,ce.default,!0)}function _e(e,t,n,i){if(vt(e.target,t),l(e)){var r=c(e,{object:e.target,name:t,type:"add",newValue:n});if(!r)return;n=r.newValue}n=(e.values[t]=new F(n,i,e.name+"."+t,!1)).value,Object.defineProperty(e.target,t,function(e){return we[e]||(we[e]={configurable:!0,enumerable:!0,get:function(){return this.$mobx.values[e].get()},set:function(t){Ee(this,e,t)}})}(t)),function(e,t,n,i){var r=d(e),o=f(),a=r||o?{type:"add",object:t,name:n,newValue:i}:null;o&&g(a);r&&p(e,a);o&&v()}(e,e.target,t,n)}function xe(e,t,n,i,r,o){o&&vt(e.target,t),e.values[t]=new me(n,e.target,r,e.name+"."+t,i),o&&Object.defineProperty(e.target,t,Se(t))}var we={},Me={};function Se(e){return Me[e]||(Me[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 i=e.$mobx,r=i.values[t];if(l(i)){if(!(s=c(i,{type:"update",object:e,name:t,newValue:n})))return;n=s.newValue}if((n=r.prepareNewValue(n))!==N){var o=d(i),a=f(),s=o||a?{type:"update",object:e,oldValue:r.value,name:t,newValue:n}:null;a&&g(s),r.setNewValue(n),o&&p(i,s),a&&v()}}var Te=bt("ObservableObjectAdministration",ye);function Ce(e){return!!ct(e)&&(K(e),Te(e.$mobx))}function Oe(e,t){if(null==e)return!1;if(void 0!==t){if(D(e)||$e(e))throw new Error(U("m019"));if(Ce(e)){var n=e.$mobx;return n.values&&!!n.values[t]}return!1}return Ce(e)||!!e.$mobx||s(e)||mn(e)||ge(e)}function ke(e){return it(!!e,":("),q((function(t,n,i,r,o){vt(t,n),it(!o||!o.get,U("m022")),_e(ve(t,void 0),n,i,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 Pe(e){for(var t=[],n=1;n=2,U("m014")),it("object"==typeof e,U("m015")),it(!$e(e),U("m016")),n.forEach((function(e){it("object"==typeof e,U("m017")),it(!Oe(e),U("m018"))}));for(var i=ve(e),r={},o=n.length-1;o>=0;o--){var a=n[o];for(var s in a)if(!0!==r[s]&&ft(a,s)){if(r[s]=!0,e===a&&!yt(e,s))continue;be(i,s,Object.getOwnPropertyDescriptor(a,s),t)}}return e}var Le=ke(Ge),Ie=ke(Ve),De=ke(He),Ne=ke(Ye),Fe=ke(qe);var ze={box:function(e,t){return arguments.length>2&&Ue("box"),new F(e,Ge,t)},shallowBox:function(e,t){return arguments.length>2&&Ue("shallowBox"),new F(e,He,t)},array:function(e,t){return arguments.length>2&&Ue("array"),new k(e,Ge,t)},shallowArray:function(e,t){return arguments.length>2&&Ue("shallowArray"),new k(e,He,t)},map:function(e,t){return arguments.length>2&&Ue("map"),new Ze(e,Ge,t)},shallowMap:function(e,t){return arguments.length>2&&Ue("shallowMap"),new Ze(e,He,t)},object:function(e,t){arguments.length>2&&Ue("object");var n={};return ve(n,t),Pe(n,e),n},shallowObject:function(e,t){arguments.length>2&&Ue("shallowObject");var n={};return ve(n,t),Ae(n,e),n},ref:function(){return arguments.length<2?We(He,arguments[0]):De.apply(null,arguments)},shallow:function(){return arguments.length<2?We(Ve,arguments[0]):Ie.apply(null,arguments)},deep:function(){return arguments.length<2?We(Ge,arguments[0]):Le.apply(null,arguments)},struct:function(){return arguments.length<2?We(Ye,arguments[0]):Ne.apply(null,arguments)}},Be=function(e){if(void 0===e&&(e=void 0),"string"==typeof arguments[1])return Le.apply(null,arguments);if(it(arguments.length<=1,U("m021")),it(!je(e),U("m020")),Oe(e))return e;var t=Ge(e,void 0,void 0);return t!==e?t:Be.box(e)};function Ue(e){nt("Expected one or two arguments to observable."+e+". Did you accidentally try to use observable."+e+" as decorator?")}function je(e){return"object"==typeof e&&null!==e&&!0===e.isMobxModifierDescriptor}function We(e,t){return it(!je(t),"Modifiers cannot be nested"),{isMobxModifierDescriptor:!0,initialValue:t,enhancer:e}}function Ge(e,t,n){return je(e)&&nt("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),Oe(e)?e:Array.isArray(e)?Be.array(e,n):dt(e)?Be.object(e,n):xt(e)?Be.map(e,n):e}function Ve(e,t,n){return je(e)&&nt("You tried to assign a modifier wrapped value to a collection, please define modifiers when creating the collection, not when modifying it"),null==e?e:Ce(e)||D(e)||$e(e)?e:Array.isArray(e)?Be.shallowArray(e,n):dt(e)?Be.shallowObject(e,n):xt(e)?Be.shallowMap(e,n):nt("The shallow modifier / decorator can only used in combination with arrays, objects and maps")}function He(e){return e}function Ye(e,t,n){if(oe(e,t))return t;if(Oe(e))return e;if(Array.isArray(e))return new k(e,Ye,n);if(xt(e))return new Ze(e,Ye,n);if(dt(e)){var i={};return ve(i,n),Re(i,Ye,[e]),i}return e}function qe(e,t,n){return oe(e,t)?t:e}function Xe(e,t){void 0===t&&(t=void 0),Gt();try{return e.apply(t)}finally{Vt()}}Object.keys(ze).forEach((function(e){return Be[e]=ze[e]})),Be.deep.struct=Be.struct,Be.ref.struct=function(){return arguments.length<2?We(qe,arguments[0]):Fe.apply(null,arguments)};var Ke={},Ze=function(){function e(e,t,n){void 0===t&&(t=Ge),void 0===n&&(n="ObservableMap@"+tt()),this.enhancer=t,this.name=n,this.$mobx=Ke,this._data=Object.create(null),this._hasMap=Object.create(null),this._keys=new k(void 0,He,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(l(this)){var i=c(this,{type:n?"update":"add",object:this,newValue:t,name:e});if(!i)return this;t=i.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,l(this))&&!(r=c(this,{type:"delete",object:this,name:e})))return!1;if(this._has(e)){var n=f(),i=d(this),r=i||n?{type:"delete",object:this,oldValue:this._data[e].value,name:e}:null;return n&&g(r),Xe((function(){t._keys.remove(e),t._updateHasMapEntry(e,!1),t._data[e].setNewValue(void 0),t._data[e]=void 0})),i&&p(this,r),n&&v(),!0}return!1},e.prototype._updateHasMapEntry=function(e,t){var n=this._hasMap[e];return n?n.setNewValue(t):n=this._hasMap[e]=new F(t,He,this.name+"."+e+"?",!1),n},e.prototype._updateValue=function(e,t){var n=this._data[e];if((t=n.prepareNewValue(t))!==N){var i=f(),r=d(this),o=r||i?{type:"update",object:this,oldValue:n.value,name:e,newValue:t}:null;i&&g(o),n.setNewValue(t),r&&p(this,o),i&&v()}},e.prototype._addValue=function(e,t){var n=this;Xe((function(){var i=n._data[e]=new F(t,n.enhancer,n.name+"."+e,!1);t=i.value,n._updateHasMapEntry(e,!0),n._keys.push(e)}));var i=f(),r=d(this),o=r||i?{type:"add",object:this,name:e,newValue:t}:null;i&&g(o),r&&p(this,o),i&&v()},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 x(this._keys.slice())},e.prototype.values=function(){return x(this._keys.map(this.get,this))},e.prototype.entries=function(){var e=this;return x(this._keys.map((function(t){return[t,e.get(t)]})))},e.prototype.forEach=function(e,t){var n=this;this.keys().forEach((function(i){return e.call(t,n.get(i),i,n)}))},e.prototype.merge=function(e){var t=this;return $e(e)&&(e=e.toJS()),Xe((function(){dt(e)?Object.keys(e).forEach((function(n){return t.set(n,e[n])})):Array.isArray(e)?e.forEach((function(e){var n=e[0],i=e[1];return t.set(n,i)})):xt(e)?e.forEach((function(e,n){return t.set(n,e)})):null!=e&&nt("Cannot initialize map from "+e)})),this},e.prototype.clear=function(){var e=this;Xe((function(){en((function(){e.keys().forEach(e.delete,e)}))}))},e.prototype.replace=function(e){var t=this;return Xe((function(){var n,i=dt(n=e)?Object.keys(n):Array.isArray(n)?n.map((function(e){return e[0]})):xt(n)?Array.from(n.keys()):$e(n)?n.keys():nt("Cannot get keys from "+n);t.keys().filter((function(e){return-1===i.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&&("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 it(!0!==t,U("m033")),h(this,e)},e.prototype.intercept=function(e){return u(this,e)},e}();function Je(e){return ot("`mobx.map` is deprecated, use `new ObservableMap` or `mobx.observable.map` instead"),Be.map(e)}w(Ze.prototype,(function(){return this.entries()}));var $e=bt("ObservableMap",Ze),Qe=[];function et(){return"undefined"!=typeof window?window:e}function tt(){return++Ot.mobxGuid}function nt(e,t){throw it(!1,e,t),"X"}function it(e,t,n){if(!e)throw new Error("[mobx] Invariant failed: "+t+(n?" in '"+n+"'":""))}Object.freeze(Qe);var rt=[];function ot(e){return-1===rt.indexOf(e)&&(rt.push(e),console.error("[mobx] Deprecated: "+e),!0)}function at(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var st=function(){};function lt(e){var t=[];return e.forEach((function(e){-1===t.indexOf(e)&&t.push(e)})),t}function ut(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 ct(e){return null!==e&&"object"==typeof e}function dt(e){if(null===e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ht(){for(var e=arguments[0],t=1,n=arguments.length;t0&&(t.dependencies=lt(e.observing).map(Ft)),t}function zt(e){var t={name:e.name};return function(e){return e.observers&&e.observers.length>0}(e)&&(t.observers=Bt(e).map(zt)),t}function Bt(e){return e.observers}function Ut(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 jt(e,t){if(1===e.observers.length)e.observers.length=0,Wt(e);else{var n=e.observers,i=e.observersIndexes,r=n.pop();if(r!==t){var o=i[t.__mapid]||0;o?i[r.__mapid]=o:delete i[r.__mapid],n[o]=r}delete i[t.__mapid]}}function Wt(e){e.isPendingUnobservation||(e.isPendingUnobservation=!0,Ot.pendingUnobservations.push(e))}function Gt(){Ot.inBatch++}function Vt(){if(0==--Ot.inBatch){pn();for(var e=Ot.pendingUnobservations,t=0;t=1e3)return void n.push("(and many more)");n.push(""+new Array(i).join("\t")+t.name);t.dependencies&&t.dependencies.forEach((function(t){return e(t,n,i+1)}))}(Nt(e),n,1),new Function("debugger;\n/*\nTracing '"+e.name+"'\n\nYou are entering this break point because derivation '"+e.name+"' is being traced and '"+t.name+"' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n"+(e instanceof me?e.derivation.toString():"")+"\n\nThe dependencies for this derivation are:\n\n"+n.join("\n")+"\n*/\n ")()}}Rt.__mobxInstanceCount?(Rt.__mobxInstanceCount++,setTimeout((function(){kt||Pt||At||(At=!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."))}),1)):Rt.__mobxInstanceCount=1,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"}(St||(St={})),function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(Et||(Et={}));var qt=function(e){this.cause=e};function Xt(e){return e instanceof qt}function Kt(e){switch(e.dependenciesState){case St.UP_TO_DATE:return!1;case St.NOT_TRACKING:case St.STALE:return!0;case St.POSSIBLY_STALE:for(var t=tn(),n=e.observing,i=n.length,r=0;r0;Ot.computationDepth>0&&t&&nt(U("m031")+e.name),!Ot.allowStateChanges&&t&&nt(U(Ot.strictMode?"m030a":"m030b")+e.name)}function $t(e,t,n){rn(e),e.newObserving=new Array(e.observing.length+100),e.unboundDepsCount=0,e.runId=++Ot.runId;var i,r=Ot.trackingDerivation;Ot.trackingDerivation=e;try{i=t.call(n)}catch(e){i=new qt(e)}return Ot.trackingDerivation=r,function(e){for(var t=e.observing,n=e.observing=e.newObserving,i=St.UP_TO_DATE,r=0,o=e.unboundDepsCount,a=0;ai&&(i=s.dependenciesState)}n.length=r,e.newObserving=null,o=t.length;for(;o--;){0===(s=t[o]).diffValue&&jt(s,e),s.diffValue=0}for(;r--;){var s;1===(s=n[r]).diffValue&&(s.diffValue=0,Ut(s,e))}i!==St.UP_TO_DATE&&(e.dependenciesState=i,e.onBecomeStale())}(e),i}function Qt(e){var t=e.observing;e.observing=[];for(var n=t.length;n--;)jt(t[n],e);e.dependenciesState=St.NOT_TRACKING}function en(e){var t=tn(),n=e();return nn(t),n}function tn(){var e=Ot.trackingDerivation;return Ot.trackingDerivation=null,e}function nn(e){Ot.trackingDerivation=e}function rn(e){if(e.dependenciesState!==St.UP_TO_DATE){e.dependenciesState=St.UP_TO_DATE;for(var t=e.observing,n=t.length;n--;)t[n].lowestObserverState=St.UP_TO_DATE}}function on(e){return console.log(e),e}function an(e,t){return ot("`whyRun` is deprecated in favor of `trace`"),(e=ln(arguments))?ge(e)||mn(e)?on(e.whyRun()):nt(U("m025")):on(U("m024"))}function sn(){for(var e=[],t=0;t0||Ot.isRunningReactions||hn(fn)}function fn(){Ot.isRunningReactions=!0;for(var e=Ot.pendingReactions,t=0;e.length>0;){++t===dn&&(console.error("Reaction doesn't converge to a stable state after "+dn+" iterations. Probably there is a cycle in the reactive function: "+e[0]),e.splice(0));for(var n=e.splice(0),i=0,r=n.length;i=0&&Ot.globalReactionErrorHandlers.splice(t,1)}},reserveArrayBuffer:L,resetGlobalState:function(){Ot.resetId++;var e=new Ct;for(var t in e)-1===Tt.indexOf(t)&&(Ot[t]=e[t]);Ot.allowStateChanges=!Ot.strictMode},isolateGlobalState:function(){Pt=!0,et().__mobxInstanceCount--},shareGlobalState:function(){ot("Using `shareGlobalState` is not recommended, use peer dependencies instead. See https://github.com/mobxjs/mobx/issues/1082 for details."),kt=!0;var e=et(),t=Ot;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?Ot=e.__mobxGlobal:e.__mobxGlobal=t},spyReport:m,spyReportEnd:v,spyReportStart:g,setReactionScheduler:function(e){var t=hn;hn=function(n){return e((function(){return t(n)}))}}},An={Reaction:un,untracked:en,Atom:a,BaseAtom:o,useStrict:G,isStrictModeEnabled:V,spy:b,comparer:ce,asReference:gn,asFlat:vn,asStructure:yn,asMap:bn,isModifierDescriptor:je,isObservableObject:Ce,isBoxedObservable:z,isObservableArray:D,ObservableMap:Ze,isObservableMap:$e,map:Je,transaction:Xe,observable:Be,computed:Mn,isObservable:Oe,isComputed:Sn,extendObservable:Pe,extendShallowObservable:Ae,observe:En,intercept:Tn,autorun:de,autorunAsync:pe,when:he,reaction:fe,action:Q,isAction:ne,runInAction:te,expr:Cn,toJS:On,createTransformer:kn,whyRun:an,isArrayLike:_t,extras:Pn},Rn=!1,Ln=function(e){var t=An[e];Object.defineProperty(An,e,{get:function(){return Rn||(Rn=!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}})};for(var In in An)Ln(In);"object"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:b,extras:Pn}),t.default=An}.call(this,n(47))},function(e,t){var n=e.exports={version:"2.6.9"};"number"==typeof __e&&(__e=n)},function(e,t,n){var i; /*! Copyright (c) 2017 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t0?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&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n>=4,n[r]=t[19===r?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,i,r){return i+(e-t)*(r-i)/(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*Mt.DEG2RAD},radToDeg:function(e){return e*Mt.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}};function St(e,t){this.x=e||0,this.y=t||0}St.prototype={constructor:St,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(e,t){return void 0===r&&(r=new St,o=new St),r.set(e,e),o.set(t,t),this.clamp(r,o)},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),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}};var Et,Tt,Ct,Ot,kt,Pt,At=0;function Rt(e,t,n,i,r,o,a,s,l,u){Object.defineProperty(this,"id",{value:At++}),this.uuid=Mt.generateUUID(),this.name="",this.image=void 0!==e?e:Rt.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:Rt.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:ve,this.wrapT=void 0!==i?i:ve,this.magFilter=void 0!==r?r:Me,this.minFilter=void 0!==o?o:Ee,this.anisotropy=void 0!==l?l:1,this.format=void 0!==a?a:je,this.type=void 0!==s?s:Te,this.offset=new St(0,0),this.repeat=new St(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:pt,this.version=0,this.onUpdate=null}function Lt(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1}function It(e,t,n){this.uuid=Mt.generateUUID(),this.width=e,this.height=t,this.scissor=new Lt(0,0,e,t),this.scissorTest=!1,this.viewport=new Lt(0,0,e,t),void 0===(n=n||{}).minFilter&&(n.minFilter=Me),this.texture=new Rt(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 Dt(e,t,n){It.call(this,e,t,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function Nt(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1}function Ft(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}function zt(){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 Bt(e,t,n,i,r,o,a,s,l,u){e=void 0!==e?e:[],t=void 0!==t?t:ce,Rt.call(this,e,t,n,i,r,o,a,s,l,u),this.flipY=!1}Rt.DEFAULT_IMAGE=void 0,Rt.DEFAULT_MAPPING=ue,Rt.prototype={constructor:Rt,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=Mt.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")).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===ue){if(e.multiply(this.repeat),e.add(this.offset),e.x<0||e.x>1)switch(this.wrapS){case ye:e.x=e.x-Math.floor(e.x);break;case ve:e.x=e.x<0?0:1;break;case be: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 ye:e.y=e.y-Math.floor(e.y);break;case ve:e.y=e.y<0?0:1;break;case be: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(Rt.prototype,i.prototype),Lt.prototype={constructor:Lt,isVector4:!0,set:function(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,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,i,r,o=e.elements,a=o[0],s=o[4],l=o[8],u=o[1],c=o[5],d=o[9],h=o[2],p=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(l-h)<.01&&Math.abs(d-p)<.01){if(Math.abs(s+u)<.1&&Math.abs(l+h)<.1&&Math.abs(d+p)<.1&&Math.abs(a+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(a+1)/2,g=(c+1)/2,y=(f+1)/2,v=(s+u)/4,b=(l+h)/4,_=(d+p)/4;return m>g&&m>y?m<.01?(n=0,i=.707106781,r=.707106781):(i=v/(n=Math.sqrt(m)),r=b/n):g>y?g<.01?(n=.707106781,i=0,r=.707106781):(n=v/(i=Math.sqrt(g)),r=_/i):y<.01?(n=.707106781,i=.707106781,r=0):(n=b/(r=Math.sqrt(y)),i=_/r),this.set(n,i,r,t),this}var x=Math.sqrt((p-d)*(p-d)+(l-h)*(l-h)+(u-s)*(u-s));return Math.abs(x)<.001&&(x=1),this.x=(p-d)/x,this.y=(l-h)/x,this.z=(u-s)/x,this.w=Math.acos((a+c+f-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,i){return void 0===e&&(e=new Lt,t=new Lt),e.set(n,n,n,n),t.set(i,i,i,i),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}},It.prototype={constructor:It,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(It.prototype,i.prototype),Dt.prototype=Object.create(It.prototype),Dt.prototype.constructor=Dt,Dt.prototype.isWebGLRenderTargetCube=!0,Nt.prototype={constructor:Nt,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,i){return this._x=e,this._y=t,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(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),i=Math.cos(e._y/2),r=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*i*r+n*a*s,this._y=n*a*r-o*i*s,this._z=n*i*s+o*a*r,this._w=n*i*r-o*a*s):"YXZ"===l?(this._x=o*i*r+n*a*s,this._y=n*a*r-o*i*s,this._z=n*i*s-o*a*r,this._w=n*i*r+o*a*s):"ZXY"===l?(this._x=o*i*r-n*a*s,this._y=n*a*r+o*i*s,this._z=n*i*s+o*a*r,this._w=n*i*r-o*a*s):"ZYX"===l?(this._x=o*i*r-n*a*s,this._y=n*a*r+o*i*s,this._z=n*i*s-o*a*r,this._w=n*i*r+o*a*s):"YZX"===l?(this._x=o*i*r+n*a*s,this._y=n*a*r+o*i*s,this._z=n*i*s-o*a*r,this._w=n*i*r-o*a*s):"XZY"===l&&(this._x=o*i*r-n*a*s,this._y=n*a*r-o*i*s,this._z=n*i*s+o*a*r,this._w=n*i*r+o*a*s),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,i=n[0],r=n[4],o=n[8],a=n[1],s=n[5],l=n[9],u=n[2],c=n[6],d=n[10],h=i+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-r)*t):i>s&&i>d?(t=2*Math.sqrt(1+i-s-d),this._w=(c-l)/t,this._x=.25*t,this._y=(r+a)/t,this._z=(o+u)/t):s>d?(t=2*Math.sqrt(1+s-i-d),this._w=(o-u)/t,this._x=(r+a)/t,this._y=.25*t,this._z=(l+c)/t):(t=2*Math.sqrt(1+d-i-s),this._w=(a-r)/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,i){return void 0===e&&(e=new Ft),(t=n.dot(i)+1)<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,i),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,i=e._y,r=e._z,o=e._w,a=t._x,s=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+i*l-r*s,this._y=i*u+o*s+r*a-n*l,this._z=r*u+o*l+n*s-i*a,this._w=o*u-n*a-i*s-r*l,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,i=this._y,r=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+r*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=i,this._z=r,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*(i+this._y),this._z=.5*(r+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=i*u+this._y*c,this._z=r*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(Nt,{slerp:function(e,t,n,i){return n.copy(e).slerp(t,i)},slerpFlat:function(e,t,n,i,r,o,a){var s=n[i+0],l=n[i+1],u=n[i+2],c=n[i+3],d=r[o+0],h=r[o+1],p=r[o+2],f=r[o+3];if(c!==f||s!==d||l!==h||u!==p){var m=1-a,g=s*d+l*h+u*p+c*f,y=g>=0?1:-1,v=1-g*g;if(v>Number.EPSILON){var b=Math.sqrt(v),_=Math.atan2(b,g*y);m=Math.sin(m*_)/b,a=Math.sin(a*_)/b}var x=a*y;if(s=s*m+d*x,l=l*m+h*x,u=u*m+p*x,c=c*m+f*x,m===1-a){var w=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=w,l*=w,u*=w,c*=w}}e[t]=s,e[t+1]=l,e[t+2]=u,e[t+3]=c}}),Ft.prototype={constructor:Ft,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(e){return!1===(e&&e.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===Ct&&(Ct=new Nt),this.applyQuaternion(Ct.setFromEuler(e))},applyAxisAngle:function(){var e;return function(t,n){return void 0===e&&(e=new Nt),this.applyQuaternion(e.setFromAxisAngle(t,n))}}(),applyMatrix3:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;this.x=r[0]*t+r[4]*n+r[8]*i+r[12],this.y=r[1]*t+r[5]*n+r[9]*i+r[13],this.z=r[2]*t+r[6]*n+r[10]*i+r[14];var o=r[3]*t+r[7]*n+r[11]*i+r[15];return this.divideScalar(o)},applyQuaternion:function(e){var t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*i-a*n,u=s*n+a*t-r*i,c=s*i+r*n-o*t,d=-r*t-o*n-a*i;return this.x=l*s+d*-r+u*-a-c*-o,this.y=u*s+d*-o+c*-r-l*-a,this.z=c*s+d*-a+l*-o-u*-r,this},project:function(e){return void 0===Tt&&(Tt=new zt),Tt.multiplyMatrices(e.projectionMatrix,Tt.getInverse(e.matrixWorld)),this.applyMatrix4(Tt)},unproject:function(){var e;return function(t){return void 0===e&&(e=new zt),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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,i){return void 0===e&&(e=new Ft,t=new Ft),e.set(n,n,n),t.set(i,i,i),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,i=this.y,r=this.z;return this.x=i*e.z-r*e.y,this.y=r*e.x-n*e.z,this.z=n*e.y-i*e.x,this},crossVectors:function(e,t){var n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,s=t.z;return this.x=i*s-r*a,this.y=r*o-n*s,this.z=n*a-i*o,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(e){return void 0===Et&&(Et=new Ft),Et.copy(this).projectOnVector(e),this.sub(Et)},reflect:function(){var e;return function(t){return void 0===e&&(e=new Ft),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(Mt.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,i=this.z-e.z;return t*t+n*n+i*i},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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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}},zt.prototype={constructor:zt,isMatrix4:!0,set:function(e,t,n,i,r,o,a,s,l,u,c,d,h,p,f,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,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]=p,g[11]=f,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 zt).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 Ft);var n=this.elements,i=t.elements,r=1/e.setFromMatrixColumn(t,0).length(),o=1/e.setFromMatrixColumn(t,1).length(),a=1/e.setFromMatrixColumn(t,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[4]=i[4]*o,n[5]=i[5]*o,n[6]=i[6]*o,n[8]=i[8]*a,n[9]=i[9]*a,n[10]=i[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,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(i),l=Math.sin(i),u=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){var d=o*u,h=o*c,p=a*u,f=a*c;t[0]=s*u,t[4]=-s*c,t[8]=l,t[1]=h+p*l,t[5]=d-f*l,t[9]=-a*s,t[2]=f-d*l,t[6]=p+h*l,t[10]=o*s}else if("YXZ"===e.order){var m=s*u,g=s*c,y=l*u,v=l*c;t[0]=m+v*a,t[4]=y*a-g,t[8]=o*l,t[1]=o*c,t[5]=o*u,t[9]=-a,t[2]=g*a-y,t[6]=v+m*a,t[10]=o*s}else if("ZXY"===e.order){m=s*u,g=s*c,y=l*u,v=l*c;t[0]=m-v*a,t[4]=-o*c,t[8]=y+g*a,t[1]=g+y*a,t[5]=o*u,t[9]=v-m*a,t[2]=-o*l,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){d=o*u,h=o*c,p=a*u,f=a*c;t[0]=s*u,t[4]=p*l-h,t[8]=d*l+f,t[1]=s*c,t[5]=f*l+d,t[9]=h*l-p,t[2]=-l,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){var b=o*s,_=o*l,x=a*s,w=a*l;t[0]=s*u,t[4]=w-b*c,t[8]=x*c+_,t[1]=c,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=_*c+x,t[10]=b-w*c}else if("XZY"===e.order){b=o*s,_=o*l,x=a*s,w=a*l;t[0]=s*u,t[4]=-c,t[8]=l*u,t[1]=b*c+w,t[5]=o*u,t[9]=_*c-x,t[2]=x*c-_,t[6]=a*u,t[10]=w*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,i=e.y,r=e.z,o=e.w,a=n+n,s=i+i,l=r+r,u=n*a,c=n*s,d=n*l,h=i*s,p=i*l,f=r*l,m=o*a,g=o*s,y=o*l;return t[0]=1-(h+f),t[4]=c-y,t[8]=d+g,t[1]=c+y,t[5]=1-(u+f),t[9]=p-m,t[2]=d-g,t[6]=p+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(e,t,n){void 0===Ot&&(Ot=new Ft,kt=new Ft,Pt=new Ft);var i=this.elements;return Pt.subVectors(e,t).normalize(),0===Pt.lengthSq()&&(Pt.z=1),Ot.crossVectors(n,Pt).normalize(),0===Ot.lengthSq()&&(Pt.z+=1e-4,Ot.crossVectors(n,Pt).normalize()),kt.crossVectors(Pt,Ot),i[0]=Ot.x,i[4]=kt.x,i[8]=Pt.x,i[1]=Ot.y,i[5]=kt.y,i[9]=Pt.y,i[2]=Ot.z,i[6]=kt.z,i[10]=Pt.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,i=t.elements,r=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],p=n[2],f=n[6],m=n[10],g=n[14],y=n[3],v=n[7],b=n[11],_=n[15],x=i[0],w=i[4],M=i[8],S=i[12],E=i[1],T=i[5],C=i[9],O=i[13],k=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]=o*x+a*E+s*k+l*L,r[4]=o*w+a*T+s*P+l*I,r[8]=o*M+a*C+s*A+l*D,r[12]=o*S+a*O+s*R+l*N,r[1]=u*x+c*E+d*k+h*L,r[5]=u*w+c*T+d*P+h*I,r[9]=u*M+c*C+d*A+h*D,r[13]=u*S+c*O+d*R+h*N,r[2]=p*x+f*E+m*k+g*L,r[6]=p*w+f*T+m*P+g*I,r[10]=p*M+f*C+m*A+g*D,r[14]=p*S+f*O+m*R+g*N,r[3]=y*x+v*E+b*k+_*L,r[7]=y*w+v*T+b*P+_*I,r[11]=y*M+v*C+b*A+_*D,r[15]=y*S+v*O+b*R+_*N,this},multiplyToArray:function(e,t,n){var i=this.elements;return this.multiplyMatrices(e,t),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(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 Ft);for(var n=0,i=t.count;n0)return e;var r=t*n,o=Gt[r];if(void 0===o&&(o=new Float32Array(r),Gt[r]=o),0!==t){i.toArray(o,0);for(var a=1,s=0;a!==t;++a)s+=n,e[a].toArray(o,s)}return o}function Yt(e,t){var n=Vt[t];void 0===n&&(n=new Int32Array(t),Vt[t]=n);for(var i=0;i!==t;++i)n[i]=e.allocTextureUnit();return n}function qt(e,t){e.uniform1f(this.addr,t)}function Xt(e,t){e.uniform1i(this.addr,t)}function Kt(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)}function Zt(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 Jt(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)}function $t(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)}function Qt(e,t){e.uniformMatrix3fv(this.addr,!1,t.elements||t)}function en(e,t){e.uniformMatrix4fv(this.addr,!1,t.elements||t)}function tn(e,t,n){var i=n.allocTextureUnit();e.uniform1i(this.addr,i),n.setTexture2D(t||jt,i)}function nn(e,t,n){var i=n.allocTextureUnit();e.uniform1i(this.addr,i),n.setTextureCube(t||Ut,i)}function rn(e,t){e.uniform2iv(this.addr,t)}function on(e,t){e.uniform3iv(this.addr,t)}function an(e,t){e.uniform4iv(this.addr,t)}function sn(e,t){e.uniform1fv(this.addr,t)}function ln(e,t){e.uniform1iv(this.addr,t)}function un(e,t){e.uniform2fv(this.addr,Ht(t,this.size,2))}function cn(e,t){e.uniform3fv(this.addr,Ht(t,this.size,3))}function dn(e,t){e.uniform4fv(this.addr,Ht(t,this.size,4))}function hn(e,t){e.uniformMatrix2fv(this.addr,!1,Ht(t,this.size,4))}function pn(e,t){e.uniformMatrix3fv(this.addr,!1,Ht(t,this.size,9))}function fn(e,t){e.uniformMatrix4fv(this.addr,!1,Ht(t,this.size,16))}function mn(e,t,n){var i=t.length,r=Yt(n,i);e.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTexture2D(t[o]||jt,r[o])}function gn(e,t,n){var i=t.length,r=Yt(n,i);e.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTextureCube(t[o]||Ut,r[o])}function yn(e,t,n){this.id=e,this.addr=n,this.setValue=function(e){switch(e){case 5126:return qt;case 35664:return Kt;case 35665:return Zt;case 35666:return Jt;case 35674:return $t;case 35675:return Qt;case 35676:return en;case 35678:return tn;case 35680:return nn;case 5124:case 35670:return Xt;case 35667:case 35671:return rn;case 35668:case 35672:return on;case 35669:case 35673:return an}}(t.type)}function vn(e,t,n){this.id=e,this.addr=n,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return sn;case 35664:return un;case 35665:return cn;case 35666:return dn;case 35674:return hn;case 35675:return pn;case 35676:return fn;case 35678:return mn;case 35680:return gn;case 5124:case 35670:return ln;case 35667:case 35671:return rn;case 35668:case 35672:return on;case 35669:case 35673:return an}}(t.type)}function bn(e){this.id=e,Wt.call(this)}bn.prototype.setValue=function(e,t){for(var n=this.seq,i=0,r=n.length;i!==r;++i){var o=n[i];o.setValue(e,t[o.id])}};var _n=/([\w\d_]+)(\])?(\[|\.)?/g;function xn(e,t){e.seq.push(t),e.map[t.id]=t}function wn(e,t,n){var i=e.name,r=i.length;for(_n.lastIndex=0;;){var o=_n.exec(i),a=_n.lastIndex,s=o[1],l="]"===o[2],u=o[3];if(l&&(s|=0),void 0===u||"["===u&&a+2===r){xn(n,void 0===u?new yn(s,e,t):new vn(s,e,t));break}var c=n.map[s];void 0===c&&xn(n,c=new bn(s)),n=c}}function Mn(e,t,n){Wt.call(this),this.renderer=n;for(var i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=0;r 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"};function Tn(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}Tn.prototype={constructor:Tn,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,i){if(t=Mt.euclideanModulo(t,1),n=Mt.clamp(n,0,1),i=Mt.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,o=2*i-r;this.r=e(o,r,t+1/3),this.g=e(o,r,t),this.b=e(o,r,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 i,r=n[1],o=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(o))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,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))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,t(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(o)){var a=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(a,s,l)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(e)){var u,c=(u=n[1]).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}e&&e.length>0&&(void 0!==(u=Cn[e])?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,i=e||{h:0,s:0,l:0},r=this.r,o=this.g,a=this.b,s=Math.max(r,o,a),l=Math.min(r,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 r:t=(o-a)/c+(o.001&&k.scale>.001&&(x.x=k.x,x.y=k.y,x.z=k.z,b=k.size*k.scale/f.w,_.x=b*g,_.y=b,c.uniform3f(s.screenPosition,x.x,x.y,x.z),c.uniform2f(s.scale,_.x,_.y),c.uniform1f(s.rotation,k.rotation),c.uniform1f(s.opacity,k.opacity),c.uniform3f(s.color,k.color.r,k.color.g,k.color.b),d.setBlending(k.blending,k.blendEquation,k.blendSrc,k.blendDst),e.setTexture2D(k.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0))}}}d.enable(c.CULL_FACE),d.enable(c.DEPTH_TEST),d.setDepthWrite(!0),e.resetGLState()}}}function Ln(e,t){var n,i,r,o,a,s,l=e.context,u=e.state,c=new Ft,d=new Nt,h=new Ft;function p(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),u=new Uint16Array([0,1,2,0,2,3]);n=l.createBuffer(),i=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,n),l.bufferData(l.ARRAY_BUFFER,t,l.STATIC_DRAW),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,i),l.bufferData(l.ELEMENT_ARRAY_BUFFER,u,l.STATIC_DRAW),r=function(){var t=l.createProgram(),n=l.createShader(l.VERTEX_SHADER),i=l.createShader(l.FRAGMENT_SHADER);return l.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")),l.shaderSource(i,["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")),l.compileShader(n),l.compileShader(i),l.attachShader(t,n),l.attachShader(t,i),l.linkProgram(t),t}(),o={position:l.getAttribLocation(r,"position"),uv:l.getAttribLocation(r,"uv")},a={uvOffset:l.getUniformLocation(r,"uvOffset"),uvScale:l.getUniformLocation(r,"uvScale"),rotation:l.getUniformLocation(r,"rotation"),scale:l.getUniformLocation(r,"scale"),color:l.getUniformLocation(r,"color"),map:l.getUniformLocation(r,"map"),opacity:l.getUniformLocation(r,"opacity"),modelViewMatrix:l.getUniformLocation(r,"modelViewMatrix"),projectionMatrix:l.getUniformLocation(r,"projectionMatrix"),fogType:l.getUniformLocation(r,"fogType"),fogDensity:l.getUniformLocation(r,"fogDensity"),fogNear:l.getUniformLocation(r,"fogNear"),fogFar:l.getUniformLocation(r,"fogFar"),fogColor:l.getUniformLocation(r,"fogColor"),alphaTest:l.getUniformLocation(r,"alphaTest")};var c=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");c.width=8,c.height=8;var d=c.getContext("2d");d.fillStyle="white",d.fillRect(0,0,8,8),(s=new Rt(c)).needsUpdate=!0}function f(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}this.render=function(m,g){if(0!==t.length){void 0===r&&p(),l.useProgram(r),u.initAttributes(),u.enableAttribute(o.position),u.enableAttribute(o.uv),u.disableUnusedAttributes(),u.disable(l.CULL_FACE),u.enable(l.BLEND),l.bindBuffer(l.ARRAY_BUFFER,n),l.vertexAttribPointer(o.position,2,l.FLOAT,!1,16,0),l.vertexAttribPointer(o.uv,2,l.FLOAT,!1,16,8),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,i),l.uniformMatrix4fv(a.projectionMatrix,!1,g.projectionMatrix.elements),u.activeTexture(l.TEXTURE0),l.uniform1i(a.map,0);var y=0,v=0,b=m.fog;b?(l.uniform3f(a.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(l.uniform1f(a.fogNear,b.near),l.uniform1f(a.fogFar,b.far),l.uniform1i(a.fogType,1),y=1,v=1):b.isFogExp2&&(l.uniform1f(a.fogDensity,b.density),l.uniform1i(a.fogType,2),y=2,v=2)):(l.uniform1i(a.fogType,0),y=0,v=0);for(var _=0,x=t.length;_this.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 St).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 St).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new St;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 In,Dn,Nn,Fn,zn,Bn,jn,Un,Wn,Gn,Vn,Hn=0;function Yn(){Object.defineProperty(this,"id",{value:Hn++}),this.uuid=Mt.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=T,this.side=y,this.shading=x,this.vertexColors=w,this.opacity=1,this.transparent=!1,this.blendSrc=j,this.blendDst=U,this.blendEquation=A,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Z,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 qn(e){Yn.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!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}function Xn(e){Yn.call(this),this.type="MeshDepthMaterial",this.depthPacking=xt,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(e)}function Kn(e,t){this.min=void 0!==e?e:new Ft(1/0,1/0,1/0),this.max=void 0!==t?t:new Ft(-1/0,-1/0,-1/0)}function Zn(e,t){this.center=void 0!==e?e:new Ft,this.radius=void 0!==t?t:0}function Jn(){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 $n(e,t){this.normal=void 0!==e?e:new Ft(1,0,0),this.constant=void 0!==t?t:0}function Qn(e,t,n,i,r,o){this.planes=[void 0!==e?e:new $n,void 0!==t?t:new $n,void 0!==n?n:new $n,void 0!==i?i:new $n,void 0!==r?r:new $n,void 0!==o?o:new $n]}function ei(e,t,n,i){var r=e.context,o=e.state,a=new Qn,s=new zt,l=t.shadows,u=new St,c=new St(i.maxTextureSize,i.maxTextureSize),d=new Ft,h=new Ft,p=[],f=1,g=2,_=1+(f|g),x=new Array(_),w=new Array(_),M={},S=[new Ft(1,0,0),new Ft(-1,0,0),new Ft(0,0,1),new Ft(0,0,-1),new Ft(0,1,0),new Ft(0,-1,0)],E=[new Ft(0,1,0),new Ft(0,1,0),new Ft(0,1,0),new Ft(0,1,0),new Ft(0,0,1),new Ft(0,0,-1)],T=[new Lt,new Lt,new Lt,new Lt,new Lt,new Lt],C=new Xn;C.depthPacking=wt,C.clipping=!0;for(var O=Pn.distanceRGBA,k=Sn.clone(O.uniforms),P=0;P!==_;++P){var A=0!=(P&f),R=0!=(P&g),L=C.clone();L.morphTargets=A,L.skinning=R,x[P]=L;var I=new qn({defines:{USE_SHADOWMAP:""},uniforms:k,vertexShader:O.vertexShader,fragmentShader:O.fragmentShader,morphTargets:A,skinning:R,clipping:!0});w[P]=I}var D=this;function N(t,n,i,r){var o=t.geometry,a=null,s=x,l=t.customDepthMaterial;if(i&&(s=w,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|=f),c&&(d|=g),a=s[d]}if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var h=a.uuid,p=n.uuid,m=M[h];void 0===m&&(m={},M[h]=m);var _=m[p];void 0===_&&(_=a.clone(),m[p]=_),a=_}a.visible=n.visible,a.wireframe=n.wireframe;var S=n.side;return D.renderSingleSided&&S==b&&(S=y),D.renderReverseSided&&(S===y?S=v:S===v&&(S=y)),a.side=S,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,i&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(r),a}function F(e,t,n){if(!1!==e.visible){if(0!=(e.layers.mask&t.layers.mask)&&(e.isMesh||e.isLine||e.isPoints))if(e.castShadow&&(!1===e.frustumCulled||!0===a.intersectsObject(e)))!0===e.material.visible&&(e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),p.push(e));for(var i=e.children,r=0,o=i.length;r0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),n.skinning=this.skinning,n.morphTargets=this.morphTargets,t){var r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n},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 i=t.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(Yn.prototype,i.prototype),qn.prototype=Object.create(Yn.prototype),qn.prototype.constructor=qn,qn.prototype.isShaderMaterial=!0,qn.prototype.copy=function(e){return Yn.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Sn.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},qn.prototype.toJSON=function(e){var t=Yn.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},Xn.prototype=Object.create(Yn.prototype),Xn.prototype.constructor=Xn,Xn.prototype.isMeshDepthMaterial=!0,Xn.prototype.copy=function(e){return Yn.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},Kn.prototype={constructor:Kn,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,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,l=e.length;sr&&(r=u),c>o&&(o=c),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(r,o,a),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,l=e.count;sr&&(r=u),c>o&&(o=c),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(r,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 Ft).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(e){return void 0===Dn&&(Dn=new Ft),this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.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 Ft).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new Ft;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new Ft;return function(t){var n=t||new Zn;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:(In=[new Ft,new Ft,new Ft,new Ft,new Ft,new Ft,new Ft,new Ft],function(e){return this.isEmpty()?this:(In[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),In[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),In[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),In[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),In[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),In[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),In[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),In[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(In),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)}},Zn.prototype={constructor:Zn,set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){void 0===Nn&&(Nn=new Kn);var n=this.center;void 0!==t?n.copy(t):Nn.setFromPoints(e).getCenter(n);for(var i=0,r=0,o=e.length;rthis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(e){var t=e||new Kn;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}},Jn.prototype={constructor:Jn,isMatrix3:!0,set:function(e,t,n,i,r,o,a,s,l){var u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=r,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 Ft);for(var n=0,i=t.count;n1?void 0:i.copy(r).multiplyScalar(a).add(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 Ft).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new Ft,t=new Jn;return function(n,i){var r=this.coplanarPoint(e).applyMatrix4(n),o=i||t.getNormalMatrix(n),a=this.normal.applyMatrix3(o).normalize();return this.constant=-r.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}},Qn.prototype={constructor:Qn,set:function(e,t,n,i,r,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),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,i=n[0],r=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],p=n[10],f=n[11],m=n[12],g=n[13],y=n[14],v=n[15];return t[0].setComponents(a-i,c-s,f-d,v-m).normalize(),t[1].setComponents(a+i,c+s,f+d,v+m).normalize(),t[2].setComponents(a+r,c+l,f+h,v+g).normalize(),t[3].setComponents(a-r,c-l,f-h,v-g).normalize(),t[4].setComponents(a-o,c-u,f-p,v-y).normalize(),t[5].setComponents(a+o,c+u,f+p,v+y).normalize(),this},intersectsObject:(Bn=new Zn,function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Bn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Bn)}),intersectsSprite:function(){var e=new Zn;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,i=-e.radius,r=0;r<6;r++){if(t[r].distanceToPoint(n)0?e.min.x:e.max.x,zn.x=i.normal.x>0?e.max.x:e.min.x,Fn.y=i.normal.y>0?e.min.y:e.max.y,zn.y=i.normal.y>0?e.max.y:e.min.y,Fn.z=i.normal.z>0?e.min.z:e.max.z,zn.z=i.normal.z>0?e.max.z:e.min.z;var r=i.distanceToPoint(Fn),o=i.distanceToPoint(zn);if(r<0&&o<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}},ti.prototype={constructor:ti,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 Ft).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 Ft;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var n=t||new Ft;n.subVectors(e,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(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new Ft;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:(Un=new Ft,Wn=new Ft,Gn=new Ft,function(e,t,n,i){Un.copy(e).add(t).multiplyScalar(.5),Wn.copy(t).sub(e).normalize(),Gn.copy(this.origin).sub(Un);var r,o,a,s,l=.5*e.distanceTo(t),u=-this.direction.dot(Wn),c=Gn.dot(this.direction),d=-Gn.dot(Wn),h=Gn.lengthSq(),p=Math.abs(1-u*u);if(p>0)if(o=u*c-d,s=l*p,(r=u*d-c)>=0)if(o>=-s)if(o<=s){var f=1/p;a=(r*=f)*(r+u*(o*=f)+2*c)+o*(u*r+o+2*d)+h}else o=l,a=-(r=Math.max(0,-(u*o+c)))*r+o*(o+2*d)+h;else o=-l,a=-(r=Math.max(0,-(u*o+c)))*r+o*(o+2*d)+h;else o<=-s?a=-(r=Math.max(0,-(-u*l+c)))*r+(o=r>0?-l:Math.min(Math.max(-l,-d),l))*(o+2*d)+h:o<=s?(r=0,a=(o=Math.min(Math.max(-l,-d),l))*(o+2*d)+h):a=-(r=Math.max(0,-(u*l+c)))*r+(o=r>0?l:Math.min(Math.max(-l,-d),l))*(o+2*d)+h;else o=u>0?-l:l,a=-(r=Math.max(0,-(u*o+c)))*r+o*(o+2*d)+h;return n&&n.copy(this.direction).multiplyScalar(r).add(this.origin),i&&i.copy(Wn).multiplyScalar(o).add(Un),a}),intersectSphere:function(){var e=new Ft;return function(t,n){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),r=e.dot(e)-i*i,o=t.radius*t.radius;if(r>o)return null;var a=Math.sqrt(o-r),s=i-a,l=i+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,i,r,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,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||r>i?null:((r>n||n!=n)&&(n=r),(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>i?null:((a>n||n!=n)&&(n=a),(s=0?n:i,t)))},intersectsBox:(jn=new Ft,function(e){return null!==this.intersectBox(e,jn)}),intersectTriangle:function(){var e=new Ft,t=new Ft,n=new Ft,i=new Ft;return function(r,o,a,s,l){t.subVectors(o,r),n.subVectors(a,r),i.crossVectors(t,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}e.subVectors(this.origin,r);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 p=-u*e.dot(i);return p<0?null:this.at(p/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)}},ni.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ni.DefaultOrder="XYZ",ni.prototype={constructor:ni,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,i){return this._x=e,this._y=t,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(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 i=Mt.clamp,r=e.elements,o=r[0],a=r[4],s=r[8],l=r[1],u=r[5],c=r[9],d=r[2],h=r[6],p=r[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(h,u),this._z=0)):"YXZ"===t?(this._x=Math.asin(-i(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(s,p),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-d,o),this._z=0)):"ZXY"===t?(this._x=Math.asin(i(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,o))):"ZYX"===t?(this._y=Math.asin(-i(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(h,p),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===t?(this._z=Math.asin(i(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,p))):"XZY"===t?(this._z=Math.asin(-i(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(h,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-c,p),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,i){return void 0===e&&(e=new zt),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,n,i)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:(Vn=new Nt,function(e){return Vn.setFromEuler(this),this.setFromQuaternion(Vn,e)}),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 Ft(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},ii.prototype={constructor:ii,set:function(e){this.mask=1<n&&(n=e[t]);return n}hi.DefaultUp=new Ft(0,1,0),hi.DefaultMatrixAutoUpdate=!0,hi.prototype={constructor:hi,isObject3D:!0,applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:(si=new Nt,function(e,t){return si.setFromAxisAngle(e,t),this.quaternion.multiply(si),this}),rotateX:function(){var e=new Ft(1,0,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateY:function(){var e=new Ft(0,1,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateZ:function(){var e=new Ft(0,0,1);return function(t){return this.rotateOnAxis(e,t)}}(),translateOnAxis:function(){var e=new Ft;return function(t,n){return e.copy(t).applyQuaternion(this.quaternion),this.position.add(e.multiplyScalar(n)),this}}(),translateX:function(){var e=new Ft(1,0,0);return function(t){return this.translateOnAxis(e,t)}}(),translateY:function(){var e=new Ft(0,1,0);return function(t){return this.translateOnAxis(e,t)}}(),translateZ:function(){var e=new Ft(0,0,1);return function(t){return this.translateOnAxis(e,t)}}(),localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:(ai=new zt,function(e){return e.applyMatrix4(ai.getInverse(this.matrixWorld))}),lookAt:function(){var e=new zt;return function(t){e.lookAt(t,this.position,this.up),this.quaternion.setFromRotationMatrix(e)}}(),add:function(e){if(arguments.length>1){for(var t=0;t1)for(var t=0;t0){i.children=[];for(var r=0;r0&&(n.geometries=o),a.length>0&&(n.materials=a),s.length>0&&(n.textures=s),l.length>0&&(n.images=l)}return n.object=i,n;function u(e){var t=[];for(var n in e){var i=e[n];delete i.metadata,t.push(i)}return t}},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?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}),fi.barycoordFromPoint=function(){var e=new Ft,t=new Ft,n=new Ft;return function(i,r,o,a,s){e.subVectors(a,r),t.subVectors(o,r),n.subVectors(i,r);var l=e.dot(e),u=e.dot(t),c=e.dot(n),d=t.dot(t),h=t.dot(n),p=l*d-u*u,f=s||new Ft;if(0===p)return f.set(-2,-1,-1);var m=1/p,g=(d*c-u*h)*m,y=(l*h-u*c)*m;return f.set(1-g-y,y,g)}}(),fi.containsPoint=function(){var e=new Ft;return function(t,n,i,r){var o=fi.barycoordFromPoint(t,n,i,r,e);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),fi.prototype={constructor:fi,set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),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 Ft,t=new Ft;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 Ft).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return fi.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new $n).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return fi.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return fi.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e,t,n,i;return function(r,o){void 0===e&&(e=new $n,t=[new pi,new pi,new pi],n=new Ft,i=new Ft);var a=o||new Ft,s=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(r,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,a=r[1]&&r[1].length>0,s=e.morphTargets,l=s.length;if(l>0){t=[];for(var u=0;u0){c=[];for(u=0;u0?1:-1,u.push(k.x,k.y,k.z),c.push(v/m),c.push(1-b/g),C+=1}}for(b=0;b0)for(h=0;h0&&(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,i,r;for(n=0,i=this.faces.length;n0&&(e+=t[n].distanceTo(t[n-1])),this.lineDistances[n]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Kn),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Zn),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,n){if(!1!==(e&&e.isGeometry)){var i,r=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&&(i=(new Jn).getNormalMatrix(t));for(var p=0,f=a.length;p=0;n--){var f=h[n];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a0,g=p.vertexNormals.length>0,y=1!==p.color.r||1!==p.color.g||1!==p.color.b,v=p.vertexColors.length>0,b=0;if(b=M(b,0,0),b=M(b,1,!0),b=M(b,2,!1),b=M(b,3,f),b=M(b,4,m),b=M(b,5,g),b=M(b,6,y),b=M(b,7,v),a.push(b),a.push(p.a,p.b,p.c),a.push(p.materialIndex),f){var _=this.faceVertexUvs[0][r];a.push(T(_[0]),T(_[1]),T(_[2]))}if(m&&a.push(S(p.normal)),g){var x=p.vertexNormals;a.push(S(x[0]),S(x[1]),S(x[2]))}if(y&&a.push(E(p.color)),v){var w=p.vertexColors;a.push(E(w[0]),E(w[1]),E(w[2]))}}function M(e,t,n){return n?e|1<0&&(e.data.colors=u),d.length>0&&(e.data.uvs=[d]),e.data.faces=a,e},clone:function(){return(new Ri).copy(this)},copy:function(e){var t,n,i,r,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?Si:wi)(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 yi(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;void 0!==n&&((new Jn).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 zt),e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e;return function(t){return void 0===e&&(e=new zt),e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e;return function(t){return void 0===e&&(e=new zt),e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e;return function(t,n,i){return void 0===e&&(e=new zt),e.makeTranslation(t,n,i),this.applyMatrix(e),this}}(),scale:function(){var e;return function(t,n,i){return void 0===e&&(e=new zt),e.makeScale(t,n,i),this.applyMatrix(e),this}}(),lookAt:function(){var e;return function(t){void 0===e&&(e=new hi),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 Ei(3*t.vertices.length,3),i=new Ei(3*t.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(t.vertices)),this.addAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var r=new Ei(t.lineDistances.length,1);this.addAttribute("lineDistance",r.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,n=e.geometry;if(e.isMesh){var i=n.__directGeometry;if(!0===n.elementsNeedUpdate&&(i=void 0,n.elementsNeedUpdate=!1),void 0===i)return this.fromGeometry(n);i.verticesNeedUpdate=n.verticesNeedUpdate,i.normalsNeedUpdate=n.normalsNeedUpdate,i.colorsNeedUpdate=n.colorsNeedUpdate,i.uvsNeedUpdate=n.uvsNeedUpdate,i.groupsNeedUpdate=n.groupsNeedUpdate,n.verticesNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.groupsNeedUpdate=!1,n=i}return!0===n.verticesNeedUpdate&&(void 0!==(t=this.attributes.position)&&(t.copyVector3sArray(n.vertices),t.needsUpdate=!0),n.verticesNeedUpdate=!1),!0===n.normalsNeedUpdate&&(void 0!==(t=this.attributes.normal)&&(t.copyVector3sArray(n.normals),t.needsUpdate=!0),n.normalsNeedUpdate=!1),!0===n.colorsNeedUpdate&&(void 0!==(t=this.attributes.color)&&(t.copyColorsArray(n.colors),t.needsUpdate=!0),n.colorsNeedUpdate=!1),n.uvsNeedUpdate&&(void 0!==(t=this.attributes.uv)&&(t.copyVector2sArray(n.uvs),t.needsUpdate=!0),n.uvsNeedUpdate=!1),n.lineDistancesNeedUpdate&&(void 0!==(t=this.attributes.lineDistance)&&(t.copyArray(n.lineDistances),t.needsUpdate=!0),n.lineDistancesNeedUpdate=!1),n.groupsNeedUpdate&&(n.computeGroups(e.geometry),this.groups=n.groups,n.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new Ci).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(3*e.vertices.length);if(this.addAttribute("position",new yi(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){var n=new Float32Array(3*e.normals.length);this.addAttribute("normal",new yi(n,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var i=new Float32Array(3*e.colors.length);this.addAttribute("color",new yi(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var r=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new yi(r,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new yi(o,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var a=new(Oi(e.indices)>65535?Uint32Array:Uint16Array)(3*e.indices.length);this.setIndex(new yi(a,1).copyIndicesArray(e.indices))}for(var s in this.groups=e.groups,e.morphTargets){for(var l=[],u=e.morphTargets[s],c=0,d=u.length;c0){var f=new Ei(4*e.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var m=new Ei(4*e.skinWeights.length,4);this.addAttribute("skinWeight",m.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 Kn);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 Kn,t=new Ft;return function(){null===this.boundingSphere&&(this.boundingSphere=new Zn);var n=this.attributes.position;if(n){var i=this.boundingSphere.center;e.setFromBufferAttribute(n),e.getCenter(i);for(var r=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 Li).copy(this)},copy:function(e){var t,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var r=e.index;null!==r&&this.setIndex(r.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,i=u.length;n0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var t=0,n=e.length;tt.far?null:{distance:l,point:f.clone(),object:e}}function y(e,t,n,a,s,l,h,f){i.fromBufferAttribute(a,l),r.fromBufferAttribute(a,h),o.fromBufferAttribute(a,f);var y=g(e,t,n,i,r,o,p);return y&&(s&&(u.fromBufferAttribute(s,l),c.fromBufferAttribute(s,h),d.fromBufferAttribute(s,f),y.uv=m(p,i,r,o,u,c,d)),y.face=new mi(l,h,f,fi.normal(i,r,o)),y.faceIndex=l),y}return function(h,f){var v,b=this.geometry,_=this.material,x=this.matrixWorld;if(void 0!==_&&(null===b.boundingSphere&&b.computeBoundingSphere(),n.copy(b.boundingSphere),n.applyMatrix4(x),!1!==h.ray.intersectsSphere(n)&&(e.getInverse(x),t.copy(h.ray).applyMatrix4(e),null===b.boundingBox||!1!==t.intersectsBox(b.boundingBox))))if(b.isBufferGeometry){var w,M,S,E,T,C=b.index,O=b.attributes.position,k=b.attributes.uv;if(null!==C)for(E=0,T=C.count;E0&&(L=z);for(var B=0,j=F.length;B/g,(function(e,t){var n=En[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return er(n)}))}function tr(e){return e.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,(function(e,t,n,i){for(var r="",o=parseInt(t);o0?e.gammaFactor:1,x=function(e,t,n){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter($i).join("\n")}(o,i,e.extensions),w=function(e){var t=[];for(var n in e){var i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(a),M=r.createProgram();n.isRawShaderMaterial?(p=[w,"\n"].filter($i).join("\n"),f=[x,w,"\n"].filter($i).join("\n")):(p=["precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,w,i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#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 "+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.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&&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($i).join("\n"),f=[x,"precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,w,i.alphaTest?"#define ALPHATEST "+i.alphaTest:"","#define GAMMA_FACTOR "+_,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 "+d:"",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.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&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",i.envMap&&e.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",i.toneMapping!==re?"#define TONE_MAPPING":"",i.toneMapping!==re?En.tonemapping_pars_fragment:"",i.toneMapping!==re?Ji("toneMapping",i.toneMapping):"",i.outputEncoding||i.mapEncoding||i.envMapEncoding||i.emissiveMapEncoding?En.encodings_pars_fragment:"",i.mapEncoding?Zi("mapTexelToLinear",i.mapEncoding):"",i.envMapEncoding?Zi("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Zi("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.outputEncoding?(y="linearToOutputTexel",v=i.outputEncoding,b=Ki(v),"vec4 "+y+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"):"",i.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter($i).join("\n")),s=Qi(s=er(s),i),l=Qi(l=er(l),i),n.isShaderMaterial||(s=tr(s),l=tr(l));var S=p+s,E=f+l,T=Hi(r,r.VERTEX_SHADER,S),C=Hi(r,r.FRAGMENT_SHADER,E);r.attachShader(M,T),r.attachShader(M,C),void 0!==n.index0AttributeName?r.bindAttribLocation(M,0,n.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(M,0,"position"),r.linkProgram(M);var O,k,P=r.getProgramInfoLog(M),A=r.getShaderInfoLog(T),R=r.getShaderInfoLog(C),L=!0,I=!0;return!1===r.getProgramParameter(M,r.LINK_STATUS)?(L=!1,console.error("THREE.WebGLProgram: shader error: ",r.getError(),"gl.VALIDATE_STATUS",r.getProgramParameter(M,r.VALIDATE_STATUS),"gl.getProgramInfoLog",P,A,R)):""!==P?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",P):""!==A&&""!==R||(I=!1),I&&(this.diagnostics={runnable:L,material:n,programLog:P,vertexShader:{log:A,prefix:p},fragmentShader:{log:R,prefix:f}}),r.deleteShader(T),r.deleteShader(C),this.getUniforms=function(){return void 0===O&&(O=new Mn(r,M,e)),O},this.getAttributes=function(){return void 0===k&&(k=function(e,t,n){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),o=0;o0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:n.premultipliedAlpha,alphaTest:n.alphaTest,doubleSided:n.side===b,flipSided:n.side===v,depthPacking:void 0!==n.depthPacking&&n.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 i in e.defines)n.push(i),n.push(e.defines[i]);for(var o=0;o65535?Si:wi)(a,1);return r(f,e.ELEMENT_ARRAY_BUFFER),i.wireframe=f,f},update:function(t){var n=i.get(t);t.geometry.isGeometry&&n.updateFromObject(t);var o=n.index,a=n.attributes;for(var s in null!==o&&r(o,e.ELEMENT_ARRAY_BUFFER),a)r(a[s],e.ARRAY_BUFFER);var l=n.morphAttributes;for(var s in l)for(var u=l[s],c=0,d=u.length;ct||e.height>t){var n=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*n),i.height=Math.floor(e.height*n),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}function c(e){return Mt.isPowerOfTwo(e.width)&&Mt.isPowerOfTwo(e.height)}function d(t){return t===_e||t===xe||t===we?e.NEAREST:e.LINEAR}function h(t){var n=t.target;n.removeEventListener("dispose",h),function(t){var n=i.get(t);if(t.image&&n.__image__webglTextureCube)e.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture)}i.delete(t)}(n),s.textures--}function p(t){var n=t.target;n.removeEventListener("dispose",p),function(t){var n=i.get(t),r=i.get(t.texture);if(!t)return;void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(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);i.delete(t.texture),i.delete(t)}(n),s.textures--}function f(t,a){var d=i.get(t);if(t.version>0&&d.__version!==t.version){var p=t.image;if(void 0===p)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==p.complete)return void function(t,i,a){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",h),t.__webglTexture=e.createTexture(),s.textures++);n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var d=u(i.image,r.maxTextureSize);(function(e){return e.wrapS!==ve||e.wrapT!==ve||e.minFilter!==_e&&e.minFilter!==Me})(i)&&!1===c(d)&&(d=function(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=Mt.nearestPowerOfTwo(e.width),t.height=Mt.nearestPowerOfTwo(e.height),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}(d));var p=c(d),f=o(i.format),g=o(i.type);m(e.TEXTURE_2D,i,p);var y,v=i.mipmaps;if(i.isDepthTexture){var b=e.DEPTH_COMPONENT;if(i.type===Re){if(!l)throw new Error("Float Depth Texture only supported in WebGL2.0");b=e.DEPTH_COMPONENT32F}else l&&(b=e.DEPTH_COMPONENT16);i.format===Ve&&b===e.DEPTH_COMPONENT&&i.type!==ke&&i.type!==Ae&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=ke,g=o(i.type)),i.format===He&&(b=e.DEPTH_STENCIL,i.type!==Fe&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=Fe,g=o(i.type))),n.texImage2D(e.TEXTURE_2D,0,b,d.width,d.height,0,f,g,null)}else if(i.isDataTexture)if(v.length>0&&p){for(var _=0,x=v.length;_-1?n.compressedTexImage2D(e.TEXTURE_2D,_,f,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(e.TEXTURE_2D,_,f,y.width,y.height,0,f,g,y.data);else if(v.length>0&&p){for(_=0,x=v.length;_1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function g(t,r,a,s){var l=o(r.texture.format),u=o(r.texture.type);n.texImage2D(s,0,l,r.width,r.height,0,l,u,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,a,s,i.get(r.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function y(t,n){e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):n.depthBuffer&&n.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}function v(t){var n=i.get(t),r=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!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),f(n.depthTexture,0);var r=i.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===Ve)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,r,0);else{if(n.depthTexture.format!==He)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,r,0)}}(n.__webglFramebuffer,t)}else if(r){n.__webglDepthbuffer=[];for(var o=0;o<6;o++)e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=e.createRenderbuffer(),y(n.__webglDepthbuffer[o],t)}else e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),y(n.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}this.setTexture2D=f,this.setTextureCube=function(t,a){var l=i.get(t);if(6===t.image.length)if(t.version>0&&l.__version!==t.version){l.__image__webglTextureCube||(t.addEventListener("dispose",h),l.__image__webglTextureCube=e.createTexture(),s.textures++),n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,l.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var d=t&&t.isCompressedTexture,p=t.image[0]&&t.image[0].isDataTexture,f=[],g=0;g<6;g++)f[g]=d||p?p?t.image[g].image:t.image[g]:u(t.image[g],r.maxCubemapSize);var y=c(f[0]),v=o(t.format),b=o(t.type);m(e.TEXTURE_CUBE_MAP,t,y);for(g=0;g<6;g++)if(d)for(var _,x=f[g].mipmaps,w=0,M=x.length;w-1?n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,w,v,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,w,v,_.width,_.height,0,v,b,_.data);else p?n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,v,f[g].width,f[g].height,0,v,b,f[g].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,v,v,b,f[g]);t.generateMipmaps&&y&&e.generateMipmap(e.TEXTURE_CUBE_MAP),l.__version=t.version,t.onUpdate&&t.onUpdate(t)}else n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,l.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,r){n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)},this.setupRenderTarget=function(t){var r=i.get(t),o=i.get(t.texture);t.addEventListener("dispose",p),o.__webglTexture=e.createTexture(),s.textures++;var a=!0===t.isWebGLRenderTargetCube,l=c(t);if(a){r.__webglFramebuffer=[];for(var u=0;u<6;u++)r.__webglFramebuffer[u]=e.createFramebuffer()}else r.__webglFramebuffer=e.createFramebuffer();if(a){n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture),m(e.TEXTURE_CUBE_MAP,t.texture,l);for(u=0;u<6;u++)g(r.__webglFramebuffer[u],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+u);t.texture.generateMipmaps&&l&&e.generateMipmap(e.TEXTURE_CUBE_MAP),n.bindTexture(e.TEXTURE_CUBE_MAP,null)}else n.bindTexture(e.TEXTURE_2D,o.__webglTexture),m(e.TEXTURE_2D,t.texture,l),g(r.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),t.texture.generateMipmaps&&l&&e.generateMipmap(e.TEXTURE_2D),n.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&v(t)},this.updateRenderTargetMipmap=function(t){var r=t.texture;if(r.generateMipmaps&&c(t)&&r.minFilter!==_e&&r.minFilter!==Me){var o=t&&t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=i.get(r).__webglTexture;n.bindTexture(o,a),e.generateMipmap(o),n.bindTexture(o,null)}}}function sr(){var e={};return{get:function(t){var n=t.uuid,i=e[n];return void 0===i&&(i={},e[n]=i),i},delete:function(t){delete e[t.uuid]},clear:function(){e={}}}}function lr(e,t,n){var i=new function(){var t=!1,n=new Lt,i=null,r=new Lt;return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,o,a,s){!0===s&&(t*=a,i*=a,o*=a),n.set(t,i,o,a),!1===r.equals(n)&&(e.clearColor(t,i,o,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(0,0,0,1)}}},r=new function(){var t=!1,n=null,i=null,r=null;return{setTest:function(t){t?V(e.DEPTH_TEST):H(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){if(t)switch(t){case q:e.depthFunc(e.NEVER);break;case X:e.depthFunc(e.ALWAYS);break;case K:e.depthFunc(e.LESS);break;case Z:e.depthFunc(e.LEQUAL);break;case J:e.depthFunc(e.EQUAL);break;case $:e.depthFunc(e.GEQUAL);break;case Q:e.depthFunc(e.GREATER);break;case ee:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},o=new function(){var t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,u=null;return{setTest:function(t){t?V(e.STENCIL_TEST):H(e.STENCIL_TEST)},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&o===a||(e.stencilFunc(t,n,a),i=t,r=n,o=a)},setOp:function(t,n,i){a===t&&s===n&&l===i||(e.stencilOp(t,n,i),a=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){u!==t&&(e.clearStencil(t),u=t)},reset:function(){t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,u=null}}},a=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),d=new Uint8Array(a),h=new Uint8Array(a),p={},f=null,m=null,g=null,y=null,v=null,b=null,_=null,x=null,w=!1,M=null,S=null,A=null,R=null,L=null,I=null,D=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),N=parseFloat(/^WebGL\ ([0-9])/.exec(e.getParameter(e.VERSION))[1]),F=parseFloat(N)>=1,z=null,B={},j=new Lt,U=new Lt;function W(t,n,i){var r=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var a=0;a0&&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=void 0!==n.precision?n.precision:"highp",a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===n.logarithmicDepthBuffer&&!!t.get("EXT_frag_depth"),l=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),c=e.getParameter(e.MAX_TEXTURE_SIZE),d=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),h=e.getParameter(e.MAX_VERTEX_ATTRIBS),p=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),f=e.getParameter(e.MAX_VARYING_VECTORS),m=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),g=u>0,y=!!t.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var n=t.get("EXT_texture_filter_anisotropic");return i=null!==n?e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:s,maxTextures:l,maxVertexTextures:u,maxTextureSize:c,maxCubemapSize:d,maxAttributes:h,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y}}function cr(e){var t={};return{get:function(n){if(void 0!==t[n])return t[n];var i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":i=e.getExtension("WEBGL_compressed_texture_etc1");break;default:i=e.getExtension(n)}return null===i&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),t[n]=i,i}}}function dr(){var e=this,t=null,n=0,i=!1,r=!1,o=new $n,a=new Jn,s={value:null,needsUpdate:!1};function l(){s.value!==t&&(s.value=t,s.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(t,n,i,r){var l=null!==t?t.length:0,u=null;if(0!==l){if(u=s.value,!0!==r||null===u){var c=i+4*l,d=n.matrixWorldInverse;a.getNormalMatrix(d),(null===u||u.length=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(c=0;c=0&&e.numSupportedMorphNormals++}var d=i.__webglShader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=le.numPlanes,i.numIntersection=le.numIntersection,d.clippingPlanes=le.uniform),i.fog=t,i.lightsHash=ge.hash,e.lights&&(d.ambientLightColor.value=ge.ambient,d.directionalLights.value=ge.directional,d.spotLights.value=ge.spot,d.rectAreaLights.value=ge.rectArea,d.pointLights.value=ge.point,d.hemisphereLights.value=ge.hemi,d.directionalShadowMap.value=ge.directionalShadowMap,d.directionalShadowMatrix.value=ge.directionalShadowMatrix,d.spotShadowMap.value=ge.spotShadowMap,d.spotShadowMatrix.value=ge.spotShadowMatrix,d.pointShadowMap.value=ge.pointShadowMap,d.pointShadowMatrix.value=ge.pointShadowMatrix);var h=i.program.getUniforms(),p=Mn.seqWithValue(h.seq,d);i.uniformsList=p}(n,t,i),n.needsUpdate=!1);var a,s,l=!1,u=!1,c=!1,d=r.program,h=d.getUniforms(),p=r.__webglShader.uniforms;if(d.id!==T&&(M.useProgram(d.program),T=d.id,l=!0,u=!0,c=!0),n.id!==k&&(k=n.id,u=!0),l||e!==q){if(h.set(M,e,"projectionMatrix"),it.logarithmicDepthBuffer&&h.setValue(M,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),e!==q&&(q=e,u=!0,c=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var f=h.map.cameraPosition;void 0!==f&&f.setValue(M,pe.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&h.setValue(M,"viewMatrix",e.matrixWorldInverse),h.set(M,S,"toneMappingExposure"),h.set(M,S,"toneMappingWhitePoint")}if(n.skinning){h.setOptional(M,i,"bindMatrix"),h.setOptional(M,i,"bindMatrixInverse");var m=i.skeleton;m&&(it.floatVertexTextures&&m.useVertexTexture?(h.set(M,m,"boneTexture"),h.set(M,m,"boneTextureWidth"),h.set(M,m,"boneTextureHeight")):h.setOptional(M,m,"boneMatrices"))}return u&&(n.lights&&(s=c,(a=p).ambientLightColor.needsUpdate=s,a.directionalLights.needsUpdate=s,a.pointLights.needsUpdate=s,a.spotLights.needsUpdate=s,a.rectAreaLights.needsUpdate=s,a.hemisphereLights.needsUpdate=s),t&&n.fog&&function(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)}(p,t),(n.isMeshBasicMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.isMeshNormalMaterial||n.isMeshDepthMaterial)&&function(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;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);if(void 0!==n){n.isWebGLRenderTarget&&(n=n.texture);var i=n.offset,r=n.repeat;e.offsetRepeat.value.set(i.x,i.y,r.x,r.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}(p,n),n.isLineBasicMaterial?jt(p,n):n.isLineDashedMaterial?(jt(p,n),function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(p,n)):n.isPointsMaterial?function(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*ne,e.scale.value=.5*te,e.map.value=t.map,null!==t.map){var n=t.map.offset,i=t.map.repeat;e.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}}(p,n):n.isMeshLambertMaterial?function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(p,n):n.isMeshToonMaterial?function(e,t){Ut(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(p,n):n.isMeshPhongMaterial?Ut(p,n):n.isMeshPhysicalMaterial?function(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,Wt(e,t)}(p,n):n.isMeshStandardMaterial?Wt(p,n):n.isMeshDepthMaterial?n.displacementMap&&(p.displacementMap.value=n.displacementMap,p.displacementScale.value=n.displacementScale,p.displacementBias.value=n.displacementBias):n.isMeshNormalMaterial&&function(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)}(p,n),void 0!==p.ltcMat&&(p.ltcMat.value=THREE.UniformsLib.LTC_MAT_TEXTURE),void 0!==p.ltcMag&&(p.ltcMag.value=THREE.UniformsLib.LTC_MAG_TEXTURE),Mn.upload(M,r.uniformsList,p,S)),h.set(M,i,"modelViewMatrix"),h.set(M,i,"normalMatrix"),h.setValue(M,"modelMatrix",i.matrixWorld),d}function jt(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function Ut(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 Wt(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 Gt(e){var t;if(e===ye)return M.REPEAT;if(e===ve)return M.CLAMP_TO_EDGE;if(e===be)return M.MIRRORED_REPEAT;if(e===_e)return M.NEAREST;if(e===xe)return M.NEAREST_MIPMAP_NEAREST;if(e===we)return M.NEAREST_MIPMAP_LINEAR;if(e===Me)return M.LINEAR;if(e===Se)return M.LINEAR_MIPMAP_NEAREST;if(e===Ee)return M.LINEAR_MIPMAP_LINEAR;if(e===Te)return M.UNSIGNED_BYTE;if(e===Ie)return M.UNSIGNED_SHORT_4_4_4_4;if(e===De)return M.UNSIGNED_SHORT_5_5_5_1;if(e===Ne)return M.UNSIGNED_SHORT_5_6_5;if(e===Ce)return M.BYTE;if(e===Oe)return M.SHORT;if(e===ke)return M.UNSIGNED_SHORT;if(e===Pe)return M.INT;if(e===Ae)return M.UNSIGNED_INT;if(e===Re)return M.FLOAT;if(e===Le&&null!==(t=nt.get("OES_texture_half_float")))return t.HALF_FLOAT_OES;if(e===ze)return M.ALPHA;if(e===Be)return M.RGB;if(e===je)return M.RGBA;if(e===Ue)return M.LUMINANCE;if(e===We)return M.LUMINANCE_ALPHA;if(e===Ve)return M.DEPTH_COMPONENT;if(e===He)return M.DEPTH_STENCIL;if(e===A)return M.FUNC_ADD;if(e===R)return M.FUNC_SUBTRACT;if(e===L)return M.FUNC_REVERSE_SUBTRACT;if(e===N)return M.ZERO;if(e===F)return M.ONE;if(e===z)return M.SRC_COLOR;if(e===B)return M.ONE_MINUS_SRC_COLOR;if(e===j)return M.SRC_ALPHA;if(e===U)return M.ONE_MINUS_SRC_ALPHA;if(e===W)return M.DST_ALPHA;if(e===G)return M.ONE_MINUS_DST_ALPHA;if(e===V)return M.DST_COLOR;if(e===H)return M.ONE_MINUS_DST_COLOR;if(e===Y)return M.SRC_ALPHA_SATURATE;if((e===Ye||e===qe||e===Xe||e===Ke)&&null!==(t=nt.get("WEBGL_compressed_texture_s3tc"))){if(e===Ye)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===qe)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===Xe)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Ke)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((e===Ze||e===Je||e===$e||e===Qe)&&null!==(t=nt.get("WEBGL_compressed_texture_pvrtc"))){if(e===Ze)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Je)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===$e)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===Qe)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===et&&null!==(t=nt.get("WEBGL_compressed_texture_etc1")))return t.COMPRESSED_RGB_ETC1_WEBGL;if((e===I||e===D)&&null!==(t=nt.get("EXT_blend_minmax"))){if(e===I)return t.MIN_EXT;if(e===D)return t.MAX_EXT}return e===Fe&&null!==(t=nt.get("WEBGL_depth_texture"))?t.UNSIGNED_INT_24_8_WEBGL:0}this.getContext=function(){return M},this.getContextAttributes=function(){return M.getContextAttributes()},this.forceContextLoss=function(){nt.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){return it.getMaxAnisotropy()},this.getPrecision=function(){return it.precision},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(e){void 0!==e&&(ne=e,this.setSize(ae.z,ae.w,!1))},this.getSize=function(){return{width:ee,height:te}},this.setSize=function(e,n,i){ee=e,te=n,t.width=e*ne,t.height=n*ne,!1!==i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n)},this.setViewport=function(e,t,n,i){rt.viewport(ae.set(e,t,n,i))},this.setScissor=function(e,t,n,i){rt.scissor(ie.set(e,t,n,i))},this.setScissorTest=function(e){rt.setScissorTest(re=e)},this.getClearColor=function(){return $},this.setClearColor=function(e,t){$.set(e),Q=void 0!==t?t:1,rt.buffers.color.setClear($.r,$.g,$.b,Q,l)},this.getClearAlpha=function(){return Q},this.setClearAlpha=function(e){Q=e,rt.buffers.color.setClear($.r,$.g,$.b,Q,l)},this.clear=function(e,t,n){var i=0;(void 0===e||e)&&(i|=M.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=M.DEPTH_BUFFER_BIT),(void 0===n||n)&&(i|=M.STENCIL_BUFFER_BIT),M.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(e,t,n,i){this.setRenderTarget(e),this.clear(t,n,i)},this.resetGLState=xt,this.dispose=function(){f=[],m=-1,d=[],p=-1,t.removeEventListener("webglcontextlost",Tt,!1)},this.renderBufferImmediate=function(e,t,n){rt.initAttributes();var i=ot.get(e);e.hasPositions&&!i.position&&(i.position=M.createBuffer()),e.hasNormals&&!i.normal&&(i.normal=M.createBuffer()),e.hasUvs&&!i.uv&&(i.uv=M.createBuffer()),e.hasColors&&!i.color&&(i.color=M.createBuffer());var r=t.getAttributes();if(e.hasPositions&&(M.bindBuffer(M.ARRAY_BUFFER,i.position),M.bufferData(M.ARRAY_BUFFER,e.positionArray,M.DYNAMIC_DRAW),rt.enableAttribute(r.position),M.vertexAttribPointer(r.position,3,M.FLOAT,!1,0,0)),e.hasNormals){if(M.bindBuffer(M.ARRAY_BUFFER,i.normal),!n.isMeshPhongMaterial&&!n.isMeshStandardMaterial&&!n.isMeshNormalMaterial&&n.shading===_)for(var o=0,a=3*e.count;o8&&(c.length=8);var f=n.morphAttributes;for(d=0,h=c.length;d=0){var c=o[l];if(void 0!==c){var d=c.normalized,h=c.itemSize,p=st.getAttributeProperties(c),f=p.__webglBuffer,m=p.type,g=p.bytesPerElement;if(c.isInterleavedBufferAttribute){var y=c.data,v=y.stride,b=c.offset;y&&y.isInstancedInterleavedBuffer?(rt.enableAttributeAndDivisor(u,y.meshPerAttribute,r),void 0===n.maxInstancedCount&&(n.maxInstancedCount=y.meshPerAttribute*y.count)):rt.enableAttribute(u),M.bindBuffer(M.ARRAY_BUFFER,f),M.vertexAttribPointer(u,h,m,d,v*g,(i*v+b)*g)}else c.isInstancedBufferAttribute?(rt.enableAttributeAndDivisor(u,c.meshPerAttribute,r),void 0===n.maxInstancedCount&&(n.maxInstancedCount=c.meshPerAttribute*c.count)):rt.enableAttribute(u),M.bindBuffer(M.ARRAY_BUFFER,f),M.vertexAttribPointer(u,h,m,d,0,i*h*g)}else if(void 0!==s){var _=s[l];if(void 0!==_)switch(_.length){case 2:M.vertexAttrib2fv(u,_);break;case 3:M.vertexAttrib3fv(u,_);break;case 4:M.vertexAttrib4fv(u,_);break;default:M.vertexAttrib1fv(u,_)}}}}rt.disableUnusedAttributes()}(i,a,n),null!==m&&M.bindBuffer(M.ELEMENT_ARRAY_BUFFER,st.getAttributeBuffer(m)));var x=0;null!==m?x=m.count:void 0!==b&&(x=b.count);var w=n.drawRange.start*_,S=n.drawRange.count*_,E=null!==o?o.start*_:0,T=null!==o?o.count*_:1/0,C=Math.max(w,E),O=Math.min(x,w+S,E+T)-1,k=Math.max(0,O-C+1);if(0!==k){if(r.isMesh)if(!0===i.wireframe)rt.setLineWidth(i.wireframeLinewidth*bt()),v.setMode(M.LINES);else switch(r.drawMode){case ct:v.setMode(M.TRIANGLES);break;case dt:v.setMode(M.TRIANGLE_STRIP);break;case ht:v.setMode(M.TRIANGLE_FAN)}else if(r.isLine){var A=i.linewidth;void 0===A&&(A=1),rt.setLineWidth(A*bt()),r.isLineSegments?v.setMode(M.LINES):v.setMode(M.LINE_STRIP)}else r.isPoints&&v.setMode(M.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&v.renderInstances(n,C,k):v.render(C,k)}},this.render=function(e,t,n,i){if(void 0===t||!0===t.isCamera){P="",k=-1,q=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),he.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromMatrix(he),c.length=0,p=-1,m=-1,y.length=0,x.length=0,ce=this.localClippingEnabled,ue=le.init(this.clippingPlanes,ce,t),function e(t,n){if(!1===t.visible)return;var i=0!=(t.layers.mask&n.layers.mask);if(i)if(t.isLight)c.push(t);else if(t.isSprite)!1!==t.frustumCulled&&!0!==(p=t,de.center.set(0,0,0),de.radius=.7071067811865476,de.applyMatrix4(p.matrixWorld),It(de))||y.push(t);else if(t.isLensFlare)x.push(t);else if(t.isImmediateRenderObject)!0===S.sortObjects&&(pe.setFromMatrixPosition(t.matrixWorld),pe.applyMatrix4(he)),Rt(t,null,t.material,pe.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!1===t.frustumCulled||!0===function(e){var t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere();return de.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),It(de)}(t))){var r=t.material;if(!0===r.visible){!0===S.sortObjects&&(pe.setFromMatrixPosition(t.matrixWorld),pe.applyMatrix4(he));var o=st.update(t);if(r.isMultiMaterial)for(var a=o.groups,s=r.materials,l=0,u=a.length;l=it.maxTextures&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+it.maxTextures),J+=1,e},this.setTexture2D=(Mt=!1,function(e,t){e&&e.isWebGLRenderTarget&&(Mt||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Mt=!0),e=e.texture),at.setTexture2D(e,t)}),this.setTexture=function(){var e=!1;return function(t,n){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),at.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?at.setTextureCube(t,n):at.setTextureCubeDynamic(t,n)}}(),this.getCurrentRenderTarget=function(){return C},this.setRenderTarget=function(e){C=e,e&&void 0===ot.get(e).__webglFramebuffer&&at.setupRenderTarget(e);var t,n=e&&e.isWebGLRenderTargetCube;if(e){var i=ot.get(e);t=n?i.__webglFramebuffer[e.activeCubeFace]:i.__webglFramebuffer,X.copy(e.scissor),K=e.scissorTest,Z.copy(e.viewport)}else t=null,X.copy(ie).multiplyScalar(ne),K=re,Z.copy(ae).multiplyScalar(ne);if(O!==t&&(M.bindFramebuffer(M.FRAMEBUFFER,t),O=t),rt.scissor(X),rt.setScissorTest(K),rt.viewport(Z),n){var r=ot.get(e.texture);M.framebufferTexture2D(M.FRAMEBUFFER,M.COLOR_ATTACHMENT0,M.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,n,i,r,o){if(!1!==(e&&e.isWebGLRenderTarget)){var a=ot.get(e).__webglFramebuffer;if(a){var s=!1;a!==O&&(M.bindFramebuffer(M.FRAMEBUFFER,a),s=!0);try{var l=e.texture,u=l.format,c=l.type;if(u!==je&&Gt(u)!==M.getParameter(M.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(c===Te||Gt(c)===M.getParameter(M.IMPLEMENTATION_COLOR_READ_TYPE)||c===Re&&(nt.get("OES_texture_float")||nt.get("WEBGL_color_buffer_float"))||c===Le&&nt.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");M.checkFramebufferStatus(M.FRAMEBUFFER)===M.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&M.readPixels(t,n,i,r,Gt(u),Gt(c),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&M.bindFramebuffer(M.FRAMEBUFFER,O)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function pr(e,t){this.name="",this.color=new Tn(e),this.density=void 0!==t?t:25e-5}function fr(e,t,n){this.name="",this.color=new Tn(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function mr(){hi.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function gr(e,t,n,i,r){hi.call(this),this.lensFlares=[],this.positionScreen=new Ft,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,n,i,r)}function yr(e){Yn.call(this),this.type="SpriteMaterial",this.color=new Tn(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function vr(e){hi.call(this),this.type="Sprite",this.material=void 0!==e?e:new yr}function br(){hi.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function _r(e,t,n){if(this.useVertexTexture=void 0===n||n,this.identityMatrix=new zt,e=e||[],this.bones=e.slice(0),this.useVertexTexture){var i=Math.sqrt(4*this.bones.length);i=Mt.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 On(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,je,Re)}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 r=0,o=this.bones.length;r=e.HAVE_CURRENT_DATA&&(u.needsUpdate=!0)}()}function Pr(e,t,n,i,r,o,a,s,l,u,c,d){Rt.call(this,null,o,a,s,l,u,i,r,c,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Ar(e,t,n,i,r,o,a,s,l){Rt.call(this,e,t,n,i,r,o,a,s,l),this.needsUpdate=!0}function Rr(e,t,n,i,r,o,a,s,l,u){if((u=void 0!==u?u:Ve)!==Ve&&u!==He)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&u===Ve&&(n=ke),void 0===n&&u===He&&(n=Fe),Rt.call(this,null,i,r,o,a,s,u,n,l),this.image={width:e,height:t},this.magFilter=void 0!==a?a:_e,this.minFilter=void 0!==s?s:_e,this.flipY=!1,this.generateMipmaps=!1}function Lr(e){Li.call(this),this.type="WireframeGeometry";var t,n,i,r,o,a,s,l,u=[],c=[0,0],d={},h=["a","b","c"];if(e&&e.isGeometry){var p=e.faces;for(t=0,i=p.length;t.9&&a<.1&&(t<.2&&(o[e+0]+=1),n<.2&&(o[e+2]+=1),i<.2&&(o[e+4]+=1))}}()}(),this.addAttribute("position",new Ei(r,3)),this.addAttribute("normal",new Ei(r.slice(),3)),this.addAttribute("uv",new Ei(o,2)),this.normalizeNormals()}function zr(e,t){Ri.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Br(e,t)),this.mergeVertices()}function Br(e,t){Fr.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function jr(e,t){Ri.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Ur(e,t)),this.mergeVertices()}function Ur(e,t){Fr.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Wr(e,t){Ri.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Gr(e,t)),this.mergeVertices()}function Gr(e,t){var n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];Fr.call(this,i,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Vr(e,t){Ri.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Hr(e,t)),this.mergeVertices()}function Hr(e,t){var n=(1+Math.sqrt(5))/2,i=1/n,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i];Fr.call(this,r,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Yr(e,t,n,i,r,o){Ri.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new qr(e,t,n,i,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function qr(e,t,n,i,r){Li.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r},t=t||64,n=n||1,i=i||8,r=r||!1;var o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,l=new Ft,u=new Ft,c=new St,d=[],h=[],p=[],f=[];function m(r){var a=e.getPointAt(r/t),c=o.normals[r],p=o.binormals[r];for(s=0;s<=i;s++){var f=s/i*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);u.x=g*c.x+m*p.x,u.y=g*c.y+m*p.y,u.z=g*c.z+m*p.z,u.normalize(),h.push(u.x,u.y,u.z),l.x=a.x+n*u.x,l.y=a.y+n*u.y,l.z=a.z+n*u.z,d.push(l.x,l.y,l.z)}}!function(){for(a=0;athis.scale.x*this.scale.y/4||t.push({distance:Math.sqrt(n),point:this.position,face:null,object:this})}),clone:function(){return new this.constructor(this.material).copy(this)}}),br.prototype=Object.assign(Object.create(hi.prototype),{constructor:br,copy:function(e){hi.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,i=t.length;n1){e.setFromMatrixPosition(n.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var r=e.distanceTo(t);i[0].object.visible=!0;for(var o=1,a=i.length;o=i[o].distance;o++)i[o-1].object.visible=!1,i[o].object.visible=!0;for(;oa))h.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(h))i.far||r.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}else for(y=0,v=m.length/3-1;ya))h.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(h))i.far||r.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var x=s.vertices,w=x.length;for(y=0;ya))h.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(h))i.far||r.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Er.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Er,isLineSegments:!0}),Tr.prototype=Object.create(Yn.prototype),Tr.prototype.constructor=Tr,Tr.prototype.isPointsMaterial=!0,Tr.prototype.copy=function(e){return Yn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},Cr.prototype=Object.assign(Object.create(hi.prototype),{constructor:Cr,isPoints:!0,raycast:function(){var e=new zt,t=new ti,n=new Zn;return function(i,r){var o=this,a=this.geometry,s=this.matrixWorld,l=i.params.Points.threshold;if(null===a.boundingSphere&&a.computeBoundingSphere(),n.copy(a.boundingSphere),n.applyMatrix4(s),!1!==i.ray.intersectsSphere(n)){e.getInverse(s),t.copy(i.ray).applyMatrix4(e);var u=l/((this.scale.x+this.scale.y+this.scale.z)/3),c=u*u,d=new Ft;if(a.isBufferGeometry){var h=a.index,p=a.attributes.position.array;if(null!==h)for(var f=h.array,m=0,g=f.length;mi.far)return;r.push({distance:u,distanceToRay:Math.sqrt(a),point:l.clone(),index:n,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Or.prototype=Object.assign(Object.create(hi.prototype),{constructor:Or}),kr.prototype=Object.create(Rt.prototype),kr.prototype.constructor=kr,Pr.prototype=Object.create(Rt.prototype),Pr.prototype.constructor=Pr,Pr.prototype.isCompressedTexture=!0,Ar.prototype=Object.create(Rt.prototype),Ar.prototype.constructor=Ar,Rr.prototype=Object.create(Rt.prototype),Rr.prototype.constructor=Rr,Rr.prototype.isDepthTexture=!0,Lr.prototype=Object.create(Li.prototype),Lr.prototype.constructor=Lr,Ir.prototype=Object.create(Ri.prototype),Ir.prototype.constructor=Ir,Dr.prototype=Object.create(Li.prototype),Dr.prototype.constructor=Dr,Nr.prototype=Object.create(Ri.prototype),Nr.prototype.constructor=Nr,Fr.prototype=Object.create(Li.prototype),Fr.prototype.constructor=Fr,zr.prototype=Object.create(Ri.prototype),zr.prototype.constructor=zr,Br.prototype=Object.create(Fr.prototype),Br.prototype.constructor=Br,jr.prototype=Object.create(Ri.prototype),jr.prototype.constructor=jr,Ur.prototype=Object.create(Fr.prototype),Ur.prototype.constructor=Ur,Wr.prototype=Object.create(Ri.prototype),Wr.prototype.constructor=Wr,Gr.prototype=Object.create(Fr.prototype),Gr.prototype.constructor=Gr,Vr.prototype=Object.create(Ri.prototype),Vr.prototype.constructor=Vr,Hr.prototype=Object.create(Fr.prototype),Hr.prototype.constructor=Hr,Yr.prototype=Object.create(Ri.prototype),Yr.prototype.constructor=Yr,qr.prototype=Object.create(Li.prototype),qr.prototype.constructor=qr,Xr.prototype=Object.create(Ri.prototype),Xr.prototype.constructor=Xr,Kr.prototype=Object.create(Li.prototype),Kr.prototype.constructor=Kr,Zr.prototype=Object.create(Ri.prototype),Zr.prototype.constructor=Zr,Jr.prototype=Object.create(Li.prototype),Jr.prototype.constructor=Jr;var $r={area:function(e){for(var t=e.length,n=0,i=t-1,r=0;r=-Number.EPSILON&&w>=-Number.EPSILON&&x>=-Number.EPSILON))return!1;return!0}return function(t,n){var i=t.length;if(i<3)return null;var r,o,a,s=[],l=[],u=[];if($r.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(c<=(r=o)&&(r=0),c<=(o=r+1)&&(o=0),c<=(a=o+1)&&(a=0),e(t,r,o,a,c,l)){var h,p,f,m,g;for(h=l[r],p=l[o],f=l[a],s.push([t[h],t[p],t[f]]),u.push([l[r],l[o],l[a]]),m=o,g=o+1;g2&&e[t-1].equals(e[0])&&e.pop()}function i(e,t,n){return e.x!==t.x?e.xNumber.EPSILON){var f;if(h>0){if(p<0||p>h)return[];if((f=u*c-l*d)<0||f>h)return[]}else{if(p>0||p0||fM?[]:v===M?o?[]:[g]:b<=M?[g,y]:[g,x])}function o(e,t,n,i){var r=t.x-e.x,o=t.y-e.y,a=n.x-e.x,s=n.y-e.y,l=i.x-e.x,u=i.y-e.y,c=r*s-o*a,d=r*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={},p=e.concat(),f=0,m=t.length;fr&&(s=0);var l=o(i[e],i[a],i[s],n[t]);if(!l)return!1;var u=n.length-1,c=t-1;c<0&&(c=u);var d=t+1;return d>u&&(d=0),!!(l=o(n[t],n[c],n[d],i[e]))}function s(e,t){var n,o;for(n=0;n0)return!0;return!1}var l=[];function u(e,n){var i,o,a,s;for(i=0;i0)return!0;return!1}for(var c,d,h,p,f,m,g,y,v,b,_=[],x=0,w=t.length;x0;){if(--S<0){console.log("Infinite Loop! Holes left:"+l.length+", Probably Hole outside Shape!");break}for(d=M;d=0)break;_[m]=!0}if(c>=0)break}}return i}(e,t),y=$r.triangulate(g,!1);for(a=0,s=y.length;a0)&&f.push(x,w,S),(l!==n-1||u0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.addAttribute("position",new Ei(c,3)),this.addAttribute("normal",new Ei(d,3)),this.addAttribute("uv",new Ei(h,2))}function po(e,t,n,i,r,o,a){co.call(this,0,e,t,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}function fo(e,t,n,i,r,o,a){ho.call(this,0,e,t,n,i,r,o,a),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}function mo(e,t,n,i){Ri.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new go(e,t,n,i))}function go(e,t,n,i){Li.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},e=e||50,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var r,o,a=[],s=[],l=[],u=[],c=new Ft,d=new St;for(s.push(0,0,0),l.push(0,0,1),u.push(.5,.5),o=0,r=3;o<=t;o++,r+=3){var h=n+o/t*i;c.x=e*Math.cos(h),c.y=e*Math.sin(h),s.push(c.x,c.y,c.z),l.push(0,0,1),d.x=(s[r]/e+1)/2,d.y=(s[r+1]/e+1)/2,u.push(d.x,d.y)}for(r=1;r<=t;r++)a.push(r,r+1,0);this.setIndex(a),this.addAttribute("position",new Ei(s,3)),this.addAttribute("normal",new Ei(l,3)),this.addAttribute("uv",new Ei(u,2))}Qr.prototype=Object.create(Ri.prototype),Qr.prototype.constructor=Qr,Qr.prototype.addShapeList=function(e,t){for(var n=e.length,i=0;iNumber.EPSILON){var h=Math.sqrt(c),p=Math.sqrt(l*l+u*u),f=t.x-s/h,m=t.y+a/h,g=((n.x-u/p-f)*u-(n.y+l/p-m)*l)/(a*u-s*l),y=(i=f+a*g-e.x)*i+(r=m+s*g-e.y)*r;if(y<=2)return new St(i,r);o=Math.sqrt(y/2)}else{var v=!1;a>Number.EPSILON?l>Number.EPSILON&&(v=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(v=!0):Math.sign(s)===Math.sign(u)&&(v=!0),v?(i=-s,r=a,o=Math.sqrt(c)):(i=a,r=s,o=Math.sqrt(c/2))}return new St(i/o,r/o)}for(var z=[],B=0,j=C.length,U=j-1,W=B+1;B=0;k--){for(A=k/p,R=d*Math.cos(A*Math.PI/2),P=h*Math.sin(A*Math.PI/2),B=0,j=C.length;B=0;){n=B,(i=B-1)<0&&(i=e.length-1);var r=0,o=g+2*p;for(r=0;r0||0===e.search(/^data\:image\/jpeg/);r.format=i?Be:je,r.image=n,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),zo.prototype=Object.assign(Object.create(hi.prototype),{constructor:zo,isLight:!0,copy:function(e){return hi.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=hi.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}}),Bo.prototype=Object.assign(Object.create(zo.prototype),{constructor:Bo,isHemisphereLight:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(jo.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}}),Uo.prototype=Object.assign(Object.create(jo.prototype),{constructor:Uo,isSpotLightShadow:!0,update:function(e){var t=2*Mt.RAD2DEG*e.angle,n=this.mapSize.width/this.mapSize.height,i=e.distance||500,r=this.camera;t===r.fov&&n===r.aspect&&i===r.far||(r.fov=t,r.aspect=n,r.far=i,r.updateProjectionMatrix())}}),Wo.prototype=Object.assign(Object.create(zo.prototype),{constructor:Wo,isSpotLight:!0,copy:function(e){return zo.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}}),Go.prototype=Object.assign(Object.create(zo.prototype),{constructor:Go,isPointLight:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),Vo.prototype=Object.assign(Object.create(jo.prototype),{constructor:Vo}),Ho.prototype=Object.assign(Object.create(zo.prototype),{constructor:Ho,isDirectionalLight:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Yo.prototype=Object.assign(Object.create(zo.prototype),{constructor:Yo,isAmbientLight:!0});var qo,Xo,Ko,Zo,Jo,$o={arraySlice:function(e,t,n){return $o.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){for(var t=e.length,n=new Array(t),i=0;i!==t;++i)n[i]=i;return n.sort((function(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){for(var i=e.length,r=new e.constructor(i),o=0,a=0;a!==i;++o)for(var s=n[o]*t,l=0;l!==t;++l)r[a++]=e[s+l];return r},flattenJSON:function(e,t,n,i){for(var r=1,o=e[0];void 0!==o&&void 0===o[i];)o=e[r++];if(void 0!==o){var a=o[i];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[i])&&(t.push(o.time),n.push.apply(n,a)),o=e[r++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[i])&&(t.push(o.time),a.toArray(n,n.length)),o=e[r++]}while(void 0!==o);else do{void 0!==(a=o[i])&&(t.push(o.time),n.push(a)),o=e[r++]}while(void 0!==o)}}};function Qo(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function ea(e,t,n,i){Qo.call(this,e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function ta(e,t,n,i){Qo.call(this,e,t,n,i)}function na(e,t,n,i){Qo.call(this,e,t,n,i)}function ia(e,t,n,i){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=$o.convertArray(t,this.TimeBufferType),this.values=$o.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation),this.validate(),this.optimize()}function ra(e,t,n,i){ia.call(this,e,t,n,i)}function oa(e,t,n,i){Qo.call(this,e,t,n,i)}function aa(e,t,n,i){ia.call(this,e,t,n,i)}function sa(e,t,n,i){ia.call(this,e,t,n,i)}function la(e,t,n,i){ia.call(this,e,t,n,i)}function ua(e,t,n){ia.call(this,e,t,n)}function ca(e,t,n,i){ia.call(this,e,t,n,i)}function da(e,t,n,i){ia.apply(this,arguments)}function ha(e,t,n){this.name=e,this.tracks=n,this.duration=void 0!==t?t:-1,this.uuid=Mt.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function pa(e){this.manager=void 0!==e?e:Ao,this.textures={}}function fa(e){this.manager=void 0!==e?e:Ao}function ma(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function ga(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:Ao,this.withCredentials=!1}function ya(e){this.manager=void 0!==e?e:Ao,this.texturePath=""}function va(e,t,n,i,r){var o=.5*(i-t),a=.5*(r-n),s=e*e;return(2*n-2*i+o+a)*(e*s)+(-3*n+3*i-2*o-a)*s+o*e+n}function ba(e,t,n,i){return function(e,t){var n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,i)}function _a(e,t,n,i,r){return function(e,t){var n=1-e;return n*n*n*t}(e,t)+function(e,t){var n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,i)+function(e,t){return e*e*e*t}(e,r)}function xa(){}function wa(e,t){this.v1=e,this.v2=t}function Ma(){this.curves=[],this.autoClose=!1}function Sa(e,t,n,i,r,o,a,s){this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function Ea(e){this.points=void 0===e?[]:e}function Ta(e,t,n,i){this.v0=e,this.v1=t,this.v2=n,this.v3=i}function Ca(e,t,n){this.v0=e,this.v1=t,this.v2=n}Qo.prototype={constructor:Qo,evaluate:function(e){var t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{var o;n:{i:if(!(e=r)break e;var s=t[1];e=(r=t[--n-1]))break t}o=n,n=0}for(;n>>1;et;)--o;if(++o,0!==r||o!==i){r>=o&&(r=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=$o.arraySlice(n,r,o),this.values=$o.arraySlice(this.values,r*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,i=this.values,r=n.length;0===r&&(console.error("track is empty",this),e=!1);for(var o=null,a=0;a!==r;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!==i&&$o.isTypedArray(i)){a=0;for(var l=i.length;a!==l;++a){var u=i[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(),i=this.getInterpolation()===at,r=1,o=e.length-1,a=1;a0){e[r]=e[o];for(f=o*n,m=r*n,h=0;h!==n;++h)t[m+h]=t[f+h];++r}return r!==e.length&&(this.times=$o.arraySlice(e,0,r),this.values=$o.arraySlice(t,0,r*n)),this}},ra.prototype=Object.assign(Object.create(qo),{constructor:ra,ValueTypeName:"vector"}),oa.prototype=Object.assign(Object.create(Qo.prototype),{constructor:oa,interpolate_:function(e,t,n,i){for(var r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=(n-t)/(i-t),u=s+a;s!==u;s+=4)Nt.slerpFlat(r,0,o,s-a,o,s,l);return r}}),aa.prototype=Object.assign(Object.create(qo),{constructor:aa,ValueTypeName:"quaternion",DefaultInterpolation:ot,InterpolantFactoryMethodLinear:function(e){return new oa(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),sa.prototype=Object.assign(Object.create(qo),{constructor:sa,ValueTypeName:"number"}),la.prototype=Object.assign(Object.create(qo),{constructor:la,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:rt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ua.prototype=Object.assign(Object.create(qo),{constructor:ua,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:rt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ca.prototype=Object.assign(Object.create(qo),{constructor:ca,ValueTypeName:"color"}),da.prototype=qo,qo.constructor=da,Object.assign(da,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=da._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){var n=[],i=[];$o.flattenJSON(e.keys,n,i,"value"),e.times=n,e.values=i}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:$o.convertArray(e.times,Array),values:$o.convertArray(e.values,Array)};var i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sa;case"vector":case"vector2":case"vector3":case"vector4":return ra;case"color":return ca;case"quaternion":return aa;case"bool":case"boolean":return ua;case"string":return la}throw new Error("Unsupported typeName: "+e)}}),ha.prototype={constructor:ha,resetDuration:function(){for(var e=0,t=0,n=this.tracks.length;t!==n;++t){var i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}this.duration=e},trim:function(){for(var e=0;e1){var u=i[d=l[1]];u||(i[d]=u=[]),u.push(s)}}var c=[];for(var d in i)c.push(ha.CreateFromMorphTargetSequence(d,i[d],t,n));return c},parseAnimation:function(e,t){if(!e)return console.error(" no animation in JSONLoader data"),null;for(var n=function(e,t,n,i,r){if(0!==n.length){var o=[],a=[];$o.flattenJSON(n,o,a,i),0!==o.length&&r.push(new e(t,o,a))}},i=[],r=e.name||"default",o=e.length||-1,a=e.fps||30,s=e.hierarchy||[],l=0;l1?e.skinWeights[i+1]:0,s=t>2?e.skinWeights[i+2]:0,l=t>3?e.skinWeights[i+3]:0;n.skinWeights.push(new Lt(o,a,s,l))}if(e.skinIndices)for(i=0,r=e.skinIndices.length;i1?e.skinIndices[i+1]:0,d=t>2?e.skinIndices[i+2]:0,h=t>3?e.skinIndices[i+3]:0;n.skinIndices.push(new Lt(u,c,d,h))}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 i=0,r=e.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var c=n.faces,d=e.morphColors[0].colors;for(i=0,r=c.length;i0&&(n.animations=t)}(),n.computeFaceNormals(),n.computeBoundingSphere(),void 0===e.materials||0===e.materials.length)return{geometry:n};var r=ma.prototype.initMaterials(e.materials,t,this.crossOrigin);return{geometry:n,materials:r}}}),Object.assign(ya.prototype,{load:function(e,t,n,i){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var r=this;new Ro(r.manager).load(e,(function(n){var o=null;try{o=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?r.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead.")}),n,i)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var n=this.parseGeometries(e.geometries),i=this.parseImages(e.images,(function(){void 0!==t&&t(a)})),r=this.parseTextures(e.textures,i),o=this.parseMaterials(e.materials,r),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 ga,i=new fa,r=0,o=e.length;r0){var o=new Do(new Po(t));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=e.length;a0?new wr(s,l):new Ii(s,l);break;case"LOD":r=new br;break;case"Line":r=new Sr(o(t.geometry),a(t.material),t.mode);break;case"LineSegments":r=new Er(o(t.geometry),a(t.material));break;case"PointCloud":case"Points":r=new Cr(o(t.geometry),a(t.material));break;case"Sprite":r=new vr(a(t.material));break;case"Group":r=new Or;break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh type. Instantiates Object3D instead.");default:r=new hi}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.children)for(var u in t.children)r.add(this.parseObject(t.children[u],n,i));if("LOD"===t.type)for(var c=t.levels,d=0;d0)){l=r;break}l=r-1}if(i[r=l]===n)return r/(o-1);var u=i[r];return(r+(n-u)/(i[r+1]-u))/(o-1)},getTangent:function(e){var t=e-1e-4,n=e+1e-4;t<0&&(t=0),n>1&&(n=1);var i=this.getPoint(t);return this.getPoint(n).clone().sub(i).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,i,r,o=new Ft,a=[],s=[],l=[],u=new Ft,c=new zt;for(n=0;n<=e;n++)i=n/e,a[n]=this.getTangentAt(i),a[n].normalize();s[0]=new Ft,l[0]=new Ft;var d=Number.MAX_VALUE,h=Math.abs(a[0].x),p=Math.abs(a[0].y),f=Math.abs(a[0].z);for(h<=d&&(d=h,o.set(1,0,0)),p<=d&&(d=p,o.set(0,1,0)),f<=d&&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(),r=Math.acos(Mt.clamp(a[n-1].dot(a[n]),-1,1)),s[n].applyMatrix4(c.makeRotationAxis(u,r))),l[n].crossVectors(a[n],s[n]);if(!0===t)for(r=Math.acos(Mt.clamp(s[0].dot(s[e]),-1,1)),r/=e,a[0].dot(u.crossVectors(s[0],s[e]))>0&&(r=-r),n=1;n<=e;n++)s[n].applyMatrix4(c.makeRotationAxis(a[n],r*n)),l[n].crossVectors(a[n],s[n]);return{tangents:a,normals:s,binormals:l}}},wa.prototype=Object.create(xa.prototype),wa.prototype.constructor=wa,wa.prototype.isLineCurve=!0,wa.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},wa.prototype.getPointAt=function(e){return this.getPoint(e)},wa.prototype.getTangent=function(e){return this.v2.clone().sub(this.v1).normalize()},Ma.prototype=Object.assign(Object.create(xa.prototype),{constructor:Ma,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 wa(t,e))},getPoint:function(e){for(var t=e*this.getLength(),n=this.getCurveLengths(),i=0;i=t){var r=n[i]-t,o=this.curves[i],a=o.getLength(),s=0===a?0:1-r/a;return o.getPointAt(s)}i++}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,i=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 Ri,n=0,i=e.length;nt;)n-=t;nt.length-2?t.length-1:i+1],l=t[i>t.length-3?t.length-1:i+2];return new St(va(r,o.x,a.x,s.x,l.x),va(r,o.y,a.y,s.y,l.y))},Ta.prototype=Object.create(xa.prototype),Ta.prototype.constructor=Ta,Ta.prototype.getPoint=function(e){var t=this.v0,n=this.v1,i=this.v2,r=this.v3;return new St(_a(e,t.x,n.x,i.x,r.x),_a(e,t.y,n.y,i.y,r.y))},Ca.prototype=Object.create(xa.prototype),Ca.prototype.constructor=Ca,Ca.prototype.getPoint=function(e){var t=this.v0,n=this.v1,i=this.v2;return new St(ba(e,t.x,n.x,i.x),ba(e,t.y,n.y,i.y))};var Oa,ka=Object.assign(Object.create(Ma.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)}});function Pa(e){Ma.call(this),this.currentPoint=new St,e&&this.fromPoints(e)}function Aa(){Pa.apply(this,arguments),this.holes=[]}function Ra(){this.subPaths=[],this.currentPath=null}function La(e){this.data=e}function Ia(e){this.manager=void 0!==e?e:Ao}Pa.prototype=ka,ka.constructor=Pa,Aa.prototype=Object.assign(Object.create(ka),{constructor:Aa,getPointsHoles:function(e){for(var t=[],n=0,i=this.holes.length;nNumber.EPSILON){if(u<0&&(a=t[o],l=-l,s=t[r],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;i=!i}}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 i}var r=$r.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return n(o);var a,s,l,u=[];if(1===o.length)return s=o[0],(l=new Aa).curves=s.curves,u.push(l),u;var c=!r(o[0].getPoints());c=e?!c:c;var d,h,p=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var y=0,v=o.length;y1){for(var b=!1,_=[],x=0,w=f.length;x0&&(b||(m=p))}y=0;for(var O=f.length;y0){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!==r;++o)e[t+o]=e[n+o]},_slerp:function(e,t,n,i,r){Nt.slerpFlat(e,t,e,t,e,n,i)},_lerp:function(e,t,n,i,r){for(var o=1-i,a=0;a!==r;++a){var s=t+a;e[s]=e[s]*o+e[n+a]*i}}},as.prototype={constructor:as,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,i=t.propertyName,r=t.propertyIndex;if(e||(e=as.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){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];i[h.uuid]=c,t[c]=h,i[u]=d,t[d]=l;for(var p=0,f=o;p!==f;++p){var m=r[p],g=m[d],y=m[c];m[c]=g,m[d]=y}}}this.nCachedObjects_=n},uncache:function(e){for(var t=this._objects,n=t.length,i=this.nCachedObjects_,r=this._indicesByUUID,o=this._bindings,a=o.length,s=0,l=arguments.length;s!==l;++s){var u=arguments[s],c=u.uuid,d=r[c];if(void 0!==d)if(delete r[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(i,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(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,i=this.loop,r=this._loopCount;if(i===tt){-1===r&&(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=i===it;if(-1===r&&(e>=0?(r=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,r+=Math.abs(a);var s=this.repetitions-r;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=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&r))return this.time=t,n-t}return this.time=t,t},_setEndings:function(e,t,n){var i=this._interpolantSettings;n?(i.endingStart=lt,i.endingEnd=lt):(i.endingStart=e?this.zeroSlopeAtStart?lt:st:ut,i.endingEnd=t?this.zeroSlopeAtEnd?lt:st:ut)},_scheduleFading:function(e,t,n){var i=this._mixer,r=i.time,o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=r,s[0]=t,a[1]=r+e,s[1]=n,this}},us.prototype={constructor:us,clipAction:function(e,t){var n=t||this._root,i=n.uuid,r="string"==typeof e?ha.findByName(n,e):e,o=null!==r?r.uuid:e,a=this._actionsByClip[o],s=null;if(void 0!==a){var l=a.actionByRoot[i];if(void 0!==l)return l;s=a.knownActions[0],null===r&&(r=s._clip)}if(null===r)return null;var u=new ls(this,r,t);return this._bindAction(u,s),this._addInactiveAction(u,o,i),u},existingAction:function(e,t){var n=t||this._root,i=n.uuid,r="string"==typeof e?ha.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[i]||null},stopAllAction:function(){var e=this._actions,t=this._nActiveActions,n=this._bindings,i=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var r=0;r!==t;++r)e[r].reset();for(r=0;r!==i;++r)n[r].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1,a=0;a!==n;++a){var s=t[a];s.enabled&&s._update(i,e,r,o)}var l=this._bindings,u=this._nActiveBindings;for(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,i=this._actionsByClip,r=i[n];if(void 0!==r){for(var o=r.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 i[n]}},uncacheRoot:function(e){var t=e.uuid,n=this._actionsByClip;for(var i in n){var r=n[i].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var o=this._bindingsByRootAndName[t];if(void 0!==o)for(var a in o){var s=o[a];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(e,t){var n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Object.assign(us.prototype,{_bindAction:function(e,t){var n=e._localRoot||this._root,i=e._clip.tracks,r=i.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!==r;++c){var d=i[c],h=d.name,p=u[h];if(void 0!==p)o[c]=p;else{if(void 0!==(p=o[c])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,h));continue}var f=t&&t._propertyBindings[c].binding.parsedPath;++(p=new os(as.create(n,h,f),d.ValueTypeName,d.getValueSize())).referenceCount,this._addInactiveBinding(p,s,h),o[c]=p}a[c].resultBuffer=p.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}for(var r=e._propertyBindings,o=0,a=r.length;o!==a;++o){var s=r[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,i=t.length;n!==i;++n){var r=t[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}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)i[l=s[1]]||(i[l]={start:1/0,end:-1/0}),o<(u=i[l]).start&&(u.start=o),o>u.end&&(u.end=o),t||(t=l)}for(var l in i){var u=i[l];this.createAnimation(l,u.start,u.end,e)}this.firstAnimation=t},ws.prototype.setAnimationDirectionForward=function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},ws.prototype.setAnimationDirectionBackward=function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},ws.prototype.setAnimationFPS=function(e,t){var n=this.animationsMap[e];n&&(n.fps=t,n.duration=(n.end-n.start)/n.fps)},ws.prototype.setAnimationDuration=function(e,t){var n=this.animationsMap[e];n&&(n.duration=t,n.fps=(n.end-n.start)/n.duration)},ws.prototype.setAnimationWeight=function(e,t){var n=this.animationsMap[e];n&&(n.weight=t)},ws.prototype.setAnimationTime=function(e,t){var n=this.animationsMap[e];n&&(n.time=t)},ws.prototype.getAnimationTime=function(e){var t=0,n=this.animationsMap[e];return n&&(t=n.time),t},ws.prototype.getAnimationDuration=function(e){var t=-1,n=this.animationsMap[e];return n&&(t=n.duration),t},ws.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()")},ws.prototype.stopAnimation=function(e){var t=this.animationsMap[e];t&&(t.active=!1)},ws.prototype.update=function(e){for(var t=0,n=this.animationsList.length;ti.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 o=i.start+Mt.clamp(Math.floor(i.time/r),0,i.length-1),a=i.weight;o!==i.currentFrame&&(this.morphTargetInfluences[i.lastFrame]=0,this.morphTargetInfluences[i.currentFrame]=1*a,this.morphTargetInfluences[o]=0,i.lastFrame=i.currentFrame,i.currentFrame=o);var s=i.time%r/r;i.directionBackwards&&(s=1-s),i.currentFrame!==i.lastFrame?(this.morphTargetInfluences[i.currentFrame]=s*a,this.morphTargetInfluences[i.lastFrame]=(1-s)*a):this.morphTargetInfluences[i.currentFrame]=a}}},Ms.prototype=Object.create(hi.prototype),Ms.prototype.constructor=Ms,Ms.prototype.isImmediateRenderObject=!0,Ss.prototype=Object.create(Er.prototype),Ss.prototype.constructor=Ss,Ss.prototype.update=function(){var e=new Ft,t=new Ft,n=new Jn;return function(){var i=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var r=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):e.y<-.99999?this.quaternion.set(1,0,0,0):(Ka.set(e.z,0,-e.x).normalize(),Xa=Math.acos(e.y),this.quaternion.setFromAxisAngle(Ka,Xa))}),Ns.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()},Ns.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},Fs.prototype=Object.create(Er.prototype),Fs.prototype.constructor=Fs;var Bs=new Ft,js=new zs,Us=new zs,Ws=new zs;function Gs(e){this.points=e||[],this.closed=!1}function Vs(e,t,n,i){this.v0=e,this.v1=t,this.v2=n,this.v3=i}function Hs(e,t,n){this.v0=e,this.v1=t,this.v2=n}function Ys(e,t){this.v1=e,this.v2=t}function qs(e,t,n,i,r,o){Sa.call(this,e,t,n,n,i,r,o)}Gs.prototype=Object.create(xa.prototype),Gs.prototype.constructor=Gs,Gs.prototype.getPoint=function(e){var t=this.points,n=t.length;n<2&&console.log("duh, you need at least 2 points");var i,r,o,a,s=(n-(this.closed?0:1))*e,l=Math.floor(s),u=s-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/t.length)+1)*t.length:0===u&&l===n-1&&(l=n-2,u=1),this.closed||l>0?i=t[(l-1)%n]:(Bs.subVectors(t[0],t[1]).add(t[0]),i=Bs),r=t[l%n],o=t[(l+1)%n],this.closed||l+20?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&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n>=4,n[r]=t[19===r?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,i,r){return i+(e-t)*(r-i)/(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*Mt.DEG2RAD},radToDeg:function(e){return e*Mt.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}};function St(e,t){this.x=e||0,this.y=t||0}St.prototype={constructor:St,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(e,t){return void 0===r&&(r=new St,o=new St),r.set(e,e),o.set(t,t),this.clamp(r,o)},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),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}};var Et,Tt,Ct,Ot,kt,Pt,At=0;function Rt(e,t,n,i,r,o,a,s,l,u){Object.defineProperty(this,"id",{value:At++}),this.uuid=Mt.generateUUID(),this.name="",this.image=void 0!==e?e:Rt.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:Rt.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:ve,this.wrapT=void 0!==i?i:ve,this.magFilter=void 0!==r?r:Me,this.minFilter=void 0!==o?o:Ee,this.anisotropy=void 0!==l?l:1,this.format=void 0!==a?a:Ue,this.type=void 0!==s?s:Te,this.offset=new St(0,0),this.repeat=new St(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==u?u:pt,this.version=0,this.onUpdate=null}function Lt(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1}function It(e,t,n){this.uuid=Mt.generateUUID(),this.width=e,this.height=t,this.scissor=new Lt(0,0,e,t),this.scissorTest=!1,this.viewport=new Lt(0,0,e,t),void 0===(n=n||{}).minFilter&&(n.minFilter=Me),this.texture=new Rt(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 Dt(e,t,n){It.call(this,e,t,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function Nt(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1}function Ft(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}function zt(){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 Bt(e,t,n,i,r,o,a,s,l,u){e=void 0!==e?e:[],t=void 0!==t?t:ce,Rt.call(this,e,t,n,i,r,o,a,s,l,u),this.flipY=!1}Rt.DEFAULT_IMAGE=void 0,Rt.DEFAULT_MAPPING=ue,Rt.prototype={constructor:Rt,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=Mt.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")).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===ue){if(e.multiply(this.repeat),e.add(this.offset),e.x<0||e.x>1)switch(this.wrapS){case ye:e.x=e.x-Math.floor(e.x);break;case ve:e.x=e.x<0?0:1;break;case be: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 ye:e.y=e.y-Math.floor(e.y);break;case ve:e.y=e.y<0?0:1;break;case be: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(Rt.prototype,i.prototype),Lt.prototype={constructor:Lt,isVector4:!0,set:function(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,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,i,r,o=e.elements,a=o[0],s=o[4],l=o[8],u=o[1],c=o[5],d=o[9],h=o[2],p=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(l-h)<.01&&Math.abs(d-p)<.01){if(Math.abs(s+u)<.1&&Math.abs(l+h)<.1&&Math.abs(d+p)<.1&&Math.abs(a+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(a+1)/2,g=(c+1)/2,y=(f+1)/2,v=(s+u)/4,b=(l+h)/4,_=(d+p)/4;return m>g&&m>y?m<.01?(n=0,i=.707106781,r=.707106781):(i=v/(n=Math.sqrt(m)),r=b/n):g>y?g<.01?(n=.707106781,i=0,r=.707106781):(n=v/(i=Math.sqrt(g)),r=_/i):y<.01?(n=.707106781,i=.707106781,r=0):(n=b/(r=Math.sqrt(y)),i=_/r),this.set(n,i,r,t),this}var x=Math.sqrt((p-d)*(p-d)+(l-h)*(l-h)+(u-s)*(u-s));return Math.abs(x)<.001&&(x=1),this.x=(p-d)/x,this.y=(l-h)/x,this.z=(u-s)/x,this.w=Math.acos((a+c+f-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,i){return void 0===e&&(e=new Lt,t=new Lt),e.set(n,n,n,n),t.set(i,i,i,i),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}},It.prototype={constructor:It,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(It.prototype,i.prototype),Dt.prototype=Object.create(It.prototype),Dt.prototype.constructor=Dt,Dt.prototype.isWebGLRenderTargetCube=!0,Nt.prototype={constructor:Nt,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,i){return this._x=e,this._y=t,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(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),i=Math.cos(e._y/2),r=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*i*r+n*a*s,this._y=n*a*r-o*i*s,this._z=n*i*s+o*a*r,this._w=n*i*r-o*a*s):"YXZ"===l?(this._x=o*i*r+n*a*s,this._y=n*a*r-o*i*s,this._z=n*i*s-o*a*r,this._w=n*i*r+o*a*s):"ZXY"===l?(this._x=o*i*r-n*a*s,this._y=n*a*r+o*i*s,this._z=n*i*s+o*a*r,this._w=n*i*r-o*a*s):"ZYX"===l?(this._x=o*i*r-n*a*s,this._y=n*a*r+o*i*s,this._z=n*i*s-o*a*r,this._w=n*i*r+o*a*s):"YZX"===l?(this._x=o*i*r+n*a*s,this._y=n*a*r+o*i*s,this._z=n*i*s-o*a*r,this._w=n*i*r-o*a*s):"XZY"===l&&(this._x=o*i*r-n*a*s,this._y=n*a*r-o*i*s,this._z=n*i*s+o*a*r,this._w=n*i*r+o*a*s),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,i=n[0],r=n[4],o=n[8],a=n[1],s=n[5],l=n[9],u=n[2],c=n[6],d=n[10],h=i+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-r)*t):i>s&&i>d?(t=2*Math.sqrt(1+i-s-d),this._w=(c-l)/t,this._x=.25*t,this._y=(r+a)/t,this._z=(o+u)/t):s>d?(t=2*Math.sqrt(1+s-i-d),this._w=(o-u)/t,this._x=(r+a)/t,this._y=.25*t,this._z=(l+c)/t):(t=2*Math.sqrt(1+d-i-s),this._w=(a-r)/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,i){return void 0===e&&(e=new Ft),(t=n.dot(i)+1)<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,i),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,i=e._y,r=e._z,o=e._w,a=t._x,s=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+i*l-r*s,this._y=i*u+o*s+r*a-n*l,this._z=r*u+o*l+n*s-i*a,this._w=o*u-n*a-i*s-r*l,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,i=this._y,r=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+r*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=i,this._z=r,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*(i+this._y),this._z=.5*(r+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=i*u+this._y*c,this._z=r*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(Nt,{slerp:function(e,t,n,i){return n.copy(e).slerp(t,i)},slerpFlat:function(e,t,n,i,r,o,a){var s=n[i+0],l=n[i+1],u=n[i+2],c=n[i+3],d=r[o+0],h=r[o+1],p=r[o+2],f=r[o+3];if(c!==f||s!==d||l!==h||u!==p){var m=1-a,g=s*d+l*h+u*p+c*f,y=g>=0?1:-1,v=1-g*g;if(v>Number.EPSILON){var b=Math.sqrt(v),_=Math.atan2(b,g*y);m=Math.sin(m*_)/b,a=Math.sin(a*_)/b}var x=a*y;if(s=s*m+d*x,l=l*m+h*x,u=u*m+p*x,c=c*m+f*x,m===1-a){var w=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=w,l*=w,u*=w,c*=w}}e[t]=s,e[t+1]=l,e[t+2]=u,e[t+3]=c}}),Ft.prototype={constructor:Ft,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(e){return!1===(e&&e.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===Ct&&(Ct=new Nt),this.applyQuaternion(Ct.setFromEuler(e))},applyAxisAngle:function(){var e;return function(t,n){return void 0===e&&(e=new Nt),this.applyQuaternion(e.setFromAxisAngle(t,n))}}(),applyMatrix3:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;this.x=r[0]*t+r[4]*n+r[8]*i+r[12],this.y=r[1]*t+r[5]*n+r[9]*i+r[13],this.z=r[2]*t+r[6]*n+r[10]*i+r[14];var o=r[3]*t+r[7]*n+r[11]*i+r[15];return this.divideScalar(o)},applyQuaternion:function(e){var t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,s=e.w,l=s*t+o*i-a*n,u=s*n+a*t-r*i,c=s*i+r*n-o*t,d=-r*t-o*n-a*i;return this.x=l*s+d*-r+u*-a-c*-o,this.y=u*s+d*-o+c*-r-l*-a,this.z=c*s+d*-a+l*-o-u*-r,this},project:function(e){return void 0===Tt&&(Tt=new zt),Tt.multiplyMatrices(e.projectionMatrix,Tt.getInverse(e.matrixWorld)),this.applyMatrix4(Tt)},unproject:function(){var e;return function(t){return void 0===e&&(e=new zt),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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,i){return void 0===e&&(e=new Ft,t=new Ft),e.set(n,n,n),t.set(i,i,i),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,i=this.y,r=this.z;return this.x=i*e.z-r*e.y,this.y=r*e.x-n*e.z,this.z=n*e.y-i*e.x,this},crossVectors:function(e,t){var n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,s=t.z;return this.x=i*s-r*a,this.y=r*o-n*s,this.z=n*a-i*o,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(e){return void 0===Et&&(Et=new Ft),Et.copy(this).projectOnVector(e),this.sub(Et)},reflect:function(){var e;return function(t){return void 0===e&&(e=new Ft),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(Mt.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,i=this.z-e.z;return t*t+n*n+i*i},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(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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}},zt.prototype={constructor:zt,isMatrix4:!0,set:function(e,t,n,i,r,o,a,s,l,u,c,d,h,p,f,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,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]=p,g[11]=f,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 zt).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 Ft);var n=this.elements,i=t.elements,r=1/e.setFromMatrixColumn(t,0).length(),o=1/e.setFromMatrixColumn(t,1).length(),a=1/e.setFromMatrixColumn(t,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[4]=i[4]*o,n[5]=i[5]*o,n[6]=i[6]*o,n[8]=i[8]*a,n[9]=i[9]*a,n[10]=i[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,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(i),l=Math.sin(i),u=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){var d=o*u,h=o*c,p=a*u,f=a*c;t[0]=s*u,t[4]=-s*c,t[8]=l,t[1]=h+p*l,t[5]=d-f*l,t[9]=-a*s,t[2]=f-d*l,t[6]=p+h*l,t[10]=o*s}else if("YXZ"===e.order){var m=s*u,g=s*c,y=l*u,v=l*c;t[0]=m+v*a,t[4]=y*a-g,t[8]=o*l,t[1]=o*c,t[5]=o*u,t[9]=-a,t[2]=g*a-y,t[6]=v+m*a,t[10]=o*s}else if("ZXY"===e.order){m=s*u,g=s*c,y=l*u,v=l*c;t[0]=m-v*a,t[4]=-o*c,t[8]=y+g*a,t[1]=g+y*a,t[5]=o*u,t[9]=v-m*a,t[2]=-o*l,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){d=o*u,h=o*c,p=a*u,f=a*c;t[0]=s*u,t[4]=p*l-h,t[8]=d*l+f,t[1]=s*c,t[5]=f*l+d,t[9]=h*l-p,t[2]=-l,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){var b=o*s,_=o*l,x=a*s,w=a*l;t[0]=s*u,t[4]=w-b*c,t[8]=x*c+_,t[1]=c,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=_*c+x,t[10]=b-w*c}else if("XZY"===e.order){b=o*s,_=o*l,x=a*s,w=a*l;t[0]=s*u,t[4]=-c,t[8]=l*u,t[1]=b*c+w,t[5]=o*u,t[9]=_*c-x,t[2]=x*c-_,t[6]=a*u,t[10]=w*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,i=e.y,r=e.z,o=e.w,a=n+n,s=i+i,l=r+r,u=n*a,c=n*s,d=n*l,h=i*s,p=i*l,f=r*l,m=o*a,g=o*s,y=o*l;return t[0]=1-(h+f),t[4]=c-y,t[8]=d+g,t[1]=c+y,t[5]=1-(u+f),t[9]=p-m,t[2]=d-g,t[6]=p+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(e,t,n){void 0===Ot&&(Ot=new Ft,kt=new Ft,Pt=new Ft);var i=this.elements;return Pt.subVectors(e,t).normalize(),0===Pt.lengthSq()&&(Pt.z=1),Ot.crossVectors(n,Pt).normalize(),0===Ot.lengthSq()&&(Pt.z+=1e-4,Ot.crossVectors(n,Pt).normalize()),kt.crossVectors(Pt,Ot),i[0]=Ot.x,i[4]=kt.x,i[8]=Pt.x,i[1]=Ot.y,i[5]=kt.y,i[9]=Pt.y,i[2]=Ot.z,i[6]=kt.z,i[10]=Pt.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,i=t.elements,r=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],p=n[2],f=n[6],m=n[10],g=n[14],y=n[3],v=n[7],b=n[11],_=n[15],x=i[0],w=i[4],M=i[8],S=i[12],E=i[1],T=i[5],C=i[9],O=i[13],k=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]=o*x+a*E+s*k+l*L,r[4]=o*w+a*T+s*P+l*I,r[8]=o*M+a*C+s*A+l*D,r[12]=o*S+a*O+s*R+l*N,r[1]=u*x+c*E+d*k+h*L,r[5]=u*w+c*T+d*P+h*I,r[9]=u*M+c*C+d*A+h*D,r[13]=u*S+c*O+d*R+h*N,r[2]=p*x+f*E+m*k+g*L,r[6]=p*w+f*T+m*P+g*I,r[10]=p*M+f*C+m*A+g*D,r[14]=p*S+f*O+m*R+g*N,r[3]=y*x+v*E+b*k+_*L,r[7]=y*w+v*T+b*P+_*I,r[11]=y*M+v*C+b*A+_*D,r[15]=y*S+v*O+b*R+_*N,this},multiplyToArray:function(e,t,n){var i=this.elements;return this.multiplyMatrices(e,t),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(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 Ft);for(var n=0,i=t.count;n0)return e;var r=t*n,o=Gt[r];if(void 0===o&&(o=new Float32Array(r),Gt[r]=o),0!==t){i.toArray(o,0);for(var a=1,s=0;a!==t;++a)s+=n,e[a].toArray(o,s)}return o}function Yt(e,t){var n=Vt[t];void 0===n&&(n=new Int32Array(t),Vt[t]=n);for(var i=0;i!==t;++i)n[i]=e.allocTextureUnit();return n}function qt(e,t){e.uniform1f(this.addr,t)}function Xt(e,t){e.uniform1i(this.addr,t)}function Kt(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)}function Zt(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 Jt(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)}function $t(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)}function Qt(e,t){e.uniformMatrix3fv(this.addr,!1,t.elements||t)}function en(e,t){e.uniformMatrix4fv(this.addr,!1,t.elements||t)}function tn(e,t,n){var i=n.allocTextureUnit();e.uniform1i(this.addr,i),n.setTexture2D(t||Ut,i)}function nn(e,t,n){var i=n.allocTextureUnit();e.uniform1i(this.addr,i),n.setTextureCube(t||jt,i)}function rn(e,t){e.uniform2iv(this.addr,t)}function on(e,t){e.uniform3iv(this.addr,t)}function an(e,t){e.uniform4iv(this.addr,t)}function sn(e,t){e.uniform1fv(this.addr,t)}function ln(e,t){e.uniform1iv(this.addr,t)}function un(e,t){e.uniform2fv(this.addr,Ht(t,this.size,2))}function cn(e,t){e.uniform3fv(this.addr,Ht(t,this.size,3))}function dn(e,t){e.uniform4fv(this.addr,Ht(t,this.size,4))}function hn(e,t){e.uniformMatrix2fv(this.addr,!1,Ht(t,this.size,4))}function pn(e,t){e.uniformMatrix3fv(this.addr,!1,Ht(t,this.size,9))}function fn(e,t){e.uniformMatrix4fv(this.addr,!1,Ht(t,this.size,16))}function mn(e,t,n){var i=t.length,r=Yt(n,i);e.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTexture2D(t[o]||Ut,r[o])}function gn(e,t,n){var i=t.length,r=Yt(n,i);e.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTextureCube(t[o]||jt,r[o])}function yn(e,t,n){this.id=e,this.addr=n,this.setValue=function(e){switch(e){case 5126:return qt;case 35664:return Kt;case 35665:return Zt;case 35666:return Jt;case 35674:return $t;case 35675:return Qt;case 35676:return en;case 35678:return tn;case 35680:return nn;case 5124:case 35670:return Xt;case 35667:case 35671:return rn;case 35668:case 35672:return on;case 35669:case 35673:return an}}(t.type)}function vn(e,t,n){this.id=e,this.addr=n,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return sn;case 35664:return un;case 35665:return cn;case 35666:return dn;case 35674:return hn;case 35675:return pn;case 35676:return fn;case 35678:return mn;case 35680:return gn;case 5124:case 35670:return ln;case 35667:case 35671:return rn;case 35668:case 35672:return on;case 35669:case 35673:return an}}(t.type)}function bn(e){this.id=e,Wt.call(this)}bn.prototype.setValue=function(e,t){for(var n=this.seq,i=0,r=n.length;i!==r;++i){var o=n[i];o.setValue(e,t[o.id])}};var _n=/([\w\d_]+)(\])?(\[|\.)?/g;function xn(e,t){e.seq.push(t),e.map[t.id]=t}function wn(e,t,n){var i=e.name,r=i.length;for(_n.lastIndex=0;;){var o=_n.exec(i),a=_n.lastIndex,s=o[1],l="]"===o[2],u=o[3];if(l&&(s|=0),void 0===u||"["===u&&a+2===r){xn(n,void 0===u?new yn(s,e,t):new vn(s,e,t));break}var c=n.map[s];void 0===c&&xn(n,c=new bn(s)),n=c}}function Mn(e,t,n){Wt.call(this),this.renderer=n;for(var i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=0;r 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"};function Tn(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}Tn.prototype={constructor:Tn,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,i){if(t=Mt.euclideanModulo(t,1),n=Mt.clamp(n,0,1),i=Mt.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,o=2*i-r;this.r=e(o,r,t+1/3),this.g=e(o,r,t),this.b=e(o,r,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 i,r=n[1],o=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(o))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,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))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,t(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(o)){var a=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(a,s,l)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(e)){var u,c=(u=n[1]).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}e&&e.length>0&&(void 0!==(u=Cn[e])?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,i=e||{h:0,s:0,l:0},r=this.r,o=this.g,a=this.b,s=Math.max(r,o,a),l=Math.min(r,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 r:t=(o-a)/c+(o.001&&k.scale>.001&&(x.x=k.x,x.y=k.y,x.z=k.z,b=k.size*k.scale/f.w,_.x=b*g,_.y=b,c.uniform3f(s.screenPosition,x.x,x.y,x.z),c.uniform2f(s.scale,_.x,_.y),c.uniform1f(s.rotation,k.rotation),c.uniform1f(s.opacity,k.opacity),c.uniform3f(s.color,k.color.r,k.color.g,k.color.b),d.setBlending(k.blending,k.blendEquation,k.blendSrc,k.blendDst),e.setTexture2D(k.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0))}}}d.enable(c.CULL_FACE),d.enable(c.DEPTH_TEST),d.setDepthWrite(!0),e.resetGLState()}}}function Ln(e,t){var n,i,r,o,a,s,l=e.context,u=e.state,c=new Ft,d=new Nt,h=new Ft;function p(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),u=new Uint16Array([0,1,2,0,2,3]);n=l.createBuffer(),i=l.createBuffer(),l.bindBuffer(l.ARRAY_BUFFER,n),l.bufferData(l.ARRAY_BUFFER,t,l.STATIC_DRAW),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,i),l.bufferData(l.ELEMENT_ARRAY_BUFFER,u,l.STATIC_DRAW),r=function(){var t=l.createProgram(),n=l.createShader(l.VERTEX_SHADER),i=l.createShader(l.FRAGMENT_SHADER);return l.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")),l.shaderSource(i,["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")),l.compileShader(n),l.compileShader(i),l.attachShader(t,n),l.attachShader(t,i),l.linkProgram(t),t}(),o={position:l.getAttribLocation(r,"position"),uv:l.getAttribLocation(r,"uv")},a={uvOffset:l.getUniformLocation(r,"uvOffset"),uvScale:l.getUniformLocation(r,"uvScale"),rotation:l.getUniformLocation(r,"rotation"),scale:l.getUniformLocation(r,"scale"),color:l.getUniformLocation(r,"color"),map:l.getUniformLocation(r,"map"),opacity:l.getUniformLocation(r,"opacity"),modelViewMatrix:l.getUniformLocation(r,"modelViewMatrix"),projectionMatrix:l.getUniformLocation(r,"projectionMatrix"),fogType:l.getUniformLocation(r,"fogType"),fogDensity:l.getUniformLocation(r,"fogDensity"),fogNear:l.getUniformLocation(r,"fogNear"),fogFar:l.getUniformLocation(r,"fogFar"),fogColor:l.getUniformLocation(r,"fogColor"),alphaTest:l.getUniformLocation(r,"alphaTest")};var c=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");c.width=8,c.height=8;var d=c.getContext("2d");d.fillStyle="white",d.fillRect(0,0,8,8),(s=new Rt(c)).needsUpdate=!0}function f(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}this.render=function(m,g){if(0!==t.length){void 0===r&&p(),l.useProgram(r),u.initAttributes(),u.enableAttribute(o.position),u.enableAttribute(o.uv),u.disableUnusedAttributes(),u.disable(l.CULL_FACE),u.enable(l.BLEND),l.bindBuffer(l.ARRAY_BUFFER,n),l.vertexAttribPointer(o.position,2,l.FLOAT,!1,16,0),l.vertexAttribPointer(o.uv,2,l.FLOAT,!1,16,8),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,i),l.uniformMatrix4fv(a.projectionMatrix,!1,g.projectionMatrix.elements),u.activeTexture(l.TEXTURE0),l.uniform1i(a.map,0);var y=0,v=0,b=m.fog;b?(l.uniform3f(a.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(l.uniform1f(a.fogNear,b.near),l.uniform1f(a.fogFar,b.far),l.uniform1i(a.fogType,1),y=1,v=1):b.isFogExp2&&(l.uniform1f(a.fogDensity,b.density),l.uniform1i(a.fogType,2),y=2,v=2)):(l.uniform1i(a.fogType,0),y=0,v=0);for(var _=0,x=t.length;_this.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 St).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 St).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new St;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 In,Dn,Nn,Fn,zn,Bn,Un,jn,Wn,Gn,Vn,Hn=0;function Yn(){Object.defineProperty(this,"id",{value:Hn++}),this.uuid=Mt.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=T,this.side=y,this.shading=x,this.vertexColors=w,this.opacity=1,this.transparent=!1,this.blendSrc=U,this.blendDst=j,this.blendEquation=A,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Z,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 qn(e){Yn.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!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}function Xn(e){Yn.call(this),this.type="MeshDepthMaterial",this.depthPacking=xt,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(e)}function Kn(e,t){this.min=void 0!==e?e:new Ft(1/0,1/0,1/0),this.max=void 0!==t?t:new Ft(-1/0,-1/0,-1/0)}function Zn(e,t){this.center=void 0!==e?e:new Ft,this.radius=void 0!==t?t:0}function Jn(){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 $n(e,t){this.normal=void 0!==e?e:new Ft(1,0,0),this.constant=void 0!==t?t:0}function Qn(e,t,n,i,r,o){this.planes=[void 0!==e?e:new $n,void 0!==t?t:new $n,void 0!==n?n:new $n,void 0!==i?i:new $n,void 0!==r?r:new $n,void 0!==o?o:new $n]}function ei(e,t,n,i){var r=e.context,o=e.state,a=new Qn,s=new zt,l=t.shadows,u=new St,c=new St(i.maxTextureSize,i.maxTextureSize),d=new Ft,h=new Ft,p=[],f=1,g=2,_=1+(f|g),x=new Array(_),w=new Array(_),M={},S=[new Ft(1,0,0),new Ft(-1,0,0),new Ft(0,0,1),new Ft(0,0,-1),new Ft(0,1,0),new Ft(0,-1,0)],E=[new Ft(0,1,0),new Ft(0,1,0),new Ft(0,1,0),new Ft(0,1,0),new Ft(0,0,1),new Ft(0,0,-1)],T=[new Lt,new Lt,new Lt,new Lt,new Lt,new Lt],C=new Xn;C.depthPacking=wt,C.clipping=!0;for(var O=Pn.distanceRGBA,k=Sn.clone(O.uniforms),P=0;P!==_;++P){var A=0!=(P&f),R=0!=(P&g),L=C.clone();L.morphTargets=A,L.skinning=R,x[P]=L;var I=new qn({defines:{USE_SHADOWMAP:""},uniforms:k,vertexShader:O.vertexShader,fragmentShader:O.fragmentShader,morphTargets:A,skinning:R,clipping:!0});w[P]=I}var D=this;function N(t,n,i,r){var o=t.geometry,a=null,s=x,l=t.customDepthMaterial;if(i&&(s=w,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|=f),c&&(d|=g),a=s[d]}if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var h=a.uuid,p=n.uuid,m=M[h];void 0===m&&(m={},M[h]=m);var _=m[p];void 0===_&&(_=a.clone(),m[p]=_),a=_}a.visible=n.visible,a.wireframe=n.wireframe;var S=n.side;return D.renderSingleSided&&S==b&&(S=y),D.renderReverseSided&&(S===y?S=v:S===v&&(S=y)),a.side=S,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,i&&void 0!==a.uniforms.lightPos&&a.uniforms.lightPos.value.copy(r),a}function F(e,t,n){if(!1!==e.visible){if(0!=(e.layers.mask&t.layers.mask)&&(e.isMesh||e.isLine||e.isPoints))if(e.castShadow&&(!1===e.frustumCulled||!0===a.intersectsObject(e)))!0===e.material.visible&&(e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),p.push(e));for(var i=e.children,r=0,o=i.length;r0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),n.skinning=this.skinning,n.morphTargets=this.morphTargets,t){var r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n},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 i=t.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},Object.assign(Yn.prototype,i.prototype),qn.prototype=Object.create(Yn.prototype),qn.prototype.constructor=qn,qn.prototype.isShaderMaterial=!0,qn.prototype.copy=function(e){return Yn.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Sn.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},qn.prototype.toJSON=function(e){var t=Yn.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},Xn.prototype=Object.create(Yn.prototype),Xn.prototype.constructor=Xn,Xn.prototype.isMeshDepthMaterial=!0,Xn.prototype.copy=function(e){return Yn.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},Kn.prototype={constructor:Kn,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,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,l=e.length;sr&&(r=u),c>o&&(o=c),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(r,o,a),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,l=e.count;sr&&(r=u),c>o&&(o=c),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(r,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 Ft).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(e){return void 0===Dn&&(Dn=new Ft),this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.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 Ft).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new Ft;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new Ft;return function(t){var n=t||new Zn;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:(In=[new Ft,new Ft,new Ft,new Ft,new Ft,new Ft,new Ft,new Ft],function(e){return this.isEmpty()?this:(In[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),In[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),In[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),In[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),In[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),In[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),In[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),In[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(In),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)}},Zn.prototype={constructor:Zn,set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){void 0===Nn&&(Nn=new Kn);var n=this.center;void 0!==t?n.copy(t):Nn.setFromPoints(e).getCenter(n);for(var i=0,r=0,o=e.length;rthis.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(e){var t=e||new Kn;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}},Jn.prototype={constructor:Jn,isMatrix3:!0,set:function(e,t,n,i,r,o,a,s,l){var u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=r,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 Ft);for(var n=0,i=t.count;n1?void 0:i.copy(r).multiplyScalar(a).add(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 Ft).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new Ft,t=new Jn;return function(n,i){var r=this.coplanarPoint(e).applyMatrix4(n),o=i||t.getNormalMatrix(n),a=this.normal.applyMatrix3(o).normalize();return this.constant=-r.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}},Qn.prototype={constructor:Qn,set:function(e,t,n,i,r,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),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,i=n[0],r=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],p=n[10],f=n[11],m=n[12],g=n[13],y=n[14],v=n[15];return t[0].setComponents(a-i,c-s,f-d,v-m).normalize(),t[1].setComponents(a+i,c+s,f+d,v+m).normalize(),t[2].setComponents(a+r,c+l,f+h,v+g).normalize(),t[3].setComponents(a-r,c-l,f-h,v-g).normalize(),t[4].setComponents(a-o,c-u,f-p,v-y).normalize(),t[5].setComponents(a+o,c+u,f+p,v+y).normalize(),this},intersectsObject:(Bn=new Zn,function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Bn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Bn)}),intersectsSprite:function(){var e=new Zn;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,i=-e.radius,r=0;r<6;r++){if(t[r].distanceToPoint(n)0?e.min.x:e.max.x,zn.x=i.normal.x>0?e.max.x:e.min.x,Fn.y=i.normal.y>0?e.min.y:e.max.y,zn.y=i.normal.y>0?e.max.y:e.min.y,Fn.z=i.normal.z>0?e.min.z:e.max.z,zn.z=i.normal.z>0?e.max.z:e.min.z;var r=i.distanceToPoint(Fn),o=i.distanceToPoint(zn);if(r<0&&o<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}},ti.prototype={constructor:ti,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 Ft).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 Ft;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var n=t||new Ft;n.subVectors(e,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(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new Ft;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:(jn=new Ft,Wn=new Ft,Gn=new Ft,function(e,t,n,i){jn.copy(e).add(t).multiplyScalar(.5),Wn.copy(t).sub(e).normalize(),Gn.copy(this.origin).sub(jn);var r,o,a,s,l=.5*e.distanceTo(t),u=-this.direction.dot(Wn),c=Gn.dot(this.direction),d=-Gn.dot(Wn),h=Gn.lengthSq(),p=Math.abs(1-u*u);if(p>0)if(o=u*c-d,s=l*p,(r=u*d-c)>=0)if(o>=-s)if(o<=s){var f=1/p;a=(r*=f)*(r+u*(o*=f)+2*c)+o*(u*r+o+2*d)+h}else o=l,a=-(r=Math.max(0,-(u*o+c)))*r+o*(o+2*d)+h;else o=-l,a=-(r=Math.max(0,-(u*o+c)))*r+o*(o+2*d)+h;else o<=-s?a=-(r=Math.max(0,-(-u*l+c)))*r+(o=r>0?-l:Math.min(Math.max(-l,-d),l))*(o+2*d)+h:o<=s?(r=0,a=(o=Math.min(Math.max(-l,-d),l))*(o+2*d)+h):a=-(r=Math.max(0,-(u*l+c)))*r+(o=r>0?l:Math.min(Math.max(-l,-d),l))*(o+2*d)+h;else o=u>0?-l:l,a=-(r=Math.max(0,-(u*o+c)))*r+o*(o+2*d)+h;return n&&n.copy(this.direction).multiplyScalar(r).add(this.origin),i&&i.copy(Wn).multiplyScalar(o).add(jn),a}),intersectSphere:function(){var e=new Ft;return function(t,n){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),r=e.dot(e)-i*i,o=t.radius*t.radius;if(r>o)return null;var a=Math.sqrt(o-r),s=i-a,l=i+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,i,r,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,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||r>i?null:((r>n||n!=n)&&(n=r),(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>i?null:((a>n||n!=n)&&(n=a),(s=0?n:i,t)))},intersectsBox:(Un=new Ft,function(e){return null!==this.intersectBox(e,Un)}),intersectTriangle:function(){var e=new Ft,t=new Ft,n=new Ft,i=new Ft;return function(r,o,a,s,l){t.subVectors(o,r),n.subVectors(a,r),i.crossVectors(t,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}e.subVectors(this.origin,r);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 p=-u*e.dot(i);return p<0?null:this.at(p/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)}},ni.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],ni.DefaultOrder="XYZ",ni.prototype={constructor:ni,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,i){return this._x=e,this._y=t,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(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 i=Mt.clamp,r=e.elements,o=r[0],a=r[4],s=r[8],l=r[1],u=r[5],c=r[9],d=r[2],h=r[6],p=r[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(h,u),this._z=0)):"YXZ"===t?(this._x=Math.asin(-i(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(s,p),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-d,o),this._z=0)):"ZXY"===t?(this._x=Math.asin(i(h,-1,1)),Math.abs(h)<.99999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(l,o))):"ZYX"===t?(this._y=Math.asin(-i(d,-1,1)),Math.abs(d)<.99999?(this._x=Math.atan2(h,p),this._z=Math.atan2(l,o)):(this._x=0,this._z=Math.atan2(-a,u))):"YZX"===t?(this._z=Math.asin(i(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,p))):"XZY"===t?(this._z=Math.asin(-i(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(h,u),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-c,p),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,i){return void 0===e&&(e=new zt),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,n,i)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:(Vn=new Nt,function(e){return Vn.setFromEuler(this),this.setFromQuaternion(Vn,e)}),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 Ft(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},ii.prototype={constructor:ii,set:function(e){this.mask=1<n&&(n=e[t]);return n}hi.DefaultUp=new Ft(0,1,0),hi.DefaultMatrixAutoUpdate=!0,hi.prototype={constructor:hi,isObject3D:!0,applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:(si=new Nt,function(e,t){return si.setFromAxisAngle(e,t),this.quaternion.multiply(si),this}),rotateX:function(){var e=new Ft(1,0,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateY:function(){var e=new Ft(0,1,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateZ:function(){var e=new Ft(0,0,1);return function(t){return this.rotateOnAxis(e,t)}}(),translateOnAxis:function(){var e=new Ft;return function(t,n){return e.copy(t).applyQuaternion(this.quaternion),this.position.add(e.multiplyScalar(n)),this}}(),translateX:function(){var e=new Ft(1,0,0);return function(t){return this.translateOnAxis(e,t)}}(),translateY:function(){var e=new Ft(0,1,0);return function(t){return this.translateOnAxis(e,t)}}(),translateZ:function(){var e=new Ft(0,0,1);return function(t){return this.translateOnAxis(e,t)}}(),localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:(ai=new zt,function(e){return e.applyMatrix4(ai.getInverse(this.matrixWorld))}),lookAt:function(){var e=new zt;return function(t){e.lookAt(t,this.position,this.up),this.quaternion.setFromRotationMatrix(e)}}(),add:function(e){if(arguments.length>1){for(var t=0;t1)for(var t=0;t0){i.children=[];for(var r=0;r0&&(n.geometries=o),a.length>0&&(n.materials=a),s.length>0&&(n.textures=s),l.length>0&&(n.images=l)}return n.object=i,n;function u(e){var t=[];for(var n in e){var i=e[n];delete i.metadata,t.push(i)}return t}},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?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}),fi.barycoordFromPoint=function(){var e=new Ft,t=new Ft,n=new Ft;return function(i,r,o,a,s){e.subVectors(a,r),t.subVectors(o,r),n.subVectors(i,r);var l=e.dot(e),u=e.dot(t),c=e.dot(n),d=t.dot(t),h=t.dot(n),p=l*d-u*u,f=s||new Ft;if(0===p)return f.set(-2,-1,-1);var m=1/p,g=(d*c-u*h)*m,y=(l*h-u*c)*m;return f.set(1-g-y,y,g)}}(),fi.containsPoint=function(){var e=new Ft;return function(t,n,i,r){var o=fi.barycoordFromPoint(t,n,i,r,e);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}(),fi.prototype={constructor:fi,set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),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 Ft,t=new Ft;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 Ft).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return fi.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new $n).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return fi.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return fi.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e,t,n,i;return function(r,o){void 0===e&&(e=new $n,t=[new pi,new pi,new pi],n=new Ft,i=new Ft);var a=o||new Ft,s=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(r,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,a=r[1]&&r[1].length>0,s=e.morphTargets,l=s.length;if(l>0){t=[];for(var u=0;u0){c=[];for(u=0;u0?1:-1,u.push(k.x,k.y,k.z),c.push(v/m),c.push(1-b/g),C+=1}}for(b=0;b0)for(h=0;h0&&(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,i,r;for(n=0,i=this.faces.length;n0&&(e+=t[n].distanceTo(t[n-1])),this.lineDistances[n]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Kn),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Zn),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,n){if(!1!==(e&&e.isGeometry)){var i,r=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&&(i=(new Jn).getNormalMatrix(t));for(var p=0,f=a.length;p=0;n--){var f=h[n];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a0,g=p.vertexNormals.length>0,y=1!==p.color.r||1!==p.color.g||1!==p.color.b,v=p.vertexColors.length>0,b=0;if(b=M(b,0,0),b=M(b,1,!0),b=M(b,2,!1),b=M(b,3,f),b=M(b,4,m),b=M(b,5,g),b=M(b,6,y),b=M(b,7,v),a.push(b),a.push(p.a,p.b,p.c),a.push(p.materialIndex),f){var _=this.faceVertexUvs[0][r];a.push(T(_[0]),T(_[1]),T(_[2]))}if(m&&a.push(S(p.normal)),g){var x=p.vertexNormals;a.push(S(x[0]),S(x[1]),S(x[2]))}if(y&&a.push(E(p.color)),v){var w=p.vertexColors;a.push(E(w[0]),E(w[1]),E(w[2]))}}function M(e,t,n){return n?e|1<0&&(e.data.colors=u),d.length>0&&(e.data.uvs=[d]),e.data.faces=a,e},clone:function(){return(new Ri).copy(this)},copy:function(e){var t,n,i,r,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?Si:wi)(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 yi(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;void 0!==n&&((new Jn).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 zt),e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e;return function(t){return void 0===e&&(e=new zt),e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e;return function(t){return void 0===e&&(e=new zt),e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e;return function(t,n,i){return void 0===e&&(e=new zt),e.makeTranslation(t,n,i),this.applyMatrix(e),this}}(),scale:function(){var e;return function(t,n,i){return void 0===e&&(e=new zt),e.makeScale(t,n,i),this.applyMatrix(e),this}}(),lookAt:function(){var e;return function(t){void 0===e&&(e=new hi),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 Ei(3*t.vertices.length,3),i=new Ei(3*t.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(t.vertices)),this.addAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var r=new Ei(t.lineDistances.length,1);this.addAttribute("lineDistance",r.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,n=e.geometry;if(e.isMesh){var i=n.__directGeometry;if(!0===n.elementsNeedUpdate&&(i=void 0,n.elementsNeedUpdate=!1),void 0===i)return this.fromGeometry(n);i.verticesNeedUpdate=n.verticesNeedUpdate,i.normalsNeedUpdate=n.normalsNeedUpdate,i.colorsNeedUpdate=n.colorsNeedUpdate,i.uvsNeedUpdate=n.uvsNeedUpdate,i.groupsNeedUpdate=n.groupsNeedUpdate,n.verticesNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.groupsNeedUpdate=!1,n=i}return!0===n.verticesNeedUpdate&&(void 0!==(t=this.attributes.position)&&(t.copyVector3sArray(n.vertices),t.needsUpdate=!0),n.verticesNeedUpdate=!1),!0===n.normalsNeedUpdate&&(void 0!==(t=this.attributes.normal)&&(t.copyVector3sArray(n.normals),t.needsUpdate=!0),n.normalsNeedUpdate=!1),!0===n.colorsNeedUpdate&&(void 0!==(t=this.attributes.color)&&(t.copyColorsArray(n.colors),t.needsUpdate=!0),n.colorsNeedUpdate=!1),n.uvsNeedUpdate&&(void 0!==(t=this.attributes.uv)&&(t.copyVector2sArray(n.uvs),t.needsUpdate=!0),n.uvsNeedUpdate=!1),n.lineDistancesNeedUpdate&&(void 0!==(t=this.attributes.lineDistance)&&(t.copyArray(n.lineDistances),t.needsUpdate=!0),n.lineDistancesNeedUpdate=!1),n.groupsNeedUpdate&&(n.computeGroups(e.geometry),this.groups=n.groups,n.groupsNeedUpdate=!1),this},fromGeometry:function(e){return e.__directGeometry=(new Ci).fromGeometry(e),this.fromDirectGeometry(e.__directGeometry)},fromDirectGeometry:function(e){var t=new Float32Array(3*e.vertices.length);if(this.addAttribute("position",new yi(t,3).copyVector3sArray(e.vertices)),e.normals.length>0){var n=new Float32Array(3*e.normals.length);this.addAttribute("normal",new yi(n,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var i=new Float32Array(3*e.colors.length);this.addAttribute("color",new yi(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var r=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new yi(r,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new yi(o,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var a=new(Oi(e.indices)>65535?Uint32Array:Uint16Array)(3*e.indices.length);this.setIndex(new yi(a,1).copyIndicesArray(e.indices))}for(var s in this.groups=e.groups,e.morphTargets){for(var l=[],u=e.morphTargets[s],c=0,d=u.length;c0){var f=new Ei(4*e.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var m=new Ei(4*e.skinWeights.length,4);this.addAttribute("skinWeight",m.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 Kn);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 Kn,t=new Ft;return function(){null===this.boundingSphere&&(this.boundingSphere=new Zn);var n=this.attributes.position;if(n){var i=this.boundingSphere.center;e.setFromBufferAttribute(n),e.getCenter(i);for(var r=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 Li).copy(this)},copy:function(e){var t,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var r=e.index;null!==r&&this.setIndex(r.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,i=u.length;n0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var t=0,n=e.length;tt.far?null:{distance:l,point:f.clone(),object:e}}function y(e,t,n,a,s,l,h,f){i.fromBufferAttribute(a,l),r.fromBufferAttribute(a,h),o.fromBufferAttribute(a,f);var y=g(e,t,n,i,r,o,p);return y&&(s&&(u.fromBufferAttribute(s,l),c.fromBufferAttribute(s,h),d.fromBufferAttribute(s,f),y.uv=m(p,i,r,o,u,c,d)),y.face=new mi(l,h,f,fi.normal(i,r,o)),y.faceIndex=l),y}return function(h,f){var v,b=this.geometry,_=this.material,x=this.matrixWorld;if(void 0!==_&&(null===b.boundingSphere&&b.computeBoundingSphere(),n.copy(b.boundingSphere),n.applyMatrix4(x),!1!==h.ray.intersectsSphere(n)&&(e.getInverse(x),t.copy(h.ray).applyMatrix4(e),null===b.boundingBox||!1!==t.intersectsBox(b.boundingBox))))if(b.isBufferGeometry){var w,M,S,E,T,C=b.index,O=b.attributes.position,k=b.attributes.uv;if(null!==C)for(E=0,T=C.count;E0&&(L=z);for(var B=0,U=F.length;B/g,(function(e,t){var n=En[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return er(n)}))}function tr(e){return e.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,(function(e,t,n,i){for(var r="",o=parseInt(t);o0?e.gammaFactor:1,x=function(e,t,n){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter($i).join("\n")}(o,i,e.extensions),w=function(e){var t=[];for(var n in e){var i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(a),M=r.createProgram();n.isRawShaderMaterial?(p=[w,"\n"].filter($i).join("\n"),f=[x,w,"\n"].filter($i).join("\n")):(p=["precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,w,i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#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 "+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.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&&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($i).join("\n"),f=[x,"precision "+i.precision+" float;","precision "+i.precision+" int;","#define SHADER_NAME "+n.__webglShader.name,w,i.alphaTest?"#define ALPHATEST "+i.alphaTest:"","#define GAMMA_FACTOR "+_,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 "+d:"",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.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&&e.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",i.envMap&&e.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",i.toneMapping!==re?"#define TONE_MAPPING":"",i.toneMapping!==re?En.tonemapping_pars_fragment:"",i.toneMapping!==re?Ji("toneMapping",i.toneMapping):"",i.outputEncoding||i.mapEncoding||i.envMapEncoding||i.emissiveMapEncoding?En.encodings_pars_fragment:"",i.mapEncoding?Zi("mapTexelToLinear",i.mapEncoding):"",i.envMapEncoding?Zi("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMapEncoding?Zi("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.outputEncoding?(y="linearToOutputTexel",v=i.outputEncoding,b=Ki(v),"vec4 "+y+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"):"",i.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter($i).join("\n")),s=Qi(s=er(s),i),l=Qi(l=er(l),i),n.isShaderMaterial||(s=tr(s),l=tr(l));var S=p+s,E=f+l,T=Hi(r,r.VERTEX_SHADER,S),C=Hi(r,r.FRAGMENT_SHADER,E);r.attachShader(M,T),r.attachShader(M,C),void 0!==n.index0AttributeName?r.bindAttribLocation(M,0,n.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(M,0,"position"),r.linkProgram(M);var O,k,P=r.getProgramInfoLog(M),A=r.getShaderInfoLog(T),R=r.getShaderInfoLog(C),L=!0,I=!0;return!1===r.getProgramParameter(M,r.LINK_STATUS)?(L=!1,console.error("THREE.WebGLProgram: shader error: ",r.getError(),"gl.VALIDATE_STATUS",r.getProgramParameter(M,r.VALIDATE_STATUS),"gl.getProgramInfoLog",P,A,R)):""!==P?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",P):""!==A&&""!==R||(I=!1),I&&(this.diagnostics={runnable:L,material:n,programLog:P,vertexShader:{log:A,prefix:p},fragmentShader:{log:R,prefix:f}}),r.deleteShader(T),r.deleteShader(C),this.getUniforms=function(){return void 0===O&&(O=new Mn(r,M,e)),O},this.getAttributes=function(){return void 0===k&&(k=function(e,t,n){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),o=0;o0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:n.premultipliedAlpha,alphaTest:n.alphaTest,doubleSided:n.side===b,flipSided:n.side===v,depthPacking:void 0!==n.depthPacking&&n.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 i in e.defines)n.push(i),n.push(e.defines[i]);for(var o=0;o65535?Si:wi)(a,1);return r(f,e.ELEMENT_ARRAY_BUFFER),i.wireframe=f,f},update:function(t){var n=i.get(t);t.geometry.isGeometry&&n.updateFromObject(t);var o=n.index,a=n.attributes;for(var s in null!==o&&r(o,e.ELEMENT_ARRAY_BUFFER),a)r(a[s],e.ARRAY_BUFFER);var l=n.morphAttributes;for(var s in l)for(var u=l[s],c=0,d=u.length;ct||e.height>t){var n=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*n),i.height=Math.floor(e.height*n),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}function c(e){return Mt.isPowerOfTwo(e.width)&&Mt.isPowerOfTwo(e.height)}function d(t){return t===_e||t===xe||t===we?e.NEAREST:e.LINEAR}function h(t){var n=t.target;n.removeEventListener("dispose",h),function(t){var n=i.get(t);if(t.image&&n.__image__webglTextureCube)e.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture)}i.delete(t)}(n),s.textures--}function p(t){var n=t.target;n.removeEventListener("dispose",p),function(t){var n=i.get(t),r=i.get(t.texture);if(!t)return;void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(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);i.delete(t.texture),i.delete(t)}(n),s.textures--}function f(t,a){var d=i.get(t);if(t.version>0&&d.__version!==t.version){var p=t.image;if(void 0===p)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==p.complete)return void function(t,i,a){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",h),t.__webglTexture=e.createTexture(),s.textures++);n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var d=u(i.image,r.maxTextureSize);(function(e){return e.wrapS!==ve||e.wrapT!==ve||e.minFilter!==_e&&e.minFilter!==Me})(i)&&!1===c(d)&&(d=function(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=Mt.nearestPowerOfTwo(e.width),t.height=Mt.nearestPowerOfTwo(e.height),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}(d));var p=c(d),f=o(i.format),g=o(i.type);m(e.TEXTURE_2D,i,p);var y,v=i.mipmaps;if(i.isDepthTexture){var b=e.DEPTH_COMPONENT;if(i.type===Re){if(!l)throw new Error("Float Depth Texture only supported in WebGL2.0");b=e.DEPTH_COMPONENT32F}else l&&(b=e.DEPTH_COMPONENT16);i.format===Ve&&b===e.DEPTH_COMPONENT&&i.type!==ke&&i.type!==Ae&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=ke,g=o(i.type)),i.format===He&&(b=e.DEPTH_STENCIL,i.type!==Fe&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=Fe,g=o(i.type))),n.texImage2D(e.TEXTURE_2D,0,b,d.width,d.height,0,f,g,null)}else if(i.isDataTexture)if(v.length>0&&p){for(var _=0,x=v.length;_-1?n.compressedTexImage2D(e.TEXTURE_2D,_,f,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(e.TEXTURE_2D,_,f,y.width,y.height,0,f,g,y.data);else if(v.length>0&&p){for(_=0,x=v.length;_1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,l.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function g(t,r,a,s){var l=o(r.texture.format),u=o(r.texture.type);n.texImage2D(s,0,l,r.width,r.height,0,l,u,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,a,s,i.get(r.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function y(t,n){e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):n.depthBuffer&&n.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}function v(t){var n=i.get(t),r=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported!");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!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),f(n.depthTexture,0);var r=i.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===Ve)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,r,0);else{if(n.depthTexture.format!==He)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,r,0)}}(n.__webglFramebuffer,t)}else if(r){n.__webglDepthbuffer=[];for(var o=0;o<6;o++)e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=e.createRenderbuffer(),y(n.__webglDepthbuffer[o],t)}else e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),y(n.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}this.setTexture2D=f,this.setTextureCube=function(t,a){var l=i.get(t);if(6===t.image.length)if(t.version>0&&l.__version!==t.version){l.__image__webglTextureCube||(t.addEventListener("dispose",h),l.__image__webglTextureCube=e.createTexture(),s.textures++),n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,l.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var d=t&&t.isCompressedTexture,p=t.image[0]&&t.image[0].isDataTexture,f=[],g=0;g<6;g++)f[g]=d||p?p?t.image[g].image:t.image[g]:u(t.image[g],r.maxCubemapSize);var y=c(f[0]),v=o(t.format),b=o(t.type);m(e.TEXTURE_CUBE_MAP,t,y);for(g=0;g<6;g++)if(d)for(var _,x=f[g].mipmaps,w=0,M=x.length;w-1?n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,w,v,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,w,v,_.width,_.height,0,v,b,_.data);else p?n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,v,f[g].width,f[g].height,0,v,b,f[g].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,v,v,b,f[g]);t.generateMipmaps&&y&&e.generateMipmap(e.TEXTURE_CUBE_MAP),l.__version=t.version,t.onUpdate&&t.onUpdate(t)}else n.activeTexture(e.TEXTURE0+a),n.bindTexture(e.TEXTURE_CUBE_MAP,l.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,r){n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)},this.setupRenderTarget=function(t){var r=i.get(t),o=i.get(t.texture);t.addEventListener("dispose",p),o.__webglTexture=e.createTexture(),s.textures++;var a=!0===t.isWebGLRenderTargetCube,l=c(t);if(a){r.__webglFramebuffer=[];for(var u=0;u<6;u++)r.__webglFramebuffer[u]=e.createFramebuffer()}else r.__webglFramebuffer=e.createFramebuffer();if(a){n.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture),m(e.TEXTURE_CUBE_MAP,t.texture,l);for(u=0;u<6;u++)g(r.__webglFramebuffer[u],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+u);t.texture.generateMipmaps&&l&&e.generateMipmap(e.TEXTURE_CUBE_MAP),n.bindTexture(e.TEXTURE_CUBE_MAP,null)}else n.bindTexture(e.TEXTURE_2D,o.__webglTexture),m(e.TEXTURE_2D,t.texture,l),g(r.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),t.texture.generateMipmaps&&l&&e.generateMipmap(e.TEXTURE_2D),n.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&v(t)},this.updateRenderTargetMipmap=function(t){var r=t.texture;if(r.generateMipmaps&&c(t)&&r.minFilter!==_e&&r.minFilter!==Me){var o=t&&t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=i.get(r).__webglTexture;n.bindTexture(o,a),e.generateMipmap(o),n.bindTexture(o,null)}}}function sr(){var e={};return{get:function(t){var n=t.uuid,i=e[n];return void 0===i&&(i={},e[n]=i),i},delete:function(t){delete e[t.uuid]},clear:function(){e={}}}}function lr(e,t,n){var i=new function(){var t=!1,n=new Lt,i=null,r=new Lt;return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,o,a,s){!0===s&&(t*=a,i*=a,o*=a),n.set(t,i,o,a),!1===r.equals(n)&&(e.clearColor(t,i,o,a),r.copy(n))},reset:function(){t=!1,i=null,r.set(0,0,0,1)}}},r=new function(){var t=!1,n=null,i=null,r=null;return{setTest:function(t){t?V(e.DEPTH_TEST):H(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){if(t)switch(t){case q:e.depthFunc(e.NEVER);break;case X:e.depthFunc(e.ALWAYS);break;case K:e.depthFunc(e.LESS);break;case Z:e.depthFunc(e.LEQUAL);break;case J:e.depthFunc(e.EQUAL);break;case $:e.depthFunc(e.GEQUAL);break;case Q:e.depthFunc(e.GREATER);break;case ee:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}},o=new function(){var t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,u=null;return{setTest:function(t){t?V(e.STENCIL_TEST):H(e.STENCIL_TEST)},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&r===n&&o===a||(e.stencilFunc(t,n,a),i=t,r=n,o=a)},setOp:function(t,n,i){a===t&&s===n&&l===i||(e.stencilOp(t,n,i),a=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){u!==t&&(e.clearStencil(t),u=t)},reset:function(){t=!1,n=null,i=null,r=null,o=null,a=null,s=null,l=null,u=null}}},a=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),d=new Uint8Array(a),h=new Uint8Array(a),p={},f=null,m=null,g=null,y=null,v=null,b=null,_=null,x=null,w=!1,M=null,S=null,A=null,R=null,L=null,I=null,D=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),N=parseFloat(/^WebGL\ ([0-9])/.exec(e.getParameter(e.VERSION))[1]),F=parseFloat(N)>=1,z=null,B={},U=new Lt,j=new Lt;function W(t,n,i){var r=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var a=0;a0&&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=void 0!==n.precision?n.precision:"highp",a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===n.logarithmicDepthBuffer&&!!t.get("EXT_frag_depth"),l=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),c=e.getParameter(e.MAX_TEXTURE_SIZE),d=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),h=e.getParameter(e.MAX_VERTEX_ATTRIBS),p=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),f=e.getParameter(e.MAX_VARYING_VECTORS),m=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),g=u>0,y=!!t.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var n=t.get("EXT_texture_filter_anisotropic");return i=null!==n?e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:s,maxTextures:l,maxVertexTextures:u,maxTextureSize:c,maxCubemapSize:d,maxAttributes:h,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y}}function cr(e){var t={};return{get:function(n){if(void 0!==t[n])return t[n];var i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":i=e.getExtension("WEBGL_compressed_texture_etc1");break;default:i=e.getExtension(n)}return null===i&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),t[n]=i,i}}}function dr(){var e=this,t=null,n=0,i=!1,r=!1,o=new $n,a=new Jn,s={value:null,needsUpdate:!1};function l(){s.value!==t&&(s.value=t,s.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(t,n,i,r){var l=null!==t?t.length:0,u=null;if(0!==l){if(u=s.value,!0!==r||null===u){var c=i+4*l,d=n.matrixWorldInverse;a.getNormalMatrix(d),(null===u||u.length=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(c=0;c=0&&e.numSupportedMorphNormals++}var d=i.__webglShader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=le.numPlanes,i.numIntersection=le.numIntersection,d.clippingPlanes=le.uniform),i.fog=t,i.lightsHash=ge.hash,e.lights&&(d.ambientLightColor.value=ge.ambient,d.directionalLights.value=ge.directional,d.spotLights.value=ge.spot,d.rectAreaLights.value=ge.rectArea,d.pointLights.value=ge.point,d.hemisphereLights.value=ge.hemi,d.directionalShadowMap.value=ge.directionalShadowMap,d.directionalShadowMatrix.value=ge.directionalShadowMatrix,d.spotShadowMap.value=ge.spotShadowMap,d.spotShadowMatrix.value=ge.spotShadowMatrix,d.pointShadowMap.value=ge.pointShadowMap,d.pointShadowMatrix.value=ge.pointShadowMatrix);var h=i.program.getUniforms(),p=Mn.seqWithValue(h.seq,d);i.uniformsList=p}(n,t,i),n.needsUpdate=!1);var a,s,l=!1,u=!1,c=!1,d=r.program,h=d.getUniforms(),p=r.__webglShader.uniforms;if(d.id!==T&&(M.useProgram(d.program),T=d.id,l=!0,u=!0,c=!0),n.id!==k&&(k=n.id,u=!0),l||e!==q){if(h.set(M,e,"projectionMatrix"),it.logarithmicDepthBuffer&&h.setValue(M,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),e!==q&&(q=e,u=!0,c=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var f=h.map.cameraPosition;void 0!==f&&f.setValue(M,pe.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&h.setValue(M,"viewMatrix",e.matrixWorldInverse),h.set(M,S,"toneMappingExposure"),h.set(M,S,"toneMappingWhitePoint")}if(n.skinning){h.setOptional(M,i,"bindMatrix"),h.setOptional(M,i,"bindMatrixInverse");var m=i.skeleton;m&&(it.floatVertexTextures&&m.useVertexTexture?(h.set(M,m,"boneTexture"),h.set(M,m,"boneTextureWidth"),h.set(M,m,"boneTextureHeight")):h.setOptional(M,m,"boneMatrices"))}return u&&(n.lights&&(s=c,(a=p).ambientLightColor.needsUpdate=s,a.directionalLights.needsUpdate=s,a.pointLights.needsUpdate=s,a.spotLights.needsUpdate=s,a.rectAreaLights.needsUpdate=s,a.hemisphereLights.needsUpdate=s),t&&n.fog&&function(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)}(p,t),(n.isMeshBasicMaterial||n.isMeshLambertMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.isMeshNormalMaterial||n.isMeshDepthMaterial)&&function(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;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);if(void 0!==n){n.isWebGLRenderTarget&&(n=n.texture);var i=n.offset,r=n.repeat;e.offsetRepeat.value.set(i.x,i.y,r.x,r.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}(p,n),n.isLineBasicMaterial?Ut(p,n):n.isLineDashedMaterial?(Ut(p,n),function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(p,n)):n.isPointsMaterial?function(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*ne,e.scale.value=.5*te,e.map.value=t.map,null!==t.map){var n=t.map.offset,i=t.map.repeat;e.offsetRepeat.value.set(n.x,n.y,i.x,i.y)}}(p,n):n.isMeshLambertMaterial?function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(p,n):n.isMeshToonMaterial?function(e,t){jt(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(p,n):n.isMeshPhongMaterial?jt(p,n):n.isMeshPhysicalMaterial?function(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,Wt(e,t)}(p,n):n.isMeshStandardMaterial?Wt(p,n):n.isMeshDepthMaterial?n.displacementMap&&(p.displacementMap.value=n.displacementMap,p.displacementScale.value=n.displacementScale,p.displacementBias.value=n.displacementBias):n.isMeshNormalMaterial&&function(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)}(p,n),void 0!==p.ltcMat&&(p.ltcMat.value=THREE.UniformsLib.LTC_MAT_TEXTURE),void 0!==p.ltcMag&&(p.ltcMag.value=THREE.UniformsLib.LTC_MAG_TEXTURE),Mn.upload(M,r.uniformsList,p,S)),h.set(M,i,"modelViewMatrix"),h.set(M,i,"normalMatrix"),h.setValue(M,"modelMatrix",i.matrixWorld),d}function Ut(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function jt(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 Wt(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 Gt(e){var t;if(e===ye)return M.REPEAT;if(e===ve)return M.CLAMP_TO_EDGE;if(e===be)return M.MIRRORED_REPEAT;if(e===_e)return M.NEAREST;if(e===xe)return M.NEAREST_MIPMAP_NEAREST;if(e===we)return M.NEAREST_MIPMAP_LINEAR;if(e===Me)return M.LINEAR;if(e===Se)return M.LINEAR_MIPMAP_NEAREST;if(e===Ee)return M.LINEAR_MIPMAP_LINEAR;if(e===Te)return M.UNSIGNED_BYTE;if(e===Ie)return M.UNSIGNED_SHORT_4_4_4_4;if(e===De)return M.UNSIGNED_SHORT_5_5_5_1;if(e===Ne)return M.UNSIGNED_SHORT_5_6_5;if(e===Ce)return M.BYTE;if(e===Oe)return M.SHORT;if(e===ke)return M.UNSIGNED_SHORT;if(e===Pe)return M.INT;if(e===Ae)return M.UNSIGNED_INT;if(e===Re)return M.FLOAT;if(e===Le&&null!==(t=nt.get("OES_texture_half_float")))return t.HALF_FLOAT_OES;if(e===ze)return M.ALPHA;if(e===Be)return M.RGB;if(e===Ue)return M.RGBA;if(e===je)return M.LUMINANCE;if(e===We)return M.LUMINANCE_ALPHA;if(e===Ve)return M.DEPTH_COMPONENT;if(e===He)return M.DEPTH_STENCIL;if(e===A)return M.FUNC_ADD;if(e===R)return M.FUNC_SUBTRACT;if(e===L)return M.FUNC_REVERSE_SUBTRACT;if(e===N)return M.ZERO;if(e===F)return M.ONE;if(e===z)return M.SRC_COLOR;if(e===B)return M.ONE_MINUS_SRC_COLOR;if(e===U)return M.SRC_ALPHA;if(e===j)return M.ONE_MINUS_SRC_ALPHA;if(e===W)return M.DST_ALPHA;if(e===G)return M.ONE_MINUS_DST_ALPHA;if(e===V)return M.DST_COLOR;if(e===H)return M.ONE_MINUS_DST_COLOR;if(e===Y)return M.SRC_ALPHA_SATURATE;if((e===Ye||e===qe||e===Xe||e===Ke)&&null!==(t=nt.get("WEBGL_compressed_texture_s3tc"))){if(e===Ye)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===qe)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===Xe)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Ke)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((e===Ze||e===Je||e===$e||e===Qe)&&null!==(t=nt.get("WEBGL_compressed_texture_pvrtc"))){if(e===Ze)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Je)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===$e)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===Qe)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===et&&null!==(t=nt.get("WEBGL_compressed_texture_etc1")))return t.COMPRESSED_RGB_ETC1_WEBGL;if((e===I||e===D)&&null!==(t=nt.get("EXT_blend_minmax"))){if(e===I)return t.MIN_EXT;if(e===D)return t.MAX_EXT}return e===Fe&&null!==(t=nt.get("WEBGL_depth_texture"))?t.UNSIGNED_INT_24_8_WEBGL:0}this.getContext=function(){return M},this.getContextAttributes=function(){return M.getContextAttributes()},this.forceContextLoss=function(){nt.get("WEBGL_lose_context").loseContext()},this.getMaxAnisotropy=function(){return it.getMaxAnisotropy()},this.getPrecision=function(){return it.precision},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(e){void 0!==e&&(ne=e,this.setSize(ae.z,ae.w,!1))},this.getSize=function(){return{width:ee,height:te}},this.setSize=function(e,n,i){ee=e,te=n,t.width=e*ne,t.height=n*ne,!1!==i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n)},this.setViewport=function(e,t,n,i){rt.viewport(ae.set(e,t,n,i))},this.setScissor=function(e,t,n,i){rt.scissor(ie.set(e,t,n,i))},this.setScissorTest=function(e){rt.setScissorTest(re=e)},this.getClearColor=function(){return $},this.setClearColor=function(e,t){$.set(e),Q=void 0!==t?t:1,rt.buffers.color.setClear($.r,$.g,$.b,Q,l)},this.getClearAlpha=function(){return Q},this.setClearAlpha=function(e){Q=e,rt.buffers.color.setClear($.r,$.g,$.b,Q,l)},this.clear=function(e,t,n){var i=0;(void 0===e||e)&&(i|=M.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=M.DEPTH_BUFFER_BIT),(void 0===n||n)&&(i|=M.STENCIL_BUFFER_BIT),M.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(e,t,n,i){this.setRenderTarget(e),this.clear(t,n,i)},this.resetGLState=xt,this.dispose=function(){f=[],m=-1,d=[],p=-1,t.removeEventListener("webglcontextlost",Tt,!1)},this.renderBufferImmediate=function(e,t,n){rt.initAttributes();var i=ot.get(e);e.hasPositions&&!i.position&&(i.position=M.createBuffer()),e.hasNormals&&!i.normal&&(i.normal=M.createBuffer()),e.hasUvs&&!i.uv&&(i.uv=M.createBuffer()),e.hasColors&&!i.color&&(i.color=M.createBuffer());var r=t.getAttributes();if(e.hasPositions&&(M.bindBuffer(M.ARRAY_BUFFER,i.position),M.bufferData(M.ARRAY_BUFFER,e.positionArray,M.DYNAMIC_DRAW),rt.enableAttribute(r.position),M.vertexAttribPointer(r.position,3,M.FLOAT,!1,0,0)),e.hasNormals){if(M.bindBuffer(M.ARRAY_BUFFER,i.normal),!n.isMeshPhongMaterial&&!n.isMeshStandardMaterial&&!n.isMeshNormalMaterial&&n.shading===_)for(var o=0,a=3*e.count;o8&&(c.length=8);var f=n.morphAttributes;for(d=0,h=c.length;d=0){var c=o[l];if(void 0!==c){var d=c.normalized,h=c.itemSize,p=st.getAttributeProperties(c),f=p.__webglBuffer,m=p.type,g=p.bytesPerElement;if(c.isInterleavedBufferAttribute){var y=c.data,v=y.stride,b=c.offset;y&&y.isInstancedInterleavedBuffer?(rt.enableAttributeAndDivisor(u,y.meshPerAttribute,r),void 0===n.maxInstancedCount&&(n.maxInstancedCount=y.meshPerAttribute*y.count)):rt.enableAttribute(u),M.bindBuffer(M.ARRAY_BUFFER,f),M.vertexAttribPointer(u,h,m,d,v*g,(i*v+b)*g)}else c.isInstancedBufferAttribute?(rt.enableAttributeAndDivisor(u,c.meshPerAttribute,r),void 0===n.maxInstancedCount&&(n.maxInstancedCount=c.meshPerAttribute*c.count)):rt.enableAttribute(u),M.bindBuffer(M.ARRAY_BUFFER,f),M.vertexAttribPointer(u,h,m,d,0,i*h*g)}else if(void 0!==s){var _=s[l];if(void 0!==_)switch(_.length){case 2:M.vertexAttrib2fv(u,_);break;case 3:M.vertexAttrib3fv(u,_);break;case 4:M.vertexAttrib4fv(u,_);break;default:M.vertexAttrib1fv(u,_)}}}}rt.disableUnusedAttributes()}(i,a,n),null!==m&&M.bindBuffer(M.ELEMENT_ARRAY_BUFFER,st.getAttributeBuffer(m)));var x=0;null!==m?x=m.count:void 0!==b&&(x=b.count);var w=n.drawRange.start*_,S=n.drawRange.count*_,E=null!==o?o.start*_:0,T=null!==o?o.count*_:1/0,C=Math.max(w,E),O=Math.min(x,w+S,E+T)-1,k=Math.max(0,O-C+1);if(0!==k){if(r.isMesh)if(!0===i.wireframe)rt.setLineWidth(i.wireframeLinewidth*bt()),v.setMode(M.LINES);else switch(r.drawMode){case ct:v.setMode(M.TRIANGLES);break;case dt:v.setMode(M.TRIANGLE_STRIP);break;case ht:v.setMode(M.TRIANGLE_FAN)}else if(r.isLine){var A=i.linewidth;void 0===A&&(A=1),rt.setLineWidth(A*bt()),r.isLineSegments?v.setMode(M.LINES):v.setMode(M.LINE_STRIP)}else r.isPoints&&v.setMode(M.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&v.renderInstances(n,C,k):v.render(C,k)}},this.render=function(e,t,n,i){if(void 0===t||!0===t.isCamera){P="",k=-1,q=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),t.matrixWorldInverse.getInverse(t.matrixWorld),he.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),se.setFromMatrix(he),c.length=0,p=-1,m=-1,y.length=0,x.length=0,ce=this.localClippingEnabled,ue=le.init(this.clippingPlanes,ce,t),function e(t,n){if(!1===t.visible)return;var i=0!=(t.layers.mask&n.layers.mask);if(i)if(t.isLight)c.push(t);else if(t.isSprite)!1!==t.frustumCulled&&!0!==(p=t,de.center.set(0,0,0),de.radius=.7071067811865476,de.applyMatrix4(p.matrixWorld),It(de))||y.push(t);else if(t.isLensFlare)x.push(t);else if(t.isImmediateRenderObject)!0===S.sortObjects&&(pe.setFromMatrixPosition(t.matrixWorld),pe.applyMatrix4(he)),Rt(t,null,t.material,pe.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!1===t.frustumCulled||!0===function(e){var t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere();return de.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),It(de)}(t))){var r=t.material;if(!0===r.visible){!0===S.sortObjects&&(pe.setFromMatrixPosition(t.matrixWorld),pe.applyMatrix4(he));var o=st.update(t);if(r.isMultiMaterial)for(var a=o.groups,s=r.materials,l=0,u=a.length;l=it.maxTextures&&console.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+it.maxTextures),J+=1,e},this.setTexture2D=(Mt=!1,function(e,t){e&&e.isWebGLRenderTarget&&(Mt||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Mt=!0),e=e.texture),at.setTexture2D(e,t)}),this.setTexture=function(){var e=!1;return function(t,n){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),at.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?at.setTextureCube(t,n):at.setTextureCubeDynamic(t,n)}}(),this.getCurrentRenderTarget=function(){return C},this.setRenderTarget=function(e){C=e,e&&void 0===ot.get(e).__webglFramebuffer&&at.setupRenderTarget(e);var t,n=e&&e.isWebGLRenderTargetCube;if(e){var i=ot.get(e);t=n?i.__webglFramebuffer[e.activeCubeFace]:i.__webglFramebuffer,X.copy(e.scissor),K=e.scissorTest,Z.copy(e.viewport)}else t=null,X.copy(ie).multiplyScalar(ne),K=re,Z.copy(ae).multiplyScalar(ne);if(O!==t&&(M.bindFramebuffer(M.FRAMEBUFFER,t),O=t),rt.scissor(X),rt.setScissorTest(K),rt.viewport(Z),n){var r=ot.get(e.texture);M.framebufferTexture2D(M.FRAMEBUFFER,M.COLOR_ATTACHMENT0,M.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,r.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,n,i,r,o){if(!1!==(e&&e.isWebGLRenderTarget)){var a=ot.get(e).__webglFramebuffer;if(a){var s=!1;a!==O&&(M.bindFramebuffer(M.FRAMEBUFFER,a),s=!0);try{var l=e.texture,u=l.format,c=l.type;if(u!==Ue&&Gt(u)!==M.getParameter(M.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(c===Te||Gt(c)===M.getParameter(M.IMPLEMENTATION_COLOR_READ_TYPE)||c===Re&&(nt.get("OES_texture_float")||nt.get("WEBGL_color_buffer_float"))||c===Le&&nt.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");M.checkFramebufferStatus(M.FRAMEBUFFER)===M.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&M.readPixels(t,n,i,r,Gt(u),Gt(c),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&M.bindFramebuffer(M.FRAMEBUFFER,O)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function pr(e,t){this.name="",this.color=new Tn(e),this.density=void 0!==t?t:25e-5}function fr(e,t,n){this.name="",this.color=new Tn(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function mr(){hi.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function gr(e,t,n,i,r){hi.call(this),this.lensFlares=[],this.positionScreen=new Ft,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,n,i,r)}function yr(e){Yn.call(this),this.type="SpriteMaterial",this.color=new Tn(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function vr(e){hi.call(this),this.type="Sprite",this.material=void 0!==e?e:new yr}function br(){hi.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function _r(e,t,n){if(this.useVertexTexture=void 0===n||n,this.identityMatrix=new zt,e=e||[],this.bones=e.slice(0),this.useVertexTexture){var i=Math.sqrt(4*this.bones.length);i=Mt.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 On(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,Ue,Re)}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 r=0,o=this.bones.length;r=e.HAVE_CURRENT_DATA&&(u.needsUpdate=!0)}()}function Pr(e,t,n,i,r,o,a,s,l,u,c,d){Rt.call(this,null,o,a,s,l,u,i,r,c,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Ar(e,t,n,i,r,o,a,s,l){Rt.call(this,e,t,n,i,r,o,a,s,l),this.needsUpdate=!0}function Rr(e,t,n,i,r,o,a,s,l,u){if((u=void 0!==u?u:Ve)!==Ve&&u!==He)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&u===Ve&&(n=ke),void 0===n&&u===He&&(n=Fe),Rt.call(this,null,i,r,o,a,s,u,n,l),this.image={width:e,height:t},this.magFilter=void 0!==a?a:_e,this.minFilter=void 0!==s?s:_e,this.flipY=!1,this.generateMipmaps=!1}function Lr(e){Li.call(this),this.type="WireframeGeometry";var t,n,i,r,o,a,s,l,u=[],c=[0,0],d={},h=["a","b","c"];if(e&&e.isGeometry){var p=e.faces;for(t=0,i=p.length;t.9&&a<.1&&(t<.2&&(o[e+0]+=1),n<.2&&(o[e+2]+=1),i<.2&&(o[e+4]+=1))}}()}(),this.addAttribute("position",new Ei(r,3)),this.addAttribute("normal",new Ei(r.slice(),3)),this.addAttribute("uv",new Ei(o,2)),this.normalizeNormals()}function zr(e,t){Ri.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Br(e,t)),this.mergeVertices()}function Br(e,t){Fr.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Ur(e,t){Ri.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new jr(e,t)),this.mergeVertices()}function jr(e,t){Fr.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Wr(e,t){Ri.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Gr(e,t)),this.mergeVertices()}function Gr(e,t){var n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];Fr.call(this,i,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Vr(e,t){Ri.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Hr(e,t)),this.mergeVertices()}function Hr(e,t){var n=(1+Math.sqrt(5))/2,i=1/n,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i];Fr.call(this,r,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Yr(e,t,n,i,r,o){Ri.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new qr(e,t,n,i,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function qr(e,t,n,i,r){Li.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r},t=t||64,n=n||1,i=i||8,r=r||!1;var o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,l=new Ft,u=new Ft,c=new St,d=[],h=[],p=[],f=[];function m(r){var a=e.getPointAt(r/t),c=o.normals[r],p=o.binormals[r];for(s=0;s<=i;s++){var f=s/i*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);u.x=g*c.x+m*p.x,u.y=g*c.y+m*p.y,u.z=g*c.z+m*p.z,u.normalize(),h.push(u.x,u.y,u.z),l.x=a.x+n*u.x,l.y=a.y+n*u.y,l.z=a.z+n*u.z,d.push(l.x,l.y,l.z)}}!function(){for(a=0;athis.scale.x*this.scale.y/4||t.push({distance:Math.sqrt(n),point:this.position,face:null,object:this})}),clone:function(){return new this.constructor(this.material).copy(this)}}),br.prototype=Object.assign(Object.create(hi.prototype),{constructor:br,copy:function(e){hi.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,i=t.length;n1){e.setFromMatrixPosition(n.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var r=e.distanceTo(t);i[0].object.visible=!0;for(var o=1,a=i.length;o=i[o].distance;o++)i[o-1].object.visible=!1,i[o].object.visible=!0;for(;oa))h.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(h))i.far||r.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}else for(y=0,v=m.length/3-1;ya))h.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(h))i.far||r.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var x=s.vertices,w=x.length;for(y=0;ya))h.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(h))i.far||r.push({distance:M,point:d.clone().applyMatrix4(this.matrixWorld),index:y,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Er.prototype=Object.assign(Object.create(Sr.prototype),{constructor:Er,isLineSegments:!0}),Tr.prototype=Object.create(Yn.prototype),Tr.prototype.constructor=Tr,Tr.prototype.isPointsMaterial=!0,Tr.prototype.copy=function(e){return Yn.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},Cr.prototype=Object.assign(Object.create(hi.prototype),{constructor:Cr,isPoints:!0,raycast:function(){var e=new zt,t=new ti,n=new Zn;return function(i,r){var o=this,a=this.geometry,s=this.matrixWorld,l=i.params.Points.threshold;if(null===a.boundingSphere&&a.computeBoundingSphere(),n.copy(a.boundingSphere),n.applyMatrix4(s),!1!==i.ray.intersectsSphere(n)){e.getInverse(s),t.copy(i.ray).applyMatrix4(e);var u=l/((this.scale.x+this.scale.y+this.scale.z)/3),c=u*u,d=new Ft;if(a.isBufferGeometry){var h=a.index,p=a.attributes.position.array;if(null!==h)for(var f=h.array,m=0,g=f.length;mi.far)return;r.push({distance:u,distanceToRay:Math.sqrt(a),point:l.clone(),index:n,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Or.prototype=Object.assign(Object.create(hi.prototype),{constructor:Or}),kr.prototype=Object.create(Rt.prototype),kr.prototype.constructor=kr,Pr.prototype=Object.create(Rt.prototype),Pr.prototype.constructor=Pr,Pr.prototype.isCompressedTexture=!0,Ar.prototype=Object.create(Rt.prototype),Ar.prototype.constructor=Ar,Rr.prototype=Object.create(Rt.prototype),Rr.prototype.constructor=Rr,Rr.prototype.isDepthTexture=!0,Lr.prototype=Object.create(Li.prototype),Lr.prototype.constructor=Lr,Ir.prototype=Object.create(Ri.prototype),Ir.prototype.constructor=Ir,Dr.prototype=Object.create(Li.prototype),Dr.prototype.constructor=Dr,Nr.prototype=Object.create(Ri.prototype),Nr.prototype.constructor=Nr,Fr.prototype=Object.create(Li.prototype),Fr.prototype.constructor=Fr,zr.prototype=Object.create(Ri.prototype),zr.prototype.constructor=zr,Br.prototype=Object.create(Fr.prototype),Br.prototype.constructor=Br,Ur.prototype=Object.create(Ri.prototype),Ur.prototype.constructor=Ur,jr.prototype=Object.create(Fr.prototype),jr.prototype.constructor=jr,Wr.prototype=Object.create(Ri.prototype),Wr.prototype.constructor=Wr,Gr.prototype=Object.create(Fr.prototype),Gr.prototype.constructor=Gr,Vr.prototype=Object.create(Ri.prototype),Vr.prototype.constructor=Vr,Hr.prototype=Object.create(Fr.prototype),Hr.prototype.constructor=Hr,Yr.prototype=Object.create(Ri.prototype),Yr.prototype.constructor=Yr,qr.prototype=Object.create(Li.prototype),qr.prototype.constructor=qr,Xr.prototype=Object.create(Ri.prototype),Xr.prototype.constructor=Xr,Kr.prototype=Object.create(Li.prototype),Kr.prototype.constructor=Kr,Zr.prototype=Object.create(Ri.prototype),Zr.prototype.constructor=Zr,Jr.prototype=Object.create(Li.prototype),Jr.prototype.constructor=Jr;var $r={area:function(e){for(var t=e.length,n=0,i=t-1,r=0;r=-Number.EPSILON&&w>=-Number.EPSILON&&x>=-Number.EPSILON))return!1;return!0}return function(t,n){var i=t.length;if(i<3)return null;var r,o,a,s=[],l=[],u=[];if($r.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(c<=(r=o)&&(r=0),c<=(o=r+1)&&(o=0),c<=(a=o+1)&&(a=0),e(t,r,o,a,c,l)){var h,p,f,m,g;for(h=l[r],p=l[o],f=l[a],s.push([t[h],t[p],t[f]]),u.push([l[r],l[o],l[a]]),m=o,g=o+1;g2&&e[t-1].equals(e[0])&&e.pop()}function i(e,t,n){return e.x!==t.x?e.xNumber.EPSILON){var f;if(h>0){if(p<0||p>h)return[];if((f=u*c-l*d)<0||f>h)return[]}else{if(p>0||p0||fM?[]:v===M?o?[]:[g]:b<=M?[g,y]:[g,x])}function o(e,t,n,i){var r=t.x-e.x,o=t.y-e.y,a=n.x-e.x,s=n.y-e.y,l=i.x-e.x,u=i.y-e.y,c=r*s-o*a,d=r*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={},p=e.concat(),f=0,m=t.length;fr&&(s=0);var l=o(i[e],i[a],i[s],n[t]);if(!l)return!1;var u=n.length-1,c=t-1;c<0&&(c=u);var d=t+1;return d>u&&(d=0),!!(l=o(n[t],n[c],n[d],i[e]))}function s(e,t){var n,o;for(n=0;n0)return!0;return!1}var l=[];function u(e,n){var i,o,a,s;for(i=0;i0)return!0;return!1}for(var c,d,h,p,f,m,g,y,v,b,_=[],x=0,w=t.length;x0;){if(--S<0){console.log("Infinite Loop! Holes left:"+l.length+", Probably Hole outside Shape!");break}for(d=M;d=0)break;_[m]=!0}if(c>=0)break}}return i}(e,t),y=$r.triangulate(g,!1);for(a=0,s=y.length;a0)&&f.push(x,w,S),(l!==n-1||u0&&y(!0),t>0&&y(!1)),this.setIndex(u),this.addAttribute("position",new Ei(c,3)),this.addAttribute("normal",new Ei(d,3)),this.addAttribute("uv",new Ei(h,2))}function po(e,t,n,i,r,o,a){co.call(this,0,e,t,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}function fo(e,t,n,i,r,o,a){ho.call(this,0,e,t,n,i,r,o,a),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}function mo(e,t,n,i){Ri.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new go(e,t,n,i))}function go(e,t,n,i){Li.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},e=e||50,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var r,o,a=[],s=[],l=[],u=[],c=new Ft,d=new St;for(s.push(0,0,0),l.push(0,0,1),u.push(.5,.5),o=0,r=3;o<=t;o++,r+=3){var h=n+o/t*i;c.x=e*Math.cos(h),c.y=e*Math.sin(h),s.push(c.x,c.y,c.z),l.push(0,0,1),d.x=(s[r]/e+1)/2,d.y=(s[r+1]/e+1)/2,u.push(d.x,d.y)}for(r=1;r<=t;r++)a.push(r,r+1,0);this.setIndex(a),this.addAttribute("position",new Ei(s,3)),this.addAttribute("normal",new Ei(l,3)),this.addAttribute("uv",new Ei(u,2))}Qr.prototype=Object.create(Ri.prototype),Qr.prototype.constructor=Qr,Qr.prototype.addShapeList=function(e,t){for(var n=e.length,i=0;iNumber.EPSILON){var h=Math.sqrt(c),p=Math.sqrt(l*l+u*u),f=t.x-s/h,m=t.y+a/h,g=((n.x-u/p-f)*u-(n.y+l/p-m)*l)/(a*u-s*l),y=(i=f+a*g-e.x)*i+(r=m+s*g-e.y)*r;if(y<=2)return new St(i,r);o=Math.sqrt(y/2)}else{var v=!1;a>Number.EPSILON?l>Number.EPSILON&&(v=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(v=!0):Math.sign(s)===Math.sign(u)&&(v=!0),v?(i=-s,r=a,o=Math.sqrt(c)):(i=a,r=s,o=Math.sqrt(c/2))}return new St(i/o,r/o)}for(var z=[],B=0,U=C.length,j=U-1,W=B+1;B=0;k--){for(A=k/p,R=d*Math.cos(A*Math.PI/2),P=h*Math.sin(A*Math.PI/2),B=0,U=C.length;B=0;){n=B,(i=B-1)<0&&(i=e.length-1);var r=0,o=g+2*p;for(r=0;r0||0===e.search(/^data\:image\/jpeg/);r.format=i?Be:Ue,r.image=n,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),zo.prototype=Object.assign(Object.create(hi.prototype),{constructor:zo,isLight:!0,copy:function(e){return hi.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=hi.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}}),Bo.prototype=Object.assign(Object.create(zo.prototype),{constructor:Bo,isHemisphereLight:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(Uo.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}}),jo.prototype=Object.assign(Object.create(Uo.prototype),{constructor:jo,isSpotLightShadow:!0,update:function(e){var t=2*Mt.RAD2DEG*e.angle,n=this.mapSize.width/this.mapSize.height,i=e.distance||500,r=this.camera;t===r.fov&&n===r.aspect&&i===r.far||(r.fov=t,r.aspect=n,r.far=i,r.updateProjectionMatrix())}}),Wo.prototype=Object.assign(Object.create(zo.prototype),{constructor:Wo,isSpotLight:!0,copy:function(e){return zo.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}}),Go.prototype=Object.assign(Object.create(zo.prototype),{constructor:Go,isPointLight:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),Vo.prototype=Object.assign(Object.create(Uo.prototype),{constructor:Vo}),Ho.prototype=Object.assign(Object.create(zo.prototype),{constructor:Ho,isDirectionalLight:!0,copy:function(e){return zo.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Yo.prototype=Object.assign(Object.create(zo.prototype),{constructor:Yo,isAmbientLight:!0});var qo,Xo,Ko,Zo,Jo,$o={arraySlice:function(e,t,n){return $o.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){for(var t=e.length,n=new Array(t),i=0;i!==t;++i)n[i]=i;return n.sort((function(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){for(var i=e.length,r=new e.constructor(i),o=0,a=0;a!==i;++o)for(var s=n[o]*t,l=0;l!==t;++l)r[a++]=e[s+l];return r},flattenJSON:function(e,t,n,i){for(var r=1,o=e[0];void 0!==o&&void 0===o[i];)o=e[r++];if(void 0!==o){var a=o[i];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[i])&&(t.push(o.time),n.push.apply(n,a)),o=e[r++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[i])&&(t.push(o.time),a.toArray(n,n.length)),o=e[r++]}while(void 0!==o);else do{void 0!==(a=o[i])&&(t.push(o.time),n.push(a)),o=e[r++]}while(void 0!==o)}}};function Qo(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function ea(e,t,n,i){Qo.call(this,e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function ta(e,t,n,i){Qo.call(this,e,t,n,i)}function na(e,t,n,i){Qo.call(this,e,t,n,i)}function ia(e,t,n,i){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=$o.convertArray(t,this.TimeBufferType),this.values=$o.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation),this.validate(),this.optimize()}function ra(e,t,n,i){ia.call(this,e,t,n,i)}function oa(e,t,n,i){Qo.call(this,e,t,n,i)}function aa(e,t,n,i){ia.call(this,e,t,n,i)}function sa(e,t,n,i){ia.call(this,e,t,n,i)}function la(e,t,n,i){ia.call(this,e,t,n,i)}function ua(e,t,n){ia.call(this,e,t,n)}function ca(e,t,n,i){ia.call(this,e,t,n,i)}function da(e,t,n,i){ia.apply(this,arguments)}function ha(e,t,n){this.name=e,this.tracks=n,this.duration=void 0!==t?t:-1,this.uuid=Mt.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function pa(e){this.manager=void 0!==e?e:Ao,this.textures={}}function fa(e){this.manager=void 0!==e?e:Ao}function ma(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}function ga(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:Ao,this.withCredentials=!1}function ya(e){this.manager=void 0!==e?e:Ao,this.texturePath=""}function va(e,t,n,i,r){var o=.5*(i-t),a=.5*(r-n),s=e*e;return(2*n-2*i+o+a)*(e*s)+(-3*n+3*i-2*o-a)*s+o*e+n}function ba(e,t,n,i){return function(e,t){var n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,i)}function _a(e,t,n,i,r){return function(e,t){var n=1-e;return n*n*n*t}(e,t)+function(e,t){var n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,i)+function(e,t){return e*e*e*t}(e,r)}function xa(){}function wa(e,t){this.v1=e,this.v2=t}function Ma(){this.curves=[],this.autoClose=!1}function Sa(e,t,n,i,r,o,a,s){this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=s||0}function Ea(e){this.points=void 0===e?[]:e}function Ta(e,t,n,i){this.v0=e,this.v1=t,this.v2=n,this.v3=i}function Ca(e,t,n){this.v0=e,this.v1=t,this.v2=n}Qo.prototype={constructor:Qo,evaluate:function(e){var t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{var o;n:{i:if(!(e=r)break e;var s=t[1];e=(r=t[--n-1]))break t}o=n,n=0}for(;n>>1;et;)--o;if(++o,0!==r||o!==i){r>=o&&(r=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=$o.arraySlice(n,r,o),this.values=$o.arraySlice(this.values,r*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,i=this.values,r=n.length;0===r&&(console.error("track is empty",this),e=!1);for(var o=null,a=0;a!==r;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!==i&&$o.isTypedArray(i)){a=0;for(var l=i.length;a!==l;++a){var u=i[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(),i=this.getInterpolation()===at,r=1,o=e.length-1,a=1;a0){e[r]=e[o];for(f=o*n,m=r*n,h=0;h!==n;++h)t[m+h]=t[f+h];++r}return r!==e.length&&(this.times=$o.arraySlice(e,0,r),this.values=$o.arraySlice(t,0,r*n)),this}},ra.prototype=Object.assign(Object.create(qo),{constructor:ra,ValueTypeName:"vector"}),oa.prototype=Object.assign(Object.create(Qo.prototype),{constructor:oa,interpolate_:function(e,t,n,i){for(var r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,l=(n-t)/(i-t),u=s+a;s!==u;s+=4)Nt.slerpFlat(r,0,o,s-a,o,s,l);return r}}),aa.prototype=Object.assign(Object.create(qo),{constructor:aa,ValueTypeName:"quaternion",DefaultInterpolation:ot,InterpolantFactoryMethodLinear:function(e){return new oa(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),sa.prototype=Object.assign(Object.create(qo),{constructor:sa,ValueTypeName:"number"}),la.prototype=Object.assign(Object.create(qo),{constructor:la,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:rt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ua.prototype=Object.assign(Object.create(qo),{constructor:ua,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:rt,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ca.prototype=Object.assign(Object.create(qo),{constructor:ca,ValueTypeName:"color"}),da.prototype=qo,qo.constructor=da,Object.assign(da,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=da._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){var n=[],i=[];$o.flattenJSON(e.keys,n,i,"value"),e.times=n,e.values=i}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:$o.convertArray(e.times,Array),values:$o.convertArray(e.values,Array)};var i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sa;case"vector":case"vector2":case"vector3":case"vector4":return ra;case"color":return ca;case"quaternion":return aa;case"bool":case"boolean":return ua;case"string":return la}throw new Error("Unsupported typeName: "+e)}}),ha.prototype={constructor:ha,resetDuration:function(){for(var e=0,t=0,n=this.tracks.length;t!==n;++t){var i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}this.duration=e},trim:function(){for(var e=0;e1){var u=i[d=l[1]];u||(i[d]=u=[]),u.push(s)}}var c=[];for(var d in i)c.push(ha.CreateFromMorphTargetSequence(d,i[d],t,n));return c},parseAnimation:function(e,t){if(!e)return console.error(" no animation in JSONLoader data"),null;for(var n=function(e,t,n,i,r){if(0!==n.length){var o=[],a=[];$o.flattenJSON(n,o,a,i),0!==o.length&&r.push(new e(t,o,a))}},i=[],r=e.name||"default",o=e.length||-1,a=e.fps||30,s=e.hierarchy||[],l=0;l1?e.skinWeights[i+1]:0,s=t>2?e.skinWeights[i+2]:0,l=t>3?e.skinWeights[i+3]:0;n.skinWeights.push(new Lt(o,a,s,l))}if(e.skinIndices)for(i=0,r=e.skinIndices.length;i1?e.skinIndices[i+1]:0,d=t>2?e.skinIndices[i+2]:0,h=t>3?e.skinIndices[i+3]:0;n.skinIndices.push(new Lt(u,c,d,h))}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 i=0,r=e.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var c=n.faces,d=e.morphColors[0].colors;for(i=0,r=c.length;i0&&(n.animations=t)}(),n.computeFaceNormals(),n.computeBoundingSphere(),void 0===e.materials||0===e.materials.length)return{geometry:n};var r=ma.prototype.initMaterials(e.materials,t,this.crossOrigin);return{geometry:n,materials:r}}}),Object.assign(ya.prototype,{load:function(e,t,n,i){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var r=this;new Ro(r.manager).load(e,(function(n){var o=null;try{o=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?r.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead.")}),n,i)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var n=this.parseGeometries(e.geometries),i=this.parseImages(e.images,(function(){void 0!==t&&t(a)})),r=this.parseTextures(e.textures,i),o=this.parseMaterials(e.materials,r),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 ga,i=new fa,r=0,o=e.length;r0){var o=new Do(new Po(t));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=e.length;a0?new wr(s,l):new Ii(s,l);break;case"LOD":r=new br;break;case"Line":r=new Sr(o(t.geometry),a(t.material),t.mode);break;case"LineSegments":r=new Er(o(t.geometry),a(t.material));break;case"PointCloud":case"Points":r=new Cr(o(t.geometry),a(t.material));break;case"Sprite":r=new vr(a(t.material));break;case"Group":r=new Or;break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh type. Instantiates Object3D instead.");default:r=new hi}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.children)for(var u in t.children)r.add(this.parseObject(t.children[u],n,i));if("LOD"===t.type)for(var c=t.levels,d=0;d0)){l=r;break}l=r-1}if(i[r=l]===n)return r/(o-1);var u=i[r];return(r+(n-u)/(i[r+1]-u))/(o-1)},getTangent:function(e){var t=e-1e-4,n=e+1e-4;t<0&&(t=0),n>1&&(n=1);var i=this.getPoint(t);return this.getPoint(n).clone().sub(i).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,i,r,o=new Ft,a=[],s=[],l=[],u=new Ft,c=new zt;for(n=0;n<=e;n++)i=n/e,a[n]=this.getTangentAt(i),a[n].normalize();s[0]=new Ft,l[0]=new Ft;var d=Number.MAX_VALUE,h=Math.abs(a[0].x),p=Math.abs(a[0].y),f=Math.abs(a[0].z);for(h<=d&&(d=h,o.set(1,0,0)),p<=d&&(d=p,o.set(0,1,0)),f<=d&&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(),r=Math.acos(Mt.clamp(a[n-1].dot(a[n]),-1,1)),s[n].applyMatrix4(c.makeRotationAxis(u,r))),l[n].crossVectors(a[n],s[n]);if(!0===t)for(r=Math.acos(Mt.clamp(s[0].dot(s[e]),-1,1)),r/=e,a[0].dot(u.crossVectors(s[0],s[e]))>0&&(r=-r),n=1;n<=e;n++)s[n].applyMatrix4(c.makeRotationAxis(a[n],r*n)),l[n].crossVectors(a[n],s[n]);return{tangents:a,normals:s,binormals:l}}},wa.prototype=Object.create(xa.prototype),wa.prototype.constructor=wa,wa.prototype.isLineCurve=!0,wa.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},wa.prototype.getPointAt=function(e){return this.getPoint(e)},wa.prototype.getTangent=function(e){return this.v2.clone().sub(this.v1).normalize()},Ma.prototype=Object.assign(Object.create(xa.prototype),{constructor:Ma,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 wa(t,e))},getPoint:function(e){for(var t=e*this.getLength(),n=this.getCurveLengths(),i=0;i=t){var r=n[i]-t,o=this.curves[i],a=o.getLength(),s=0===a?0:1-r/a;return o.getPointAt(s)}i++}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,i=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 Ri,n=0,i=e.length;nt;)n-=t;nt.length-2?t.length-1:i+1],l=t[i>t.length-3?t.length-1:i+2];return new St(va(r,o.x,a.x,s.x,l.x),va(r,o.y,a.y,s.y,l.y))},Ta.prototype=Object.create(xa.prototype),Ta.prototype.constructor=Ta,Ta.prototype.getPoint=function(e){var t=this.v0,n=this.v1,i=this.v2,r=this.v3;return new St(_a(e,t.x,n.x,i.x,r.x),_a(e,t.y,n.y,i.y,r.y))},Ca.prototype=Object.create(xa.prototype),Ca.prototype.constructor=Ca,Ca.prototype.getPoint=function(e){var t=this.v0,n=this.v1,i=this.v2;return new St(ba(e,t.x,n.x,i.x),ba(e,t.y,n.y,i.y))};var Oa,ka=Object.assign(Object.create(Ma.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)}});function Pa(e){Ma.call(this),this.currentPoint=new St,e&&this.fromPoints(e)}function Aa(){Pa.apply(this,arguments),this.holes=[]}function Ra(){this.subPaths=[],this.currentPath=null}function La(e){this.data=e}function Ia(e){this.manager=void 0!==e?e:Ao}Pa.prototype=ka,ka.constructor=Pa,Aa.prototype=Object.assign(Object.create(ka),{constructor:Aa,getPointsHoles:function(e){for(var t=[],n=0,i=this.holes.length;nNumber.EPSILON){if(u<0&&(a=t[o],l=-l,s=t[r],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;i=!i}}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 i}var r=$r.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return n(o);var a,s,l,u=[];if(1===o.length)return s=o[0],(l=new Aa).curves=s.curves,u.push(l),u;var c=!r(o[0].getPoints());c=e?!c:c;var d,h,p=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var y=0,v=o.length;y1){for(var b=!1,_=[],x=0,w=f.length;x0&&(b||(m=p))}y=0;for(var O=f.length;y0){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!==r;++o)e[t+o]=e[n+o]},_slerp:function(e,t,n,i,r){Nt.slerpFlat(e,t,e,t,e,n,i)},_lerp:function(e,t,n,i,r){for(var o=1-i,a=0;a!==r;++a){var s=t+a;e[s]=e[s]*o+e[n+a]*i}}},as.prototype={constructor:as,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,i=t.propertyName,r=t.propertyIndex;if(e||(e=as.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){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];i[h.uuid]=c,t[c]=h,i[u]=d,t[d]=l;for(var p=0,f=o;p!==f;++p){var m=r[p],g=m[d],y=m[c];m[c]=g,m[d]=y}}}this.nCachedObjects_=n},uncache:function(e){for(var t=this._objects,n=t.length,i=this.nCachedObjects_,r=this._indicesByUUID,o=this._bindings,a=o.length,s=0,l=arguments.length;s!==l;++s){var u=arguments[s],c=u.uuid,d=r[c];if(void 0!==d)if(delete r[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(i,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(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,i=this.loop,r=this._loopCount;if(i===tt){-1===r&&(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=i===it;if(-1===r&&(e>=0?(r=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,r+=Math.abs(a);var s=this.repetitions-r;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=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&r))return this.time=t,n-t}return this.time=t,t},_setEndings:function(e,t,n){var i=this._interpolantSettings;n?(i.endingStart=lt,i.endingEnd=lt):(i.endingStart=e?this.zeroSlopeAtStart?lt:st:ut,i.endingEnd=t?this.zeroSlopeAtEnd?lt:st:ut)},_scheduleFading:function(e,t,n){var i=this._mixer,r=i.time,o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=r,s[0]=t,a[1]=r+e,s[1]=n,this}},us.prototype={constructor:us,clipAction:function(e,t){var n=t||this._root,i=n.uuid,r="string"==typeof e?ha.findByName(n,e):e,o=null!==r?r.uuid:e,a=this._actionsByClip[o],s=null;if(void 0!==a){var l=a.actionByRoot[i];if(void 0!==l)return l;s=a.knownActions[0],null===r&&(r=s._clip)}if(null===r)return null;var u=new ls(this,r,t);return this._bindAction(u,s),this._addInactiveAction(u,o,i),u},existingAction:function(e,t){var n=t||this._root,i=n.uuid,r="string"==typeof e?ha.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[i]||null},stopAllAction:function(){var e=this._actions,t=this._nActiveActions,n=this._bindings,i=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var r=0;r!==t;++r)e[r].reset();for(r=0;r!==i;++r)n[r].useCount=0;return this},update:function(e){e*=this.timeScale;for(var t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1,a=0;a!==n;++a){var s=t[a];s.enabled&&s._update(i,e,r,o)}var l=this._bindings,u=this._nActiveBindings;for(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,i=this._actionsByClip,r=i[n];if(void 0!==r){for(var o=r.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 i[n]}},uncacheRoot:function(e){var t=e.uuid,n=this._actionsByClip;for(var i in n){var r=n[i].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var o=this._bindingsByRootAndName[t];if(void 0!==o)for(var a in o){var s=o[a];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(e,t){var n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Object.assign(us.prototype,{_bindAction:function(e,t){var n=e._localRoot||this._root,i=e._clip.tracks,r=i.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!==r;++c){var d=i[c],h=d.name,p=u[h];if(void 0!==p)o[c]=p;else{if(void 0!==(p=o[c])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,h));continue}var f=t&&t._propertyBindings[c].binding.parsedPath;++(p=new os(as.create(n,h,f),d.ValueTypeName,d.getValueSize())).referenceCount,this._addInactiveBinding(p,s,h),o[c]=p}a[c].resultBuffer=p.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}for(var r=e._propertyBindings,o=0,a=r.length;o!==a;++o){var s=r[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,i=t.length;n!==i;++n){var r=t[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}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)i[l=s[1]]||(i[l]={start:1/0,end:-1/0}),o<(u=i[l]).start&&(u.start=o),o>u.end&&(u.end=o),t||(t=l)}for(var l in i){var u=i[l];this.createAnimation(l,u.start,u.end,e)}this.firstAnimation=t},ws.prototype.setAnimationDirectionForward=function(e){var t=this.animationsMap[e];t&&(t.direction=1,t.directionBackwards=!1)},ws.prototype.setAnimationDirectionBackward=function(e){var t=this.animationsMap[e];t&&(t.direction=-1,t.directionBackwards=!0)},ws.prototype.setAnimationFPS=function(e,t){var n=this.animationsMap[e];n&&(n.fps=t,n.duration=(n.end-n.start)/n.fps)},ws.prototype.setAnimationDuration=function(e,t){var n=this.animationsMap[e];n&&(n.duration=t,n.fps=(n.end-n.start)/n.duration)},ws.prototype.setAnimationWeight=function(e,t){var n=this.animationsMap[e];n&&(n.weight=t)},ws.prototype.setAnimationTime=function(e,t){var n=this.animationsMap[e];n&&(n.time=t)},ws.prototype.getAnimationTime=function(e){var t=0,n=this.animationsMap[e];return n&&(t=n.time),t},ws.prototype.getAnimationDuration=function(e){var t=-1,n=this.animationsMap[e];return n&&(t=n.duration),t},ws.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()")},ws.prototype.stopAnimation=function(e){var t=this.animationsMap[e];t&&(t.active=!1)},ws.prototype.update=function(e){for(var t=0,n=this.animationsList.length;ti.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 o=i.start+Mt.clamp(Math.floor(i.time/r),0,i.length-1),a=i.weight;o!==i.currentFrame&&(this.morphTargetInfluences[i.lastFrame]=0,this.morphTargetInfluences[i.currentFrame]=1*a,this.morphTargetInfluences[o]=0,i.lastFrame=i.currentFrame,i.currentFrame=o);var s=i.time%r/r;i.directionBackwards&&(s=1-s),i.currentFrame!==i.lastFrame?(this.morphTargetInfluences[i.currentFrame]=s*a,this.morphTargetInfluences[i.lastFrame]=(1-s)*a):this.morphTargetInfluences[i.currentFrame]=a}}},Ms.prototype=Object.create(hi.prototype),Ms.prototype.constructor=Ms,Ms.prototype.isImmediateRenderObject=!0,Ss.prototype=Object.create(Er.prototype),Ss.prototype.constructor=Ss,Ss.prototype.update=function(){var e=new Ft,t=new Ft,n=new Jn;return function(){var i=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var r=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):e.y<-.99999?this.quaternion.set(1,0,0,0):(Ka.set(e.z,0,-e.x).normalize(),Xa=Math.acos(e.y),this.quaternion.setFromAxisAngle(Ka,Xa))}),Ns.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()},Ns.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},Fs.prototype=Object.create(Er.prototype),Fs.prototype.constructor=Fs;var Bs=new Ft,Us=new zs,js=new zs,Ws=new zs;function Gs(e){this.points=e||[],this.closed=!1}function Vs(e,t,n,i){this.v0=e,this.v1=t,this.v2=n,this.v3=i}function Hs(e,t,n){this.v0=e,this.v1=t,this.v2=n}function Ys(e,t){this.v1=e,this.v2=t}function qs(e,t,n,i,r,o){Sa.call(this,e,t,n,n,i,r,o)}Gs.prototype=Object.create(xa.prototype),Gs.prototype.constructor=Gs,Gs.prototype.getPoint=function(e){var t=this.points,n=t.length;n<2&&console.log("duh, you need at least 2 points");var i,r,o,a,s=(n-(this.closed?0:1))*e,l=Math.floor(s),u=s-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/t.length)+1)*t.length:0===u&&l===n-1&&(l=n-2,u=1),this.closed||l>0?i=t[(l-1)%n]:(Bs.subVectors(t[0],t[1]).add(t[0]),i=Bs),r=t[l%n],o=t[(l+1)%n],this.closed||l+2 @@ -26,12 +26,12 @@ var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__p * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */(function(){var o,a=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",u="__lodash_hash_undefined__",c=500,d="__lodash_placeholder__",h=1,p=2,f=4,m=1,g=2,y=1,v=2,b=4,_=8,x=16,w=32,M=64,S=128,E=256,T=512,C=30,O="...",k=800,P=16,A=1,R=2,L=1/0,I=9007199254740991,D=17976931348623157e292,N=NaN,F=4294967295,z=F-1,B=F>>>1,j=[["ary",S],["bind",y],["bindKey",v],["curry",_],["curryRight",x],["flip",T],["partial",w],["partialRight",M],["rearg",E]],U="[object Arguments]",W="[object Array]",G="[object AsyncFunction]",V="[object Boolean]",H="[object Date]",Y="[object DOMException]",q="[object Error]",X="[object Function]",K="[object GeneratorFunction]",Z="[object Map]",J="[object Number]",$="[object Null]",Q="[object Object]",ee="[object Proxy]",te="[object RegExp]",ne="[object Set]",ie="[object String]",re="[object Symbol]",oe="[object Undefined]",ae="[object WeakMap]",se="[object WeakSet]",le="[object ArrayBuffer]",ue="[object DataView]",ce="[object Float32Array]",de="[object Float64Array]",he="[object Int8Array]",pe="[object Int16Array]",fe="[object Int32Array]",me="[object Uint8Array]",ge="[object Uint8ClampedArray]",ye="[object Uint16Array]",ve="[object Uint32Array]",be=/\b__p \+= '';/g,_e=/\b(__p \+=) '' \+/g,xe=/(__e\(.*?\)|\b__t\)) \+\n'';/g,we=/&(?:amp|lt|gt|quot|#39);/g,Me=/[&<>"']/g,Se=RegExp(we.source),Ee=RegExp(Me.source),Te=/<%-([\s\S]+?)%>/g,Ce=/<%([\s\S]+?)%>/g,Oe=/<%=([\s\S]+?)%>/g,ke=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pe=/^\w*$/,Ae=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Re=/[\\^$.*+?()[\]{}|]/g,Le=RegExp(Re.source),Ie=/^\s+|\s+$/g,De=/^\s+/,Ne=/\s+$/,Fe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ze=/\{\n\/\* \[wrapped with (.+)\] \*/,Be=/,? & /,je=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ue=/\\(\\)?/g,We=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ge=/\w*$/,Ve=/^[-+]0x[0-9a-f]+$/i,He=/^0b[01]+$/i,Ye=/^\[object .+?Constructor\]$/,qe=/^0o[0-7]+$/i,Xe=/^(?:0|[1-9]\d*)$/,Ke=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ze=/($^)/,Je=/['\n\r\u2028\u2029\\]/g,$e="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qe="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",et="[\\ud800-\\udfff]",tt="["+Qe+"]",nt="["+$e+"]",it="\\d+",rt="[\\u2700-\\u27bf]",ot="[a-z\\xdf-\\xf6\\xf8-\\xff]",at="[^\\ud800-\\udfff"+Qe+it+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",st="\\ud83c[\\udffb-\\udfff]",lt="[^\\ud800-\\udfff]",ut="(?:\\ud83c[\\udde6-\\uddff]){2}",ct="[\\ud800-\\udbff][\\udc00-\\udfff]",dt="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ht="(?:"+ot+"|"+at+")",pt="(?:"+dt+"|"+at+")",ft="(?:"+nt+"|"+st+")"+"?",mt="[\\ufe0e\\ufe0f]?"+ft+("(?:\\u200d(?:"+[lt,ut,ct].join("|")+")[\\ufe0e\\ufe0f]?"+ft+")*"),gt="(?:"+[rt,ut,ct].join("|")+")"+mt,yt="(?:"+[lt+nt+"?",nt,ut,ct,et].join("|")+")",vt=RegExp("['’]","g"),bt=RegExp(nt,"g"),_t=RegExp(st+"(?="+st+")|"+yt+mt,"g"),xt=RegExp([dt+"?"+ot+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[tt,dt,"$"].join("|")+")",pt+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[tt,dt+ht,"$"].join("|")+")",dt+"?"+ht+"+(?:['’](?:d|ll|m|re|s|t|ve))?",dt+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",it,gt].join("|"),"g"),wt=RegExp("[\\u200d\\ud800-\\udfff"+$e+"\\ufe0e\\ufe0f]"),Mt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,St=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Et=-1,Tt={};Tt[ce]=Tt[de]=Tt[he]=Tt[pe]=Tt[fe]=Tt[me]=Tt[ge]=Tt[ye]=Tt[ve]=!0,Tt[U]=Tt[W]=Tt[le]=Tt[V]=Tt[ue]=Tt[H]=Tt[q]=Tt[X]=Tt[Z]=Tt[J]=Tt[Q]=Tt[te]=Tt[ne]=Tt[ie]=Tt[ae]=!1;var Ct={};Ct[U]=Ct[W]=Ct[le]=Ct[ue]=Ct[V]=Ct[H]=Ct[ce]=Ct[de]=Ct[he]=Ct[pe]=Ct[fe]=Ct[Z]=Ct[J]=Ct[Q]=Ct[te]=Ct[ne]=Ct[ie]=Ct[re]=Ct[me]=Ct[ge]=Ct[ye]=Ct[ve]=!0,Ct[q]=Ct[X]=Ct[ae]=!1;var Ot={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=parseFloat,Pt=parseInt,At="object"==typeof e&&e&&e.Object===Object&&e,Rt="object"==typeof self&&self&&self.Object===Object&&self,Lt=At||Rt||Function("return this")(),It=t&&!t.nodeType&&t,Dt=It&&"object"==typeof i&&i&&!i.nodeType&&i,Nt=Dt&&Dt.exports===It,Ft=Nt&&At.process,zt=function(){try{var e=Dt&&Dt.require&&Dt.require("util").types;return e||Ft&&Ft.binding&&Ft.binding("util")}catch(e){}}(),Bt=zt&&zt.isArrayBuffer,jt=zt&&zt.isDate,Ut=zt&&zt.isMap,Wt=zt&&zt.isRegExp,Gt=zt&&zt.isSet,Vt=zt&&zt.isTypedArray;function Ht(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Yt(e,t,n,i){for(var r=-1,o=null==e?0:e.length;++r-1}function $t(e,t,n){for(var i=-1,r=null==e?0:e.length;++i-1;);return n}function xn(e,t){for(var n=e.length;n--&&ln(t,e[n],0)>-1;);return n}var wn=pn({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Mn=pn({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sn(e){return"\\"+Ot[e]}function En(e){return wt.test(e)}function Tn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,i){n[++t]=[i,e]})),n}function Cn(e,t){return function(n){return e(t(n))}}function On(e,t){for(var n=-1,i=e.length,r=0,o=[];++n",""":'"',"'":"'"});var In=function e(t){var n,i=(t=null==t?Lt:In.defaults(Lt.Object(),t,In.pick(Lt,St))).Array,r=t.Date,$e=t.Error,Qe=t.Function,et=t.Math,tt=t.Object,nt=t.RegExp,it=t.String,rt=t.TypeError,ot=i.prototype,at=Qe.prototype,st=tt.prototype,lt=t["__core-js_shared__"],ut=at.toString,ct=st.hasOwnProperty,dt=0,ht=(n=/[^.]+$/.exec(lt&<.keys&<.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",pt=st.toString,ft=ut.call(tt),mt=Lt._,gt=nt("^"+ut.call(ct).replace(Re,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yt=Nt?t.Buffer:o,_t=t.Symbol,wt=t.Uint8Array,Ot=yt?yt.allocUnsafe:o,At=Cn(tt.getPrototypeOf,tt),Rt=tt.create,It=st.propertyIsEnumerable,Dt=ot.splice,Ft=_t?_t.isConcatSpreadable:o,zt=_t?_t.iterator:o,on=_t?_t.toStringTag:o,pn=function(){try{var e=Bo(tt,"defineProperty");return e({},"",{}),e}catch(e){}}(),Dn=t.clearTimeout!==Lt.clearTimeout&&t.clearTimeout,Nn=r&&r.now!==Lt.Date.now&&r.now,Fn=t.setTimeout!==Lt.setTimeout&&t.setTimeout,zn=et.ceil,Bn=et.floor,jn=tt.getOwnPropertySymbols,Un=yt?yt.isBuffer:o,Wn=t.isFinite,Gn=ot.join,Vn=Cn(tt.keys,tt),Hn=et.max,Yn=et.min,qn=r.now,Xn=t.parseInt,Kn=et.random,Zn=ot.reverse,Jn=Bo(t,"DataView"),$n=Bo(t,"Map"),Qn=Bo(t,"Promise"),ei=Bo(t,"Set"),ti=Bo(t,"WeakMap"),ni=Bo(tt,"create"),ii=ti&&new ti,ri={},oi=da(Jn),ai=da($n),si=da(Qn),li=da(ei),ui=da(ti),ci=_t?_t.prototype:o,di=ci?ci.valueOf:o,hi=ci?ci.toString:o;function pi(e){if(Os(e)&&!ys(e)&&!(e instanceof yi)){if(e instanceof gi)return e;if(ct.call(e,"__wrapped__"))return ha(e)}return new gi(e)}var fi=function(){function e(){}return function(t){if(!Cs(t))return{};if(Rt)return Rt(t);e.prototype=t;var n=new e;return e.prototype=o,n}}();function mi(){}function gi(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=o}function yi(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function vi(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Di(e,t,n,i,r,a){var s,l=t&h,u=t&p,c=t&f;if(n&&(s=r?n(e,i,r,a):n(e)),s!==o)return s;if(!Cs(e))return e;var d=ys(e);if(d){if(s=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&ct.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!l)return no(e,s)}else{var m=Wo(e),g=m==X||m==K;if(xs(e))return Zr(e,l);if(m==Q||m==U||g&&!r){if(s=u||g?{}:Vo(e),!l)return u?function(e,t){return io(e,Uo(e),t)}(e,function(e,t){return e&&io(t,ol(t),e)}(s,e)):function(e,t){return io(e,jo(e),t)}(e,Ai(s,e))}else{if(!Ct[m])return r?e:{};s=function(e,t,n){var i=e.constructor;switch(t){case le:return Jr(e);case V:case H:return new i(+e);case ue:return function(e,t){var n=t?Jr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case ce:case de:case he:case pe:case fe:case me:case ge:case ye:case ve:return $r(e,n);case Z:return new i;case J:case ie:return new i(e);case te:return function(e){var t=new e.constructor(e.source,Ge.exec(e));return t.lastIndex=e.lastIndex,t}(e);case ne:return new i;case re:return r=e,di?tt(di.call(r)):{}}var r}(e,m,l)}}a||(a=new wi);var y=a.get(e);if(y)return y;a.set(e,s),Ls(e)?e.forEach((function(i){s.add(Di(i,t,n,i,e,a))})):ks(e)&&e.forEach((function(i,r){s.set(r,Di(i,t,n,r,e,a))}));var v=d?o:(c?u?Ro:Ao:u?ol:rl)(e);return qt(v||e,(function(i,r){v&&(i=e[r=i]),Oi(s,r,Di(i,t,n,r,e,a))})),s}function Ni(e,t,n){var i=n.length;if(null==e)return!i;for(e=tt(e);i--;){var r=n[i],a=t[r],s=e[r];if(s===o&&!(r in e)||!a(s))return!1}return!0}function Fi(e,t,n){if("function"!=typeof e)throw new rt(l);return ra((function(){e.apply(o,n)}),t)}function zi(e,t,n,i){var r=-1,o=Jt,s=!0,l=e.length,u=[],c=t.length;if(!l)return u;n&&(t=Qt(t,yn(n))),i?(o=$t,s=!1):t.length>=a&&(o=bn,s=!1,t=new xi(t));e:for(;++r-1},bi.prototype.set=function(e,t){var n=this.__data__,i=ki(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this},_i.prototype.clear=function(){this.size=0,this.__data__={hash:new vi,map:new($n||bi),string:new vi}},_i.prototype.delete=function(e){var t=Fo(this,e).delete(e);return this.size-=t?1:0,t},_i.prototype.get=function(e){return Fo(this,e).get(e)},_i.prototype.has=function(e){return Fo(this,e).has(e)},_i.prototype.set=function(e,t){var n=Fo(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this},xi.prototype.add=xi.prototype.push=function(e){return this.__data__.set(e,u),this},xi.prototype.has=function(e){return this.__data__.has(e)},wi.prototype.clear=function(){this.__data__=new bi,this.size=0},wi.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},wi.prototype.get=function(e){return this.__data__.get(e)},wi.prototype.has=function(e){return this.__data__.has(e)},wi.prototype.set=function(e,t){var n=this.__data__;if(n instanceof bi){var i=n.__data__;if(!$n||i.length0&&n(s)?t>1?Vi(s,t-1,n,i,r):en(r,s):i||(r[r.length]=s)}return r}var Hi=so(),Yi=so(!0);function qi(e,t){return e&&Hi(e,t,rl)}function Xi(e,t){return e&&Yi(e,t,rl)}function Ki(e,t){return Zt(t,(function(t){return Ss(e[t])}))}function Zi(e,t){for(var n=0,i=(t=Yr(t,e)).length;null!=e&&nt}function er(e,t){return null!=e&&ct.call(e,t)}function tr(e,t){return null!=e&&t in tt(e)}function nr(e,t,n){for(var r=n?$t:Jt,a=e[0].length,s=e.length,l=s,u=i(s),c=1/0,d=[];l--;){var h=e[l];l&&t&&(h=Qt(h,yn(t))),c=Yn(h.length,c),u[l]=!n&&(t||a>=120&&h.length>=120)?new xi(l&&h):o}h=e[0];var p=-1,f=u[0];e:for(;++p=s)return l;var u=n[i];return l*("desc"==u?-1:1)}}return e.index-t.index}(e,t,n)}))}function vr(e,t,n){for(var i=-1,r=t.length,o={};++i-1;)s!==e&&Dt.call(s,l,1),Dt.call(e,l,1);return e}function _r(e,t){for(var n=e?t.length:0,i=n-1;n--;){var r=t[n];if(n==i||r!==o){var o=r;Yo(r)?Dt.call(e,r,1):zr(e,r)}}return e}function xr(e,t){return e+Bn(Kn()*(t-e+1))}function wr(e,t){var n="";if(!e||t<1||t>I)return n;do{t%2&&(n+=e),(t=Bn(t/2))&&(e+=e)}while(t);return n}function Mr(e,t){return oa(ea(e,t,Pl),e+"")}function Sr(e){return Si(pl(e))}function Er(e,t){var n=pl(e);return la(n,Ii(t,0,n.length))}function Tr(e,t,n,i){if(!Cs(e))return e;for(var r=-1,a=(t=Yr(t,e)).length,s=a-1,l=e;null!=l&&++ro?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var a=i(o);++r>>1,a=e[o];null!==a&&!Ds(a)&&(n?a<=t:a=a){var c=t?null:Mo(e);if(c)return kn(c);s=!1,r=bn,u=new xi}else u=t?[]:l;e:for(;++i=i?e:Pr(e,t,n)}var Kr=Dn||function(e){return Lt.clearTimeout(e)};function Zr(e,t){if(t)return e.slice();var n=e.length,i=Ot?Ot(n):new e.constructor(n);return e.copy(i),i}function Jr(e){var t=new e.constructor(e.byteLength);return new wt(t).set(new wt(e)),t}function $r(e,t){var n=t?Jr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Qr(e,t){if(e!==t){var n=e!==o,i=null===e,r=e==e,a=Ds(e),s=t!==o,l=null===t,u=t==t,c=Ds(t);if(!l&&!c&&!a&&e>t||a&&s&&u&&!l&&!c||i&&s&&u||!n&&u||!r)return 1;if(!i&&!a&&!c&&e1?n[r-1]:o,s=r>2?n[2]:o;for(a=e.length>3&&"function"==typeof a?(r--,a):o,s&&qo(n[0],n[1],s)&&(a=r<3?o:a,r=1),t=tt(t);++i-1?r[a?t[s]:s]:o}}function po(e){return Po((function(t){var n=t.length,i=n,r=gi.prototype.thru;for(e&&t.reverse();i--;){var a=t[i];if("function"!=typeof a)throw new rt(l);if(r&&!s&&"wrapper"==Io(a))var s=new gi([],!0)}for(i=s?i:n;++i1&&_.reverse(),h&&cl))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var d=-1,h=!0,p=n&g?new xi:o;for(a.set(e,t),a.set(t,e);++d-1&&e%1==0&&e1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(Fe,"{\n/* [wrapped with "+t+"] */\n")}(i,function(e,t){return qt(j,(function(n){var i="_."+n[0];t&n[1]&&!Jt(e,i)&&e.push(i)})),e.sort()}(function(e){var t=e.match(ze);return t?t[1].split(Be):[]}(i),n)))}function sa(e){var t=0,n=0;return function(){var i=qn(),r=P-(i-n);if(n=i,r>0){if(++t>=k)return arguments[0]}else t=0;return e.apply(o,arguments)}}function la(e,t){var n=-1,i=e.length,r=i-1;for(t=t===o?i:t;++n1?e[t-1]:o;return n="function"==typeof n?(e.pop(),n):o,Ra(e,n)}));function Ba(e){var t=pi(e);return t.__chain__=!0,t}function ja(e,t){return t(e)}var Ua=Po((function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,r=function(t){return Li(t,e)};return!(t>1||this.__actions__.length)&&i instanceof yi&&Yo(n)?((i=i.slice(n,+n+(t?1:0))).__actions__.push({func:ja,args:[r],thisArg:o}),new gi(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(o),e}))):this.thru(r)}));var Wa=ro((function(e,t,n){ct.call(e,n)?++e[n]:Ri(e,n,1)}));var Ga=ho(ga),Va=ho(ya);function Ha(e,t){return(ys(e)?qt:Bi)(e,No(t,3))}function Ya(e,t){return(ys(e)?Xt:ji)(e,No(t,3))}var qa=ro((function(e,t,n){ct.call(e,n)?e[n].push(t):Ri(e,n,[t])}));var Xa=Mr((function(e,t,n){var r=-1,o="function"==typeof t,a=bs(e)?i(e.length):[];return Bi(e,(function(e){a[++r]=o?Ht(t,e,n):ir(e,t,n)})),a})),Ka=ro((function(e,t,n){Ri(e,n,t)}));function Za(e,t){return(ys(e)?Qt:hr)(e,No(t,3))}var Ja=ro((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var $a=Mr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&qo(e,t[0],t[1])?t=[]:n>2&&qo(t[0],t[1],t[2])&&(t=[t[0]]),yr(e,Vi(t,1),[])})),Qa=Nn||function(){return Lt.Date.now()};function es(e,t,n){return t=n?o:t,t=e&&null==t?e.length:t,Eo(e,S,o,o,o,o,t)}function ts(e,t){var n;if("function"!=typeof t)throw new rt(l);return e=Us(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=o),n}}var ns=Mr((function(e,t,n){var i=y;if(n.length){var r=On(n,Do(ns));i|=w}return Eo(e,i,t,n,r)})),is=Mr((function(e,t,n){var i=y|v;if(n.length){var r=On(n,Do(is));i|=w}return Eo(t,i,e,n,r)}));function rs(e,t,n){var i,r,a,s,u,c,d=0,h=!1,p=!1,f=!0;if("function"!=typeof e)throw new rt(l);function m(t){var n=i,a=r;return i=r=o,d=t,s=e.apply(a,n)}function g(e){var n=e-c;return c===o||n>=t||n<0||p&&e-d>=a}function y(){var e=Qa();if(g(e))return v(e);u=ra(y,function(e){var n=t-(e-c);return p?Yn(n,a-(e-d)):n}(e))}function v(e){return u=o,f&&i?m(e):(i=r=o,s)}function b(){var e=Qa(),n=g(e);if(i=arguments,r=this,c=e,n){if(u===o)return function(e){return d=e,u=ra(y,t),h?m(e):s}(c);if(p)return Kr(u),u=ra(y,t),m(c)}return u===o&&(u=ra(y,t)),s}return t=Gs(t)||0,Cs(n)&&(h=!!n.leading,a=(p="maxWait"in n)?Hn(Gs(n.maxWait)||0,t):a,f="trailing"in n?!!n.trailing:f),b.cancel=function(){u!==o&&Kr(u),d=0,i=c=r=u=o},b.flush=function(){return u===o?s:v(Qa())},b}var os=Mr((function(e,t){return Fi(e,1,t)})),as=Mr((function(e,t,n){return Fi(e,Gs(t)||0,n)}));function ss(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new rt(l);var n=function(){var i=arguments,r=t?t.apply(this,i):i[0],o=n.cache;if(o.has(r))return o.get(r);var a=e.apply(this,i);return n.cache=o.set(r,a)||o,a};return n.cache=new(ss.Cache||_i),n}function ls(e){if("function"!=typeof e)throw new rt(l);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}ss.Cache=_i;var us=qr((function(e,t){var n=(t=1==t.length&&ys(t[0])?Qt(t[0],yn(No())):Qt(Vi(t,1),yn(No()))).length;return Mr((function(i){for(var r=-1,o=Yn(i.length,n);++r=t})),gs=rr(function(){return arguments}())?rr:function(e){return Os(e)&&ct.call(e,"callee")&&!It.call(e,"callee")},ys=i.isArray,vs=Bt?yn(Bt):function(e){return Os(e)&&$i(e)==le};function bs(e){return null!=e&&Ts(e.length)&&!Ss(e)}function _s(e){return Os(e)&&bs(e)}var xs=Un||Gl,ws=jt?yn(jt):function(e){return Os(e)&&$i(e)==H};function Ms(e){if(!Os(e))return!1;var t=$i(e);return t==q||t==Y||"string"==typeof e.message&&"string"==typeof e.name&&!As(e)}function Ss(e){if(!Cs(e))return!1;var t=$i(e);return t==X||t==K||t==G||t==ee}function Es(e){return"number"==typeof e&&e==Us(e)}function Ts(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=I}function Cs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Os(e){return null!=e&&"object"==typeof e}var ks=Ut?yn(Ut):function(e){return Os(e)&&Wo(e)==Z};function Ps(e){return"number"==typeof e||Os(e)&&$i(e)==J}function As(e){if(!Os(e)||$i(e)!=Q)return!1;var t=At(e);if(null===t)return!0;var n=ct.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&ut.call(n)==ft}var Rs=Wt?yn(Wt):function(e){return Os(e)&&$i(e)==te};var Ls=Gt?yn(Gt):function(e){return Os(e)&&Wo(e)==ne};function Is(e){return"string"==typeof e||!ys(e)&&Os(e)&&$i(e)==ie}function Ds(e){return"symbol"==typeof e||Os(e)&&$i(e)==re}var Ns=Vt?yn(Vt):function(e){return Os(e)&&Ts(e.length)&&!!Tt[$i(e)]};var Fs=_o(dr),zs=_o((function(e,t){return e<=t}));function Bs(e){if(!e)return[];if(bs(e))return Is(e)?Rn(e):no(e);if(zt&&e[zt])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[zt]());var t=Wo(e);return(t==Z?Tn:t==ne?kn:pl)(e)}function js(e){return e?(e=Gs(e))===L||e===-L?(e<0?-1:1)*D:e==e?e:0:0===e?e:0}function Us(e){var t=js(e),n=t%1;return t==t?n?t-n:t:0}function Ws(e){return e?Ii(Us(e),0,F):0}function Gs(e){if("number"==typeof e)return e;if(Ds(e))return N;if(Cs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Cs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Ie,"");var n=He.test(e);return n||qe.test(e)?Pt(e.slice(2),n?2:8):Ve.test(e)?N:+e}function Vs(e){return io(e,ol(e))}function Hs(e){return null==e?"":Nr(e)}var Ys=oo((function(e,t){if(Jo(t)||bs(t))io(t,rl(t),e);else for(var n in t)ct.call(t,n)&&Oi(e,n,t[n])})),qs=oo((function(e,t){io(t,ol(t),e)})),Xs=oo((function(e,t,n,i){io(t,ol(t),e,i)})),Ks=oo((function(e,t,n,i){io(t,rl(t),e,i)})),Zs=Po(Li);var Js=Mr((function(e,t){e=tt(e);var n=-1,i=t.length,r=i>2?t[2]:o;for(r&&qo(t[0],t[1],r)&&(i=1);++n1),t})),io(e,Ro(e),n),i&&(n=Di(n,h|p|f,Oo));for(var r=t.length;r--;)zr(n,t[r]);return n}));var ul=Po((function(e,t){return null==e?{}:function(e,t){return vr(e,t,(function(t,n){return el(e,n)}))}(e,t)}));function cl(e,t){if(null==e)return{};var n=Qt(Ro(e),(function(e){return[e]}));return t=No(t),vr(e,n,(function(e,n){return t(e,n[0])}))}var dl=So(rl),hl=So(ol);function pl(e){return null==e?[]:vn(e,rl(e))}var fl=uo((function(e,t,n){return t=t.toLowerCase(),e+(n?ml(t):t)}));function ml(e){return Ml(Hs(e).toLowerCase())}function gl(e){return(e=Hs(e))&&e.replace(Ke,wn).replace(bt,"")}var yl=uo((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),vl=uo((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),bl=lo("toLowerCase");var _l=uo((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var xl=uo((function(e,t,n){return e+(n?" ":"")+Ml(t)}));var wl=uo((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ml=lo("toUpperCase");function Sl(e,t,n){return e=Hs(e),(t=n?o:t)===o?function(e){return Mt.test(e)}(e)?function(e){return e.match(xt)||[]}(e):function(e){return e.match(je)||[]}(e):e.match(t)||[]}var El=Mr((function(e,t){try{return Ht(e,o,t)}catch(e){return Ms(e)?e:new $e(e)}})),Tl=Po((function(e,t){return qt(t,(function(t){t=ca(t),Ri(e,t,ns(e[t],e))})),e}));function Cl(e){return function(){return e}}var Ol=po(),kl=po(!0);function Pl(e){return e}function Al(e){return lr("function"==typeof e?e:Di(e,h))}var Rl=Mr((function(e,t){return function(n){return ir(n,e,t)}})),Ll=Mr((function(e,t){return function(n){return ir(e,n,t)}}));function Il(e,t,n){var i=rl(t),r=Ki(t,i);null!=n||Cs(t)&&(r.length||!i.length)||(n=t,t=e,e=this,r=Ki(t,rl(t)));var o=!(Cs(n)&&"chain"in n&&!n.chain),a=Ss(e);return qt(r,(function(n){var i=t[n];e[n]=i,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),r=n.__actions__=no(this.__actions__);return r.push({func:i,args:arguments,thisArg:e}),n.__chain__=t,n}return i.apply(e,en([this.value()],arguments))})})),e}function Dl(){}var Nl=yo(Qt),Fl=yo(Kt),zl=yo(rn);function Bl(e){return Xo(e)?hn(ca(e)):function(e){return function(t){return Zi(t,e)}}(e)}var jl=bo(),Ul=bo(!0);function Wl(){return[]}function Gl(){return!1}var Vl=go((function(e,t){return e+t}),0),Hl=wo("ceil"),Yl=go((function(e,t){return e/t}),1),ql=wo("floor");var Xl,Kl=go((function(e,t){return e*t}),1),Zl=wo("round"),Jl=go((function(e,t){return e-t}),0);return pi.after=function(e,t){if("function"!=typeof t)throw new rt(l);return e=Us(e),function(){if(--e<1)return t.apply(this,arguments)}},pi.ary=es,pi.assign=Ys,pi.assignIn=qs,pi.assignInWith=Xs,pi.assignWith=Ks,pi.at=Zs,pi.before=ts,pi.bind=ns,pi.bindAll=Tl,pi.bindKey=is,pi.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return ys(e)?e:[e]},pi.chain=Ba,pi.chunk=function(e,t,n){t=(n?qo(e,t,n):t===o)?1:Hn(Us(t),0);var r=null==e?0:e.length;if(!r||t<1)return[];for(var a=0,s=0,l=i(zn(r/t));ar?0:r+n),(i=i===o||i>r?r:Us(i))<0&&(i+=r),i=n>i?0:Ws(i);n>>0)?(e=Hs(e))&&("string"==typeof t||null!=t&&!Rs(t))&&!(t=Nr(t))&&En(e)?Xr(Rn(e),0,n):e.split(t,n):[]},pi.spread=function(e,t){if("function"!=typeof e)throw new rt(l);return t=null==t?0:Hn(Us(t),0),Mr((function(n){var i=n[t],r=Xr(n,0,t);return i&&en(r,i),Ht(e,this,r)}))},pi.tail=function(e){var t=null==e?0:e.length;return t?Pr(e,1,t):[]},pi.take=function(e,t,n){return e&&e.length?Pr(e,0,(t=n||t===o?1:Us(t))<0?0:t):[]},pi.takeRight=function(e,t,n){var i=null==e?0:e.length;return i?Pr(e,(t=i-(t=n||t===o?1:Us(t)))<0?0:t,i):[]},pi.takeRightWhile=function(e,t){return e&&e.length?jr(e,No(t,3),!1,!0):[]},pi.takeWhile=function(e,t){return e&&e.length?jr(e,No(t,3)):[]},pi.tap=function(e,t){return t(e),e},pi.throttle=function(e,t,n){var i=!0,r=!0;if("function"!=typeof e)throw new rt(l);return Cs(n)&&(i="leading"in n?!!n.leading:i,r="trailing"in n?!!n.trailing:r),rs(e,t,{leading:i,maxWait:t,trailing:r})},pi.thru=ja,pi.toArray=Bs,pi.toPairs=dl,pi.toPairsIn=hl,pi.toPath=function(e){return ys(e)?Qt(e,ca):Ds(e)?[e]:no(ua(Hs(e)))},pi.toPlainObject=Vs,pi.transform=function(e,t,n){var i=ys(e),r=i||xs(e)||Ns(e);if(t=No(t,4),null==n){var o=e&&e.constructor;n=r?i?new o:[]:Cs(e)&&Ss(o)?fi(At(e)):{}}return(r?qt:qi)(e,(function(e,i,r){return t(n,e,i,r)})),n},pi.unary=function(e){return es(e,1)},pi.union=Oa,pi.unionBy=ka,pi.unionWith=Pa,pi.uniq=function(e){return e&&e.length?Fr(e):[]},pi.uniqBy=function(e,t){return e&&e.length?Fr(e,No(t,2)):[]},pi.uniqWith=function(e,t){return t="function"==typeof t?t:o,e&&e.length?Fr(e,o,t):[]},pi.unset=function(e,t){return null==e||zr(e,t)},pi.unzip=Aa,pi.unzipWith=Ra,pi.update=function(e,t,n){return null==e?e:Br(e,t,Hr(n))},pi.updateWith=function(e,t,n,i){return i="function"==typeof i?i:o,null==e?e:Br(e,t,Hr(n),i)},pi.values=pl,pi.valuesIn=function(e){return null==e?[]:vn(e,ol(e))},pi.without=La,pi.words=Sl,pi.wrap=function(e,t){return cs(Hr(t),e)},pi.xor=Ia,pi.xorBy=Da,pi.xorWith=Na,pi.zip=Fa,pi.zipObject=function(e,t){return Gr(e||[],t||[],Oi)},pi.zipObjectDeep=function(e,t){return Gr(e||[],t||[],Tr)},pi.zipWith=za,pi.entries=dl,pi.entriesIn=hl,pi.extend=qs,pi.extendWith=Xs,Il(pi,pi),pi.add=Vl,pi.attempt=El,pi.camelCase=fl,pi.capitalize=ml,pi.ceil=Hl,pi.clamp=function(e,t,n){return n===o&&(n=t,t=o),n!==o&&(n=(n=Gs(n))==n?n:0),t!==o&&(t=(t=Gs(t))==t?t:0),Ii(Gs(e),t,n)},pi.clone=function(e){return Di(e,f)},pi.cloneDeep=function(e){return Di(e,h|f)},pi.cloneDeepWith=function(e,t){return Di(e,h|f,t="function"==typeof t?t:o)},pi.cloneWith=function(e,t){return Di(e,f,t="function"==typeof t?t:o)},pi.conformsTo=function(e,t){return null==t||Ni(e,t,rl(t))},pi.deburr=gl,pi.defaultTo=function(e,t){return null==e||e!=e?t:e},pi.divide=Yl,pi.endsWith=function(e,t,n){e=Hs(e),t=Nr(t);var i=e.length,r=n=n===o?i:Ii(Us(n),0,i);return(n-=t.length)>=0&&e.slice(n,r)==t},pi.eq=ps,pi.escape=function(e){return(e=Hs(e))&&Ee.test(e)?e.replace(Me,Mn):e},pi.escapeRegExp=function(e){return(e=Hs(e))&&Le.test(e)?e.replace(Re,"\\$&"):e},pi.every=function(e,t,n){var i=ys(e)?Kt:Ui;return n&&qo(e,t,n)&&(t=o),i(e,No(t,3))},pi.find=Ga,pi.findIndex=ga,pi.findKey=function(e,t){return an(e,No(t,3),qi)},pi.findLast=Va,pi.findLastIndex=ya,pi.findLastKey=function(e,t){return an(e,No(t,3),Xi)},pi.floor=ql,pi.forEach=Ha,pi.forEachRight=Ya,pi.forIn=function(e,t){return null==e?e:Hi(e,No(t,3),ol)},pi.forInRight=function(e,t){return null==e?e:Yi(e,No(t,3),ol)},pi.forOwn=function(e,t){return e&&qi(e,No(t,3))},pi.forOwnRight=function(e,t){return e&&Xi(e,No(t,3))},pi.get=Qs,pi.gt=fs,pi.gte=ms,pi.has=function(e,t){return null!=e&&Go(e,t,er)},pi.hasIn=el,pi.head=ba,pi.identity=Pl,pi.includes=function(e,t,n,i){e=bs(e)?e:pl(e),n=n&&!i?Us(n):0;var r=e.length;return n<0&&(n=Hn(r+n,0)),Is(e)?n<=r&&e.indexOf(t,n)>-1:!!r&&ln(e,t,n)>-1},pi.indexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var r=null==n?0:Us(n);return r<0&&(r=Hn(i+r,0)),ln(e,t,r)},pi.inRange=function(e,t,n){return t=js(t),n===o?(n=t,t=0):n=js(n),function(e,t,n){return e>=Yn(t,n)&&e=-I&&e<=I},pi.isSet=Ls,pi.isString=Is,pi.isSymbol=Ds,pi.isTypedArray=Ns,pi.isUndefined=function(e){return e===o},pi.isWeakMap=function(e){return Os(e)&&Wo(e)==ae},pi.isWeakSet=function(e){return Os(e)&&$i(e)==se},pi.join=function(e,t){return null==e?"":Gn.call(e,t)},pi.kebabCase=yl,pi.last=Ma,pi.lastIndexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var r=i;return n!==o&&(r=(r=Us(n))<0?Hn(i+r,0):Yn(r,i-1)),t==t?function(e,t,n){for(var i=n+1;i--;)if(e[i]===t)return i;return i}(e,t,r):sn(e,cn,r,!0)},pi.lowerCase=vl,pi.lowerFirst=bl,pi.lt=Fs,pi.lte=zs,pi.max=function(e){return e&&e.length?Wi(e,Pl,Qi):o},pi.maxBy=function(e,t){return e&&e.length?Wi(e,No(t,2),Qi):o},pi.mean=function(e){return dn(e,Pl)},pi.meanBy=function(e,t){return dn(e,No(t,2))},pi.min=function(e){return e&&e.length?Wi(e,Pl,dr):o},pi.minBy=function(e,t){return e&&e.length?Wi(e,No(t,2),dr):o},pi.stubArray=Wl,pi.stubFalse=Gl,pi.stubObject=function(){return{}},pi.stubString=function(){return""},pi.stubTrue=function(){return!0},pi.multiply=Kl,pi.nth=function(e,t){return e&&e.length?gr(e,Us(t)):o},pi.noConflict=function(){return Lt._===this&&(Lt._=mt),this},pi.noop=Dl,pi.now=Qa,pi.pad=function(e,t,n){e=Hs(e);var i=(t=Us(t))?An(e):0;if(!t||i>=t)return e;var r=(t-i)/2;return vo(Bn(r),n)+e+vo(zn(r),n)},pi.padEnd=function(e,t,n){e=Hs(e);var i=(t=Us(t))?An(e):0;return t&&it){var i=e;e=t,t=i}if(n||e%1||t%1){var r=Kn();return Yn(e+r*(t-e+kt("1e-"+((r+"").length-1))),t)}return xr(e,t)},pi.reduce=function(e,t,n){var i=ys(e)?tn:fn,r=arguments.length<3;return i(e,No(t,4),n,r,Bi)},pi.reduceRight=function(e,t,n){var i=ys(e)?nn:fn,r=arguments.length<3;return i(e,No(t,4),n,r,ji)},pi.repeat=function(e,t,n){return t=(n?qo(e,t,n):t===o)?1:Us(t),wr(Hs(e),t)},pi.replace=function(){var e=arguments,t=Hs(e[0]);return e.length<3?t:t.replace(e[1],e[2])},pi.result=function(e,t,n){var i=-1,r=(t=Yr(t,e)).length;for(r||(r=1,e=o);++iI)return[];var n=F,i=Yn(e,F);t=No(t),e-=F;for(var r=gn(i,t);++n=a)return e;var l=n-An(i);if(l<1)return i;var u=s?Xr(s,0,l).join(""):e.slice(0,l);if(r===o)return u+i;if(s&&(l+=u.length-l),Rs(r)){if(e.slice(l).search(r)){var c,d=u;for(r.global||(r=nt(r.source,Hs(Ge.exec(r))+"g")),r.lastIndex=0;c=r.exec(d);)var h=c.index;u=u.slice(0,h===o?l:h)}}else if(e.indexOf(Nr(r),l)!=l){var p=u.lastIndexOf(r);p>-1&&(u=u.slice(0,p))}return u+i},pi.unescape=function(e){return(e=Hs(e))&&Se.test(e)?e.replace(we,Ln):e},pi.uniqueId=function(e){var t=++dt;return Hs(e)+t},pi.upperCase=wl,pi.upperFirst=Ml,pi.each=Ha,pi.eachRight=Ya,pi.first=ba,Il(pi,(Xl={},qi(pi,(function(e,t){ct.call(pi.prototype,t)||(Xl[t]=e)})),Xl),{chain:!1}),pi.VERSION="4.17.15",qt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){pi[e].placeholder=pi})),qt(["drop","take"],(function(e,t){yi.prototype[e]=function(n){n=n===o?1:Hn(Us(n),0);var i=this.__filtered__&&!t?new yi(this):this.clone();return i.__filtered__?i.__takeCount__=Yn(n,i.__takeCount__):i.__views__.push({size:Yn(n,F),type:e+(i.__dir__<0?"Right":"")}),i},yi.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),qt(["filter","map","takeWhile"],(function(e,t){var n=t+1,i=n==A||3==n;yi.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:No(e,3),type:n}),t.__filtered__=t.__filtered__||i,t}})),qt(["head","last"],(function(e,t){var n="take"+(t?"Right":"");yi.prototype[e]=function(){return this[n](1).value()[0]}})),qt(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");yi.prototype[e]=function(){return this.__filtered__?new yi(this):this[n](1)}})),yi.prototype.compact=function(){return this.filter(Pl)},yi.prototype.find=function(e){return this.filter(e).head()},yi.prototype.findLast=function(e){return this.reverse().find(e)},yi.prototype.invokeMap=Mr((function(e,t){return"function"==typeof e?new yi(this):this.map((function(n){return ir(n,e,t)}))})),yi.prototype.reject=function(e){return this.filter(ls(No(e)))},yi.prototype.slice=function(e,t){e=Us(e);var n=this;return n.__filtered__&&(e>0||t<0)?new yi(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==o&&(n=(t=Us(t))<0?n.dropRight(-t):n.take(t-e)),n)},yi.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},yi.prototype.toArray=function(){return this.take(F)},qi(yi.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),r=pi[i?"take"+("last"==t?"Right":""):t],a=i||/^find/.test(t);r&&(pi.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,l=t instanceof yi,u=s[0],c=l||ys(t),d=function(e){var t=r.apply(pi,en([e],s));return i&&h?t[0]:t};c&&n&&"function"==typeof u&&1!=u.length&&(l=c=!1);var h=this.__chain__,p=!!this.__actions__.length,f=a&&!h,m=l&&!p;if(!a&&c){t=m?t:new yi(this);var g=e.apply(t,s);return g.__actions__.push({func:ja,args:[d],thisArg:o}),new gi(g,h)}return f&&m?e.apply(this,s):(g=this.thru(d),f?i?g.value()[0]:g.value():g)})})),qt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=ot[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);pi.prototype[e]=function(){var e=arguments;if(i&&!this.__chain__){var r=this.value();return t.apply(ys(r)?r:[],e)}return this[n]((function(n){return t.apply(ys(n)?n:[],e)}))}})),qi(yi.prototype,(function(e,t){var n=pi[t];if(n){var i=n.name+"";ct.call(ri,i)||(ri[i]=[]),ri[i].push({name:t,func:n})}})),ri[fo(o,v).name]=[{name:"wrapper",func:o}],yi.prototype.clone=function(){var e=new yi(this.__wrapped__);return e.__actions__=no(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=no(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=no(this.__views__),e},yi.prototype.reverse=function(){if(this.__filtered__){var e=new yi(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},yi.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=ys(e),i=t<0,r=n?e.length:0,o=function(e,t,n){var i=-1,r=n.length;for(;++i=this.__values__.length;return{done:e,value:e?o:this.__values__[this.__index__++]}},pi.prototype.plant=function(e){for(var t,n=this;n instanceof mi;){var i=ha(n);i.__index__=0,i.__values__=o,t?r.__wrapped__=i:t=i;var r=i;n=n.__wrapped__}return r.__wrapped__=e,t},pi.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof yi){var t=e;return this.__actions__.length&&(t=new yi(this)),(t=t.reverse()).__actions__.push({func:ja,args:[Ca],thisArg:o}),new gi(t,this.__chain__)}return this.thru(Ca)},pi.prototype.toJSON=pi.prototype.valueOf=pi.prototype.value=function(){return Ur(this.__wrapped__,this.__actions__)},pi.prototype.first=pi.prototype.head,zt&&(pi.prototype[zt]=function(){return this}),pi}();Lt._=In,(r=function(){return In}.call(t,n,t,i))===o||(i.exports=r)}).call(this)}).call(this,n(47),n(74)(e))},function(e,t,n){e.exports={default:n(190),__esModule:!0}},function(e,t,n){e.exports={default:n(192),__esModule:!0}},function(e,t,n){"use strict";var i,r,o=e.exports=n(30),a=n(155);o.codegen=n(412),o.fetch=n(413),o.path=n(414),o.fs=o.inquire("fs"),o.toArray=function(e){if(e){for(var t=Object.keys(e),n=new Array(t.length),i=0;i3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=new i.MeshBasicMaterial({map:d.load(e),transparent:!0,depthWrite:!1}),l=new i.Mesh(new i.PlaneGeometry(t,n),s);return l.material.side=i.DoubleSide,l.position.set(r,o,a),l.overdraw=!0,l},t.drawDashedLineFromPoints=function(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]:1,l=!(arguments.length>7&&void 0!==arguments[7])||arguments[7],u=(new i.Path).createGeometry(e);u.computeLineDistances();var c=new i.LineDashedMaterial({color:t,dashSize:r,linewidth:n,gapSize:o,transparent:!0,opacity:s}),d=new i.Line(u,c);h(d,a),d.matrixAutoUpdate=l,l||d.updateMatrix();return d},t.drawCircle=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:32,r=new i.CircleGeometry(e,n);return new i.Mesh(r,t)},t.drawThickBandFromPoints=function(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=u(e.map((function(e){return[e.x,e.y]}))),s=new i.ShaderMaterial(c({side:i.DoubleSide,diffuse:n,thickness:t,opacity:r,transparent:!0})),l=new i.Mesh(a,s);return h(l,o),l},t.drawSegmentsFromPoints=p,t.drawBox=function(e,t,n){var r=new i.CubeGeometry(e.x,e.y,e.z),o=new i.MeshBasicMaterial({color:t}),a=new i.Mesh(r,o),s=new i.BoxHelper(a);return s.material.linewidth=n,s},t.drawDashedBox=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.01,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.02,a=new i.CubeGeometry(e.x,e.y,e.z);a=new i.EdgesGeometry(a),(a=(new i.Geometry).fromBufferGeometry(a)).computeLineDistances();var s=new i.LineDashedMaterial({color:t,linewidth:n,dashSize:r,gapSize:o});return new i.LineSegments(a,s)},t.drawArrow=function(e,t,n,r,o){var a=new i.Vector3(0,e,0),s=new i.Vector3(0,0,0),l=new i.Vector3(r/2,e-n,0),u=new i.Vector3(-r/2,e-n,0);return p([s,a,l,a,u],o,t,1)},t.getShapeGeometryFromPoints=f,t.drawShapeFromPoints=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new i.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 i.Mesh(a,t);h(s,r),s.matrixAutoUpdate=o,!1===o&&s.updateMatrix();return s};var i=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}(n(11)),r=a(n(225)),o=a(n(234));function a(e){return e&&e.__esModule?e:{default:e}}var s=n(14),l=.04,u=(0,r.default)(i),c=(0,o.default)(i),d=new i.TextureLoader;function h(e,t){if(t){var n=t*l;e.position.z+=n}}function p(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 i.Path).createGeometry(e),u=new i.LineBasicMaterial({color:t,linewidth:n,transparent:a,opacity:s}),c=new i.Line(l,u);return h(c,r),c.matrixAutoUpdate=o,!1===o&&c.updateMatrix(),c}function f(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new i.Shape;if(t){n.moveTo(e[0].x,e[0].y);for(var r=1;r2&&void 0!==arguments[2]&&arguments[2];this.coordinates.isInitialized()&&!n||this.coordinates.initialize(e,t)}},{key:"updateDimension",value:function(e,t){e=e||(this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.dimension.width=e,this.dimension.height=t)}},{key:"enableOrbitControls",value:function(e){var t=this.adc.mesh.position;this.camera.position.set(t.x,t.y,50),"FLU"===this.coordinates.systemName?this.camera.up.set(1,0,0):this.camera.up.set(0,0,1);var n=new o.Vector3(t.x,t.y,0);this.camera.lookAt(n),this.controls.target0=n.clone(),this.controls.position0=this.camera.position.clone(),this.controls.zoom0=this.camera.zoom,this.controls.minDistance=4,this.controls.maxDistance=4e3,this.controls.minPolarAngle=0,this.controls.maxPolarAngle=Math.PI/2,this.controls.enabled=!0,this.controls.enableRotate=e,this.controls.reset()}},{key:"adjustCamera",value:function(e,t){if(!this.routingEditor.isInEditingMode()){switch(this.camera.fov=PARAMETERS.camera[t].fov,this.camera.near=PARAMETERS.camera[t].near,this.camera.far=PARAMETERS.camera[t].far,t){case"Default":var n=this.viewDistance*Math.cos(e.rotation.y)*Math.cos(this.viewAngle),i=this.viewDistance*Math.sin(e.rotation.y)*Math.cos(this.viewAngle),r=this.viewDistance*Math.sin(this.viewAngle);this.camera.position.x=e.position.x-n,this.camera.position.y=e.position.y-i,this.camera.position.z=e.position.z+r,this.camera.up.set(0,0,1),this.camera.lookAt({x:e.position.x+n,y:e.position.y+i,z:0}),this.controls.enabled=!1;break;case"Near":n=.5*this.viewDistance*Math.cos(e.rotation.y)*Math.cos(this.viewAngle),i=.5*this.viewDistance*Math.sin(e.rotation.y)*Math.cos(this.viewAngle),r=.5*this.viewDistance*Math.sin(this.viewAngle),this.camera.position.x=e.position.x-n,this.camera.position.y=e.position.y-i,this.camera.position.z=e.position.z+r,this.camera.up.set(0,0,1),this.camera.lookAt({x:e.position.x+n,y:e.position.y+i,z:0}),this.controls.enabled=!1;break;case"Overhead":i=.5*this.viewDistance*Math.sin(e.rotation.y)*Math.cos(this.viewAngle),r=2*this.viewDistance*Math.sin(this.viewAngle),this.camera.position.x=e.position.x,this.camera.position.y=e.position.y+i,this.camera.position.z=2*(e.position.z+r),"FLU"===this.coordinates.systemName?this.camera.up.set(1,0,0):this.camera.up.set(0,1,0),this.camera.lookAt({x:e.position.x,y:e.position.y+i,z:0}),this.controls.enabled=!1;break;case"Map":this.controls.enabled||this.enableOrbitControls(!0);break;case"CameraView":var o=this.cameraData.get(),a=o.position,s=o.rotation,l=this.coordinates.applyOffset(a),u=l.x,c=l.y,d=l.z;this.camera.position.set(u,c,d),this.camera.rotation.set(s.x+Math.PI,-s.y,-s.z),this.controls.enabled=!1;var h=document.getElementById("camera-image");h&&this.cameraData.imageSrcData&&(h.src=this.cameraData.imageSrcData)}this.camera.updateProjectionMatrix()}}},{key:"enableRouteEditing",value:function(){this.enableOrbitControls(!1),this.routingEditor.enableEditingMode(this.camera,this.adc),document.getElementById(this.canvasId).addEventListener("mousedown",this.onMouseDownHandler,!1)}},{key:"disableRouteEditing",value:function(){this.routingEditor.disableEditingMode(this.scene);var e=document.getElementById(this.canvasId);e&&e.removeEventListener("mousedown",this.onMouseDownHandler,!1)}},{key:"addDefaultEndPoint",value:function(e){for(var t=0;t1&&void 0!==arguments[1]&&arguments[1];t&&this.map.removeAllElements(this.scene),this.map.appendMapData(e,this.coordinates,this.scene)}},{key:"updatePointCloud",value:function(e){this.coordinates.isInitialized()&&this.adc.mesh&&this.pointCloud.update(e,this.adc.mesh)}},{key:"updateMapIndex",value:function(e,t,n){this.routingEditor.isInEditingMode()&&PARAMETERS.routingEditor.radiusOfMapRequest!==n||this.map.updateIndex(e,t,this.scene)}},{key:"isMobileDevice",value:function(){return navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)}},{key:"getGeolocation",value:function(e){if(this.coordinates.isInitialized()){var t=e.currentTarget.getBoundingClientRect(),n=new o.Vector3((e.clientX-t.left)/this.dimension.width*2-1,-(e.clientY-t.top)/this.dimension.height*2+1,0);n.unproject(this.camera);var i=n.sub(this.camera.position).normalize(),r=-this.camera.position.z/i.z,a=this.camera.position.clone().add(i.multiplyScalar(r));return this.coordinates.applyOffset(a,!0)}}},{key:"getMouseOverLanes",value:function(e){var t=e.currentTarget.getBoundingClientRect(),n=new o.Vector3((e.clientX-t.left)/this.dimension.width*2-1,-(e.clientY-t.top)/this.dimension.height*2+1,0),i=new o.Raycaster;i.setFromCamera(n,this.camera);var r=this.map.data.lane.reduce((function(e,t){return e.concat(t.drewObjects)}),[]);return i.intersectObjects(r).map((function(e){return e.object.name}))}}]),e}());t.default=S},function(e,t,n){"use strict";(function(e){var i=t;function r(e,t,n){for(var i=Object.keys(t),r=0;r0)},i.Buffer=function(){try{var e=i.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),i._Buffer_from=null,i._Buffer_allocUnsafe=null,i.newBuffer=function(e){return"number"==typeof e?i.Buffer?i._Buffer_allocUnsafe(e):new i.Array(e):i.Buffer?i._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},i.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,i.Long=i.global.dcodeIO&&i.global.dcodeIO.Long||i.global.Long||i.inquire("long"),i.key2Re=/^true|false|0|1$/,i.key32Re=/^-?(?:0|[1-9][0-9]*)$/,i.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,i.longToHash=function(e){return e?i.LongBits.from(e).toHash():i.LongBits.zeroHash},i.longFromHash=function(e,t){var n=i.LongBits.fromHash(e);return i.Long?i.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},i.merge=r,i.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},i.newError=o,i.ProtocolError=o("ProtocolError"),i.oneOfGetter=function(e){for(var t={},n=0;n-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},i.oneOfSetter=function(e){return function(t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:0;if(e.constructor===Array&&e.length>0)for(;t1&&void 0!==arguments[1]&&arguments[1],n=new Date(e),i=n.getHours(),r=n.getMinutes(),o=n.getSeconds(),a=(i=i<10?"0"+i:i)+":"+(r=r<10?"0"+r:r)+":"+(o=o<10?"0"+o:o);if(t){var s=n.getMilliseconds();s<10?s="00"+s:s<100&&(s="0"+s),a+=":"+s}return a},t.calculateLaneMarkerPoints=function(e,t){if(!e||!t)return[];for(var n=e.positionX,i=e.positionY,r=e.heading,a=t.c0Position,s=t.c1HeadingAngle,l=t.c2Curvature,u=t.c3CurvatureDerivative,c=t.viewRange,d=[u,l,s,a],h=[],p=0;p=t.length?{value:void 0,done:!0}:(e=i(t,n),this._i+=e.length,{value:e,done:!1})}))},function(e,t){e.exports={}},function(e,t,n){e.exports={default:n(238),__esModule:!0}},function(e,t,n){"use strict";e.exports=o,o.className="ReflectionObject";var i,r=n(17);function o(e,t){if(!r.isString(e))throw TypeError("name must be a string");if(t&&!r.isObject(t))throw TypeError("options must be an object");this.options=t,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(o.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),o.prototype.toJSON=function(){throw Error()},o.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var t=e.root;t instanceof i&&t._handleAdd(this)},o.prototype.onRemove=function(e){var t=e.root;t instanceof i&&t._handleRemove(this),this.parent=null,this.resolved=!1},o.prototype.resolve=function(){return this.resolved?this:(this.root instanceof i&&(this.resolved=!0),this)},o.prototype.getOption=function(e){if(this.options)return this.options[e]},o.prototype.setOption=function(e,t,n){return n&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},o.prototype.setOptions=function(e,t){if(e)for(var n=Object.keys(e),i=0;ib;b++)if((g=t?v(a(f=e[b])[0],f[1]):v(e[b]))===u||g===c)return g}else for(m=y.call(e);!(f=m.next()).done;)if((g=r(m,v,f.value,t))===u||g===c)return g}).BREAK=u,t.RETURN=c},function(e,t,n){"use strict";e.exports=function(){return new Worker(n.p+"worker.bundle.js")}},function(e,t,n){"use strict";e.exports=c;var i=n(45);((c.prototype=Object.create(i.prototype)).constructor=c).className="Namespace";var r,o,a,s=n(46),l=n(17);function u(e,t){if(e&&e.length){for(var n={},i=0;i=t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var n=0;n0;){var i=e.shift();if(n.nested&&n.nested[i]){if(!((n=n.nested[i])instanceof c))throw Error("path conflicts with non-namespace objects")}else n.add(n=new c(i))}return t&&n.addJSON(t),n},c.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t-1)return i}else if(i instanceof c&&(i=i.lookup(e.slice(1),t,!0)))return i}else for(var r=0;r=0&&c.splice(t,1)}function g(e){var t=document.createElement("style");return e.attrs.type="text/css",y(t,e.attrs),f(e,t),t}function y(e,t){Object.keys(t).forEach((function(n){e.setAttribute(n,t[n])}))}function v(e,t){var n,i,r,o;if(t.transform&&e.css){if(!(o=t.transform(e.css)))return function(){};e.css=o}if(t.singleton){var a=u++;n=l||(l=g(t)),i=x.bind(null,n,a,!1),r=x.bind(null,n,a,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",y(t,e.attrs),f(e,t),t}(t),i=M.bind(null,n,t),r=function(){m(n),n.href&&URL.revokeObjectURL(n.href)}):(n=g(t),i=w.bind(null,n),r=function(){m(n)});return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||(t.singleton=a()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=p(e,t);return h(n,t),function(e){for(var i=[],r=0;r0?r(i(e),9007199254740991):0}},function(e,t){var n=0,i=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++n+i).toString(36))}},function(e,t,n){var i=n(65)("meta"),r=n(22),o=n(38),a=n(23).f,s=0,l=Object.isExtensible||function(){return!0},u=!n(37)((function(){return l(Object.preventExtensions({}))})),c=function(e){a(e,i,{value:{i:"O"+ ++s,w:{}}})},d=e.exports={KEY:i,NEED:!1,fastKey:function(e,t){if(!r(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,i)){if(!l(e))return"F";if(!t)return"E";c(e)}return e[i].i},getWeak:function(e,t){if(!o(e,i)){if(!l(e))return!0;if(!t)return!1;c(e)}return e[i].w},onFreeze:function(e){return u&&d.NEED&&l(e)&&!o(e,i)&&c(e),e}}},function(e,t,n){var i=n(25),r=n(114),o=n(84),a=n(82)("IE_PROTO"),s=function(){},l=function(){var e,t=n(75)("iframe"),i=o.length;for(t.style.display="none",n(115).appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("