- ***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}function n(t){return"function"==typeof t}var r=!1,s={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack;r=t},get useDeprecatedSynchronousErrorHandling(){return r}};function o(t){setTimeout((function(){throw t}),0)}var a={closed:!0,next:function(t){},error:function(t){if(s.useDeprecatedSynchronousErrorHandling)throw t;o(t)},complete:function(){}},c=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function h(t){return null!==t&&"object"==typeof t}var l=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),u=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var i=this,r=i._parentOrParents,s=i._ctorUnsubscribe,o=i._unsubscribe,a=i._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,r instanceof t)r.remove(this);else if(null!==r)for(var u=0;u<r.length;++u){r[u].remove(this)}if(n(o)){s&&(this._unsubscribe=void 0);try{o.call(this)}catch(t){e=t instanceof l?d(t.errors):[t]}}if(c(a)){u=-1;for(var p=a.length;++u<p;){var f=a[u];if(h(f))try{f.unsubscribe()}catch(t){e=e||[],t instanceof l?e=e.concat(d(t.errors)):e.push(t)}}}if(e)throw new l(e)}},t.prototype.add=function(e){var i=e;if(!e)return t.EMPTY;switch(typeof e){case"function":i=new t(e);case"object":if(i===this||i.closed||"function"!=typeof i.unsubscribe)return i;if(this.closed)return i.unsubscribe(),i;if(!(i instanceof t)){var n=i;(i=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var r=i._parentOrParents;if(null===r)i._parentOrParents=this;else if(r instanceof t){if(r===this)return i;i._parentOrParents=[r,this]}else{if(-1!==r.indexOf(this))return i;r.push(this)}var s=this._subscriptions;return null===s?this._subscriptions=[i]:s.push(i),i},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var i=e.indexOf(t);-1!==i&&e.splice(i,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function d(t){return t.reduce((function(t,e){return t.concat(e instanceof l?e.errors:e)}),[])}var p=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),f=function(t){function e(i,n,r){var s=t.call(this)||this;switch(s.syncErrorValue=null,s.syncErrorThrown=!1,s.syncErrorThrowable=!1,s.isStopped=!1,arguments.length){case 0:s.destination=a;break;case 1:if(!i){s.destination=a;break}if("object"==typeof i){i instanceof e?(s.syncErrorThrowable=i.syncErrorThrowable,s.destination=i,i.add(s)):(s.syncErrorThrowable=!0,s.destination=new m(s,i));break}default:s.syncErrorThrowable=!0,s.destination=new m(s,i,n,r)}return s}return i(e,t),e.prototype[p]=function(){return this},e.create=function(t,i,n){var r=new e(t,i,n);return r.syncErrorThrowable=!1,r},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(u),m=function(t){function e(e,i,r,s){var o,c=t.call(this)||this;c._parentSubscriber=e;var h=c;return n(i)?o=i:i&&(o=i.next,r=i.error,s=i.complete,i!==a&&(n((h=Object.create(i)).unsubscribe)&&c.add(h.unsubscribe.bind(h)),h.unsubscribe=c.unsubscribe.bind(c))),c._context=h,c._next=o,c._error=r,c._complete=s,c}return i(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;s.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,i=s.useDeprecatedSynchronousErrorHandling;if(this._error)i&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)i?(e.syncErrorValue=t,e.syncErrorThrown=!0):o(t),this.unsubscribe();else{if(this.unsubscribe(),i)throw t;o(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var i=function(){return t._complete.call(t._context)};s.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,i),this.unsubscribe()):(this.__tryOrUnsub(i),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),s.useDeprecatedSynchronousErrorHandling)throw t;o(t)}},e.prototype.__tryOrSetError=function(t,e,i){if(!s.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,i)}catch(e){return s.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(o(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(f);var g=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function _(t){return t}function v(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return y(t)}function y(t){return 0===t.length?_:1===t.length?t[0]:function(e){return t.reduce((function(t,e){return e(t)}),e)}}var b=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var i=new t;return i.source=this,i.operator=e,i},t.prototype.subscribe=function(t,e,i){var n=this.operator,r=function(t,e,i){if(t){if(t instanceof f)return t;if(t[p])return t[p]()}return t||e||i?new f(t,e,i):new f(a)}(t,e,i);if(n?r.add(n.call(r,this.source)):r.add(this.source||s.useDeprecatedSynchronousErrorHandling&&!r.syncErrorThrowable?this._subscribe(r):this._trySubscribe(r)),s.useDeprecatedSynchronousErrorHandling&&r.syncErrorThrowable&&(r.syncErrorThrowable=!1,r.syncErrorThrown))throw r.syncErrorValue;return r},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){s.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),!function(t){for(;t;){var e=t,i=e.closed,n=e.destination,r=e.isStopped;if(i||r)return!1;t=n&&n instanceof f?n:null}return!0}(t)?console.warn(e):t.error(e)}},t.prototype.forEach=function(t,e){var i=this;return new(e=x(e))((function(e,n){var r;r=i.subscribe((function(e){try{t(e)}catch(t){n(t),r&&r.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[g]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:y(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=x(t))((function(t,i){var n;e.subscribe((function(t){return n=t}),(function(t){return i(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function x(t){if(t||(t=Promise),!t)throw new Error("no Promise impl found");return t}var w=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),S=function(t){function e(e,i){var n=t.call(this)||this;return n.subject=e,n.subscriber=i,n.closed=!1,n}return i(e,t),e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var i=e.indexOf(this.subscriber);-1!==i&&e.splice(i,1)}}},e}(u),M=function(t){function e(e){var i=t.call(this,e)||this;return i.destination=e,i}return i(e,t),e}(f),T=function(t){function e(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return i(e,t),e.prototype[p]=function(){return new M(this)},e.prototype.lift=function(t){var e=new C(this,this);return e.operator=t,e},e.prototype.next=function(t){if(this.closed)throw new w;if(!this.isStopped)for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].next(t)},e.prototype.error=function(t){if(this.closed)throw new w;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,i=e.length,n=e.slice(),r=0;r<i;r++)n[r].error(t);this.observers.length=0},e.prototype.complete=function(){if(this.closed)throw new w;this.isStopped=!0;for(var t=this.observers,e=t.length,i=t.slice(),n=0;n<e;n++)i[n].complete();this.observers.length=0},e.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},e.prototype._trySubscribe=function(e){if(this.closed)throw new w;return t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){if(this.closed)throw new w;return this.hasError?(t.error(this.thrownError),u.EMPTY):this.isStopped?(t.complete(),u.EMPTY):(this.observers.push(t),new S(this,t))},e.prototype.asObservable=function(){var t=new b;return t.source=this,t},e.create=function(t,e){return new C(t,e)},e}(b),C=function(t){function e(e,i){var n=t.call(this)||this;return n.destination=e,n.source=i,n}return i(e,t),e.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},e.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},e.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},e.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):u.EMPTY},e}(T);function E(){return function(t){return t.lift(new I(t))}}var I=function(){function t(t){this.connectable=t}return t.prototype.call=function(t,e){var i=this.connectable;i._refCount++;var n=new A(t,i),r=e.subscribe(n);return n.closed||(n.connection=i.connect()),r},t}(),A=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return i(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var i=this.connection,n=t._connection;this.connection=null,!n||i&&n!==i||n.unsubscribe()}}else this.connection=null},e}(f),P=function(t){function e(e,i){var n=t.call(this)||this;return n.source=e,n.subjectFactory=i,n._refCount=0,n._isComplete=!1,n}return i(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new u).add(this.source.subscribe(new L(this.getSubject(),this))),t.closed&&(this._connection=null,t=u.EMPTY)),t},e.prototype.refCount=function(){return E()(this)},e}(b),R=function(){var t=P.prototype;return{operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:t._subscribe},_isComplete:{value:t._isComplete,writable:!0},getSubject:{value:t.getSubject},connect:{value:t.connect},refCount:{value:t.refCount}}}(),L=function(t){function e(e,i){var n=t.call(this,e)||this;return n.connectable=i,n}return i(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(M),O=function(t){function e(e){var i=t.call(this)||this;return i._value=e,i}return i(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),e.prototype._subscribe=function(e){var i=t.prototype._subscribe.call(this,e);return i&&!i.closed&&e.next(this._value),i},e.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new w;return this._value},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(T),N=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n.pending=!1,n}return i(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var i=this.id,n=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(n,i,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},e.prototype.requestAsyncId=function(t,e,i){return void 0===i&&(i=0),setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,e,i){if(void 0===i&&(i=0),null!==i&&this.delay===i&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,e);if(i)return i;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var i=!1,n=void 0;try{this.work(t)}catch(t){i=!0,n=!!t&&t||new Error(t)}if(i)return this.unsubscribe(),n},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,i=e.actions,n=i.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&i.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,i){return t.call(this)||this}return i(e,t),e.prototype.schedule=function(t,e){return this},e}(u)),D=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.scheduler=e,n.work=i,n}return i(e,t),e.prototype.schedule=function(e,i){return void 0===i&&(i=0),i>0?t.prototype.schedule.call(this,e,i):(this.delay=i,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,i){return i>0||this.closed?t.prototype.execute.call(this,e,i):this._execute(e,i)},e.prototype.requestAsyncId=function(e,i,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,i,n):e.flush(this)},e}(N),$=function(){function t(e,i){void 0===i&&(i=t.now),this.SchedulerAction=e,this.now=i}return t.prototype.schedule=function(t,e,i){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(i,e)},t.now=function(){return Date.now()},t}(),k=function(t){function e(i,n){void 0===n&&(n=$.now);var r=t.call(this,i,(function(){return e.delegate&&e.delegate!==r?e.delegate.now():n()}))||this;return r.actions=[],r.active=!1,r.scheduled=void 0,r}return i(e,t),e.prototype.schedule=function(i,n,r){return void 0===n&&(n=0),e.delegate&&e.delegate!==this?e.delegate.schedule(i,n,r):t.prototype.schedule.call(this,i,n,r)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var i;this.active=!0;do{if(i=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,i){for(;t=e.shift();)t.unsubscribe();throw i}}},e}($),z=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e}(k))(D),F=new b((function(t){return t.complete()}));function B(t){return t?function(t){return new b((function(e){return t.schedule((function(){return e.complete()}))}))}(t):F}function j(t){return t&&"function"==typeof t.schedule}var H=function(t){return function(e){for(var i=0,n=t.length;i<n&&!e.closed;i++)e.next(t[i]);e.complete()}};function U(t,e){return new b((function(i){var n=new u,r=0;return n.add(e.schedule((function(){r!==t.length?(i.next(t[r++]),i.closed||n.add(this.schedule())):i.complete()}))),n}))}function V(t,e){return e?U(t,e):new b(H(t))}function G(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return j(i)?(t.pop(),U(t,i)):V(t)}function q(t,e){return new b(e?function(i){return e.schedule(W,0,{error:t,subscriber:i})}:function(e){return e.error(t)})}function W(t){var e=t.error;t.subscriber.error(e)}var X=function(){function t(t,e,i){this.kind=t,this.value=e,this.error=i,this.hasValue="N"===t}return t.prototype.observe=function(t){switch(this.kind){case"N":return t.next&&t.next(this.value);case"E":return t.error&&t.error(this.error);case"C":return t.complete&&t.complete()}},t.prototype.do=function(t,e,i){switch(this.kind){case"N":return t&&t(this.value);case"E":return e&&e(this.error);case"C":return i&&i()}},t.prototype.accept=function(t,e,i){return t&&"function"==typeof t.next?this.observe(t):this.do(t,e,i)},t.prototype.toObservable=function(){switch(this.kind){case"N":return G(this.value);case"E":return q(this.error);case"C":return B()}throw new Error("unexpected notification kind value")},t.createNext=function(e){return void 0!==e?new t("N",e):t.undefinedValueNotification},t.createError=function(e){return new t("E",void 0,e)},t.createComplete=function(){return t.completeNotification},t.completeNotification=new t("C"),t.undefinedValueNotification=new t("N",void 0),t}(),Y=function(t){function e(e,i,n){void 0===n&&(n=0);var r=t.call(this,e)||this;return r.scheduler=i,r.delay=n,r}return i(e,t),e.dispatch=function(t){var e=t.notification,i=t.destination;e.observe(i),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new Z(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(X.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(X.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(X.createComplete()),this.unsubscribe()},e}(f),Z=function(){return function(t,e){this.notification=t,this.destination=e}}(),J=function(t){function e(e,i,n){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===i&&(i=Number.POSITIVE_INFINITY);var r=t.call(this)||this;return r.scheduler=n,r._events=[],r._infiniteTimeWindow=!1,r._bufferSize=e<1?1:e,r._windowTime=i<1?1:i,i===Number.POSITIVE_INFINITY?(r._infiniteTimeWindow=!0,r.next=r.nextInfiniteTimeWindow):r.next=r.nextTimeWindow,r}return i(e,t),e.prototype.nextInfiniteTimeWindow=function(e){if(!this.isStopped){var i=this._events;i.push(e),i.length>this._bufferSize&&i.shift()}t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this.isStopped||(this._events.push(new K(this._getNow(),e)),this._trimBufferThenGetEvents()),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,i=this._infiniteTimeWindow,n=i?this._events:this._trimBufferThenGetEvents(),r=this.scheduler,s=n.length;if(this.closed)throw new w;if(this.isStopped||this.hasError?e=u.EMPTY:(this.observers.push(t),e=new S(this,t)),r&&t.add(t=new Y(t,r)),i)for(var o=0;o<s&&!t.closed;o++)t.next(n[o]);else for(o=0;o<s&&!t.closed;o++)t.next(n[o].value);return this.hasError?t.error(this.thrownError):this.isStopped&&t.complete(),e},e.prototype._getNow=function(){return(this.scheduler||z).now()},e.prototype._trimBufferThenGetEvents=function(){for(var t=this._getNow(),e=this._bufferSize,i=this._windowTime,n=this._events,r=n.length,s=0;s<r&&!(t-n[s].time<i);)s++;return r>e&&(s=Math.max(s,r-e)),s>0&&n.splice(0,s),n},e}(T),K=function(){return function(t,e){this.time=t,this.value=e}}(),Q=new k(N);function tt(){}var et=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),it=function(){function t(){return Error.call(this),this.message="no elements in sequence",this.name="EmptyError",this}return t.prototype=Object.create(Error.prototype),t}(),nt=function(){function t(){return Error.call(this),this.message="Timeout has occurred",this.name="TimeoutError",this}return t.prototype=Object.create(Error.prototype),t}();function rt(t,e){return function(i){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return i.lift(new st(t,e))}}var st=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new ot(t,this.project,this.thisArg))},t}(),ot=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.project=i,r.count=0,r.thisArg=n||r,r}return i(e,t),e.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(f),at=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.notifyNext=function(t,e,i,n,r){this.destination.next(e)},e.prototype.notifyError=function(t,e){this.destination.error(t)},e.prototype.notifyComplete=function(t){this.destination.complete()},e}(f),ct=function(t){function e(e,i,n){var r=t.call(this)||this;return r.parent=e,r.outerValue=i,r.outerIndex=n,r.index=0,r}return i(e,t),e.prototype._next=function(t){this.parent.notifyNext(this.outerValue,t,this.outerIndex,this.index++,this)},e.prototype._error=function(t){this.parent.notifyError(t,this),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},e}(f);function ht(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}var lt=ht(),ut=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function dt(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then}var pt=function(t){if(t&&"function"==typeof t[g])return n=t,function(t){var e=n[g]();if("function"!=typeof e.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return e.subscribe(t)};if(ut(t))return H(t);if(dt(t))return i=t,function(t){return i.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,o),t};if(t&&"function"==typeof t[lt])return e=t,function(t){for(var i=e[lt]();;){var n=void 0;try{n=i.next()}catch(e){return t.error(e),t}if(n.done){t.complete();break}if(t.next(n.value),t.closed)break}return"function"==typeof i.return&&t.add((function(){i.return&&i.return()})),t};var e,i,n,r=h(t)?"an invalid object":"'"+t+"'";throw new TypeError("You provided "+r+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")};function ft(t,e,i,n,r){if(void 0===r&&(r=new ct(t,i,n)),!r.closed)return e instanceof b?e.subscribe(r):pt(e)(r)}var mt={};function gt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=void 0,n=void 0;return j(t[t.length-1])&&(n=t.pop()),"function"==typeof t[t.length-1]&&(i=t.pop()),1===t.length&&c(t[0])&&(t=t[0]),V(t,n).lift(new _t(i))}var _t=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new vt(t,this.resultSelector))},t}(),vt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.resultSelector=i,n.active=0,n.values=[],n.observables=[],n}return i(e,t),e.prototype._next=function(t){this.values.push(mt),this.observables.push(t)},e.prototype._complete=function(){var t=this.observables,e=t.length;if(0===e)this.destination.complete();else{this.active=e,this.toRespond=e;for(var i=0;i<e;i++){var n=t[i];this.add(ft(this,n,void 0,i))}}},e.prototype.notifyComplete=function(t){0==(this.active-=1)&&this.destination.complete()},e.prototype.notifyNext=function(t,e,i){var n=this.values,r=n[i],s=this.toRespond?r===mt?--this.toRespond:this.toRespond:0;n[i]=e,0===s&&(this.resultSelector?this._tryResultSelector(n):this.destination.next(n.slice()))},e.prototype._tryResultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(at);function yt(t,e){if(null!=t){if(function(t){return t&&"function"==typeof t[g]}(t))return function(t,e){return new b((function(i){var n=new u;return n.add(e.schedule((function(){var r=t[g]();n.add(r.subscribe({next:function(t){n.add(e.schedule((function(){return i.next(t)})))},error:function(t){n.add(e.schedule((function(){return i.error(t)})))},complete:function(){n.add(e.schedule((function(){return i.complete()})))}}))}))),n}))}(t,e);if(dt(t))return function(t,e){return new b((function(i){var n=new u;return n.add(e.schedule((function(){return t.then((function(t){n.add(e.schedule((function(){i.next(t),n.add(e.schedule((function(){return i.complete()})))})))}),(function(t){n.add(e.schedule((function(){return i.error(t)})))}))}))),n}))}(t,e);if(ut(t))return U(t,e);if(function(t){return t&&"function"==typeof t[lt]}(t)||"string"==typeof t)return function(t,e){if(!t)throw new Error("Iterable cannot be null");return new b((function(i){var n,r=new u;return r.add((function(){n&&"function"==typeof n.return&&n.return()})),r.add(e.schedule((function(){n=t[lt](),r.add(e.schedule((function(){if(!i.closed){var t,e;try{var r=n.next();t=r.value,e=r.done}catch(t){return void i.error(t)}e?i.complete():(i.next(t),this.schedule())}})))}))),r}))}(t,e)}throw new TypeError((null!==t&&typeof t||t)+" is not observable")}function bt(t,e){return e?yt(t,e):t instanceof b?t:new b(pt(t))}var xt=function(t){function e(e){var i=t.call(this)||this;return i.parent=e,i}return i(e,t),e.prototype._next=function(t){this.parent.notifyNext(t)},e.prototype._error=function(t){this.parent.notifyError(t),this.unsubscribe()},e.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},e}(f),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyError=function(t){this.destination.error(t)},e.prototype.notifyComplete=function(){this.destination.complete()},e}(f);function St(t,e){if(!e.closed)return t instanceof b?t.subscribe(e):pt(t)(e)}function Mt(t,e,i){return void 0===i&&(i=Number.POSITIVE_INFINITY),"function"==typeof e?function(n){return n.pipe(Mt((function(i,n){return bt(t(i,n)).pipe(rt((function(t,r){return e(i,t,n,r)})))}),i))}:("number"==typeof e&&(i=e),function(e){return e.lift(new Tt(t,i))})}var Tt=function(){function t(t,e){void 0===e&&(e=Number.POSITIVE_INFINITY),this.project=t,this.concurrent=e}return t.prototype.call=function(t,e){return e.subscribe(new Ct(t,this.project,this.concurrent))},t}(),Ct=function(t){function e(e,i,n){void 0===n&&(n=Number.POSITIVE_INFINITY);var r=t.call(this,e)||this;return r.project=i,r.concurrent=n,r.hasCompleted=!1,r.buffer=[],r.active=0,r.index=0,r}return i(e,t),e.prototype._next=function(t){this.active<this.concurrent?this._tryNext(t):this.buffer.push(t)},e.prototype._tryNext=function(t){var e,i=this.index++;try{e=this.project(t,i)}catch(t){return void this.destination.error(t)}this.active++,this._innerSub(e)},e.prototype._innerSub=function(t){var e=new xt(this),i=this.destination;i.add(e);var n=St(t,e);n!==e&&i.add(n)},e.prototype._complete=function(){this.hasCompleted=!0,0===this.active&&0===this.buffer.length&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this.destination.next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t.length>0?this._next(t.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(wt);function Et(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),Mt(_,t)}function It(){return Et(1)}function At(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return It()(G.apply(void 0,t))}function Pt(t,e,i,r){return n(i)&&(r=i,i=void 0),r?Pt(t,e,i).pipe(rt((function(t){return c(t)?r.apply(void 0,t):r(t)}))):new b((function(n){Rt(t,e,(function(t){arguments.length>1?n.next(Array.prototype.slice.call(arguments)):n.next(t)}),n,i)}))}function Rt(t,e,i,n,r){var s;if(function(t){return t&&"function"==typeof t.addEventListener&&"function"==typeof t.removeEventListener}(t)){var o=t;t.addEventListener(e,i,r),s=function(){return o.removeEventListener(e,i,r)}}else if(function(t){return t&&"function"==typeof t.on&&"function"==typeof t.off}(t)){var a=t;t.on(e,i),s=function(){return a.off(e,i)}}else if(function(t){return t&&"function"==typeof t.addListener&&"function"==typeof t.removeListener}(t)){var c=t;t.addListener(e,i),s=function(){return c.removeListener(e,i)}}else{if(!t||!t.length)throw new TypeError("Invalid event target");for(var h=0,l=t.length;h<l;h++)Rt(t[h],e,i,n,r)}n.add(s)}function Lt(t){return!c(t)&&t-parseFloat(t)+1>=0}function Ot(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=Number.POSITIVE_INFINITY,n=null,r=t[t.length-1];return j(r)?(n=t.pop(),t.length>1&&"number"==typeof t[t.length-1]&&(i=t.pop())):"number"==typeof r&&(i=t.pop()),null===n&&1===t.length&&t[0]instanceof b?t[0]:Et(i)(V(t,n))}function Nt(t,e){return function(i){return i.lift(new Dt(t,e))}}var Dt=function(){function t(t,e){this.predicate=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new $t(t,this.predicate,this.thisArg))},t}(),$t=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.predicate=i,r.thisArg=n,r.count=0,r}return i(e,t),e.prototype._next=function(t){var e;try{e=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}e&&this.destination.next(t)},e}(f);function kt(t,e,i){void 0===t&&(t=0);var n=-1;return Lt(e)?n=Number(e)<1?1:Number(e):j(e)&&(i=e),j(i)||(i=Q),new b((function(e){var r=Lt(t)?t:+t-i.now();return i.schedule(zt,r,{index:0,period:n,subscriber:e})}))}function zt(t){var e=t.index,i=t.period,n=t.subscriber;if(n.next(e),!n.closed){if(-1===i)return n.complete();t.index=e+1,this.schedule(t,i)}}function Ft(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return"function"==typeof i&&t.pop(),V(t,void 0).lift(new Bt(i))}var Bt=function(){function t(t){this.resultSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new jt(t,this.resultSelector))},t}(),jt=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.resultSelector=i,r.iterators=[],r.active=0,r.resultSelector="function"==typeof i?i:void 0,r}return i(e,t),e.prototype._next=function(t){var e=this.iterators;c(t)?e.push(new Ut(t)):"function"==typeof t[lt]?e.push(new Ht(t[lt]())):e.push(new Vt(this.destination,this,t))},e.prototype._complete=function(){var t=this.iterators,e=t.length;if(this.unsubscribe(),0!==e){this.active=e;for(var i=0;i<e;i++){var n=t[i];if(n.stillUnsubscribed)this.destination.add(n.subscribe());else this.active--}}else this.destination.complete()},e.prototype.notifyInactive=function(){this.active--,0===this.active&&this.destination.complete()},e.prototype.checkIterators=function(){for(var t=this.iterators,e=t.length,i=this.destination,n=0;n<e;n++){if("function"==typeof(o=t[n]).hasValue&&!o.hasValue())return}var r=!1,s=[];for(n=0;n<e;n++){var o,a=(o=t[n]).next();if(o.hasCompleted()&&(r=!0),a.done)return void i.complete();s.push(a.value)}this.resultSelector?this._tryresultSelector(s):i.next(s),r&&i.complete()},e.prototype._tryresultSelector=function(t){var e;try{e=this.resultSelector.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(f),Ht=function(){function t(t){this.iterator=t,this.nextResult=t.next()}return t.prototype.hasValue=function(){return!0},t.prototype.next=function(){var t=this.nextResult;return this.nextResult=this.iterator.next(),t},t.prototype.hasCompleted=function(){var t=this.nextResult;return Boolean(t&&t.done)},t}(),Ut=function(){function t(t){this.array=t,this.index=0,this.length=0,this.length=t.length}return t.prototype[lt]=function(){return this},t.prototype.next=function(t){var e=this.index++,i=this.array;return e<this.length?{value:i[e],done:!1}:{value:null,done:!0}},t.prototype.hasValue=function(){return this.array.length>this.index},t.prototype.hasCompleted=function(){return this.array.length===this.index},t}(),Vt=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.parent=i,r.observable=n,r.stillUnsubscribed=!0,r.buffer=[],r.isComplete=!1,r}return i(e,t),e.prototype[lt]=function(){return this},e.prototype.next=function(){var t=this.buffer;return 0===t.length&&this.isComplete?{value:null,done:!0}:{value:t.shift(),done:!1}},e.prototype.hasValue=function(){return this.buffer.length>0},e.prototype.hasCompleted=function(){return 0===this.buffer.length&&this.isComplete},e.prototype.notifyComplete=function(){this.buffer.length>0?(this.isComplete=!0,this.parent.notifyInactive()):this.destination.complete()},e.prototype.notifyNext=function(t){this.buffer.push(t),this.parent.checkIterators()},e.prototype.subscribe=function(){return St(this.observable,new xt(this))},e}(wt);var Gt=function(){function t(t){this.durationSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new qt(t,this.durationSelector))},t}(),qt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.durationSelector=i,n.hasValue=!1,n}return i(e,t),e.prototype._next=function(t){if(this.value=t,this.hasValue=!0,!this.throttled){var e=void 0;try{e=(0,this.durationSelector)(t)}catch(t){return this.destination.error(t)}var i=St(e,new xt(this));!i||i.closed?this.clearThrottle():this.add(this.throttled=i)}},e.prototype.clearThrottle=function(){var t=this,e=t.value,i=t.hasValue,n=t.throttled;n&&(this.remove(n),this.throttled=void 0,n.unsubscribe()),i&&(this.value=void 0,this.hasValue=!1,this.destination.next(e))},e.prototype.notifyNext=function(){this.clearThrottle()},e.prototype.notifyComplete=function(){this.clearThrottle()},e}(wt);function Wt(t,e){return void 0===e&&(e=Q),i=function(){return kt(t,e)},function(t){return t.lift(new Gt(i))};var i}function Xt(t,e){return void 0===e&&(e=null),function(i){return i.lift(new Yt(t,e))}}var Yt=function(){function t(t,e){this.bufferSize=t,this.startBufferEvery=e,this.subscriberClass=e&&t!==e?Jt:Zt}return t.prototype.call=function(t,e){return e.subscribe(new this.subscriberClass(t,this.bufferSize,this.startBufferEvery))},t}(),Zt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.bufferSize=i,n.buffer=[],n}return i(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(f),Jt=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.bufferSize=i,r.startBufferEvery=n,r.buffers=[],r.count=0,r}return i(e,t),e.prototype._next=function(t){var e=this,i=e.bufferSize,n=e.startBufferEvery,r=e.buffers,s=e.count;this.count++,s%n==0&&r.push([]);for(var o=r.length;o--;){var a=r[o];a.push(t),a.length===i&&(r.splice(o,1),this.destination.next(a))}},e.prototype._complete=function(){for(var e=this.buffers,i=this.destination;e.length>0;){var n=e.shift();n.length>0&&i.next(n)}t.prototype._complete.call(this)},e}(f);var Kt=function(){function t(t){this.closingSelector=t}return t.prototype.call=function(t,e){return e.subscribe(new Qt(t,this.closingSelector))},t}(),Qt=function(t){function e(e,i){var n=t.call(this,e)||this;return n.closingSelector=i,n.subscribing=!1,n.openBuffer(),n}return i(e,t),e.prototype._next=function(t){this.buffer.push(t)},e.prototype._complete=function(){var e=this.buffer;e&&this.destination.next(e),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){this.buffer=void 0,this.subscribing=!1},e.prototype.notifyNext=function(){this.openBuffer()},e.prototype.notifyComplete=function(){this.subscribing?this.complete():this.openBuffer()},e.prototype.openBuffer=function(){var t=this.closingSubscription;t&&(this.remove(t),t.unsubscribe());var e,i=this.buffer;this.buffer&&this.destination.next(i),this.buffer=[];try{e=(0,this.closingSelector)()}catch(t){return this.error(t)}t=new u,this.closingSubscription=t,this.add(t),this.subscribing=!0,t.add(St(e,new xt(this))),this.subscribing=!1},e}(wt);function te(t){return function(e){var i=new ee(t),n=e.lift(i);return i.caught=n}}var ee=function(){function t(t){this.selector=t}return t.prototype.call=function(t,e){return e.subscribe(new ie(t,this.selector,this.caught))},t}(),ie=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.selector=i,r.caught=n,r}return i(e,t),e.prototype.error=function(e){if(!this.isStopped){var i=void 0;try{i=this.selector(e,this.caught)}catch(e){return void t.prototype.error.call(this,e)}this._unsubscribeAndRecycle();var n=new xt(this);this.add(n);var r=St(i,n);r!==n&&this.add(r)}},e}(wt);function ne(t,e){return Mt(t,e,1)}function re(t,e){return void 0===e&&(e=Q),function(i){return i.lift(new se(t,e))}}var se=function(){function t(t,e){this.dueTime=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new oe(t,this.dueTime,this.scheduler))},t}(),oe=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.dueTime=i,r.scheduler=n,r.debouncedSubscription=null,r.lastValue=null,r.hasValue=!1,r}return i(e,t),e.prototype._next=function(t){this.clearDebounce(),this.lastValue=t,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(ae,this.dueTime,this))},e.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},e.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var t=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(t)}},e.prototype.clearDebounce=function(){var t=this.debouncedSubscription;null!==t&&(this.remove(t),t.unsubscribe(),this.debouncedSubscription=null)},e}(f);function ae(t){t.debouncedNext()}function ce(t){return void 0===t&&(t=null),function(e){return e.lift(new he(t))}}var he=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new le(t,this.defaultValue))},t}(),le=function(t){function e(e,i){var n=t.call(this,e)||this;return n.defaultValue=i,n.isEmpty=!0,n}return i(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(f);function ue(t,e){return function(i){return i.lift(new de(t,e))}}var de=function(){function t(t,e){this.compare=t,this.keySelector=e}return t.prototype.call=function(t,e){return e.subscribe(new pe(t,this.compare,this.keySelector))},t}(),pe=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.keySelector=n,r.hasKey=!1,"function"==typeof i&&(r.compare=i),r}return i(e,t),e.prototype.compare=function(t,e){return t===e},e.prototype._next=function(t){var e;try{var i=this.keySelector;e=i?i(t):t}catch(t){return this.destination.error(t)}var n=!1;if(this.hasKey)try{n=(0,this.compare)(this.key,e)}catch(t){return this.destination.error(t)}else this.hasKey=!0;n||(this.key=e,this.destination.next(t))},e}(f);function fe(t){return void 0===t&&(t=_e),function(e){return e.lift(new me(t))}}var me=function(){function t(t){this.errorFactory=t}return t.prototype.call=function(t,e){return e.subscribe(new ge(t,this.errorFactory))},t}(),ge=function(t){function e(e,i){var n=t.call(this,e)||this;return n.errorFactory=i,n.hasValue=!1,n}return i(e,t),e.prototype._next=function(t){this.hasValue=!0,this.destination.next(t)},e.prototype._complete=function(){if(this.hasValue)return this.destination.complete();var t=void 0;try{t=this.errorFactory()}catch(e){t=e}this.destination.error(t)},e}(f);function _e(){return new it}function ve(t){return function(e){return 0===t?B():e.lift(new ye(t))}}var ye=function(){function t(t){if(this.total=t,this.total<0)throw new et}return t.prototype.call=function(t,e){return e.subscribe(new be(t,this.total))},t}(),be=function(t){function e(e,i){var n=t.call(this,e)||this;return n.total=i,n.count=0,n}return i(e,t),e.prototype._next=function(t){var e=this.total,i=++this.count;i<=e&&(this.destination.next(t),i===e&&(this.destination.complete(),this.unsubscribe()))},e}(f);function xe(t,e,i){return void 0===e&&(e=Number.POSITIVE_INFINITY),e=(e||0)<1?Number.POSITIVE_INFINITY:e,function(n){return n.lift(new we(t,e,i))}}var we=function(){function t(t,e,i){this.project=t,this.concurrent=e,this.scheduler=i}return t.prototype.call=function(t,e){return e.subscribe(new Se(t,this.project,this.concurrent,this.scheduler))},t}(),Se=function(t){function e(e,i,n,r){var s=t.call(this,e)||this;return s.project=i,s.concurrent=n,s.scheduler=r,s.index=0,s.active=0,s.hasCompleted=!1,n<Number.POSITIVE_INFINITY&&(s.buffer=[]),s}return i(e,t),e.dispatch=function(t){var e=t.subscriber,i=t.result,n=t.value,r=t.index;e.subscribeToProjection(i,n,r)},e.prototype._next=function(t){var i=this.destination;if(i.closed)this._complete();else{var n=this.index++;if(this.active<this.concurrent){i.next(t);try{var r=(0,this.project)(t,n);if(this.scheduler){var s={subscriber:this,result:r,value:t,index:n};this.destination.add(this.scheduler.schedule(e.dispatch,0,s))}else this.subscribeToProjection(r,t,n)}catch(t){i.error(t)}}else this.buffer.push(t)}},e.prototype.subscribeToProjection=function(t,e,i){this.active++,this.destination.add(St(t,new xt(this)))},e.prototype._complete=function(){this.hasCompleted=!0,this.hasCompleted&&0===this.active&&this.destination.complete(),this.unsubscribe()},e.prototype.notifyNext=function(t){this._next(t)},e.prototype.notifyComplete=function(){var t=this.buffer;this.active--,t&&t.length>0&&this._next(t.shift()),this.hasCompleted&&0===this.active&&this.destination.complete()},e}(wt);function Me(t){return function(e){return e.lift(new Te(t))}}var Te=function(){function t(t){this.callback=t}return t.prototype.call=function(t,e){return e.subscribe(new Ce(t,this.callback))},t}(),Ce=function(t){function e(e,i){var n=t.call(this,e)||this;return n.add(new u(i)),n}return i(e,t),e}(f);function Ee(t,e){var i=arguments.length>=2;return function(n){return n.pipe(t?Nt((function(e,i){return t(e,i,n)})):_,ve(1),i?ce(e):fe((function(){return new it})))}}function Ie(t){return function(e){return 0===t?B():e.lift(new Ae(t))}}var Ae=function(){function t(t){if(this.total=t,this.total<0)throw new et}return t.prototype.call=function(t,e){return e.subscribe(new Pe(t,this.total))},t}(),Pe=function(t){function e(e,i){var n=t.call(this,e)||this;return n.total=i,n.ring=new Array,n.count=0,n}return i(e,t),e.prototype._next=function(t){var e=this.ring,i=this.total,n=this.count++;e.length<i?e.push(t):e[n%i]=t},e.prototype._complete=function(){var t=this.destination,e=this.count;if(e>0)for(var i=this.count>=this.total?this.total:this.count,n=this.ring,r=0;r<i;r++){var s=e++%i;t.next(n[s])}t.complete()},e}(f);function Re(t,e){var i=arguments.length>=2;return function(n){return n.pipe(t?Nt((function(e,i){return t(e,i,n)})):_,Ie(1),i?ce(e):fe((function(){return new it})))}}function Le(t,e){var i=!1;return arguments.length>=2&&(i=!0),function(n){return n.lift(new Oe(t,e,i))}}var Oe=function(){function t(t,e,i){void 0===i&&(i=!1),this.accumulator=t,this.seed=e,this.hasSeed=i}return t.prototype.call=function(t,e){return e.subscribe(new Ne(t,this.accumulator,this.seed,this.hasSeed))},t}(),Ne=function(t){function e(e,i,n,r){var s=t.call(this,e)||this;return s.accumulator=i,s._seed=n,s.hasSeed=r,s.index=0,s}return i(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var e,i=this.index++;try{e=this.accumulator(this.seed,t,i)}catch(t){this.destination.error(t)}this.seed=e,this.destination.next(e)},e}(f);function De(t,e){return arguments.length>=2?function(i){return v(Le(t,e),Ie(1),ce(e))(i)}:function(e){return v(Le((function(e,i,n){return t(e,i,n+1)})),Ie(1))(e)}}function $e(t,e){return function(i){var n;if(n="function"==typeof t?t:function(){return t},"function"==typeof e)return i.lift(new ke(n,e));var r=Object.create(i,R);return r.source=i,r.subjectFactory=n,r}}var ke=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var i=this.selector,n=this.subjectFactory(),r=i(n).subscribe(t);return r.add(e.subscribe(n)),r},t}();function ze(){return function(t){return t.lift(new Fe)}}var Fe=function(){function t(){}return t.prototype.call=function(t,e){return e.subscribe(new Be(t))},t}(),Be=function(t){function e(e){var i=t.call(this,e)||this;return i.hasPrev=!1,i}return i(e,t),e.prototype._next=function(t){var e;this.hasPrev?e=[this.prev,t]:this.hasPrev=!0,this.prev=t,e&&this.destination.next(e)},e}(f);function je(t,e){return function(i){for(var n=i,r=0;r<e;r++){var s=null!=n?n[t[r]]:void 0;if(void 0===s)return;n=s}return n}}function He(t){return t?$e((function(){return new T}),t):$e(new T)}function Ue(t,e,i,n){i&&"function"!=typeof i&&(n=i);var r="function"==typeof i?i:void 0,s=new J(t,e,n);return function(t){return $e((function(){return s}),r)(t)}}function Ve(t){return void 0===t&&(t=-1),function(e){return e.lift(new Ge(t,e))}}var Ge=function(){function t(t,e){this.count=t,this.source=e}return t.prototype.call=function(t,e){return e.subscribe(new qe(t,this.count,this.source))},t}(),qe=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.count=i,r.source=n,r}return i(e,t),e.prototype.error=function(e){if(!this.isStopped){var i=this.source,n=this.count;if(0===n)return t.prototype.error.call(this,e);n>-1&&(this.count=n-1),i.subscribe(this._unsubscribeAndRecycle())}},e}(f);var We=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var i=new Xe(t),n=e.subscribe(i);return n.add(St(this.notifier,new xt(i))),n},t}(),Xe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hasValue=!1,e}return i(e,t),e.prototype._next=function(t){this.value=t,this.hasValue=!0},e.prototype.notifyNext=function(){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},e}(wt);function Ye(){return new T}function Ze(){return function(t){return E()($e(Ye)(t))}}function Je(t){return function(e){return e.lift(new Ke(t))}}var Ke=function(){function t(t){this.total=t}return t.prototype.call=function(t,e){return e.subscribe(new Qe(t,this.total))},t}(),Qe=function(t){function e(e,i){var n=t.call(this,e)||this;return n.total=i,n.count=0,n}return i(e,t),e.prototype._next=function(t){++this.count>this.total&&this.destination.next(t)},e}(f);function ti(t){return function(e){return e.lift(new ei(t))}}var ei=function(){function t(t){this.predicate=t}return t.prototype.call=function(t,e){return e.subscribe(new ii(t,this.predicate))},t}(),ii=function(t){function e(e,i){var n=t.call(this,e)||this;return n.predicate=i,n.skipping=!0,n.index=0,n}return i(e,t),e.prototype._next=function(t){var e=this.destination;this.skipping&&this.tryCallPredicate(t),this.skipping||e.next(t)},e.prototype.tryCallPredicate=function(t){try{var e=this.predicate(t,this.index++);this.skipping=Boolean(e)}catch(t){this.destination.error(t)}},e}(f);function ni(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[t.length-1];return j(i)?(t.pop(),function(e){return At(t,e,i)}):function(e){return At(t,e)}}function ri(t,e){return"function"==typeof e?function(i){return i.pipe(ri((function(i,n){return bt(t(i,n)).pipe(rt((function(t,r){return e(i,t,n,r)})))})))}:function(e){return e.lift(new si(t))}}var si=function(){function t(t){this.project=t}return t.prototype.call=function(t,e){return e.subscribe(new oi(t,this.project))},t}(),oi=function(t){function e(e,i){var n=t.call(this,e)||this;return n.project=i,n.index=0,n}return i(e,t),e.prototype._next=function(t){var e,i=this.index++;try{e=this.project(t,i)}catch(t){return void this.destination.error(t)}this._innerSub(e)},e.prototype._innerSub=function(t){var e=this.innerSubscription;e&&e.unsubscribe();var i=new xt(this),n=this.destination;n.add(i),this.innerSubscription=St(t,i),this.innerSubscription!==i&&n.add(this.innerSubscription)},e.prototype._complete=function(){var e=this.innerSubscription;e&&!e.closed||t.prototype._complete.call(this),this.unsubscribe()},e.prototype._unsubscribe=function(){this.innerSubscription=void 0},e.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&t.prototype._complete.call(this)},e.prototype.notifyNext=function(t){this.destination.next(t)},e}(wt);function ai(t){return function(e){return e.lift(new ci(t))}}var ci=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var i=new hi(t),n=St(this.notifier,new xt(i));return n&&!i.seenValue?(i.add(n),e.subscribe(i)):i},t}(),hi=function(t){function e(e){var i=t.call(this,e)||this;return i.seenValue=!1,i}return i(e,t),e.prototype.notifyNext=function(){this.seenValue=!0,this.complete()},e.prototype.notifyComplete=function(){},e}(wt);function li(t,e){return void 0===e&&(e=!1),function(i){return i.lift(new ui(t,e))}}var ui=function(){function t(t,e){this.predicate=t,this.inclusive=e}return t.prototype.call=function(t,e){return e.subscribe(new di(t,this.predicate,this.inclusive))},t}(),di=function(t){function e(e,i,n){var r=t.call(this,e)||this;return r.predicate=i,r.inclusive=n,r.index=0,r}return i(e,t),e.prototype._next=function(t){var e,i=this.destination;try{e=this.predicate(t,this.index++)}catch(t){return void i.error(t)}this.nextOrComplete(t,e)},e.prototype.nextOrComplete=function(t,e){var i=this.destination;Boolean(e)?i.next(t):(this.inclusive&&i.next(t),i.complete())},e}(f);function pi(t,e,i){return function(n){return n.lift(new fi(t,e,i))}}var fi=function(){function t(t,e,i){this.nextOrObserver=t,this.error=e,this.complete=i}return t.prototype.call=function(t,e){return e.subscribe(new mi(t,this.nextOrObserver,this.error,this.complete))},t}(),mi=function(t){function e(e,i,r,s){var o=t.call(this,e)||this;return o._tapNext=tt,o._tapError=tt,o._tapComplete=tt,o._tapError=r||tt,o._tapComplete=s||tt,n(i)?(o._context=o,o._tapNext=i):i&&(o._context=i,o._tapNext=i.next||tt,o._tapError=i.error||tt,o._tapComplete=i.complete||tt),o}return i(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(f);function gi(t,e,i){return void 0===i&&(i=Q),function(n){var r,s=(r=t)instanceof Date&&!isNaN(+r),o=s?+t-i.now():Math.abs(t);return n.lift(new _i(o,s,e,i))}}var _i=function(){function t(t,e,i,n){this.waitFor=t,this.absoluteTimeout=e,this.withObservable=i,this.scheduler=n}return t.prototype.call=function(t,e){return e.subscribe(new vi(t,this.absoluteTimeout,this.waitFor,this.withObservable,this.scheduler))},t}(),vi=function(t){function e(e,i,n,r,s){var o=t.call(this,e)||this;return o.absoluteTimeout=i,o.waitFor=n,o.withObservable=r,o.scheduler=s,o.scheduleTimeout(),o}return i(e,t),e.dispatchTimeout=function(t){var e=t.withObservable;t._unsubscribeAndRecycle(),t.add(St(e,new xt(t)))},e.prototype.scheduleTimeout=function(){var t=this.action;t?this.action=t.schedule(this,this.waitFor):this.add(this.action=this.scheduler.schedule(e.dispatchTimeout,this.waitFor,this))},e.prototype._next=function(e){this.absoluteTimeout||this.scheduleTimeout(),t.prototype._next.call(this,e)},e.prototype._unsubscribe=function(){this.action=void 0,this.scheduler=null,this.withObservable=null},e}(wt);function yi(t,e){return void 0===e&&(e=Q),gi(t,q(new nt),e)}function bi(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){var i;"function"==typeof t[t.length-1]&&(i=t.pop());var n=t;return e.lift(new xi(n,i))}}var xi=function(){function t(t,e){this.observables=t,this.project=e}return t.prototype.call=function(t,e){return e.subscribe(new wi(t,this.observables,this.project))},t}(),wi=function(t){function e(e,i,n){var r=t.call(this,e)||this;r.observables=i,r.project=n,r.toRespond=[];var s=i.length;r.values=new Array(s);for(var o=0;o<s;o++)r.toRespond.push(o);for(o=0;o<s;o++){var a=i[o];r.add(ft(r,a,void 0,o))}return r}return i(e,t),e.prototype.notifyNext=function(t,e,i){this.values[i]=e;var n=this.toRespond;if(n.length>0){var r=n.indexOf(i);-1!==r&&n.splice(r,1)}},e.prototype.notifyComplete=function(){},e.prototype._next=function(t){if(0===this.toRespond.length){var e=[t].concat(this.values);this.project?this._tryProject(e):this.destination.next(e)}},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(at);class Si{createFilter(t){return new Function("node","return "+this._compile(t)+";")}_compile(t){if(null==t||t.length<=1)return"true";const e=t[0];return"("+("=="===e?this._compileComparisonOp("===",t[1],t[2],!1):"!="===e?this._compileComparisonOp("!==",t[1],t[2],!1):">"===e||">="===e||"<"===e||"<="===e?this._compileComparisonOp(e,t[1],t[2],!0):"in"===e?this._compileInOp(t[1],t.slice(2)):"!in"===e?this._compileNegation(this._compileInOp(t[1],t.slice(2))):"all"===e?this._compileLogicalOp(t.slice(1),"&&"):"true")+")"}_compare(t,e){return t<e?-1:t>e?1:0}_compileComparisonOp(t,e,i,n){const r=this._compilePropertyReference(e),s=JSON.stringify(i);return(n?"typeof "+r+"===typeof "+s+"&&":"")+r+t+s}_compileInOp(t,e){const i=this._compare;return JSON.stringify(e.sort(i))+".indexOf("+this._compilePropertyReference(t)+")!==-1"}_compileLogicalOp(t,e){const i=this._compile.bind(this);return t.map(i).join(e)}_compileNegation(t){return"!("+t+")"}_compilePropertyReference(t){return"node["+JSON.stringify(t)+"]"}}const Mi=100,Ti=1e3,Ci=1001,Ei=1002,Ii=1003,Ai=1006,Pi=1008,Ri=1009,Li=1012,Oi=1014,Ni=1015,Di=1016,$i=1020,ki=1022,zi=1023,Fi=1026,Bi=1027,ji=2300,Hi=2301,Ui=2302,Vi=2400,Gi=2401,qi=2402,Wi=2500,Xi=3e3,Yi=7680,Zi=35044,Ji=35048,Ki="300 es";function Qi(){}Object.assign(Qi.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)},removeEventListener:function(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}},dispatchEvent:function(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e<n;e++)i[e].call(this,t)}}});const tn=[];for(let t=0;t<256;t++)tn[t]=(t<16?"0":"")+t.toString(16);let en=1234567;const nn={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(tn[255&t]+tn[t>>8&255]+tn[t>>16&255]+tn[t>>24&255]+"-"+tn[255&e]+tn[e>>8&255]+"-"+tn[e>>16&15|64]+tn[e>>24&255]+"-"+tn[63&i|128]+tn[i>>8&255]+"-"+tn[i>>16&255]+tn[i>>24&255]+tn[255&n]+tn[n>>8&255]+tn[n>>16&255]+tn[n>>24&255]).toUpperCase()},clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},lerp:function(t,e,i){return(1-i)*t+i*e},damp:function(t,e,i,n){return nn.lerp(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(nn.euclideanModulo(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){return void 0!==t&&(en=t%2147483647),en=16807*en%2147483647,(en-1)/2147483646},degToRad:function(t){return t*nn.DEG2RAD},radToDeg:function(t){return t*nn.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,o=Math.sin,a=s(i/2),c=o(i/2),h=s((e+n)/2),l=o((e+n)/2),u=s((e-n)/2),d=o((e-n)/2),p=s((n-e)/2),f=o((n-e)/2);switch(r){case"XYX":t.set(a*l,c*u,c*d,a*h);break;case"YZY":t.set(c*d,a*l,c*u,a*h);break;case"ZXZ":t.set(c*u,c*d,a*l,a*h);break;case"XZX":t.set(a*l,c*f,c*p,a*h);break;case"YXY":t.set(c*p,a*l,c*f,a*h);break;case"ZYZ":t.set(c*f,c*p,a*l,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class rn{constructor(t=0,e=0){Object.defineProperty(this,"isVector2",{value:!0}),this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}class sn{constructor(){Object.defineProperty(this,"isMatrix3",{value:!0}),this.elements=[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.")}set(t,e,i,n,r,s,o,a,c){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=r,h[5]=a,h[6]=i,h[7]=s,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}clone(){return(new this.constructor).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[3],a=i[6],c=i[1],h=i[4],l=i[7],u=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],_=n[1],v=n[4],y=n[7],b=n[2],x=n[5],w=n[8];return r[0]=s*f+o*_+a*b,r[3]=s*m+o*v+a*x,r[6]=s*g+o*y+a*w,r[1]=c*f+h*_+l*b,r[4]=c*m+h*v+l*x,r[7]=c*g+h*y+l*w,r[2]=u*f+d*_+p*b,r[5]=u*m+d*v+p*x,r[8]=u*g+d*y+p*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8];return e*s*h-e*o*c-i*r*h+i*o*a+n*r*c-n*s*a}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=h*s-o*c,u=o*a-h*r,d=c*r-s*a,p=e*l+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return t[0]=l*f,t[1]=(n*c-h*i)*f,t[2]=(o*i-n*s)*f,t[3]=u*f,t[4]=(h*e-n*a)*f,t[5]=(n*r-o*e)*f,t[6]=d*f,t[7]=(i*a-c*e)*f,t[8]=(s*e-i*r)*f,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).copy(this).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,o){const a=Math.cos(r),c=Math.sin(r);return this.set(i*a,i*c,-i*(a*s+c*o)+s+t,-n*c,n*a,-n*(-c*s+a*o)+o+e,0,0,1),this}scale(t,e){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.elements,r=n[0],s=n[3],o=n[6],a=n[1],c=n[4],h=n[7];return n[0]=e*r+i*a,n[3]=e*s+i*c,n[6]=e*o+i*h,n[1]=-i*r+e*a,n[4]=-i*s+e*c,n[7]=-i*o+e*h,this}translate(t,e){const i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}}let on;const an={getDataURL:function(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===on&&(on=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),on.width=t.width,on.height=t.height;const i=on.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=on}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}};let cn=0;function hn(t=hn.DEFAULT_IMAGE,e=hn.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,o=1023,a=1009,c=1,h=3e3){Object.defineProperty(this,"id",{value:cn++}),this.uuid=nn.generateUUID(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=a,this.offset=new rn(0,0),this.repeat=new rn(1,1),this.center=new rn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new sn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.version=0,this.onUpdate=null}function ln(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?an.getDataURL(t):t.data?{data:Array.prototype.slice.call(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}hn.DEFAULT_IMAGE=void 0,hn.DEFAULT_MAPPING=300,hn.prototype=Object.assign(Object.create(Qi.prototype),{constructor:hn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const i={metadata:{version:4.5,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],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=nn.generateUUID()),!e&&void 0===t.images[n.uuid]){let e;if(Array.isArray(n)){e=[];for(let t=0,i=n.length;t<i;t++)n[t].isDataTexture?e.push(ln(n[t].image)):e.push(ln(n[t]))}else e=ln(n);t.images[n.uuid]={uuid:n.uuid,url:e}}i.image=n.uuid}return e||(t.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ti:t.x=t.x-Math.floor(t.x);break;case Ci:t.x=t.x<0?0:1;break;case Ei:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case Ti:t.y=t.y-Math.floor(t.y);break;case Ci:t.y=t.y<0?0:1;break;case Ei:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(hn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});class un{constructor(t=0,e=0,i=0,n=1){Object.defineProperty(this,"isVector4",{value:!0}),this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const s=.01,o=.1,a=t.elements,c=a[0],h=a[4],l=a[8],u=a[1],d=a[5],p=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(h-u)<s&&Math.abs(l-f)<s&&Math.abs(p-m)<s){if(Math.abs(h+u)<o&&Math.abs(l+f)<o&&Math.abs(p+m)<o&&Math.abs(c+d+g-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(c+1)/2,a=(d+1)/2,_=(g+1)/2,v=(h+u)/4,y=(l+f)/4,b=(p+m)/4;return t>a&&t>_?t<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(t),n=v/i,r=y/i):a>_?a<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(a),i=v/n,r=b/n):_<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(_),i=y/r,n=b/r),this.set(i,n,r,e),this}let _=Math.sqrt((m-p)*(m-p)+(l-f)*(l-f)+(u-h)*(u-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(l-f)/_,this.z=(u-h)/_,this.w=Math.acos((c+d+g-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){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(){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(){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(){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(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}}class dn extends Qi{constructor(t,e,i){super(),Object.defineProperty(this,"isWebGLRenderTarget",{value:!0}),this.width=t,this.height=e,this.scissor=new un(0,0,t,e),this.scissorTest=!1,this.viewport=new un(0,0,t,e),i=i||{},this.texture=new hn(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:Ai,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}setSize(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class pn{constructor(t=0,e=0,i=0,n=1){Object.defineProperty(this,"isQuaternion",{value:!0}),this._x=t,this._y=e,this._z=i,this._w=n}static slerp(t,e,i,n){return i.copy(t).slerp(e,n)}static slerpFlat(t,e,i,n,r,s,o){let a=i[n+0],c=i[n+1],h=i[n+2],l=i[n+3];const u=r[s+0],d=r[s+1],p=r[s+2],f=r[s+3];if(l!==f||a!==u||c!==d||h!==p){let t=1-o;const e=a*u+c*d+h*p+l*f,i=e>=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,e*i);t=Math.sin(t*s)/r,o=Math.sin(o*s)/r}const r=o*i;if(a=a*t+u*r,c=c*t+d*r,h=h*t+p*r,l=l*t+f*r,t===1-o){const t=1/Math.sqrt(a*a+c*c+h*h+l*l);a*=t,c*=t,h*=t,l*=t}}t[e]=a,t[e+1]=c,t[e+2]=h,t[e+3]=l}static multiplyQuaternionsFlat(t,e,i,n,r,s){const o=i[n],a=i[n+1],c=i[n+2],h=i[n+3],l=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return t[e]=o*p+h*l+a*d-c*u,t[e+1]=a*p+h*u+c*l-o*d,t[e+2]=c*p+h*d+o*u-a*l,t[e+3]=h*p-o*l-a*u-c*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=t._x,n=t._y,r=t._z,s=t._order,o=Math.cos,a=Math.sin,c=o(i/2),h=o(n/2),l=o(r/2),u=a(i/2),d=a(n/2),p=a(r/2);switch(s){case"XYZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"YXZ":this._x=u*h*l+c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"ZXY":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l-u*d*p;break;case"ZYX":this._x=u*h*l-c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l+u*d*p;break;case"YZX":this._x=u*h*l+c*d*p,this._y=c*d*l+u*h*p,this._z=c*h*p-u*d*l,this._w=c*h*l-u*d*p;break;case"XZY":this._x=u*h*l-c*d*p,this._y=c*d*l-u*h*p,this._z=c*h*p+u*d*l,this._w=c*h*l+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],o=e[5],a=e[9],c=e[2],h=e[6],l=e[10],u=i+o+l;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(h-a)*t,this._y=(r-c)*t,this._z=(s-n)*t}else if(i>o&&i>l){const t=2*Math.sqrt(1+i-o-l);this._w=(h-a)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+c)/t}else if(o>l){const t=2*Math.sqrt(1+o-i-l);this._w=(r-c)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(a+h)/t}else{const t=2*Math.sqrt(1+l-i-o);this._w=(s-n)/t,this._x=(r+c)/t,this._y=(a+h)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-6?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(nn.clamp(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,o=e._x,a=e._y,c=e._z,h=e._w;return this._x=i*h+s*o+n*c-r*a,this._y=n*h+s*a+r*o-i*c,this._z=r*h+s*c+i*a-n*o,this._w=s*h-i*o-n*a-r*c,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,s=this._w;let o=s*t._w+i*t._x+n*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(a),h=Math.atan2(c,o),l=Math.sin((1-e)*h)/c,u=Math.sin(e*h)/c;return this._w=s*l+this._w*u,this._x=i*l+this._x*u,this._y=n*l+this._y*u,this._z=r*l+this._z*u,this._onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}class fn{constructor(t=0,e=0,i=0){Object.defineProperty(this,"isVector3",{value:!0}),this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(gn.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(gn.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,o=t.z,a=t.w,c=a*e+s*n-o*i,h=a*i+o*e-r*n,l=a*n+r*i-s*e,u=-r*e-s*i-o*n;return this.x=c*a+u*-r+h*-o-l*-s,this.y=h*a+u*-s+l*-r-c*-o,this.z=l*a+u*-o+c*-s-h*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return mn.copy(this).projectOnVector(t),this.sub(mn)}reflect(t){return this.sub(mn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(nn.clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}const mn=new fn,gn=new pn;class _n{constructor(t,e){Object.defineProperty(this,"isBox3",{value:!0}),this.min=void 0!==t?t:new fn(1/0,1/0,1/0),this.max=void 0!==e?e:new fn(-1/0,-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,c=t.length;a<c;a+=3){const c=t[a],h=t[a+1],l=t[a+2];c<e&&(e=c),h<i&&(i=h),l<n&&(n=l),c>r&&(r=c),h>s&&(s=h),l>o&&(o=l)}return this.min.set(e,i,n),this.max.set(r,s,o),this}setFromBufferAttribute(t){let e=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,o=-1/0;for(let a=0,c=t.count;a<c;a++){const c=t.getX(a),h=t.getY(a),l=t.getZ(a);c<e&&(e=c),h<i&&(i=h),l<n&&(n=l),c>r&&(r=c),h>s&&(s=h),l>o&&(o=l)}return this.min.set(e,i,n),this.max.set(r,s,o),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=bn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t){return this.makeEmpty(),this.expandByObject(t)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new fn),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new fn),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t){t.updateWorldMatrix(!1,!1);const e=t.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),xn.copy(e.boundingBox),xn.applyMatrix4(t.matrixWorld),this.union(xn));const i=t.children;for(let t=0,e=i.length;t<e;t++)this.expandByObject(i[t]);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new fn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,bn),bn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(In),An.subVectors(this.max,In),wn.subVectors(t.a,In),Sn.subVectors(t.b,In),Mn.subVectors(t.c,In),Tn.subVectors(Sn,wn),Cn.subVectors(Mn,Sn),En.subVectors(wn,Mn);let e=[0,-Tn.z,Tn.y,0,-Cn.z,Cn.y,0,-En.z,En.y,Tn.z,0,-Tn.x,Cn.z,0,-Cn.x,En.z,0,-En.x,-Tn.y,Tn.x,0,-Cn.y,Cn.x,0,-En.y,En.x,0];return!!vn(e,wn,Sn,Mn,An)&&(e=[1,0,0,0,1,0,0,0,1],!!vn(e,wn,Sn,Mn,An)&&(Pn.crossVectors(Tn,Cn),e=[Pn.x,Pn.y,Pn.z],vn(e,wn,Sn,Mn,An)))}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new fn),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return bn.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(bn).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(yn)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}function vn(t,e,i,n,r){for(let s=0,o=t.length-3;s<=o;s+=3){Rn.fromArray(t,s);const o=r.x*Math.abs(Rn.x)+r.y*Math.abs(Rn.y)+r.z*Math.abs(Rn.z),a=e.dot(Rn),c=i.dot(Rn),h=n.dot(Rn);if(Math.max(-Math.max(a,c,h),Math.min(a,c,h))>o)return!1}return!0}const yn=[new fn,new fn,new fn,new fn,new fn,new fn,new fn,new fn],bn=new fn,xn=new _n,wn=new fn,Sn=new fn,Mn=new fn,Tn=new fn,Cn=new fn,En=new fn,In=new fn,An=new fn,Pn=new fn,Rn=new fn,Ln=new _n;class On{constructor(t,e){this.center=void 0!==t?t:new fn,this.radius=void 0!==e?e:-1}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):Ln.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;e<r;e++)n=Math.max(n,i.distanceToSquared(t[e]));return this.radius=Math.sqrt(n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return void 0===e&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),e=new fn),e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new _n),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}}const Nn=new fn,Dn=new fn,$n=new fn,kn=new fn,zn=new fn,Fn=new fn,Bn=new fn;class jn{constructor(t,e){this.origin=void 0!==t?t:new fn,this.direction=void 0!==e?e:new fn(0,0,-1)}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new fn),e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Nn)),this}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new fn),e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Nn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Nn.copy(this.direction).multiplyScalar(e).add(this.origin),Nn.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Dn.copy(t).add(e).multiplyScalar(.5),$n.copy(e).sub(t).normalize(),kn.copy(this.origin).sub(Dn);const r=.5*t.distanceTo(e),s=-this.direction.dot($n),o=kn.dot(this.direction),a=-kn.dot($n),c=kn.lengthSq(),h=Math.abs(1-s*s);let l,u,d,p;if(h>0)if(l=s*a-o,u=s*o-a,p=r*h,l>=0)if(u>=-p)if(u<=p){const t=1/h;l*=t,u*=t,d=l*(l+s*u+2*o)+u*(s*l+u+2*a)+c}else u=r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u=-r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;else u<=-p?(l=Math.max(0,-(-s*r+o)),u=l>0?-r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c):u<=p?(l=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+c):(l=Math.max(0,-(s*r+o)),u=l>0?r:Math.min(Math.max(-r,-a),r),d=-l*l+u*(u+2*a)+c);else u=s>0?-r:r,l=Math.max(0,-(s*u+o)),d=-l*l+u*(u+2*a)+c;return i&&i.copy(this.direction).multiplyScalar(l).add(this.origin),n&&n.copy($n).multiplyScalar(u).add(Dn),d}intersectSphere(t,e){Nn.subVectors(t.center,this.origin);const i=Nn.dot(this.direction),n=Nn.dot(Nn)-i*i,r=t.radius*t.radius;if(n>r)return null;const s=Math.sqrt(r-n),o=i-s,a=i+s;return o<0&&a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,s,o,a;const c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(i=(t.min.x-u.x)*c,n=(t.max.x-u.x)*c):(i=(t.max.x-u.x)*c,n=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,s=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,s=(t.min.y-u.y)*h),i>s||r>n?null:((r>i||i!=i)&&(i=r),(s<n||n!=n)&&(n=s),l>=0?(o=(t.min.z-u.z)*l,a=(t.max.z-u.z)*l):(o=(t.max.z-u.z)*l,a=(t.min.z-u.z)*l),i>a||o>n?null:((o>i||i!=i)&&(i=o),(a<n||n!=n)&&(n=a),n<0?null:this.at(i>=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Nn)}intersectTriangle(t,e,i,n,r){zn.subVectors(e,t),Fn.subVectors(i,t),Bn.crossVectors(zn,Fn);let s,o=this.direction.dot(Bn);if(o>0){if(n)return null;s=1}else{if(!(o<0))return null;s=-1,o=-o}kn.subVectors(this.origin,t);const a=s*this.direction.dot(Fn.crossVectors(kn,Fn));if(a<0)return null;const c=s*this.direction.dot(zn.cross(kn));if(c<0)return null;if(a+c>o)return null;const h=-s*kn.dot(Bn);return h<0?null:this.at(h/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}class Hn{constructor(){Object.defineProperty(this,"isMatrix4",{value:!0}),this.elements=[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.")}set(t,e,i,n,r,s,o,a,c,h,l,u,d,p,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=o,g[13]=a,g[2]=c,g[6]=h,g[10]=l,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Hn).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/Un.setFromMatrixColumn(t,0).length(),r=1/Un.setFromMatrixColumn(t,1).length(),s=1/Un.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),o=Math.sin(i),a=Math.cos(n),c=Math.sin(n),h=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){const t=s*h,i=s*l,n=o*h,r=o*l;e[0]=a*h,e[4]=-a*l,e[8]=c,e[1]=i+n*c,e[5]=t-r*c,e[9]=-o*a,e[2]=r-t*c,e[6]=n+i*c,e[10]=s*a}else if("YXZ"===t.order){const t=a*h,i=a*l,n=c*h,r=c*l;e[0]=t+r*o,e[4]=n*o-i,e[8]=s*c,e[1]=s*l,e[5]=s*h,e[9]=-o,e[2]=i*o-n,e[6]=r+t*o,e[10]=s*a}else if("ZXY"===t.order){const t=a*h,i=a*l,n=c*h,r=c*l;e[0]=t-r*o,e[4]=-s*l,e[8]=n+i*o,e[1]=i+n*o,e[5]=s*h,e[9]=r-t*o,e[2]=-s*c,e[6]=o,e[10]=s*a}else if("ZYX"===t.order){const t=s*h,i=s*l,n=o*h,r=o*l;e[0]=a*h,e[4]=n*c-i,e[8]=t*c+r,e[1]=a*l,e[5]=r*c+t,e[9]=i*c-n,e[2]=-c,e[6]=o*a,e[10]=s*a}else if("YZX"===t.order){const t=s*a,i=s*c,n=o*a,r=o*c;e[0]=a*h,e[4]=r-t*l,e[8]=n*l+i,e[1]=l,e[5]=s*h,e[9]=-o*h,e[2]=-c*h,e[6]=i*l+n,e[10]=t-r*l}else if("XZY"===t.order){const t=s*a,i=s*c,n=o*a,r=o*c;e[0]=a*h,e[4]=-l,e[8]=c*h,e[1]=t*l+r,e[5]=s*h,e[9]=i*l-n,e[2]=n*l-i,e[6]=o*h,e[10]=r*l+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Gn,t,qn)}lookAt(t,e,i){const n=this.elements;return Yn.subVectors(t,e),0===Yn.lengthSq()&&(Yn.z=1),Yn.normalize(),Wn.crossVectors(i,Yn),0===Wn.lengthSq()&&(1===Math.abs(i.z)?Yn.x+=1e-4:Yn.z+=1e-4,Yn.normalize(),Wn.crossVectors(i,Yn)),Wn.normalize(),Xn.crossVectors(Yn,Wn),n[0]=Wn.x,n[4]=Xn.x,n[8]=Yn.x,n[1]=Wn.y,n[5]=Xn.y,n[9]=Yn.y,n[2]=Wn.z,n[6]=Xn.z,n[10]=Yn.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],o=i[4],a=i[8],c=i[12],h=i[1],l=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],_=i[3],v=i[7],y=i[11],b=i[15],x=n[0],w=n[4],S=n[8],M=n[12],T=n[1],C=n[5],E=n[9],I=n[13],A=n[2],P=n[6],R=n[10],L=n[14],O=n[3],N=n[7],D=n[11],$=n[15];return r[0]=s*x+o*T+a*A+c*O,r[4]=s*w+o*C+a*P+c*N,r[8]=s*S+o*E+a*R+c*D,r[12]=s*M+o*I+a*L+c*$,r[1]=h*x+l*T+u*A+d*O,r[5]=h*w+l*C+u*P+d*N,r[9]=h*S+l*E+u*R+d*D,r[13]=h*M+l*I+u*L+d*$,r[2]=p*x+f*T+m*A+g*O,r[6]=p*w+f*C+m*P+g*N,r[10]=p*S+f*E+m*R+g*D,r[14]=p*M+f*I+m*L+g*$,r[3]=_*x+v*T+y*A+b*O,r[7]=_*w+v*C+y*P+b*N,r[11]=_*S+v*E+y*R+b*D,r[15]=_*M+v*I+y*L+b*$,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],o=t[5],a=t[9],c=t[13],h=t[2],l=t[6],u=t[10],d=t[14];return t[3]*(+r*a*l-n*c*l-r*o*u+i*c*u+n*o*d-i*a*d)+t[7]*(+e*a*d-e*c*u+r*s*u-n*s*d+n*c*h-r*a*h)+t[11]*(+e*c*l-e*o*d-r*s*l+i*s*d+r*o*h-i*c*h)+t[15]*(-n*o*h-e*a*l+e*o*u+n*s*l-i*s*u+i*a*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=t[9],u=t[10],d=t[11],p=t[12],f=t[13],m=t[14],g=t[15],_=l*m*c-f*u*c+f*a*d-o*m*d-l*a*g+o*u*g,v=p*u*c-h*m*c-p*a*d+s*m*d+h*a*g-s*u*g,y=h*f*c-p*l*c+p*o*d-s*f*d-h*o*g+s*l*g,b=p*l*a-h*f*a-p*o*u+s*f*u+h*o*m-s*l*m,x=e*_+i*v+n*y+r*b;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return t[0]=_*w,t[1]=(f*u*r-l*m*r-f*n*d+i*m*d+l*n*g-i*u*g)*w,t[2]=(o*m*r-f*a*r+f*n*c-i*m*c-o*n*g+i*a*g)*w,t[3]=(l*a*r-o*u*r-l*n*c+i*u*c+o*n*d-i*a*d)*w,t[4]=v*w,t[5]=(h*m*r-p*u*r+p*n*d-e*m*d-h*n*g+e*u*g)*w,t[6]=(p*a*r-s*m*r-p*n*c+e*m*c+s*n*g-e*a*g)*w,t[7]=(s*u*r-h*a*r+h*n*c-e*u*c-s*n*d+e*a*d)*w,t[8]=y*w,t[9]=(p*l*r-h*f*r-p*i*d+e*f*d+h*i*g-e*l*g)*w,t[10]=(s*f*r-p*o*r+p*i*c-e*f*c-s*i*g+e*o*g)*w,t[11]=(h*o*r-s*l*r-h*i*c+e*l*c+s*i*d-e*o*d)*w,t[12]=b*w,t[13]=(h*f*n-p*l*n+p*i*u-e*f*u-h*i*m+e*l*m)*w,t[14]=(p*o*n-s*f*n-p*i*a+e*f*a+s*i*m-e*o*m)*w,t[15]=(s*l*n-h*o*n+h*i*a-e*l*a-s*i*u+e*o*u)*w,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,o=t.y,a=t.z,c=r*s,h=r*o;return this.set(c*s+i,c*o-n*a,c*a+n*o,0,c*o+n*a,h*o+i,h*a-n*s,0,c*a-n*o,h*a+n*s,r*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i){return this.set(1,e,i,0,t,1,i,0,t,e,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,s=e._y,o=e._z,a=e._w,c=r+r,h=s+s,l=o+o,u=r*c,d=r*h,p=r*l,f=s*h,m=s*l,g=o*l,_=a*c,v=a*h,y=a*l,b=i.x,x=i.y,w=i.z;return n[0]=(1-(f+g))*b,n[1]=(d+y)*b,n[2]=(p-v)*b,n[3]=0,n[4]=(d-y)*x,n[5]=(1-(u+g))*x,n[6]=(m+_)*x,n[7]=0,n[8]=(p+v)*w,n[9]=(m-_)*w,n[10]=(1-(u+f))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=Un.set(n[0],n[1],n[2]).length();const s=Un.set(n[4],n[5],n[6]).length(),o=Un.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],Vn.copy(this);const a=1/r,c=1/s,h=1/o;return Vn.elements[0]*=a,Vn.elements[1]*=a,Vn.elements[2]*=a,Vn.elements[4]*=c,Vn.elements[5]*=c,Vn.elements[6]*=c,Vn.elements[8]*=h,Vn.elements[9]*=h,Vn.elements[10]*=h,e.setFromRotationMatrix(Vn),i.x=r,i.y=s,i.z=o,this}makePerspective(t,e,i,n,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,a=2*r/(e-t),c=2*r/(i-n),h=(e+t)/(e-t),l=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return o[0]=a,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=l,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,n,r,s){const o=this.elements,a=1/(e-t),c=1/(i-n),h=1/(s-r),l=(e+t)*a,u=(i+n)*c,d=(s+r)*h;return o[0]=2*a,o[4]=0,o[8]=0,o[12]=-l,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*h,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Un=new fn,Vn=new Hn,Gn=new fn(0,0,0),qn=new fn(1,1,1),Wn=new fn,Xn=new fn,Yn=new fn;class Zn{constructor(t=0,e=0,i=0,n=Zn.DefaultOrder){Object.defineProperty(this,"isEuler",{value:!0}),this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._order=n||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e,i){const n=nn.clamp,r=t.elements,s=r[0],o=r[4],a=r[8],c=r[1],h=r[5],l=r[9],u=r[2],d=r[6],p=r[10];switch(e=e||this._order){case"XYZ":this._y=Math.asin(n(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-n(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-n(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(n(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-l,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!1!==i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Jn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Jn,e,i)}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e||this._order)}reorder(t){return Kn.setFromEuler(this),this.setFromQuaternion(Kn,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new fn(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}Zn.DefaultOrder="XYZ",Zn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];const Jn=new Hn,Kn=new pn;class Qn{constructor(){this.mask=1}set(t){this.mask=1<<t|0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}}let tr=0;const er=new fn,ir=new pn,nr=new Hn,rr=new fn,sr=new fn,or=new fn,ar=new pn,cr=new fn(1,0,0),hr=new fn(0,1,0),lr=new fn(0,0,1),ur={type:"added"},dr={type:"removed"};function pr(){Object.defineProperty(this,"id",{value:tr++}),this.uuid=nn.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=pr.DefaultUp.clone();const t=new fn,e=new Zn,i=new pn,n=new fn(1,1,1);e._onChange((function(){i.setFromEuler(e,!1)})),i._onChange((function(){e.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Hn},normalMatrix:{value:new sn}}),this.matrix=new Hn,this.matrixWorld=new Hn,this.matrixAutoUpdate=pr.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Qn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}pr.DefaultUp=new fn(0,1,0),pr.DefaultMatrixAutoUpdate=!0,pr.prototype=Object.assign(Object.create(Qi.prototype),{constructor:pr,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,e){return ir.setFromAxisAngle(t,e),this.quaternion.multiply(ir),this},rotateOnWorldAxis:function(t,e){return ir.setFromAxisAngle(t,e),this.quaternion.premultiply(ir),this},rotateX:function(t){return this.rotateOnAxis(cr,t)},rotateY:function(t){return this.rotateOnAxis(hr,t)},rotateZ:function(t){return this.rotateOnAxis(lr,t)},translateOnAxis:function(t,e){return er.copy(t).applyQuaternion(this.quaternion),this.position.add(er.multiplyScalar(e)),this},translateX:function(t){return this.translateOnAxis(cr,t)},translateY:function(t){return this.translateOnAxis(hr,t)},translateZ:function(t){return this.translateOnAxis(lr,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(nr.copy(this.matrixWorld).invert())},lookAt:function(t,e,i){t.isVector3?rr.copy(t):rr.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),sr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?nr.lookAt(sr,rr,this.up):nr.lookAt(rr,sr,this.up),this.quaternion.setFromRotationMatrix(nr),n&&(nr.extractRotation(n.matrixWorld),ir.setFromRotationMatrix(nr),this.quaternion.premultiply(ir.invert()))},add:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(ur)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(dr)),this},clear:function(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(dr)}return this.children.length=0,this},attach:function(t){return this.updateWorldMatrix(!0,!1),nr.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),nr.multiply(t.parent.matrixWorld)),t.applyMatrix4(nr),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(t,e);if(void 0!==n)return n}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new pn),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(sr,t,or),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(sr,ar,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()},raycast:function(){},traverse:function(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)},traverseVisible:function(t){if(!1===this.visible)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)},traverseAncestors:function(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)},updateWorldMatrix:function(t,e){const i=this.parent;if(!0===t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const t=this.children;for(let e=0,i=t.length;e<i;e++)t[e].updateWorldMatrix(!1,!0)}},toJSON:function(t){const e=void 0===t||"string"==typeof t,i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};function r(e,i){return void 0===e[i.uuid]&&(e[i.uuid]=i.toJSON(t)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON()),this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e<n;e++){const n=i[e];r(t.shapes,n)}else r(t.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let i=0,n=this.material.length;i<n;i++)e.push(r(t.materials,this.material[i]));n.material=e}else n.material=r(t.materials,this.material);if(this.children.length>0){n.children=[];for(let e=0;e<this.children.length;e++)n.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let e=0;e<this.animations.length;e++){const i=this.animations[e];n.animations.push(r(t.animations,i))}}if(e){const e=s(t.geometries),n=s(t.materials),r=s(t.textures),o=s(t.images),a=s(t.shapes),c=s(t.skeletons),h=s(t.animations);e.length>0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),o.length>0&&(i.images=o),a.length>0&&(i.shapes=a),c.length>0&&(i.skeletons=c),h.length>0&&(i.animations=h)}return i.object=n,i;function s(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const i=t.children[e];this.add(i.clone())}return this}});const fr=new fn,mr=new fn,gr=new sn;class _r{constructor(t,e){Object.defineProperty(this,"isPlane",{value:!0}),this.normal=void 0!==t?t:new fn(1,0,0),this.constant=void 0!==e?e:0}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=fr.subVectors(i,e).cross(mr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new fn),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new fn);const i=t.delta(fr),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;const r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?void 0:e.copy(i).multiplyScalar(r).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new fn),t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||gr.getNormalMatrix(t),n=this.coplanarPoint(fr).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}const vr=new fn,yr=new fn,br=new fn,xr=new fn,wr=new fn,Sr=new fn,Mr=new fn,Tr=new fn,Cr=new fn,Er=new fn;class Ir{constructor(t,e,i){this.a=void 0!==t?t:new fn,this.b=void 0!==e?e:new fn,this.c=void 0!==i?i:new fn}static getNormal(t,e,i,n){void 0===n&&(console.warn("THREE.Triangle: .getNormal() target is now required"),n=new fn),n.subVectors(i,e),vr.subVectors(t,e),n.cross(vr);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){vr.subVectors(n,e),yr.subVectors(i,e),br.subVectors(t,e);const s=vr.dot(vr),o=vr.dot(yr),a=vr.dot(br),c=yr.dot(yr),h=yr.dot(br),l=s*c-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new fn),0===l)return r.set(-2,-1,-1);const u=1/l,d=(c*a-o*h)*u,p=(s*h-o*a)*u;return r.set(1-d-p,p,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,xr),xr.x>=0&&xr.y>=0&&xr.x+xr.y<=1}static getUV(t,e,i,n,r,s,o,a){return this.getBarycoord(t,e,i,n,xr),a.set(0,0),a.addScaledVector(r,xr.x),a.addScaledVector(s,xr.y),a.addScaledVector(o,xr.z),a}static isFrontFacing(t,e,i,n){return vr.subVectors(i,e),yr.subVectors(t,e),vr.cross(yr).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return vr.subVectors(this.c,this.b),yr.subVectors(this.a,this.b),.5*vr.cross(yr).length()}getMidpoint(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new fn),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ir.getNormal(this.a,this.b,this.c,t)}getPlane(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new _r),t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ir.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,r){return Ir.getUV(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return Ir.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ir.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new fn);const i=this.a,n=this.b,r=this.c;let s,o;wr.subVectors(n,i),Sr.subVectors(r,i),Tr.subVectors(t,i);const a=wr.dot(Tr),c=Sr.dot(Tr);if(a<=0&&c<=0)return e.copy(i);Cr.subVectors(t,n);const h=wr.dot(Cr),l=Sr.dot(Cr);if(h>=0&&l<=h)return e.copy(n);const u=a*l-h*c;if(u<=0&&a>=0&&h<=0)return s=a/(a-h),e.copy(i).addScaledVector(wr,s);Er.subVectors(t,r);const d=wr.dot(Er),p=Sr.dot(Er);if(p>=0&&d<=p)return e.copy(r);const f=d*c-a*p;if(f<=0&&c>=0&&p<=0)return o=c/(c-p),e.copy(i).addScaledVector(Sr,o);const m=h*p-d*l;if(m<=0&&l-h>=0&&d-p>=0)return Mr.subVectors(r,n),o=(l-h)/(l-h+(d-p)),e.copy(n).addScaledVector(Mr,o);const g=1/(m+f+u);return s=f*g,o=u*g,e.copy(i).addScaledVector(wr,s).addScaledVector(Sr,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Ar={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Pr={h:0,s:0,l:0},Rr={h:0,s:0,l:0};function Lr(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function Or(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Nr(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Dr{constructor(t,e,i){return Object.defineProperty(this,"isColor",{value:!0}),void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,e,i){return this.r=t,this.g=e,this.b=i,this}setHSL(t,e,i){if(t=nn.euclideanModulo(t,1),e=nn.clamp(e,0,1),i=nn.clamp(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=Lr(r,n,t+1/3),this.g=Lr(r,n,t),this.b=Lr(r,n,t-1/3)}return this}setStyle(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,e(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,e(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(t[1])/360,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=i[1],e=t.length;if(3===e)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this}setColorName(t){const e=Ar[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copyGammaToLinear(t,e=2){return this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this}copyLinearToGamma(t,e=2){const i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Or(t.r),this.g=Or(t.g),this.b=Or(t.b),this}copyLinearToSRGB(t){return this.r=Nr(t.r),this.g=Nr(t.g),this.b=Nr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});const e=this.r,i=this.g,n=this.b,r=Math.max(e,i,n),s=Math.min(e,i,n);let o,a;const c=(s+r)/2;if(s===r)o=0,a=0;else{const t=r-s;switch(a=c<=.5?t/(r+s):t/(2-r-s),r){case e:o=(i-n)/t+(i<n?6:0);break;case i:o=(n-e)/t+2;break;case n:o=(e-i)/t+4}o/=6}return t.h=o,t.s=a,t.l=c,t}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(t,e,i){return this.getHSL(Pr),Pr.h+=t,Pr.s+=e,Pr.l+=i,this.setHSL(Pr.h,Pr.s,Pr.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Pr),t.getHSL(Rr);const i=nn.lerp(Pr.h,Rr.h,e),n=nn.lerp(Pr.s,Rr.s,e),r=nn.lerp(Pr.l,Rr.l,e);return this.setHSL(i,n,r),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),!0===t.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}Dr.NAMES=Ar,Dr.prototype.r=1,Dr.prototype.g=1,Dr.prototype.b=1;class $r{constructor(t,e,i,n,r,s=0){this.a=t,this.b=e,this.c=i,this.normal=n&&n.isVector3?n:new fn,this.vertexNormals=Array.isArray(n)?n:[],this.color=r&&r.isColor?r:new Dr,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=s}clone(){return(new this.constructor).copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,i=t.vertexNormals.length;e<i;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,i=t.vertexColors.length;e<i;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}}let kr=0;function zr(){Object.defineProperty(this,"id",{value:kr++}),this.uuid=nn.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=Mi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Yi,this.stencilZFail=Yi,this.stencilZPass=Yi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}function Fr(t){zr.call(this),this.type="MeshBasicMaterial",this.color=new Dr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}zr.prototype=Object.assign(Object.create(Qi.prototype),{constructor:zr,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}},toJSON:function(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(i.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,i.reflectivity=this.reflectivity,i.refractionRatio=this.refractionRatio,void 0!==this.combine&&(i.combine=this.combine),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(i.size=this.size),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),!0===this.flatShading&&(i.flatShading=this.flatShading),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.morphNormals&&(i.morphNormals=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(zr.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Fr.prototype=Object.create(zr.prototype),Fr.prototype.constructor=Fr,Fr.prototype.isMeshBasicMaterial=!0,Fr.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this};const Br=new fn,jr=new rn;function Hr(t,e,i){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===i,this.usage=Zi,this.updateRange={offset:0,count:-1},this.version=0}function Ur(t,e,i){Hr.call(this,new Int8Array(t),e,i)}function Vr(t,e,i){Hr.call(this,new Uint8Array(t),e,i)}function Gr(t,e,i){Hr.call(this,new Uint8ClampedArray(t),e,i)}function qr(t,e,i){Hr.call(this,new Int16Array(t),e,i)}function Wr(t,e,i){Hr.call(this,new Uint16Array(t),e,i)}function Xr(t,e,i){Hr.call(this,new Int32Array(t),e,i)}function Yr(t,e,i){Hr.call(this,new Uint32Array(t),e,i)}function Zr(t,e,i){Hr.call(this,new Uint16Array(t),e,i)}function Jr(t,e,i){Hr.call(this,new Float32Array(t),e,i)}function Kr(t,e,i){Hr.call(this,new Float64Array(t),e,i)}function Qr(t){if(0===t.length)return-1/0;let e=t[0];for(let i=1,n=t.length;i<n;++i)t[i]>e&&(e=t[i]);return e}Object.defineProperty(Hr.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Hr.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[t+n]=e.array[i+n];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),r=new Dr),e[i++]=r.r,e[i++]=r.g,e[i++]=r.b}return this},copyVector2sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),r=new rn),e[i++]=r.x,e[i++]=r.y}return this},copyVector3sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),r=new fn),e[i++]=r.x,e[i++]=r.y,e[i++]=r.z}return this},copyVector4sArray:function(t){const e=this.array;let i=0;for(let n=0,r=t.length;n<r;n++){let r=t[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),r=new un),e[i++]=r.x,e[i++]=r.y,e[i++]=r.z,e[i++]=r.w}return this},applyMatrix3:function(t){if(2===this.itemSize)for(let e=0,i=this.count;e<i;e++)jr.fromBufferAttribute(this,e),jr.applyMatrix3(t),this.setXY(e,jr.x,jr.y);else if(3===this.itemSize)for(let e=0,i=this.count;e<i;e++)Br.fromBufferAttribute(this,e),Br.applyMatrix3(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},applyMatrix4:function(t){for(let e=0,i=this.count;e<i;e++)Br.x=this.getX(e),Br.y=this.getY(e),Br.z=this.getZ(e),Br.applyMatrix4(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},applyNormalMatrix:function(t){for(let e=0,i=this.count;e<i;e++)Br.x=this.getX(e),Br.y=this.getY(e),Br.z=this.getZ(e),Br.applyNormalMatrix(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},transformDirection:function(t){for(let e=0,i=this.count;e<i;e++)Br.x=this.getX(e),Br.y=this.getY(e),Br.z=this.getZ(e),Br.transformDirection(t),this.setXYZ(e,Br.x,Br.y,Br.z);return this},set:function(t,e=0){return this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}}),Ur.prototype=Object.create(Hr.prototype),Ur.prototype.constructor=Ur,Vr.prototype=Object.create(Hr.prototype),Vr.prototype.constructor=Vr,Gr.prototype=Object.create(Hr.prototype),Gr.prototype.constructor=Gr,qr.prototype=Object.create(Hr.prototype),qr.prototype.constructor=qr,Wr.prototype=Object.create(Hr.prototype),Wr.prototype.constructor=Wr,Xr.prototype=Object.create(Hr.prototype),Xr.prototype.constructor=Xr,Yr.prototype=Object.create(Hr.prototype),Yr.prototype.constructor=Yr,Zr.prototype=Object.create(Hr.prototype),Zr.prototype.constructor=Zr,Zr.prototype.isFloat16BufferAttribute=!0,Jr.prototype=Object.create(Hr.prototype),Jr.prototype.constructor=Jr,Kr.prototype=Object.create(Hr.prototype),Kr.prototype.constructor=Kr;const ts={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function es(t,e){return new ts[t](e)}let is=0;const ns=new Hn,rs=new pr,ss=new fn,os=new _n,as=new _n,cs=new fn;function hs(){Object.defineProperty(this,"id",{value:is++}),this.uuid=nn.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}hs.prototype=Object.assign(Object.create(Qi.prototype),{constructor:hs,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){return Array.isArray(t)?this.index=new(Qr(t)>65535?Yr:Wr)(t,1):this.index=t,this},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute:function(t){return delete this.attributes[t],this},hasAttribute:function(t){return void 0!==this.attributes[t]},addGroup:function(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix4:function(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const e=(new sn).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return ns.makeRotationX(t),this.applyMatrix4(ns),this},rotateY:function(t){return ns.makeRotationY(t),this.applyMatrix4(ns),this},rotateZ:function(t){return ns.makeRotationZ(t),this.applyMatrix4(ns),this},translate:function(t,e,i){return ns.makeTranslation(t,e,i),this.applyMatrix4(ns),this},scale:function(t,e,i){return ns.makeScale(t,e,i),this.applyMatrix4(ns),this},lookAt:function(t){return rs.lookAt(t),rs.updateMatrix(),this.applyMatrix4(rs.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(ss).negate(),this.translate(ss.x,ss.y,ss.z),this},setFromPoints:function(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];e.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new Jr(e,3)),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new _n);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new fn(-1/0,-1/0,-1/0),new fn(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];os.setFromBufferAttribute(i),this.morphTargetsRelative?(cs.addVectors(this.boundingBox.min,os.min),this.boundingBox.expandByPoint(cs),cs.addVectors(this.boundingBox.max,os.max),this.boundingBox.expandByPoint(cs)):(this.boundingBox.expandByPoint(os.min),this.boundingBox.expandByPoint(os.max))}}else 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(){null===this.boundingSphere&&(this.boundingSphere=new On);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new fn,1/0);if(t){const i=this.boundingSphere.center;if(os.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t<i;t++){const i=e[t];as.setFromBufferAttribute(i),this.morphTargetsRelative?(cs.addVectors(os.min,as.min),os.expandByPoint(cs),cs.addVectors(os.max,as.max),os.expandByPoint(cs)):(os.expandByPoint(as.min),os.expandByPoint(as.max))}os.getCenter(i);let n=0;for(let e=0,r=t.count;e<r;e++)cs.fromBufferAttribute(t,e),n=Math.max(n,i.distanceToSquared(cs));if(e)for(let r=0,s=e.length;r<s;r++){const s=e[r],o=this.morphTargetsRelative;for(let e=0,r=s.count;e<r;e++)cs.fromBufferAttribute(s,e),o&&(ss.fromBufferAttribute(t,e),cs.add(ss)),n=Math.max(n,i.distanceToSquared(cs))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeTangents:function(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=t.array,n=e.position.array,r=e.normal.array,s=e.uv.array,o=n.length/3;void 0===e.tangent&&this.setAttribute("tangent",new Hr(new Float32Array(4*o),4));const a=e.tangent.array,c=[],h=[];for(let t=0;t<o;t++)c[t]=new fn,h[t]=new fn;const l=new fn,u=new fn,d=new fn,p=new rn,f=new rn,m=new rn,g=new fn,_=new fn;function v(t,e,i){l.fromArray(n,3*t),u.fromArray(n,3*e),d.fromArray(n,3*i),p.fromArray(s,2*t),f.fromArray(s,2*e),m.fromArray(s,2*i),u.sub(l),d.sub(l),f.sub(p),m.sub(p);const r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(r),_.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(r),c[t].add(g),c[e].add(g),c[i].add(g),h[t].add(_),h[e].add(_),h[i].add(_))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let t=0,e=y.length;t<e;++t){const e=y[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)v(i[t+0],i[t+1],i[t+2])}const b=new fn,x=new fn,w=new fn,S=new fn;function M(t){w.fromArray(r,3*t),S.copy(w);const e=c[t];b.copy(e),b.sub(w.multiplyScalar(w.dot(e))).normalize(),x.crossVectors(S,e);const i=x.dot(h[t])<0?-1:1;a[4*t]=b.x,a[4*t+1]=b.y,a[4*t+2]=b.z,a[4*t+3]=i}for(let t=0,e=y.length;t<e;++t){const e=y[t],n=e.start;for(let t=n,r=n+e.count;t<r;t+=3)M(i[t+0]),M(i[t+1]),M(i[t+2])}},computeVertexNormals:function(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let i=this.getAttribute("normal");if(void 0===i)i=new Hr(new Float32Array(3*e.count),3),this.setAttribute("normal",i);else for(let t=0,e=i.count;t<e;t++)i.setXYZ(t,0,0,0);const n=new fn,r=new fn,s=new fn,o=new fn,a=new fn,c=new fn,h=new fn,l=new fn;if(t)for(let u=0,d=t.count;u<d;u+=3){const d=t.getX(u+0),p=t.getX(u+1),f=t.getX(u+2);n.fromBufferAttribute(e,d),r.fromBufferAttribute(e,p),s.fromBufferAttribute(e,f),h.subVectors(s,r),l.subVectors(n,r),h.cross(l),o.fromBufferAttribute(i,d),a.fromBufferAttribute(i,p),c.fromBufferAttribute(i,f),o.add(h),a.add(h),c.add(h),i.setXYZ(d,o.x,o.y,o.z),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(f,c.x,c.y,c.z)}else for(let t=0,o=e.count;t<o;t+=3)n.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),s.fromBufferAttribute(e,t+2),h.subVectors(s,r),l.subVectors(n,r),h.cross(l),i.setXYZ(t+0,h.x,h.y,h.z),i.setXYZ(t+1,h.x,h.y,h.z),i.setXYZ(t+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}},merge:function(t,e){if(!t||!t.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t);void 0===e&&(e=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const i=this.attributes;for(const n in i){if(void 0===t.attributes[n])continue;const r=i[n].array,s=t.attributes[n],o=s.array,a=s.itemSize*e,c=Math.min(o.length,r.length-a);for(let t=0,e=a;t<c;t++,e++)r[e]=o[t]}return this},normalizeNormals:function(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)cs.fromBufferAttribute(t,e),cs.normalize(),t.setXYZ(e,cs.x,cs.y,cs.z)},toNonIndexed:function(){function t(t,e){const i=t.array,n=t.itemSize,r=t.normalized,s=new i.constructor(e.length*n);let o=0,a=0;for(let t=0,r=e.length;t<r;t++){o=e[t]*n;for(let t=0;t<n;t++)s[a++]=i[o++]}return new Hr(s,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new hs,i=this.index.array,n=this.attributes;for(const r in n){const s=t(n[r],i);e.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],o=r[n];for(let e=0,n=o.length;e<n;e++){const n=t(o[e],i);s.push(n)}e.morphAttributes[n]=s}e.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let t=0,i=s.length;t<i;t++){const i=s[t];e.addGroup(i.start,i.count,i.materialIndex)}return e},toJSON:function(){const t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e],r=n.toJSON(t.data);""!==n.name&&(r.name=n.name),t.data.attributes[e]=r}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],s=[];for(let e=0,n=i.length;e<n;e++){const n=i[e],r=n.toJSON(t.data);""!==n.name&&(r.name=n.name),s.push(r)}s.length>0&&(n[e]=s,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t},clone:function(){return(new hs).copy(this)},copy:function(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t<r;t++)i.push(n[t].clone(e));this.morphAttributes[t]=i}this.morphTargetsRelative=t.morphTargetsRelative;const s=t.groups;for(let t=0,e=s.length;t<e;t++){const e=s[t];this.addGroup(e.start,e.count,e.materialIndex)}const o=t.boundingBox;null!==o&&(this.boundingBox=o.clone());const a=t.boundingSphere;return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});const ls=new Hn,us=new jn,ds=new On,ps=new fn,fs=new fn,ms=new fn,gs=new fn,_s=new fn,vs=new fn,ys=new fn,bs=new fn,xs=new fn,ws=new rn,Ss=new rn,Ms=new rn,Ts=new fn,Cs=new fn;function Es(t=new hs,e=new Fr){pr.call(this),this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}function Is(t,e,i,n,r,s,o,a,c,h,l,u){ps.fromBufferAttribute(r,h),fs.fromBufferAttribute(r,l),ms.fromBufferAttribute(r,u);const d=t.morphTargetInfluences;if(e.morphTargets&&s&&d){ys.set(0,0,0),bs.set(0,0,0),xs.set(0,0,0);for(let t=0,e=s.length;t<e;t++){const e=d[t],i=s[t];0!==e&&(gs.fromBufferAttribute(i,h),_s.fromBufferAttribute(i,l),vs.fromBufferAttribute(i,u),o?(ys.addScaledVector(gs,e),bs.addScaledVector(_s,e),xs.addScaledVector(vs,e)):(ys.addScaledVector(gs.sub(ps),e),bs.addScaledVector(_s.sub(fs),e),xs.addScaledVector(vs.sub(ms),e)))}ps.add(ys),fs.add(bs),ms.add(xs)}t.isSkinnedMesh&&(t.boneTransform(h,ps),t.boneTransform(l,fs),t.boneTransform(u,ms));const p=function(t,e,i,n,r,s,o,a){let c;if(c=1===e.side?n.intersectTriangle(o,s,r,!0,a):n.intersectTriangle(r,s,o,2!==e.side,a),null===c)return null;Cs.copy(a),Cs.applyMatrix4(t.matrixWorld);const h=i.ray.origin.distanceTo(Cs);return h<i.near||h>i.far?null:{distance:h,point:Cs.clone(),object:t}}(t,e,i,n,ps,fs,ms,Ts);if(p){a&&(ws.fromBufferAttribute(a,h),Ss.fromBufferAttribute(a,l),Ms.fromBufferAttribute(a,u),p.uv=Ir.getUV(Ts,ps,fs,ms,ws,Ss,Ms,new rn)),c&&(ws.fromBufferAttribute(c,h),Ss.fromBufferAttribute(c,l),Ms.fromBufferAttribute(c,u),p.uv2=Ir.getUV(Ts,ps,fs,ms,ws,Ss,Ms,new rn));const t=new $r(h,l,u);Ir.getNormal(ps,fs,ms,t.normal),p.face=t}return p}Es.prototype=Object.assign(Object.create(pr.prototype),{constructor:Es,isMesh:!0,copy:function(t){return pr.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),ds.copy(i.boundingSphere),ds.applyMatrix4(r),!1===t.ray.intersectsSphere(ds))return;if(ls.copy(r).invert(),us.copy(t.ray).applyMatrix4(ls),null!==i.boundingBox&&!1===us.intersectsBox(i.boundingBox))return;let s;if(i.isBufferGeometry){const r=i.index,o=i.attributes.position,a=i.morphAttributes.position,c=i.morphTargetsRelative,h=i.attributes.uv,l=i.attributes.uv2,u=i.groups,d=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,p=u.length;i<p;i++){const p=u[i],f=n[p.materialIndex];for(let i=Math.max(p.start,d.start),n=Math.min(p.start+p.count,d.start+d.count);i<n;i+=3){const n=r.getX(i),u=r.getX(i+1),d=r.getX(i+2);s=Is(this,f,t,us,o,a,c,h,l,n,u,d),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{for(let i=Math.max(0,d.start),u=Math.min(r.count,d.start+d.count);i<u;i+=3){const u=r.getX(i),d=r.getX(i+1),p=r.getX(i+2);s=Is(this,n,t,us,o,a,c,h,l,u,d,p),s&&(s.faceIndex=Math.floor(i/3),e.push(s))}}else if(void 0!==o)if(Array.isArray(n))for(let i=0,r=u.length;i<r;i++){const r=u[i],p=n[r.materialIndex];for(let i=Math.max(r.start,d.start),n=Math.min(r.start+r.count,d.start+d.count);i<n;i+=3){s=Is(this,p,t,us,o,a,c,h,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=r.materialIndex,e.push(s))}}else{for(let i=Math.max(0,d.start),r=Math.min(o.count,d.start+d.count);i<r;i+=3){s=Is(this,n,t,us,o,a,c,h,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),e.push(s))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}});class As extends hs{constructor(t=1,e=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const o=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const a=[],c=[],h=[],l=[];let u=0,d=0;function p(t,e,i,n,r,s,p,f,m,g,_){const v=s/m,y=p/g,b=s/2,x=p/2,w=f/2,S=m+1,M=g+1;let T=0,C=0;const E=new fn;for(let s=0;s<M;s++){const o=s*y-x;for(let a=0;a<S;a++){const u=a*v-b;E[t]=u*n,E[e]=o*r,E[i]=w,c.push(E.x,E.y,E.z),E[t]=0,E[e]=0,E[i]=f>0?1:-1,h.push(E.x,E.y,E.z),l.push(a/m),l.push(1-s/g),T+=1}}for(let t=0;t<g;t++)for(let e=0;e<m;e++){const i=u+e+S*t,n=u+e+S*(t+1),r=u+(e+1)+S*(t+1),s=u+(e+1)+S*t;a.push(i,n,s),a.push(n,r,s),C+=6}o.addGroup(d,C,_),d+=C,u+=T}p("z","y","x",-1,-1,i,e,t,s,r,0),p("z","y","x",1,-1,i,e,-t,s,r,1),p("x","z","y",1,1,t,i,e,n,s,2),p("x","z","y",1,-1,t,i,-e,n,s,3),p("x","y","z",1,-1,t,e,i,n,r,4),p("x","y","z",-1,-1,t,e,-i,n,r,5),this.setIndex(a),this.setAttribute("position",new Jr(c,3)),this.setAttribute("normal",new Jr(h,3)),this.setAttribute("uv",new Jr(l,2))}}function Ps(t){const e={};for(const i in t){e[i]={};for(const n in t[i]){const r=t[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?e[i][n]=r.clone():Array.isArray(r)?e[i][n]=r.slice():e[i][n]=r}}return e}function Rs(t){const e={};for(let i=0;i<t.length;i++){const n=Ps(t[i]);for(const t in n)e[t]=n[t]}return e}const Ls={clone:Ps,merge:Rs};function Os(t){zr.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,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function Ns(){pr.call(this),this.type="Camera",this.matrixWorldInverse=new Hn,this.projectionMatrix=new Hn,this.projectionMatrixInverse=new Hn}function Ds(t=50,e=1,i=.1,n=2e3){Ns.call(this),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Os.prototype=Object.create(zr.prototype),Os.prototype.constructor=Os,Os.prototype.isShaderMaterial=!0,Os.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ps(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this},Os.prototype.toJSON=function(t){const e=zr.prototype.toJSON.call(this,t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?e.uniforms[i]={type:"t",value:n.toJSON(t).uuid}:n&&n.isColor?e.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?e.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?e.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?e.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?e.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?e.uniforms[i]={type:"m4",value:n.toArray()}:e.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},Ns.prototype=Object.assign(Object.create(pr.prototype),{constructor:Ns,isCamera:!0,copy:function(t,e){return pr.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new fn),this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){pr.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(t,e){pr.prototype.updateWorldMatrix.call(this,t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),Ds.prototype=Object.assign(Object.create(Ns.prototype),{constructor:Ds,isPerspectiveCamera:!0,copy:function(t,e){return Ns.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){const e=.5*this.getFilmHeight()/t;this.fov=2*nn.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){const t=Math.tan(.5*nn.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*nn.RAD2DEG*Math.atan(Math.tan(.5*nn.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,i,n,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const t=this.near;let e=t*Math.tan(.5*nn.DEG2RAD*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,o=s.fullHeight;r+=s.offsetX*n/t,e-=s.offsetY*i/o,n*=s.width/t,i*=s.height/o}const o=this.filmOffset;0!==o&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}});const $s=90;function ks(t,e,i){if(pr.call(this),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new Ds($s,1,t,e);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new fn(1,0,0)),this.add(n);const r=new Ds($s,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new fn(-1,0,0)),this.add(r);const s=new Ds($s,1,t,e);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new fn(0,1,0)),this.add(s);const o=new Ds($s,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new fn(0,-1,0)),this.add(o);const a=new Ds($s,1,t,e);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new fn(0,0,1)),this.add(a);const c=new Ds($s,1,t,e);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new fn(0,0,-1)),this.add(c),this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();const h=t.xr.enabled,l=t.getRenderTarget();t.xr.enabled=!1;const u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(e,n),t.setRenderTarget(i,1),t.render(e,r),t.setRenderTarget(i,2),t.render(e,s),t.setRenderTarget(i,3),t.render(e,o),t.setRenderTarget(i,4),t.render(e,a),i.texture.generateMipmaps=u,t.setRenderTarget(i,5),t.render(e,c),t.setRenderTarget(l),t.xr.enabled=h}}function zs(t,e,i,n,r,s,o,a,c,h){t=void 0!==t?t:[],e=void 0!==e?e:301,o=void 0!==o?o:ki,hn.call(this,t,e,i,n,r,s,o,a,c,h),this.flipY=!1,this._needsFlipEnvMap=!0}ks.prototype=Object.create(pr.prototype),ks.prototype.constructor=ks,zs.prototype=Object.create(hn.prototype),zs.prototype.constructor=zs,zs.prototype.isCubeTexture=!0,Object.defineProperty(zs.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});class Fs extends dn{constructor(t,e,i){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=i),super(t,t,e),Object.defineProperty(this,"isWebGLCubeRenderTarget",{value:!0}),e=e||{},this.texture=new zs(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=zi,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new As(5,5,5),r=new Os({name:"CubemapFromEquirect",uniforms:Ps(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const s=new Es(n,r),o=e.minFilter;e.minFilter===Pi&&(e.minFilter=Ai);return new ks(1,10,this).update(t,s),e.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,i,n){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}function Bs(t,e,i,n,r,s,o,a,c,h,l,u){hn.call(this,null,s,o,a,c,h,n,r,l,u),this.image={data:t||null,width:e||1,height:i||1},this.magFilter=void 0!==c?c:Ii,this.minFilter=void 0!==h?h:Ii,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}Bs.prototype=Object.create(hn.prototype),Bs.prototype.constructor=Bs,Bs.prototype.isDataTexture=!0;const js=new On,Hs=new fn;class Us{constructor(t,e,i,n,r,s){this.planes=[void 0!==t?t:new _r,void 0!==e?e:new _r,void 0!==i?i:new _r,void 0!==n?n:new _r,void 0!==r?r:new _r,void 0!==s?s:new _r]}set(t,e,i,n,r,s){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(s),this}clone(){return(new this.constructor).copy(this)}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){const e=this.planes,i=t.elements,n=i[0],r=i[1],s=i[2],o=i[3],a=i[4],c=i[5],h=i[6],l=i[7],u=i[8],d=i[9],p=i[10],f=i[11],m=i[12],g=i[13],_=i[14],v=i[15];return e[0].setComponents(o-n,l-a,f-u,v-m).normalize(),e[1].setComponents(o+n,l+a,f+u,v+m).normalize(),e[2].setComponents(o+r,l+c,f+d,v+g).normalize(),e[3].setComponents(o-r,l-c,f-d,v-g).normalize(),e[4].setComponents(o-s,l-h,f-p,v-_).normalize(),e[5].setComponents(o+s,l+h,f+p,v+_).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),js.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(js)}intersectsSprite(t){return js.center.set(0,0,0),js.radius=.7071067811865476,js.applyMatrix4(t.matrixWorld),this.intersectsSphere(js)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)<n)return!1}return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(Hs.x=n.normal.x>0?t.max.x:t.min.x,Hs.y=n.normal.y>0?t.max.y:t.min.y,Hs.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(Hs)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}}function Vs(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Gs(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version<e.version)&&n.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const s=n.get(e);void 0===s?n.set(e,function(e,n){const r=e.array,s=e.usage,o=t.createBuffer();t.bindBuffer(n,o),t.bufferData(n,r,s),e.onUploadCallback();let a=5126;return r instanceof Float32Array?a=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?e.isFloat16BufferAttribute?i?a=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):a=5123:r instanceof Int16Array?a=5122:r instanceof Uint32Array?a=5125:r instanceof Int32Array?a=5124:r instanceof Int8Array?a=5120:r instanceof Uint8Array&&(a=5121),{buffer:o,type:a,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,r)):s.version<e.version&&(!function(e,n,r){const s=n.array,o=n.updateRange;t.bindBuffer(r,e),-1===o.count?t.bufferSubData(r,0,s):(i?t.bufferSubData(r,o.offset*s.BYTES_PER_ELEMENT,s,o.offset,o.count):t.bufferSubData(r,o.offset*s.BYTES_PER_ELEMENT,s.subarray(o.offset,o.offset+o.count)),o.count=-1)}(s.buffer,e,r),s.version=e.version)}}}class qs extends hs{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const r=t/2,s=e/2,o=Math.floor(i),a=Math.floor(n),c=o+1,h=a+1,l=t/o,u=e/a,d=[],p=[],f=[],m=[];for(let t=0;t<h;t++){const e=t*u-s;for(let i=0;i<c;i++){const n=i*l-r;p.push(n,-e,0),f.push(0,0,1),m.push(i/o),m.push(1-t/a)}}for(let t=0;t<a;t++)for(let e=0;e<o;e++){const i=e+c*t,n=e+c*(t+1),r=e+1+c*(t+1),s=e+1+c*t;d.push(i,n,s),d.push(n,r,s)}this.setIndex(d),this.setAttribute("position",new Jr(p,3)),this.setAttribute("normal",new Jr(f,3)),this.setAttribute("uv",new Jr(m,2))}}const Ws={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\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\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\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}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( 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 LTC_Uv( const in vec3 N, const in vec3 V, 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\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\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#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",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 = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\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",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor.xyz *= color.xyz;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(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}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\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#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\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 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",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.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\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.a );\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.a );\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.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, 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.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.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 = cLogLuvM * value.rgb;\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 = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\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\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 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 roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, 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\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\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",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\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",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",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\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};\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};\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};\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 ltc_1;\tuniform sampler2D ltc_2;\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",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial 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\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_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#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 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\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 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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\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}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * 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 defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"#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 );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\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}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\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}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\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( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), 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( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), 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 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\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, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\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",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\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",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\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",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\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\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}\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}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).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\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\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 <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <transmissionmap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\n\t#endif\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <transmissionmap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},Xs={common:{diffuse:{value:new Dr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new sn},uv2Transform:{value:new sn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new rn(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Dr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Dr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new sn}},sprite:{diffuse:{value:new Dr(15658734)},opacity:{value:1},center:{value:new rn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new sn}}},Ys={basic:{uniforms:Rs([Xs.common,Xs.specularmap,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.fog]),vertexShader:Ws.meshbasic_vert,fragmentShader:Ws.meshbasic_frag},lambert:{uniforms:Rs([Xs.common,Xs.specularmap,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)}}]),vertexShader:Ws.meshlambert_vert,fragmentShader:Ws.meshlambert_frag},phong:{uniforms:Rs([Xs.common,Xs.specularmap,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)},specular:{value:new Dr(1118481)},shininess:{value:30}}]),vertexShader:Ws.meshphong_vert,fragmentShader:Ws.meshphong_frag},standard:{uniforms:Rs([Xs.common,Xs.envmap,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.roughnessmap,Xs.metalnessmap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ws.meshphysical_vert,fragmentShader:Ws.meshphysical_frag},toon:{uniforms:Rs([Xs.common,Xs.aomap,Xs.lightmap,Xs.emissivemap,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.gradientmap,Xs.fog,Xs.lights,{emissive:{value:new Dr(0)}}]),vertexShader:Ws.meshtoon_vert,fragmentShader:Ws.meshtoon_frag},matcap:{uniforms:Rs([Xs.common,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,Xs.fog,{matcap:{value:null}}]),vertexShader:Ws.meshmatcap_vert,fragmentShader:Ws.meshmatcap_frag},points:{uniforms:Rs([Xs.points,Xs.fog]),vertexShader:Ws.points_vert,fragmentShader:Ws.points_frag},dashed:{uniforms:Rs([Xs.common,Xs.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ws.linedashed_vert,fragmentShader:Ws.linedashed_frag},depth:{uniforms:Rs([Xs.common,Xs.displacementmap]),vertexShader:Ws.depth_vert,fragmentShader:Ws.depth_frag},normal:{uniforms:Rs([Xs.common,Xs.bumpmap,Xs.normalmap,Xs.displacementmap,{opacity:{value:1}}]),vertexShader:Ws.normal_vert,fragmentShader:Ws.normal_frag},sprite:{uniforms:Rs([Xs.sprite,Xs.fog]),vertexShader:Ws.sprite_vert,fragmentShader:Ws.sprite_frag},background:{uniforms:{uvTransform:{value:new sn},t2D:{value:null}},vertexShader:Ws.background_vert,fragmentShader:Ws.background_frag},cube:{uniforms:Rs([Xs.envmap,{opacity:{value:1}}]),vertexShader:Ws.cube_vert,fragmentShader:Ws.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ws.equirect_vert,fragmentShader:Ws.equirect_frag},distanceRGBA:{uniforms:Rs([Xs.common,Xs.displacementmap,{referencePosition:{value:new fn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ws.distanceRGBA_vert,fragmentShader:Ws.distanceRGBA_frag},shadow:{uniforms:Rs([Xs.lights,Xs.fog,{color:{value:new Dr(0)},opacity:{value:1}}]),vertexShader:Ws.shadow_vert,fragmentShader:Ws.shadow_frag}};function Zs(t,e,i,n,r){const s=new Dr(0);let o,a,c=0,h=null,l=0,u=null;function d(t,e){i.buffers.color.setClear(t.r,t.g,t.b,e,r)}return{getClearColor:function(){return s},setClearColor:function(t,e=1){s.set(t),c=e,d(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,d(s,c)},render:function(i,r,p,f){let m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=e.get(m));const g=t.xr,_=g.getSession&&g.getSession();_&&"additive"===_.environmentBlendMode&&(m=null),null===m?d(s,c):m&&m.isColor&&(d(m,1),f=!0),(t.autoClear||f)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||m.isWebGLCubeRenderTarget||306===m.mapping)?(void 0===a&&(a=new Es(new As(1,1,1),new Os({name:"BackgroundCubeMaterial",uniforms:Ps(Ys.cube.uniforms),vertexShader:Ys.cube.vertexShader,fragmentShader:Ys.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),a.geometry.deleteAttribute("uv"),a.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(a.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(a)),m.isWebGLCubeRenderTarget&&(m=m.texture),a.material.uniforms.envMap.value=m,a.material.uniforms.flipEnvMap.value=m.isCubeTexture&&m._needsFlipEnvMap?-1:1,h===m&&l===m.version&&u===t.toneMapping||(a.material.needsUpdate=!0,h=m,l=m.version,u=t.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null)):m&&m.isTexture&&(void 0===o&&(o=new Es(new qs(2,2),new Os({name:"BackgroundMaterial",uniforms:Ps(Ys.background.uniforms),vertexShader:Ys.background.vertexShader,fragmentShader:Ys.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(o)),o.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),o.material.uniforms.uvTransform.value.copy(m.matrix),h===m&&l===m.version&&u===t.toneMapping||(o.material.needsUpdate=!0,h=m,l=m.version,u=t.toneMapping),i.unshift(o,o.geometry,o.material,0,0,null))}}}function Js(t,e,i,n){const r=t.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||null!==s,a={},c=d(null);let h=c;function l(e){return n.isWebGL2?t.bindVertexArray(e):s.bindVertexArrayOES(e)}function u(e){return n.isWebGL2?t.deleteVertexArray(e):s.deleteVertexArrayOES(e)}function d(t){const e=[],i=[],n=[];for(let t=0;t<r;t++)e[t]=0,i[t]=0,n[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:i,attributeDivisors:n,object:t,attributes:{},index:null}}function p(){const t=h.newAttributes;for(let e=0,i=t.length;e<i;e++)t[e]=0}function f(t){m(t,0)}function m(i,r){const s=h.newAttributes,o=h.enabledAttributes,a=h.attributeDivisors;if(s[i]=1,0===o[i]&&(t.enableVertexAttribArray(i),o[i]=1),a[i]!==r){(n.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),a[i]=r}}function g(){const e=h.newAttributes,i=h.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==e[n]&&(t.disableVertexAttribArray(n),i[n]=0)}function _(e,i,r,s,o,a){!0!==n.isWebGL2||5124!==r&&5125!==r?t.vertexAttribPointer(e,i,r,s,o,a):t.vertexAttribIPointer(e,i,r,o,a)}function v(){y(),h!==c&&(h=c,l(h.object))}function y(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:function(r,c,u,v,y){let b=!1;if(o){const e=function(e,i,r){const o=!0===r.wireframe;let c=a[e.id];void 0===c&&(c={},a[e.id]=c);let h=c[i.id];void 0===h&&(h={},c[i.id]=h);let l=h[o];void 0===l&&(l=d(n.isWebGL2?t.createVertexArray():s.createVertexArrayOES()),h[o]=l);return l}(v,u,c);h!==e&&(h=e,l(h.object)),b=function(t,e){const i=h.attributes,n=t.attributes;let r=0;for(const t in n){const e=i[t],s=n[t];if(void 0===e)return!0;if(e.attribute!==s)return!0;if(e.data!==s.data)return!0;r++}return h.attributesNum!==r||h.index!==e}(v,y),b&&function(t,e){const i={},n=t.attributes;let r=0;for(const t in n){const e=n[t],s={};s.attribute=e,e.data&&(s.data=e.data),i[t]=s,r++}h.attributes=i,h.attributesNum=r,h.index=e}(v,y)}else{const t=!0===c.wireframe;h.geometry===v.id&&h.program===u.id&&h.wireframe===t||(h.geometry=v.id,h.program=u.id,h.wireframe=t,b=!0)}!0===r.isInstancedMesh&&(b=!0),null!==y&&i.update(y,34963),b&&(!function(r,s,o,a){if(!1===n.isWebGL2&&(r.isInstancedMesh||a.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;p();const c=a.attributes,h=o.getAttributes(),l=s.defaultAttributeValues;for(const e in h){const n=h[e];if(n>=0){const s=c[e];if(void 0!==s){const e=s.normalized,r=s.itemSize,o=i.get(s);if(void 0===o)continue;const c=o.buffer,h=o.type,l=o.bytesPerElement;if(s.isInterleavedBufferAttribute){const i=s.data,o=i.stride,u=s.offset;i&&i.isInstancedInterleavedBuffer?(m(n,i.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=i.meshPerAttribute*i.count)):f(n),t.bindBuffer(34962,c),_(n,r,h,e,o*l,u*l)}else s.isInstancedBufferAttribute?(m(n,s.meshPerAttribute),void 0===a._maxInstanceCount&&(a._maxInstanceCount=s.meshPerAttribute*s.count)):f(n),t.bindBuffer(34962,c),_(n,r,h,e,0,0)}else if("instanceMatrix"===e){const e=i.get(r.instanceMatrix);if(void 0===e)continue;const s=e.buffer,o=e.type;m(n+0,1),m(n+1,1),m(n+2,1),m(n+3,1),t.bindBuffer(34962,s),t.vertexAttribPointer(n+0,4,o,!1,64,0),t.vertexAttribPointer(n+1,4,o,!1,64,16),t.vertexAttribPointer(n+2,4,o,!1,64,32),t.vertexAttribPointer(n+3,4,o,!1,64,48)}else if("instanceColor"===e){const e=i.get(r.instanceColor);if(void 0===e)continue;const s=e.buffer,o=e.type;m(n,1),t.bindBuffer(34962,s),t.vertexAttribPointer(n,3,o,!1,12,0)}else if(void 0!==l){const i=l[e];if(void 0!==i)switch(i.length){case 2:t.vertexAttrib2fv(n,i);break;case 3:t.vertexAttrib3fv(n,i);break;case 4:t.vertexAttrib4fv(n,i);break;default:t.vertexAttrib1fv(n,i)}}}}g()}(r,c,u,v),null!==y&&t.bindBuffer(34963,i.get(y).buffer))},reset:v,resetDefaultState:y,dispose:function(){v();for(const t in a){const e=a[t];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete a[t]}},releaseStatesOfGeometry:function(t){if(void 0===a[t.id])return;const e=a[t.id];for(const t in e){const i=e[t];for(const t in i)u(i[t].object),delete i[t];delete e[t]}delete a[t.id]},releaseStatesOfProgram:function(t){for(const e in a){const i=a[e];if(void 0===i[t.id])continue;const n=i[t.id];for(const t in n)u(n[t].object),delete n[t];delete i[t.id]}},initAttributes:p,enableAttribute:f,disableUnusedAttributes:g}}function Ks(t,e,i,n){const r=n.isWebGL2;let s;this.setMode=function(t){s=t},this.render=function(e,n){t.drawArrays(s,e,n),i.update(n,s,1)},this.renderInstances=function(n,o,a){if(0===a)return;let c,h;if(r)c=t,h="drawArraysInstanced";else if(c=e.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===c)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[h](s,n,o,a),i.update(o,s,a)}}function Qs(t,e,i){let n;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let o=void 0!==i.precision?i.precision:"highp";const a=r(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);const c=!0===i.logarithmicDepthBuffer,h=t.getParameter(34930),l=t.getParameter(35660),u=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),g=t.getParameter(36349),_=l>0,v=s||!!e.get("OES_texture_float");return{isWebGL2:s,getMaxAnisotropy:function(){if(void 0!==n)return n;const i=e.get("EXT_texture_filter_anisotropic");return n=null!==i?t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,n},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:u,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:_,floatFragmentTextures:v,floatVertexTextures:_&&v,maxSamples:s?t.getParameter(36183):0}}function to(t){const e=this;let i=null,n=0,r=!1,s=!1;const o=new _r,a=new sn,c={value:null,needsUpdate:!1};function h(){c.value!==i&&(c.value=i,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function l(t,i,n,r){const s=null!==t?t.length:0;let h=null;if(0!==s){if(h=c.value,!0!==r||null===h){const e=n+4*s,r=i.matrixWorldInverse;a.getNormalMatrix(r),(null===h||h.length<e)&&(h=new Float32Array(e));for(let e=0,i=n;e!==s;++e,i+=4)o.copy(t[e]).applyMatrix4(r,a),o.normal.toArray(h,i),h[i+3]=o.constant}c.value=h,c.needsUpdate=!0}return e.numPlanes=s,e.numIntersection=0,h}this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,s){const o=0!==t.length||e||0!==n||r;return r=e,i=l(t,s,0),n=t.length,o},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1,h()},this.setState=function(e,o,a){const u=e.clippingPlanes,d=e.clipIntersection,p=e.clipShadows,f=t.get(e);if(!r||null===u||0===u.length||s&&!p)s?l(null):h();else{const t=s?0:n,e=4*t;let r=f.clippingState||null;c.value=r,r=l(u,o,e,a);for(let t=0;t!==e;++t)r[t]=i[t];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function eo(t){let e=new WeakMap;function i(t,e){return 303===e?t.mapping=301:304===e&&(t.mapping=302),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping;if(303===s||304===s){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const o=t.getRenderList(),a=t.getRenderTarget(),c=new Fs(s.height/2);return c.fromEquirectangularTexture(t,r),e.set(r,c),t.setRenderTarget(a),t.setRenderList(o),r.addEventListener("dispose",n),i(c.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}function io(t){const e={};function i(i){if(void 0!==e[i])return e[i];let n;switch(i){case"WEBGL_depth_texture":n=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=t.getExtension(i)}return e[i]=n,n}return{has:function(t){return null!==i(t)},init:function(t){t.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(t){const e=i(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function no(t,e,i,n){const r={},s=new WeakMap;function o(t){const a=t.target;null!==a.index&&e.remove(a.index);for(const t in a.attributes)e.remove(a.attributes[t]);a.removeEventListener("dispose",o),delete r[a.id];const c=s.get(a);c&&(e.remove(c),s.delete(a)),n.releaseStatesOfGeometry(a),!0===a.isInstancedBufferGeometry&&delete a._maxInstanceCount,i.memory.geometries--}function a(t){const i=[],n=t.index,r=t.attributes.position;let o=0;if(null!==n){const t=n.array;o=n.version;for(let e=0,n=t.length;e<n;e+=3){const n=t[e+0],r=t[e+1],s=t[e+2];i.push(n,r,r,s,s,n)}}else{const t=r.array;o=r.version;for(let e=0,n=t.length/3-1;e<n;e+=3){const t=e+0,n=e+1,r=e+2;i.push(t,n,n,r,r,t)}}const a=new(Qr(i)>65535?Yr:Wr)(i,1);a.version=o;const c=s.get(t);c&&e.remove(c),s.set(t,a)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",o),r[e.id]=!0,i.memory.geometries++),e},update:function(t){const i=t.attributes;for(const t in i)e.update(i[t],34962);const n=t.morphAttributes;for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t++)e.update(i[t],34962)}},getWireframeAttribute:function(t){const e=s.get(t);if(e){const i=t.index;null!==i&&e.version<i.version&&a(t)}else a(t);return s.get(t)}}}function ro(t,e,i,n){const r=n.isWebGL2;let s,o,a;this.setMode=function(t){s=t},this.setIndex=function(t){o=t.type,a=t.bytesPerElement},this.render=function(e,n){t.drawElements(s,n,o,e*a),i.update(n,s,1)},this.renderInstances=function(n,c,h){if(0===h)return;let l,u;if(r)l=t,u="drawElementsInstanced";else if(l=e.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===l)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[u](s,c,o,n*a,h),i.update(c,s,h)}}function so(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,i,n){switch(e.calls++,i){case 4:e.triangles+=n*(t/3);break;case 1:e.lines+=n*(t/2);break;case 3:e.lines+=n*(t-1);break;case 2:e.lines+=n*t;break;case 0:e.points+=n*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}function oo(t,e){return t[0]-e[0]}function ao(t,e){return Math.abs(e[1])-Math.abs(t[1])}function co(t){const e={},i=new Float32Array(8),n=[];for(let t=0;t<8;t++)n[t]=[t,0];return{update:function(r,s,o,a){const c=r.morphTargetInfluences,h=void 0===c?0:c.length;let l=e[s.id];if(void 0===l){l=[];for(let t=0;t<h;t++)l[t]=[t,0];e[s.id]=l}for(let t=0;t<h;t++){const e=l[t];e[0]=t,e[1]=c[t]}l.sort(ao);for(let t=0;t<8;t++)t<h&&l[t][1]?(n[t][0]=l[t][0],n[t][1]=l[t][1]):(n[t][0]=Number.MAX_SAFE_INTEGER,n[t][1]=0);n.sort(oo);const u=o.morphTargets&&s.morphAttributes.position,d=o.morphNormals&&s.morphAttributes.normal;let p=0;for(let t=0;t<8;t++){const e=n[t],r=e[0],o=e[1];r!==Number.MAX_SAFE_INTEGER&&o?(u&&s.getAttribute("morphTarget"+t)!==u[r]&&s.setAttribute("morphTarget"+t,u[r]),d&&s.getAttribute("morphNormal"+t)!==d[r]&&s.setAttribute("morphNormal"+t,d[r]),i[t]=o,p+=o):(u&&!0===s.hasAttribute("morphTarget"+t)&&s.deleteAttribute("morphTarget"+t),d&&!0===s.hasAttribute("morphNormal"+t)&&s.deleteAttribute("morphNormal"+t),i[t]=0)}const f=s.morphTargetsRelative?1:1-p;a.getUniforms().setValue(t,"morphTargetBaseInfluence",f),a.getUniforms().setValue(t,"morphTargetInfluences",i)}}}function ho(t,e,i,n){let r=new WeakMap;function s(t){const e=t.target;e.removeEventListener("dispose",s),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(t){const o=n.render.frame,a=t.geometry,c=e.get(t,a);return r.get(c)!==o&&(e.update(c),r.set(c,o)),t.isInstancedMesh&&(!1===t.hasEventListener("dispose",s)&&t.addEventListener("dispose",s),i.update(t.instanceMatrix,34962),null!==t.instanceColor&&i.update(t.instanceColor,34962)),c},dispose:function(){r=new WeakMap}}}function lo(t=null,e=1,i=1,n=1){hn.call(this,null),this.image={data:t,width:e,height:i,depth:n},this.magFilter=Ii,this.minFilter=Ii,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}function uo(t=null,e=1,i=1,n=1){hn.call(this,null),this.image={data:t,width:e,height:i,depth:n},this.magFilter=Ii,this.minFilter=Ii,this.wrapR=Ci,this.generateMipmaps=!1,this.flipY=!1,this.needsUpdate=!0}Ys.physical={uniforms:Rs([Ys.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new rn(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new Dr(0)},transmission:{value:0},transmissionMap:{value:null}}]),vertexShader:Ws.meshphysical_vert,fragmentShader:Ws.meshphysical_frag},lo.prototype=Object.create(hn.prototype),lo.prototype.constructor=lo,lo.prototype.isDataTexture2DArray=!0,uo.prototype=Object.create(hn.prototype),uo.prototype.constructor=uo,uo.prototype.isDataTexture3D=!0;const po=new hn,fo=new lo,mo=new uo,go=new zs,_o=[],vo=[],yo=new Float32Array(16),bo=new Float32Array(9),xo=new Float32Array(4);function wo(t,e,i){const n=t[0];if(n<=0||n>0)return t;const r=e*i;let s=_o[r];if(void 0===s&&(s=new Float32Array(r),_o[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function So(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Mo(t,e){for(let i=0,n=e.length;i<n;i++)t[i]=e[i]}function To(t,e){let i=vo[e];void 0===i&&(i=new Int32Array(e),vo[e]=i);for(let n=0;n!==e;++n)i[n]=t.allocateTextureUnit();return i}function Co(t,e){const i=this.cache;i[0]!==e&&(t.uniform1f(this.addr,e),i[0]=e)}function Eo(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),i[0]=e.x,i[1]=e.y);else{if(So(i,e))return;t.uniform2fv(this.addr,e),Mo(i,e)}}function Io(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),i[0]=e.x,i[1]=e.y,i[2]=e.z);else if(void 0!==e.r)i[0]===e.r&&i[1]===e.g&&i[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),i[0]=e.r,i[1]=e.g,i[2]=e.b);else{if(So(i,e))return;t.uniform3fv(this.addr,e),Mo(i,e)}}function Ao(t,e){const i=this.cache;if(void 0!==e.x)i[0]===e.x&&i[1]===e.y&&i[2]===e.z&&i[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=e.w);else{if(So(i,e))return;t.uniform4fv(this.addr,e),Mo(i,e)}}function Po(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(So(i,e))return;t.uniformMatrix2fv(this.addr,!1,e),Mo(i,e)}else{if(So(i,n))return;xo.set(n),t.uniformMatrix2fv(this.addr,!1,xo),Mo(i,n)}}function Ro(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(So(i,e))return;t.uniformMatrix3fv(this.addr,!1,e),Mo(i,e)}else{if(So(i,n))return;bo.set(n),t.uniformMatrix3fv(this.addr,!1,bo),Mo(i,n)}}function Lo(t,e){const i=this.cache,n=e.elements;if(void 0===n){if(So(i,e))return;t.uniformMatrix4fv(this.addr,!1,e),Mo(i,e)}else{if(So(i,n))return;yo.set(n),t.uniformMatrix4fv(this.addr,!1,yo),Mo(i,n)}}function Oo(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(e||po,r)}function No(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(e||fo,r)}function Do(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(e||mo,r)}function $o(t,e,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(t.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(e||go,r)}function ko(t,e){const i=this.cache;i[0]!==e&&(t.uniform1i(this.addr,e),i[0]=e)}function zo(t,e){const i=this.cache;So(i,e)||(t.uniform2iv(this.addr,e),Mo(i,e))}function Fo(t,e){const i=this.cache;So(i,e)||(t.uniform3iv(this.addr,e),Mo(i,e))}function Bo(t,e){const i=this.cache;So(i,e)||(t.uniform4iv(this.addr,e),Mo(i,e))}function jo(t,e){const i=this.cache;i[0]!==e&&(t.uniform1ui(this.addr,e),i[0]=e)}function Ho(t,e){t.uniform1fv(this.addr,e)}function Uo(t,e){t.uniform1iv(this.addr,e)}function Vo(t,e){t.uniform2iv(this.addr,e)}function Go(t,e){t.uniform3iv(this.addr,e)}function qo(t,e){t.uniform4iv(this.addr,e)}function Wo(t,e){const i=wo(e,this.size,2);t.uniform2fv(this.addr,i)}function Xo(t,e){const i=wo(e,this.size,3);t.uniform3fv(this.addr,i)}function Yo(t,e){const i=wo(e,this.size,4);t.uniform4fv(this.addr,i)}function Zo(t,e){const i=wo(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,i)}function Jo(t,e){const i=wo(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,i)}function Ko(t,e){const i=wo(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,i)}function Qo(t,e,i){const n=e.length,r=To(i,n);t.uniform1iv(this.addr,r);for(let t=0;t!==n;++t)i.safeSetTexture2D(e[t]||po,r[t])}function ta(t,e,i){const n=e.length,r=To(i,n);t.uniform1iv(this.addr,r);for(let t=0;t!==n;++t)i.safeSetTextureCube(e[t]||go,r[t])}function ea(t,e,i){this.id=t,this.addr=i,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Co;case 35664:return Eo;case 35665:return Io;case 35666:return Ao;case 35674:return Po;case 35675:return Ro;case 35676:return Lo;case 5124:case 35670:return ko;case 35667:case 35671:return zo;case 35668:case 35672:return Fo;case 35669:case 35673:return Bo;case 5125:return jo;case 35678:case 36198:case 36298:case 36306:case 35682:return Oo;case 35679:case 36299:case 36307:return Do;case 35680:case 36300:case 36308:case 36293:return $o;case 36289:case 36303:case 36311:case 36292:return No}}(e.type)}function ia(t,e,i){this.id=t,this.addr=i,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Ho;case 35664:return Wo;case 35665:return Xo;case 35666:return Yo;case 35674:return Zo;case 35675:return Jo;case 35676:return Ko;case 5124:case 35670:return Uo;case 35667:case 35671:return Vo;case 35668:case 35672:return Go;case 35669:case 35673:return qo;case 35678:case 36198:case 36298:case 36306:case 35682:return Qo;case 35680:case 36300:case 36308:case 36293:return ta}}(e.type)}function na(t){this.id=t,this.seq=[],this.map={}}ia.prototype.updateCache=function(t){const e=this.cache;t instanceof Float32Array&&e.length!==t.length&&(this.cache=new Float32Array(t.length)),Mo(e,t)},na.prototype.setValue=function(t,e,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(t,e[s.id],i)}};const ra=/(\w+)(\])?(\[|\.)?/g;function sa(t,e){t.seq.push(e),t.map[e.id]=e}function oa(t,e,i){const n=t.name,r=n.length;for(ra.lastIndex=0;;){const s=ra.exec(n),o=ra.lastIndex;let a=s[1];const c="]"===s[2],h=s[3];if(c&&(a|=0),void 0===h||"["===h&&o+2===r){sa(i,void 0===h?new ea(a,t,e):new ia(a,t,e));break}{let t=i.map[a];void 0===t&&(t=new na(a),sa(i,t)),i=t}}}function aa(t,e){this.seq=[],this.map={};const i=t.getProgramParameter(e,35718);for(let n=0;n<i;++n){const i=t.getActiveUniform(e,n);oa(i,t.getUniformLocation(e,i.name),this)}}function ca(t,e,i){const n=t.createShader(e);return t.shaderSource(n,i),t.compileShader(n),n}aa.prototype.setValue=function(t,e,i,n){const r=this.map[e];void 0!==r&&r.setValue(t,i,n)},aa.prototype.setOptional=function(t,e,i){const n=e[i];void 0!==n&&this.setValue(t,i,n)},aa.upload=function(t,e,i,n){for(let r=0,s=e.length;r!==s;++r){const s=e[r],o=i[s.id];!1!==o.needsUpdate&&s.setValue(t,o.value,n)}},aa.seqWithValue=function(t,e){const i=[];for(let n=0,r=t.length;n!==r;++n){const r=t[n];r.id in e&&i.push(r)}return i};let ha=0;function la(t){switch(t){case Xi:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}function ua(t,e,i){const n=t.getShaderParameter(e,35713),r=t.getShaderInfoLog(e).trim();if(n&&""===r)return"";return"THREE.WebGLShader: gl.getShaderInfoLog() "+i+"\n"+r+function(t){const e=t.split("\n");for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join("\n")}(t.getShaderSource(e))}function da(t,e){const i=la(e);return"vec4 "+t+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function pa(t,e){const i=la(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function fa(t,e){let i;switch(e){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function ma(t){return""!==t}function ga(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function _a(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const va=/^[ \t]*#include +<([\w\d./]+)>/gm;function ya(t){return t.replace(va,ba)}function ba(t,e){const i=Ws[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return ya(i)}const xa=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,wa=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Sa(t){return t.replace(wa,Ta).replace(xa,Ma)}function Ma(t,e,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Ta(t,e,i,n)}function Ta(t,e,i,n){let r="";for(let t=parseInt(e);t<parseInt(i);t++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return r}function Ca(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Ea(t,e,i,n){const r=t.getContext(),s=i.defines;let o=i.vertexShader,a=i.fragmentShader;const c=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(i),h=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case 301:case 302:e="ENVMAP_TYPE_CUBE";break;case 306:case 307:e="ENVMAP_TYPE_CUBE_UV"}return e}(i),l=function(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case 302:case 307:e="ENVMAP_MODE_REFRACTION"}return e}(i),u=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(i),d=t.gammaFactor>0?t.gammaFactor:1,p=i.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ma).join("\n")}(i),f=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(s),m=r.createProgram();let g,_,v=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=[f].filter(ma).join("\n"),g.length>0&&(g+="\n"),_=[p,f].filter(ma).join("\n"),_.length>0&&(_+="\n")):(g=[Ca(i),"#define SHADER_NAME "+i.shaderName,f,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",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.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_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.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",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":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+c:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#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(ma).join("\n"),_=[p,Ca(i),"#define SHADER_NAME "+i.shaderName,f,i.alphaTest?"#define ALPHATEST "+i.alphaTest+(i.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+d,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+h:"",i.envMap?"#define "+l:"",i.envMap?"#define "+u:"",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.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.sheen?"#define USE_SHEEN":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+c:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?Ws.tonemapping_pars_fragment:"",0!==i.toneMapping?fa("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",Ws.encodings_pars_fragment,i.map?da("mapTexelToLinear",i.mapEncoding):"",i.matcap?da("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?da("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?da("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.lightMap?da("lightMapTexelToLinear",i.lightMapEncoding):"",pa("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ma).join("\n")),o=ya(o),o=ga(o,i),o=_a(o,i),a=ya(a),a=ga(a,i),a=_a(a,i),o=Sa(o),a=Sa(a),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(v="#version 300 es\n",g=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",i.glslVersion===Ki?"":"out highp vec4 pc_fragColor;",i.glslVersion===Ki?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+_);const y=v+_+a,b=ca(r,35633,v+g+o),x=ca(r,35632,y);if(r.attachShader(m,b),r.attachShader(m,x),void 0!==i.index0AttributeName?r.bindAttribLocation(m,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(m,0,"position"),r.linkProgram(m),t.debug.checkShaderErrors){const t=r.getProgramInfoLog(m).trim(),e=r.getShaderInfoLog(b).trim(),i=r.getShaderInfoLog(x).trim();let n=!0,s=!0;if(!1===r.getProgramParameter(m,35714)){n=!1;const e=ua(r,b,"vertex"),i=ua(r,x,"fragment");console.error("THREE.WebGLProgram: shader error: ",r.getError(),"35715",r.getProgramParameter(m,35715),"gl.getProgramInfoLog",t,e,i)}else""!==t?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",t):""!==e&&""!==i||(s=!1);s&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:g},fragmentShader:{log:i,prefix:_}})}let w,S;return r.deleteShader(b),r.deleteShader(x),this.getUniforms=function(){return void 0===w&&(w=new aa(r,m)),w},this.getAttributes=function(){return void 0===S&&(S=function(t,e){const i={},n=t.getProgramParameter(e,35721);for(let r=0;r<n;r++){const n=t.getActiveAttrib(e,r).name;i[n]=t.getAttribLocation(e,n)}return i}(r,m)),S},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(m),this.program=void 0},this.name=i.shaderName,this.id=ha++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=b,this.fragmentShader=x,this}function Ia(t,e,i,n,r,s){const o=[],a=n.isWebGL2,c=n.logarithmicDepthBuffer,h=n.floatVertexTextures,l=n.maxVertexUniforms,u=n.vertexTextures;let d=n.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},f=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","sheen","transmissionMap"];function m(t){let e;return t&&t.isTexture?e=t.encoding:t&&t.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e=t.texture.encoding):e=Xi,e}return{getParameters:function(r,o,f,g,_){const v=g.fog,y=r.isMeshStandardMaterial?g.environment:null,b=e.get(r.envMap||y),x=p[r.type],w=_.isSkinnedMesh?function(t){const e=t.skeleton.bones;if(h)return 1024;{const t=l,i=Math.floor((t-20)/4),n=Math.min(i,e.length);return n<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+n+"."),0):n}}(_):0;let S,M;if(null!==r.precision&&(d=n.getMaxPrecision(r.precision),d!==r.precision&&console.warn("THREE.WebGLProgram.getParameters:",r.precision,"not supported, using",d,"instead.")),x){const t=Ys[x];S=t.vertexShader,M=t.fragmentShader}else S=r.vertexShader,M=r.fragmentShader;const T=t.getRenderTarget();return{isWebGL2:a,shaderID:x,shaderName:r.type,vertexShader:S,fragmentShader:M,defines:r.defines,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:d,instancing:!0===_.isInstancedMesh,instancingColor:!0===_.isInstancedMesh&&null!==_.instanceColor,supportsVertexTextures:u,outputEncoding:null!==T?m(T.texture):t.outputEncoding,map:!!r.map,mapEncoding:m(r.map),matcap:!!r.matcap,matcapEncoding:m(r.matcap),envMap:!!b,envMapMode:b&&b.mapping,envMapEncoding:m(b),envMapCubeUV:!!b&&(306===b.mapping||307===b.mapping),lightMap:!!r.lightMap,lightMapEncoding:m(r.lightMap),aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,emissiveMapEncoding:m(r.emissiveMap),bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:1===r.normalMapType,tangentSpaceNormalMap:0===r.normalMapType,clearcoatMap:!!r.clearcoatMap,clearcoatRoughnessMap:!!r.clearcoatRoughnessMap,clearcoatNormalMap:!!r.clearcoatNormalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,alphaMap:!!r.alphaMap,gradientMap:!!r.gradientMap,sheen:!!r.sheen,transmissionMap:!!r.transmissionMap,combine:r.combine,vertexTangents:r.normalMap&&r.vertexTangents,vertexColors:r.vertexColors,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.displacementMap||r.transmissionMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||r.transmissionMap||!r.displacementMap),fog:!!v,useFog:r.fog,fogExp2:v&&v.isFogExp2,flatShading:r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:c,skinning:r.skinning&&w>0,maxBones:w,useVertexTexture:h,morphTargets:r.morphTargets,morphNormals:r.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:r.dithering,shadowMapEnabled:t.shadowMap.enabled&&f.length>0,shadowMapType:t.shadowMap.type,toneMapping:r.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:2===r.side,flipSided:1===r.side,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:a||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:a||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:a||i.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t<f.length;t++)i.push(e[f[t]]);i.push(t.outputEncoding),i.push(t.gammaFactor)}return i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=p[t.type];let i;if(e){const t=Ys[e];i=Ls.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=o.length;t<e;t++){const e=o[t];if(e.cacheKey===i){n=e,++n.usedTimes;break}}return void 0===n&&(n=new Ea(t,i,e,r),o.push(n)),n},releaseProgram:function(t){if(0==--t.usedTimes){const e=o.indexOf(t);o[e]=o[o.length-1],o.pop(),t.destroy()}},programs:o}}function Aa(){let t=new WeakMap;return{get:function(e){let i=t.get(e);return void 0===i&&(i={},t.set(e,i)),i},remove:function(e){t.delete(e)},update:function(e,i,n){t.get(e)[i]=n},dispose:function(){t=new WeakMap}}}function Pa(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function Ra(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function La(t){const e=[];let i=0;const n=[],r=[],s={id:-1};function o(n,r,o,a,c,h){let l=e[i];const u=t.get(o);return void 0===l?(l={id:n.id,object:n,geometry:r,material:o,program:u.program||s,groupOrder:a,renderOrder:n.renderOrder,z:c,group:h},e[i]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=o,l.program=u.program||s,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=c,l.group=h),i++,l}return{opaque:n,transparent:r,init:function(){i=0,n.length=0,r.length=0},push:function(t,e,i,s,a,c){const h=o(t,e,i,s,a,c);(!0===i.transparent?r:n).push(h)},unshift:function(t,e,i,s,a,c){const h=o(t,e,i,s,a,c);(!0===i.transparent?r:n).unshift(h)},finish:function(){for(let t=i,n=e.length;t<n;t++){const i=e[t];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.program=null,i.group=null}},sort:function(t,e){n.length>1&&n.sort(t||Pa),r.length>1&&r.sort(e||Ra)}}}function Oa(t){let e=new WeakMap;return{get:function(i,n){const r=e.get(i);let s;return void 0===r?(s=new La(t),e.set(i,new WeakMap),e.get(i).set(n,s)):(s=r.get(n),void 0===s&&(s=new La(t),r.set(n,s))),s},dispose:function(){e=new WeakMap}}}function Na(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new fn,color:new Dr};break;case"SpotLight":i={position:new fn,direction:new fn,color:new Dr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new fn,color:new Dr,distance:0,decay:0};break;case"HemisphereLight":i={direction:new fn,skyColor:new Dr,groundColor:new Dr};break;case"RectAreaLight":i={color:new Dr,position:new fn,halfWidth:new fn,halfHeight:new fn}}return t[e.id]=i,i}}}let Da=0;function $a(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ka(t,e){const i=new Na,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let t=0;t<9;t++)r.probe.push(new fn);const s=new fn,o=new Hn,a=new Hn;return{setup:function(s){let o=0,a=0,c=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let h=0,l=0,u=0,d=0,p=0,f=0,m=0,g=0;s.sort($a);for(let t=0,e=s.length;t<e;t++){const e=s[t],_=e.color,v=e.intensity,y=e.distance,b=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)o+=_.r*v,a+=_.g*v,c+=_.b*v;else if(e.isLightProbe)for(let t=0;t<9;t++)r.probe[t].addScaledVector(e.sh.coefficients[t],v);else if(e.isDirectionalLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.directionalShadow[h]=i,r.directionalShadowMap[h]=b,r.directionalShadowMatrix[h]=e.shadow.matrix,f++}r.directional[h]=t,h++}else if(e.isSpotLight){const t=i.get(e);if(t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(_).multiplyScalar(v),t.distance=y,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,r.spotShadow[u]=i,r.spotShadowMap[u]=b,r.spotShadowMatrix[u]=e.shadow.matrix,g++}r.spot[u]=t,u++}else if(e.isRectAreaLight){const t=i.get(e);t.color.copy(_).multiplyScalar(v),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),r.rectArea[d]=t,d++}else if(e.isPointLight){const t=i.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,i=n.get(e);i.shadowBias=t.bias,i.shadowNormalBias=t.normalBias,i.shadowRadius=t.radius,i.shadowMapSize=t.mapSize,i.shadowCameraNear=t.camera.near,i.shadowCameraFar=t.camera.far,r.pointShadow[l]=i,r.pointShadowMap[l]=b,r.pointShadowMatrix[l]=e.shadow.matrix,m++}r.point[l]=t,l++}else if(e.isHemisphereLight){const t=i.get(e);t.skyColor.copy(e.color).multiplyScalar(v),t.groundColor.copy(e.groundColor).multiplyScalar(v),r.hemi[p]=t,p++}}d>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=Xs.LTC_FLOAT_1,r.rectAreaLTC2=Xs.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Xs.LTC_HALF_1,r.rectAreaLTC2=Xs.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=a,r.ambient[2]=c;const _=r.hash;_.directionalLength===h&&_.pointLength===l&&_.spotLength===u&&_.rectAreaLength===d&&_.hemiLength===p&&_.numDirectionalShadows===f&&_.numPointShadows===m&&_.numSpotShadows===g||(r.directional.length=h,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=p,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=m,r.spotShadowMatrix.length=g,_.directionalLength=h,_.pointLength=l,_.spotLength=u,_.rectAreaLength=d,_.hemiLength=p,_.numDirectionalShadows=f,_.numPointShadows=m,_.numSpotShadows=g,r.version=Da++)},setupView:function(t,e){let i=0,n=0,c=0,h=0,l=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e<d;e++){const d=t[e];if(d.isDirectionalLight){const t=r.directional[i];t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),i++}else if(d.isSpotLight){const t=r.spot[c];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),t.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),t.direction.sub(s),t.direction.transformDirection(u),c++}else if(d.isRectAreaLight){const t=r.rectArea[h];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),a.identity(),o.copy(d.matrixWorld),o.premultiply(u),a.extractRotation(o),t.halfWidth.set(.5*d.width,0,0),t.halfHeight.set(0,.5*d.height,0),t.halfWidth.applyMatrix4(a),t.halfHeight.applyMatrix4(a),h++}else if(d.isPointLight){const t=r.point[n];t.position.setFromMatrixPosition(d.matrixWorld),t.position.applyMatrix4(u),n++}else if(d.isHemisphereLight){const t=r.hemi[l];t.direction.setFromMatrixPosition(d.matrixWorld),t.direction.transformDirection(u),t.direction.normalize(),l++}}},state:r}}function za(t,e){const i=new ka(t,e),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(){i.setup(n)},setupLightsView:function(t){i.setupView(n,t)},pushLight:function(t){n.push(t)},pushShadow:function(t){r.push(t)}}}function Fa(t,e){let i=new WeakMap;return{get:function(n,r=0){let s;return!1===i.has(n)?(s=new za(t,e),i.set(n,[]),i.get(n).push(s)):r>=i.get(n).length?(s=new za(t,e),i.get(n).push(s)):s=i.get(n)[r],s},dispose:function(){i=new WeakMap}}}function Ba(t){zr.call(this),this.type="MeshDepthMaterial",this.depthPacking=3200,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.setValues(t)}function ja(t){zr.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new fn,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}Ba.prototype=Object.create(zr.prototype),Ba.prototype.constructor=Ba,Ba.prototype.isMeshDepthMaterial=!0,Ba.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},ja.prototype=Object.create(zr.prototype),ja.prototype.constructor=ja,ja.prototype.isMeshDistanceMaterial=!0,ja.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this};function Ha(t,e,i){let n=new Us;const r=new rn,s=new rn,o=new un,a=[],c=[],h={},l={0:1,1:0,2:2},u=new Os({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new rn},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),d=u.clone();d.defines.HORIZONTAL_PASS=1;const p=new hs;p.setAttribute("position",new Hr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Es(p,u),m=this;function g(i,n){const r=e.update(f);u.uniforms.shadow_pass.value=i.map.texture,u.uniforms.resolution.value=i.mapSize,u.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,u,f,null),d.uniforms.shadow_pass.value=i.mapPass.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,d,f,null)}function _(t,e,i){const n=t<<0|e<<1|i<<2;let r=a[n];return void 0===r&&(r=new Ba({depthPacking:3201,morphTargets:t,skinning:e}),a[n]=r),r}function v(t,e,i){const n=t<<0|e<<1|i<<2;let r=c[n];return void 0===r&&(r=new ja({morphTargets:t,skinning:e}),c[n]=r),r}function y(e,i,n,r,s,o,a){let c=null,u=_,d=e.customDepthMaterial;if(!0===r.isPointLight&&(u=v,d=e.customDistanceMaterial),void 0===d){let t=!1;!0===n.morphTargets&&(t=i.morphAttributes&&i.morphAttributes.position&&i.morphAttributes.position.length>0);let r=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e));c=u(t,r,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){const t=c.uuid,e=n.uuid;let i=h[t];void 0===i&&(i={},h[t]=i);let r=i[e];void 0===r&&(r=c.clone(),i[e]=r),c=r}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=3===a?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:l[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=s,c.farDistance=o),c}function b(i,r,s,o,a){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),r=i.material;if(Array.isArray(r)){const e=n.groups;for(let c=0,h=e.length;c<h;c++){const h=e[c],l=r[h.materialIndex];if(l&&l.visible){const e=y(i,n,l,o,s.near,s.far,a);t.renderBufferDirect(s,null,n,e,i,h)}}}else if(r.visible){const e=y(i,n,r,o,s.near,s.far,a);t.renderBufferDirect(s,null,n,e,i,null)}}const c=i.children;for(let t=0,e=c.length;t<e;t++)b(c[t],r,s,o,a)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,a,c){if(!1===m.enabled)return;if(!1===m.autoUpdate&&!1===m.needsUpdate)return;if(0===e.length)return;const h=t.getRenderTarget(),l=t.getActiveCubeFace(),u=t.getActiveMipmapLevel(),d=t.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let h=0,l=e.length;h<l;h++){const l=e[h],u=l.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const p=u.getFrameExtents();if(r.multiply(p),s.copy(u.mapSize),(r.x>i||r.y>i)&&(r.x>i&&(s.x=Math.floor(i/p.x),r.x=s.x*p.x,u.mapSize.x=s.x),r.y>i&&(s.y=Math.floor(i/p.y),r.y=s.y*p.y,u.mapSize.y=s.y)),null===u.map&&!u.isPointLightShadow&&3===this.type){const t={minFilter:Ai,magFilter:Ai,format:zi};u.map=new dn(r.x,r.y,t),u.map.texture.name=l.name+".shadowMap",u.mapPass=new dn(r.x,r.y,t),u.camera.updateProjectionMatrix()}if(null===u.map){const t={minFilter:Ii,magFilter:Ii,format:zi};u.map=new dn(r.x,r.y,t),u.map.texture.name=l.name+".shadowMap",u.camera.updateProjectionMatrix()}t.setRenderTarget(u.map),t.clear();const f=u.getViewportCount();for(let t=0;t<f;t++){const e=u.getViewport(t);o.set(s.x*e.x,s.y*e.y,s.x*e.z,s.y*e.w),d.viewport(o),u.updateMatrices(l,t),n=u.getFrustum(),b(a,c,u.camera,l,this.type)}u.isPointLightShadow||3!==this.type||g(u,c),u.needsUpdate=!1}m.needsUpdate=!1,t.setRenderTarget(h,l,u)}}function Ua(t,e,i){const n=i.isWebGL2;const r=new function(){let e=!1;const i=new un;let n=null;const r=new un(0,0,0,0);return{setMask:function(i){n===i||e||(t.colorMask(i,i,i,i),n=i)},setLocked:function(t){e=t},setClear:function(e,n,s,o,a){!0===a&&(e*=o,n*=o,s*=o),i.set(e,n,s,o),!1===r.equals(i)&&(t.clearColor(e,n,s,o),r.copy(i))},reset:function(){e=!1,n=null,r.set(-1,0,0,0)}}},s=new function(){let e=!1,i=null,n=null,r=null;return{setTest:function(t){t?O(2929):N(2929)},setMask:function(n){i===n||e||(t.depthMask(n),i=n)},setFunc:function(e){if(n!==e){if(e)switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);n=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,i=null,n=null,r=null}}},o=new function(){let e=!1,i=null,n=null,r=null,s=null,o=null,a=null,c=null,h=null;return{setTest:function(t){e||(t?O(2960):N(2960))},setMask:function(n){i===n||e||(t.stencilMask(n),i=n)},setFunc:function(e,i,o){n===e&&r===i&&s===o||(t.stencilFunc(e,i,o),n=e,r=i,s=o)},setOp:function(e,i,n){o===e&&a===i&&c===n||(t.stencilOp(e,i,n),o=e,a=i,c=n)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,i=null,n=null,r=null,s=null,o=null,a=null,c=null,h=null}}};let a={},c=null,h=null,l=null,u=null,d=null,p=null,f=null,m=null,g=null,_=!1,v=null,y=null,b=null,x=null,w=null;const S=t.getParameter(35661);let M=!1,T=0;const C=t.getParameter(7938);-1!==C.indexOf("WebGL")?(T=parseFloat(/^WebGL (\d)/.exec(C)[1]),M=T>=1):-1!==C.indexOf("OpenGL ES")&&(T=parseFloat(/^OpenGL ES (\d)/.exec(C)[1]),M=T>=2);let E=null,I={};const A=new un,P=new un;function R(e,i,n){const r=new Uint8Array(4),s=t.createTexture();t.bindTexture(e,s),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;e<n;e++)t.texImage2D(i+e,0,6408,1,1,0,6408,5121,r);return s}const L={};function O(e){!0!==a[e]&&(t.enable(e),a[e]=!0)}function N(e){!1!==a[e]&&(t.disable(e),a[e]=!1)}L[3553]=R(3553,3553,1),L[34067]=R(34067,34069,6),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),O(2929),s.setFunc(3),z(!1),F(1),O(2884),k(0);const D={[Mi]:32774,101:32778,102:32779};if(n)D[103]=32775,D[104]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(D[103]=t.MIN_EXT,D[104]=t.MAX_EXT)}const $={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function k(e,i,n,r,s,o,a,c){if(0!==e){if(h||(O(3042),h=!0),5===e)s=s||i,o=o||n,a=a||r,i===u&&s===f||(t.blendEquationSeparate(D[i],D[s]),u=i,f=s),n===d&&r===p&&o===m&&a===g||(t.blendFuncSeparate($[n],$[r],$[o],$[a]),d=n,p=r,m=o,g=a),l=e,_=null;else if(e!==l||c!==_){if(u===Mi&&f===Mi||(t.blendEquation(32774),u=Mi,f=Mi),c)switch(e){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,0,769,771);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFunc(0,769);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}d=null,p=null,m=null,g=null,l=e,_=c}}else h&&(N(3042),h=!1)}function z(e){v!==e&&(e?t.frontFace(2304):t.frontFace(2305),v=e)}function F(e){0!==e?(O(2884),e!==y&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):N(2884),y=e}function B(e,i,n){e?(O(32823),x===i&&w===n||(t.polygonOffset(i,n),x=i,w=n)):N(32823)}function j(e){void 0===e&&(e=33984+S-1),E!==e&&(t.activeTexture(e),E=e)}return{buffers:{color:r,depth:s,stencil:o},enable:O,disable:N,useProgram:function(e){return c!==e&&(t.useProgram(e),c=e,!0)},setBlending:k,setMaterial:function(t,e){2===t.side?N(2884):O(2884);let i=1===t.side;e&&(i=!i),z(i),1===t.blending&&!1===t.transparent?k(0):k(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),s.setFunc(t.depthFunc),s.setTest(t.depthTest),s.setMask(t.depthWrite),r.setMask(t.colorWrite);const n=t.stencilWrite;o.setTest(n),n&&(o.setMask(t.stencilWriteMask),o.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),o.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),B(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits)},setFlipSided:z,setCullFace:F,setLineWidth:function(e){e!==b&&(M&&t.lineWidth(e),b=e)},setPolygonOffset:B,setScissorTest:function(t){t?O(3089):N(3089)},activeTexture:j,bindTexture:function(e,i){null===E&&j();let n=I[E];void 0===n&&(n={type:void 0,texture:void 0},I[E]=n),n.type===e&&n.texture===i||(t.bindTexture(e,i||L[e]),n.type=e,n.texture=i)},unbindTexture:function(){const e=I[E];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===A.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),A.copy(e))},viewport:function(e){!1===P.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),P.copy(e))},reset:function(){a={},E=null,I={},c=null,h=null,l=null,u=null,d=null,p=null,f=null,m=null,g=null,_=!1,v=null,y=null,b=null,x=null,w=null,r.reset(),s.reset(),o.reset()}}}function Va(t,e,i,n,r,s,o){const a=r.isWebGL2,c=r.maxTextures,h=r.maxCubemapSize,l=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let p,f=!1;try{f="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(t){}function m(t,e){return f?new OffscreenCanvas(t,e):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function g(t,e,i,n){let r=1;if((t.width>n||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?nn.floorPowerOfTwo:Math.floor,s=n(r*t.width),o=n(r*t.height);void 0===p&&(p=m(s,o));const a=i?m(s,o):p;a.width=s,a.height=o;return a.getContext("2d").drawImage(t,0,0,s,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+s+"x"+o+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function _(t){return nn.isPowerOfTwo(t.width)&&nn.isPowerOfTwo(t.height)}function v(t,e){return t.generateMipmaps&&e&&t.minFilter!==Ii&&t.minFilter!==Ai}function y(e,i,r,s){t.generateMipmap(e);n.get(i).__maxMipLevel=Math.log(Math.max(r,s))*Math.LOG2E}function b(i,n,r){if(!1===a)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let s=n;return 6403===n&&(5126===r&&(s=33326),5131===r&&(s=33325),5121===r&&(s=33321)),6407===n&&(5126===r&&(s=34837),5131===r&&(s=34843),5121===r&&(s=32849)),6408===n&&(5126===r&&(s=34836),5131===r&&(s=34842),5121===r&&(s=32856)),33325!==s&&33326!==s&&34842!==s&&34836!==s||e.get("EXT_color_buffer_float"),s}function x(t){return t===Ii||1004===t||1005===t?9728:9729}function w(e){const i=e.target;i.removeEventListener("dispose",w),function(e){const i=n.get(e);if(void 0===i.__webglInit)return;t.deleteTexture(i.__webglTexture),n.remove(e)}(i),i.isVideoTexture&&d.delete(i),o.memory.textures--}function S(e){const i=e.target;i.removeEventListener("dispose",S),function(e){const i=n.get(e),r=n.get(e.texture);if(!e)return;void 0!==r.__webglTexture&&t.deleteTexture(r.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&t.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer);n.remove(e.texture),n.remove(e)}(i),o.memory.textures--}let M=0;function T(t,e){const r=n.get(t);if(t.isVideoTexture&&function(t){const e=o.render.frame;d.get(t)!==e&&(d.set(t,e),t.update())}(t),t.version>0&&r.__version!==t.version){const i=t.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void R(r,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+e),i.bindTexture(3553,r.__webglTexture)}function C(e,r){const o=n.get(e);e.version>0&&o.__version!==e.version?function(e,n,r){if(6!==n.image.length)return;P(e,n),i.activeTexture(33984+r),i.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment);const o=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),c=n.image[0]&&n.image[0].isDataTexture,l=[];for(let t=0;t<6;t++)l[t]=o||c?c?n.image[t].image:n.image[t]:g(n.image[t],!1,!0,h);const u=l[0],d=_(u)||a,p=s.convert(n.format),f=s.convert(n.type),m=b(n.internalFormat,p,f);let x;if(A(34067,n,d),o){for(let t=0;t<6;t++){x=l[t].mipmaps;for(let e=0;e<x.length;e++){const r=x[e];n.format!==zi&&n.format!==ki?null!==p?i.compressedTexImage2D(34069+t,e,m,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+t,e,m,r.width,r.height,0,p,f,r.data)}}e.__maxMipLevel=x.length-1}else{x=n.mipmaps;for(let t=0;t<6;t++)if(c){i.texImage2D(34069+t,0,m,l[t].width,l[t].height,0,p,f,l[t].data);for(let e=0;e<x.length;e++){const n=x[e].image[t].image;i.texImage2D(34069+t,e+1,m,n.width,n.height,0,p,f,n.data)}}else{i.texImage2D(34069+t,0,m,p,f,l[t]);for(let e=0;e<x.length;e++){const n=x[e];i.texImage2D(34069+t,e+1,m,p,f,n.image[t])}}e.__maxMipLevel=x.length}v(n,d)&&y(34067,n,u.width,u.height);e.__version=n.version,n.onUpdate&&n.onUpdate(n)}(o,e,r):(i.activeTexture(33984+r),i.bindTexture(34067,o.__webglTexture))}const E={[Ti]:10497,[Ci]:33071,[Ei]:33648},I={[Ii]:9728,1004:9984,1005:9986,[Ai]:9729,1007:9985,[Pi]:9987};function A(i,s,o){o?(t.texParameteri(i,10242,E[s.wrapS]),t.texParameteri(i,10243,E[s.wrapT]),32879!==i&&35866!==i||t.texParameteri(i,32882,E[s.wrapR]),t.texParameteri(i,10240,I[s.magFilter]),t.texParameteri(i,10241,I[s.minFilter])):(t.texParameteri(i,10242,33071),t.texParameteri(i,10243,33071),32879!==i&&35866!==i||t.texParameteri(i,32882,33071),s.wrapS===Ci&&s.wrapT===Ci||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,10240,x(s.magFilter)),t.texParameteri(i,10241,x(s.minFilter)),s.minFilter!==Ii&&s.minFilter!==Ai&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));const c=e.get("EXT_texture_filter_anisotropic");if(c){if(s.type===Ni&&null===e.get("OES_texture_float_linear"))return;if(s.type===Di&&null===(a||e.get("OES_texture_half_float_linear")))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(t.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function P(e,i){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",w),e.__webglTexture=t.createTexture(),o.memory.textures++)}function R(e,n,r){let o=3553;n.isDataTexture2DArray&&(o=35866),n.isDataTexture3D&&(o=32879),P(e,n),i.activeTexture(33984+r),i.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment);const c=function(t){return!a&&(t.wrapS!==Ci||t.wrapT!==Ci||t.minFilter!==Ii&&t.minFilter!==Ai)}(n)&&!1===_(n.image),h=g(n.image,c,!1,l),u=_(h)||a,d=s.convert(n.format);let p,f=s.convert(n.type),m=b(n.internalFormat,d,f);A(o,n,u);const x=n.mipmaps;if(n.isDepthTexture)m=6402,a?m=n.type===Ni?36012:n.type===Oi?33190:n.type===$i?35056:33189:n.type===Ni&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===Fi&&6402===m&&n.type!==Li&&n.type!==Oi&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=Li,f=s.convert(n.type)),n.format===Bi&&6402===m&&(m=34041,n.type!==$i&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=$i,f=s.convert(n.type))),i.texImage2D(3553,0,m,h.width,h.height,0,d,f,null);else if(n.isDataTexture)if(x.length>0&&u){for(let t=0,e=x.length;t<e;t++)p=x[t],i.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);n.generateMipmaps=!1,e.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,m,h.width,h.height,0,d,f,h.data),e.__maxMipLevel=0;else if(n.isCompressedTexture){for(let t=0,e=x.length;t<e;t++)p=x[t],n.format!==zi&&n.format!==ki?null!==d?i.compressedTexImage2D(3553,t,m,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,t,m,p.width,p.height,0,d,f,p.data);e.__maxMipLevel=x.length-1}else if(n.isDataTexture2DArray)i.texImage3D(35866,0,m,h.width,h.height,h.depth,0,d,f,h.data),e.__maxMipLevel=0;else if(n.isDataTexture3D)i.texImage3D(32879,0,m,h.width,h.height,h.depth,0,d,f,h.data),e.__maxMipLevel=0;else if(x.length>0&&u){for(let t=0,e=x.length;t<e;t++)p=x[t],i.texImage2D(3553,t,m,d,f,p);n.generateMipmaps=!1,e.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,m,d,f,h),e.__maxMipLevel=0;v(n,u)&&y(o,n,h.width,h.height),e.__version=n.version,n.onUpdate&&n.onUpdate(n)}function L(e,r,o,a){const c=s.convert(r.texture.format),h=s.convert(r.texture.type),l=b(r.texture.internalFormat,c,h);i.texImage2D(a,0,l,r.width,r.height,0,c,h,null),t.bindFramebuffer(36160,e),t.framebufferTexture2D(36160,o,a,n.get(r.texture).__webglTexture,0),t.bindFramebuffer(36160,null)}function O(e,i,n){if(t.bindRenderbuffer(36161,e),i.depthBuffer&&!i.stencilBuffer){let r=33189;if(n){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===Ni?r=36012:e.type===Oi&&(r=33190));const n=D(i);t.renderbufferStorageMultisample(36161,n,r,i.width,i.height)}else t.renderbufferStorage(36161,r,i.width,i.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(i.depthBuffer&&i.stencilBuffer){if(n){const e=D(i);t.renderbufferStorageMultisample(36161,e,35056,i.width,i.height)}else t.renderbufferStorage(36161,34041,i.width,i.height);t.framebufferRenderbuffer(36160,33306,36161,e)}else{const e=s.convert(i.texture.format),r=s.convert(i.texture.type),o=b(i.texture.internalFormat,e,r);if(n){const e=D(i);t.renderbufferStorageMultisample(36161,e,o,i.width,i.height)}else t.renderbufferStorage(36161,o,i.width,i.height)}t.bindRenderbuffer(36161,null)}function N(e){const i=n.get(e),r=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,e),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),T(i.depthTexture,0);const r=n.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===Fi)t.framebufferTexture2D(36160,36096,3553,r,0);else{if(i.depthTexture.format!==Bi)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(36160,33306,3553,r,0)}}(i.__webglFramebuffer,e)}else if(r){i.__webglDepthbuffer=[];for(let n=0;n<6;n++)t.bindFramebuffer(36160,i.__webglFramebuffer[n]),i.__webglDepthbuffer[n]=t.createRenderbuffer(),O(i.__webglDepthbuffer[n],e,!1)}else t.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),O(i.__webglDepthbuffer,e,!1);t.bindFramebuffer(36160,null)}function D(t){return a&&t.isWebGLMultisampleRenderTarget?Math.min(u,t.samples):0}let $=!1,k=!1;this.allocateTextureUnit=function(){const t=M;return t>=c&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+c),M+=1,t},this.resetTextureUnits=function(){M=0},this.setTexture2D=T,this.setTexture2DArray=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?R(r,t,e):(i.activeTexture(33984+e),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?R(r,t,e):(i.activeTexture(33984+e),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=C,this.setupRenderTarget=function(e){const r=n.get(e),c=n.get(e.texture);e.addEventListener("dispose",S),c.__webglTexture=t.createTexture(),o.memory.textures++;const h=!0===e.isWebGLCubeRenderTarget,l=!0===e.isWebGLMultisampleRenderTarget,u=_(e)||a;if(!a||e.texture.format!==ki||e.texture.type!==Ni&&e.texture.type!==Di||(e.texture.format=zi,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){r.__webglFramebuffer=[];for(let e=0;e<6;e++)r.__webglFramebuffer[e]=t.createFramebuffer()}else if(r.__webglFramebuffer=t.createFramebuffer(),l)if(a){r.__webglMultisampledFramebuffer=t.createFramebuffer(),r.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,r.__webglColorRenderbuffer);const i=s.convert(e.texture.format),n=s.convert(e.texture.type),o=b(e.texture.internalFormat,i,n),a=D(e);t.renderbufferStorageMultisample(36161,a,o,e.width,e.height),t.bindFramebuffer(36160,r.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,r.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),e.depthBuffer&&(r.__webglDepthRenderbuffer=t.createRenderbuffer(),O(r.__webglDepthRenderbuffer,e,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(h){i.bindTexture(34067,c.__webglTexture),A(34067,e.texture,u);for(let t=0;t<6;t++)L(r.__webglFramebuffer[t],e,36064,34069+t);v(e.texture,u)&&y(34067,e.texture,e.width,e.height),i.bindTexture(34067,null)}else i.bindTexture(3553,c.__webglTexture),A(3553,e.texture,u),L(r.__webglFramebuffer,e,36064,3553),v(e.texture,u)&&y(3553,e.texture,e.width,e.height),i.bindTexture(3553,null);e.depthBuffer&&N(e)},this.updateRenderTargetMipmap=function(t){const e=t.texture;if(v(e,_(t)||a)){const r=t.isWebGLCubeRenderTarget?34067:3553,s=n.get(e).__webglTexture;i.bindTexture(r,s),y(r,e,t.width,t.height),i.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(e){if(e.isWebGLMultisampleRenderTarget)if(a){const i=n.get(e);t.bindFramebuffer(36008,i.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,i.__webglFramebuffer);const r=e.width,s=e.height;let o=16384;e.depthBuffer&&(o|=256),e.stencilBuffer&&(o|=1024),t.blitFramebuffer(0,0,r,s,0,0,r,s,o,9728),t.bindFramebuffer(36160,i.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(t,e){t&&t.isWebGLRenderTarget&&(!1===$&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),$=!0),t=t.texture),T(t,e)},this.safeSetTextureCube=function(t,e){t&&t.isWebGLCubeRenderTarget&&(!1===k&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),k=!0),t=t.texture),C(t,e)}}function Ga(t,e,i){const n=i.isWebGL2;return{convert:function(t){let i;if(t===Ri)return 5121;if(1017===t)return 32819;if(1018===t)return 32820;if(1019===t)return 33635;if(1010===t)return 5120;if(1011===t)return 5122;if(t===Li)return 5123;if(1013===t)return 5124;if(t===Oi)return 5125;if(t===Ni)return 5126;if(t===Di)return n?5131:(i=e.get("OES_texture_half_float"),null!==i?i.HALF_FLOAT_OES:null);if(1021===t)return 6406;if(t===ki)return 6407;if(t===zi)return 6408;if(1024===t)return 6409;if(1025===t)return 6410;if(t===Fi)return 6402;if(t===Bi)return 34041;if(1028===t)return 6403;if(1029===t)return 36244;if(1030===t)return 33319;if(1031===t)return 33320;if(1032===t)return 36248;if(1033===t)return 36249;if(33776===t||33777===t||33778===t||33779===t){if(i=e.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(33776===t)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===t)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===t)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===t)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===t||35841===t||35842===t||35843===t){if(i=e.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(35840===t)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===t)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===t)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===t)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===t)return i=e.get("WEBGL_compressed_texture_etc1"),null!==i?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((37492===t||37496===t)&&(i=e.get("WEBGL_compressed_texture_etc"),null!==i)){if(37492===t)return i.COMPRESSED_RGB8_ETC2;if(37496===t)return i.COMPRESSED_RGBA8_ETC2_EAC}return 37808===t||37809===t||37810===t||37811===t||37812===t||37813===t||37814===t||37815===t||37816===t||37817===t||37818===t||37819===t||37820===t||37821===t||37840===t||37841===t||37842===t||37843===t||37844===t||37845===t||37846===t||37847===t||37848===t||37849===t||37850===t||37851===t||37852===t||37853===t?(i=e.get("WEBGL_compressed_texture_astc"),null!==i?t:null):36492===t?(i=e.get("EXT_texture_compression_bptc"),null!==i?t:null):t===$i?n?34042:(i=e.get("WEBGL_depth_texture"),null!==i?i.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}function qa(t=[]){Ds.call(this),this.cameras=t}function Wa(){pr.call(this),this.type="Group"}function Xa(){this._targetRay=null,this._grip=null,this._hand=null}function Ya(t,e){const i=this;let n=null,r=1,s=null,o="local-floor",a=null;const c=[],h=new Map,l=new Ds;l.layers.enable(1),l.viewport=new un;const u=new Ds;u.layers.enable(2),u.viewport=new un;const d=[l,u],p=new qa;p.layers.enable(1),p.layers.enable(2);let f=null,m=null;function g(t){const e=h.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function _(){h.forEach((function(t,e){t.disconnect(e)})),h.clear(),f=null,m=null,t.setFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),S.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function v(t){const e=n.inputSources;for(let t=0;t<c.length;t++)h.set(e[t],c[t]);for(let e=0;e<t.removed.length;e++){const i=t.removed[e],n=h.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),h.delete(i))}for(let e=0;e<t.added.length;e++){const i=t.added[e],n=h.get(i);n&&n.dispatchEvent({type:"connected",data:i})}}this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=c[t];return void 0===e&&(e=new Xa,c[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=c[t];return void 0===e&&(e=new Xa,c[t]=e),e.getGripSpace()},this.getHand=function(t){let e=c[t];return void 0===e&&(e=new Xa,c[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){o=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s},this.getSession=function(){return n},this.setSession=async function(t){if(n=t,null!==n){n.addEventListener("select",g),n.addEventListener("selectstart",g),n.addEventListener("selectend",g),n.addEventListener("squeeze",g),n.addEventListener("squeezestart",g),n.addEventListener("squeezeend",g),n.addEventListener("end",_),n.addEventListener("inputsourceschange",v);const t=e.getContextAttributes();!0!==t.xrCompatible&&await e.makeXRCompatible();const a={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:r},c=new XRWebGLLayer(n,e,a);n.updateRenderState({baseLayer:c}),s=await n.requestReferenceSpace(o),S.setContext(n),S.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const y=new fn,b=new fn;function x(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.getCamera=function(t){p.near=u.near=l.near=t.near,p.far=u.far=l.far=t.far,f===p.near&&m===p.far||(n.updateRenderState({depthNear:p.near,depthFar:p.far}),f=p.near,m=p.far);const e=t.parent,i=p.cameras;x(p,e);for(let t=0;t<i.length;t++)x(i[t],e);t.matrixWorld.copy(p.matrixWorld),t.matrix.copy(p.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale);const r=t.children;for(let t=0,e=r.length;t<e;t++)r[t].updateMatrixWorld(!0);return 2===i.length?function(t,e,i){y.setFromMatrixPosition(e.matrixWorld),b.setFromMatrixPosition(i.matrixWorld);const n=y.distanceTo(b),r=e.projectionMatrix.elements,s=i.projectionMatrix.elements,o=r[14]/(r[10]-1),a=r[14]/(r[10]+1),c=(r[9]+1)/r[5],h=(r[9]-1)/r[5],l=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=o*l,p=o*u,f=n/(-l+u),m=f*-l;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(m),t.translateZ(f),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const g=o+f,_=a+f,v=d-m,x=p+(n-m),w=c*a/_*g,S=h*a/_*g;t.projectionMatrix.makePerspective(v,x,w,S,g,_)}(p,l,u):p.projectionMatrix.copy(l.projectionMatrix),p};let w=null;const S=new Vs;S.setAnimationLoop((function(e,i){if(a=i.getViewerPose(s),null!==a){const e=a.views,i=n.renderState.baseLayer;t.setFramebuffer(i.framebuffer);let r=!1;e.length!==p.cameras.length&&(p.cameras.length=0,r=!0);for(let t=0;t<e.length;t++){const n=e[t],s=i.getViewport(n),o=d[t];o.matrix.fromArray(n.transform.matrix),o.projectionMatrix.fromArray(n.projectionMatrix),o.viewport.set(s.x,s.y,s.width,s.height),0===t&&p.matrix.copy(o.matrix),!0===r&&p.cameras.push(o)}}const r=n.inputSources;for(let t=0;t<c.length;t++){const e=c[t],n=r[t];e.update(n,i,s)}w&&w(e,i)})),this.setAnimationLoop=function(t){w=t},this.dispose=function(){}}function Za(t){function e(e,i){e.opacity.value=i.opacity,i.color&&e.diffuse.value.copy(i.color),i.emissive&&e.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(e.map.value=i.map),i.alphaMap&&(e.alphaMap.value=i.alphaMap),i.specularMap&&(e.specularMap.value=i.specularMap);const n=t.get(i).envMap;if(n){e.envMap.value=n,e.flipEnvMap.value=n.isCubeTexture&&n._needsFlipEnvMap?-1:1,e.reflectivity.value=i.reflectivity,e.refractionRatio.value=i.refractionRatio;const r=t.get(n).__maxMipLevel;void 0!==r&&(e.maxMipLevel.value=r)}let r,s;i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap&&(r=i.clearcoatRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),i.aoMap?s=i.aoMap:i.lightMap&&(s=i.lightMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),e.uv2Transform.value.copy(s.matrix))}function i(e,i){e.roughness.value=i.roughness,e.metalness.value=i.metalness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap),i.bumpMap&&(e.bumpMap.value=i.bumpMap,e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias);t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,n,r,s){n.isMeshBasicMaterial?e(t,n):n.isMeshLambertMaterial?(e(t,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,n)):n.isMeshToonMaterial?(e(t,n),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshPhongMaterial?(e(t,n),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshStandardMaterial?(e(t,n),n.isMeshPhysicalMaterial?function(t,e){i(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap);e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate());t.transmission.value=e.transmission,e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap)}(t,n):i(t,n)):n.isMeshMatcapMaterial?(e(t,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDepthMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDistanceMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,n)):n.isMeshNormalMaterial?(e(t,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,i,n){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*n,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let r;e.map?r=e.map:e.alphaMap&&(r=e.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,n,r,s):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);let i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Ja(t){const e=void 0!==(t=t||{}).canvas?t.canvas:function(){const t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.style.display="block",t}(),i=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,r=void 0===t.depth||t.depth,s=void 0===t.stencil||t.stencil,o=void 0!==t.antialias&&t.antialias,a=void 0===t.premultipliedAlpha||t.premultipliedAlpha,c=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,h=void 0!==t.powerPreference?t.powerPreference:"default",l=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=Xi,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1,this.maxMorphTargets=8,this.maxMorphNormals=4;const f=this;let m=!1,g=null,_=0,v=0,y=null,b=null,x=-1,w=null;const S=new un,M=new un;let T=null,C=e.width,E=e.height,I=1,A=null,P=null;const R=new un(0,0,C,E),L=new un(0,0,C,E);let O=!1;const N=new Us;let D=!1,$=!1;const k=new Hn,z=new fn,F={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function B(){return null===y?I:1}let j,H,U,V,G,q,W,X,Y,Z,J,K,Q,tt,et,it,nt,rt,st,ot,at,ct=i;function ht(t,i){for(let n=0;n<t.length;n++){const r=t[n],s=e.getContext(r,i);if(null!==s)return s}return null}try{const t={alpha:n,depth:r,stencil:s,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:l};if(e.addEventListener("webglcontextlost",pt,!1),e.addEventListener("webglcontextrestored",ft,!1),null===ct){const e=["webgl2","webgl","experimental-webgl"];if(!0===f.isWebGL1Renderer&&e.shift(),ct=ht(e,t),null===ct)throw ht(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===ct.getShaderPrecisionFormat&&(ct.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function lt(){j=new io(ct),H=new Qs(ct,j,t),j.init(H),ot=new Ga(ct,j,H),U=new Ua(ct,j,H),U.scissor(M.copy(L).multiplyScalar(I).floor()),U.viewport(S.copy(R).multiplyScalar(I).floor()),V=new so(ct),G=new Aa,q=new Va(ct,j,U,G,H,ot,V),W=new eo(f),X=new Gs(ct,H),at=new Js(ct,j,X,H),Y=new no(ct,X,V,at),Z=new ho(ct,Y,X,V),nt=new co(ct),et=new to(G),J=new Ia(f,W,j,H,at,et),K=new Za(G),Q=new Oa(G),tt=new Fa(j,H),it=new Zs(f,W,U,Z,a),rt=new Ks(ct,j,V,H),st=new ro(ct,j,V,H),V.programs=J.programs,f.capabilities=H,f.extensions=j,f.properties=G,f.renderLists=Q,f.state=U,f.info=V}lt();const ut=new Ya(f,ct);this.xr=ut;const dt=new Ha(f,Z,H.maxTextureSize);function pt(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function ft(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1,lt()}function mt(t){const e=t.target;e.removeEventListener("dispose",mt),function(t){gt(t),G.remove(t)}(e)}function gt(t){const e=G.get(t).program;void 0!==e&&J.releaseProgram(e)}this.shadowMap=dt,this.getContext=function(){return ct},this.getContextAttributes=function(){return ct.getContextAttributes()},this.forceContextLoss=function(){const t=j.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=j.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(t){void 0!==t&&(I=t,this.setSize(C,E,!1))},this.getSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),t=new rn),t.set(C,E)},this.setSize=function(t,i,n){ut.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(C=t,E=i,e.width=Math.floor(t*I),e.height=Math.floor(i*I),!1!==n&&(e.style.width=t+"px",e.style.height=i+"px"),this.setViewport(0,0,t,i))},this.getDrawingBufferSize=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),t=new rn),t.set(C*I,E*I).floor()},this.setDrawingBufferSize=function(t,i,n){C=t,E=i,I=n,e.width=Math.floor(t*n),e.height=Math.floor(i*n),this.setViewport(0,0,t,i)},this.getCurrentViewport=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),t=new un),t.copy(S)},this.getViewport=function(t){return t.copy(R)},this.setViewport=function(t,e,i,n){t.isVector4?R.set(t.x,t.y,t.z,t.w):R.set(t,e,i,n),U.viewport(S.copy(R).multiplyScalar(I).floor())},this.getScissor=function(t){return t.copy(L)},this.setScissor=function(t,e,i,n){t.isVector4?L.set(t.x,t.y,t.z,t.w):L.set(t,e,i,n),U.scissor(M.copy(L).multiplyScalar(I).floor())},this.getScissorTest=function(){return O},this.setScissorTest=function(t){U.setScissorTest(O=t)},this.setOpaqueSort=function(t){A=t},this.setTransparentSort=function(t){P=t},this.getClearColor=function(t){return void 0===t&&(console.warn("WebGLRenderer: .getClearColor() now requires a Color as an argument"),t=new Dr),t.copy(it.getClearColor())},this.setClearColor=function(){it.setClearColor.apply(it,arguments)},this.getClearAlpha=function(){return it.getClearAlpha()},this.setClearAlpha=function(){it.setClearAlpha.apply(it,arguments)},this.clear=function(t,e,i){let n=0;(void 0===t||t)&&(n|=16384),(void 0===e||e)&&(n|=256),(void 0===i||i)&&(n|=1024),ct.clear(n)},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.dispose=function(){e.removeEventListener("webglcontextlost",pt,!1),e.removeEventListener("webglcontextrestored",ft,!1),Q.dispose(),tt.dispose(),G.dispose(),W.dispose(),Z.dispose(),at.dispose(),ut.dispose(),vt.stop()},this.renderBufferImmediate=function(t,e){at.initAttributes();const i=G.get(t);t.hasPositions&&!i.position&&(i.position=ct.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=ct.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=ct.createBuffer()),t.hasColors&&!i.color&&(i.color=ct.createBuffer());const n=e.getAttributes();t.hasPositions&&(ct.bindBuffer(34962,i.position),ct.bufferData(34962,t.positionArray,35048),at.enableAttribute(n.position),ct.vertexAttribPointer(n.position,3,5126,!1,0,0)),t.hasNormals&&(ct.bindBuffer(34962,i.normal),ct.bufferData(34962,t.normalArray,35048),at.enableAttribute(n.normal),ct.vertexAttribPointer(n.normal,3,5126,!1,0,0)),t.hasUvs&&(ct.bindBuffer(34962,i.uv),ct.bufferData(34962,t.uvArray,35048),at.enableAttribute(n.uv),ct.vertexAttribPointer(n.uv,2,5126,!1,0,0)),t.hasColors&&(ct.bindBuffer(34962,i.color),ct.bufferData(34962,t.colorArray,35048),at.enableAttribute(n.color),ct.vertexAttribPointer(n.color,3,5126,!1,0,0)),at.disableUnusedAttributes(),ct.drawArrays(4,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,i,n,r,s){null===e&&(e=F);const o=r.isMesh&&r.matrixWorld.determinant()<0,a=St(t,e,n,r);U.setMaterial(n,o);let c=i.index;const h=i.attributes.position;if(null===c){if(void 0===h||0===h.count)return}else if(0===c.count)return;let l,u=1;!0===n.wireframe&&(c=Y.getWireframeAttribute(i),u=2),(n.morphTargets||n.morphNormals)&&nt.update(r,i,n,a),at.setup(r,n,a,i,c);let d=rt;null!==c&&(l=X.get(c),d=st,d.setIndex(l));const p=null!==c?c.count:h.count,f=i.drawRange.start*u,m=i.drawRange.count*u,g=null!==s?s.start*u:0,_=null!==s?s.count*u:1/0,v=Math.max(f,g),y=Math.min(p,f+m,g+_)-1,b=Math.max(0,y-v+1);if(0!==b){if(r.isMesh)!0===n.wireframe?(U.setLineWidth(n.wireframeLinewidth*B()),d.setMode(1)):d.setMode(4);else if(r.isLine){let t=n.linewidth;void 0===t&&(t=1),U.setLineWidth(t*B()),r.isLineSegments?d.setMode(1):r.isLineLoop?d.setMode(2):d.setMode(3)}else r.isPoints?d.setMode(0):r.isSprite&&d.setMode(4);if(r.isInstancedMesh)d.renderInstances(v,b,r.count);else if(i.isInstancedBufferGeometry){const t=Math.min(i.instanceCount,i._maxInstanceCount);d.renderInstances(v,b,t)}else d.render(v,b)}},this.compile=function(t,e){d=tt.get(t),d.init(),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights();const i=new WeakMap;t.traverse((function(e){const n=e.material;if(n)if(Array.isArray(n))for(let r=0;r<n.length;r++){const s=n[r];!1===i.has(s)&&(wt(s,t,e),i.set(s))}else!1===i.has(n)&&(wt(n,t,e),i.set(n))}))};let _t=null;const vt=new Vs;function yt(t,e,i,n){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)i=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)d.pushLight(t),t.castShadow&&d.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||N.intersectsSprite(t)){n&&z.setFromMatrixPosition(t.matrixWorld).applyMatrix4(k);const e=Z.update(t),r=t.material;r.visible&&u.push(t,e,r,i,z.z,null)}}else if(t.isImmediateRenderObject)n&&z.setFromMatrixPosition(t.matrixWorld).applyMatrix4(k),u.push(t,null,t.material,i,z.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==V.render.frame&&(t.skeleton.update(),t.skeleton.frame=V.render.frame),!t.frustumCulled||N.intersectsObject(t))){n&&z.setFromMatrixPosition(t.matrixWorld).applyMatrix4(k);const e=Z.update(t),r=t.material;if(Array.isArray(r)){const n=e.groups;for(let s=0,o=n.length;s<o;s++){const o=n[s],a=r[o.materialIndex];a&&a.visible&&u.push(t,e,a,i,z.z,o)}}else r.visible&&u.push(t,e,r,i,z.z,null)}const r=t.children;for(let t=0,s=r.length;t<s;t++)yt(r[t],e,i,n)}function bt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=s.object,a=s.geometry,c=null===n?s.material:n,h=s.group;if(i.isArrayCamera){const t=i.cameras;for(let i=0,n=t.length;i<n;i++){const n=t[i];o.layers.test(n.layers)&&(U.viewport(S.copy(n.viewport)),d.setupLightsView(n),xt(o,e,n,a,c,h))}}else xt(o,e,i,a,c,h)}}function xt(t,e,i,n,r,s){if(t.onBeforeRender(f,e,i,n,r,s),t.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){const n=St(i,e,r,t);U.setMaterial(r),at.reset(),function(t,e){t.render((function(t){f.renderBufferImmediate(t,e)}))}(t,n)}else f.renderBufferDirect(i,e,n,r,t,s);t.onAfterRender(f,e,i,n,r,s)}function wt(t,e,i){!0!==e.isScene&&(e=F);const n=G.get(t),r=d.state.lights,s=d.state.shadowsArray,o=r.state.version,a=J.getParameters(t,r.state,s,e,i),c=J.getProgramCacheKey(a);let h=n.program,l=!0;if(n.environment=t.isMeshStandardMaterial?e.environment:null,n.fog=e.fog,n.envMap=W.get(t.envMap||n.environment),void 0===h)t.addEventListener("dispose",mt);else if(h.cacheKey!==c)gt(t);else if(n.lightsStateVersion!==o)l=!1;else{if(void 0!==a.shaderID)return;l=!1}l&&(a.uniforms=J.getUniforms(t),t.onBeforeCompile(a,f),h=J.acquireProgram(a,c),n.program=h,n.uniforms=a.uniforms,n.outputEncoding=a.outputEncoding);const u=n.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(n.numClippingPlanes=et.numPlanes,n.numIntersection=et.numIntersection,u.clippingPlanes=et.uniform),n.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),n.lightsStateVersion=o,n.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotShadowMatrix.value=r.state.spotShadowMatrix,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=n.program.getUniforms(),m=aa.seqWithValue(p.seq,u);n.uniformsList=m}function St(t,e,i,n){!0!==e.isScene&&(e=F),q.resetTextureUnits();const r=e.fog,s=i.isMeshStandardMaterial?e.environment:null,o=null===y?f.outputEncoding:y.texture.encoding,a=W.get(i.envMap||s),c=G.get(i),h=d.state.lights;if(!0===D&&(!0===$||t!==w)){const e=t===w&&i.id===x;et.setState(i,t,e)}i.version===c.__version?i.fog&&c.fog!==r||c.environment!==s||c.needsLights&&c.lightsStateVersion!==h.state.version?wt(i,e,n):void 0===c.numClippingPlanes||c.numClippingPlanes===et.numPlanes&&c.numIntersection===et.numIntersection?(c.outputEncoding!==o||c.envMap!==a)&&wt(i,e,n):wt(i,e,n):(wt(i,e,n),c.__version=i.version);let l=!1,u=!1,p=!1;const m=c.program,g=m.getUniforms(),_=c.uniforms;if(U.useProgram(m.program)&&(l=!0,u=!0,p=!0),i.id!==x&&(x=i.id,u=!0),l||w!==t){if(g.setValue(ct,"projectionMatrix",t.projectionMatrix),H.logarithmicDepthBuffer&&g.setValue(ct,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),w!==t&&(w=t,u=!0,p=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const e=g.map.cameraPosition;void 0!==e&&e.setValue(ct,z.setFromMatrixPosition(t.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&g.setValue(ct,"isOrthographic",!0===t.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||i.skinning)&&g.setValue(ct,"viewMatrix",t.matrixWorldInverse)}if(i.skinning){g.setOptional(ct,n,"bindMatrix"),g.setOptional(ct,n,"bindMatrixInverse");const t=n.skeleton;if(t){const e=t.bones;if(H.floatVertexTextures){if(null===t.boneTexture){let i=Math.sqrt(4*e.length);i=nn.ceilPowerOfTwo(i),i=Math.max(i,4);const n=new Float32Array(i*i*4);n.set(t.boneMatrices);const r=new Bs(n,i,i,zi,Ni);t.boneMatrices=n,t.boneTexture=r,t.boneTextureSize=i}g.setValue(ct,"boneTexture",t.boneTexture,q),g.setValue(ct,"boneTextureSize",t.boneTextureSize)}else g.setOptional(ct,t,"boneMatrices")}}var v,b;return(u||c.receiveShadow!==n.receiveShadow)&&(c.receiveShadow=n.receiveShadow,g.setValue(ct,"receiveShadow",n.receiveShadow)),u&&(g.setValue(ct,"toneMappingExposure",f.toneMappingExposure),c.needsLights&&(b=p,(v=_).ambientLightColor.needsUpdate=b,v.lightProbe.needsUpdate=b,v.directionalLights.needsUpdate=b,v.directionalLightShadows.needsUpdate=b,v.pointLights.needsUpdate=b,v.pointLightShadows.needsUpdate=b,v.spotLights.needsUpdate=b,v.spotLightShadows.needsUpdate=b,v.rectAreaLights.needsUpdate=b,v.hemisphereLights.needsUpdate=b),r&&i.fog&&K.refreshFogUniforms(_,r),K.refreshMaterialUniforms(_,i,I,E),aa.upload(ct,c.uniformsList,_,q)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(aa.upload(ct,c.uniformsList,_,q),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&g.setValue(ct,"center",n.center),g.setValue(ct,"modelViewMatrix",n.modelViewMatrix),g.setValue(ct,"normalMatrix",n.normalMatrix),g.setValue(ct,"modelMatrix",n.matrixWorld),m}vt.setAnimationLoop((function(t){ut.isPresenting||_t&&_t(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){_t=t,ut.setAnimationLoop(t),null===t?vt.stop():vt.start()},this.render=function(t,e){let i,n;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),i=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),n=arguments[3]),void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===m)return;at.resetDefaultState(),x=-1,w=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===ut.enabled&&!0===ut.isPresenting&&(e=ut.getCamera(e)),!0===t.isScene&&t.onBeforeRender(f,t,e,i||y),d=tt.get(t,p.length),d.init(),p.push(d),k.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),N.setFromProjectionMatrix(k),$=this.localClippingEnabled,D=et.init(this.clippingPlanes,$,e),u=Q.get(t,e),u.init(),yt(t,e,0,f.sortObjects),u.finish(),!0===f.sortObjects&&u.sort(A,P),!0===D&&et.beginShadows();const r=d.state.shadowsArray;dt.render(r,t,e),d.setupLights(),d.setupLightsView(e),!0===D&&et.endShadows(),!0===this.info.autoReset&&this.info.reset(),void 0!==i&&this.setRenderTarget(i),it.render(u,t,e,n);const s=u.opaque,o=u.transparent;s.length>0&&bt(s,t,e),o.length>0&&bt(o,t,e),!0===t.isScene&&t.onAfterRender(f,t,e),null!==y&&(q.updateRenderTargetMipmap(y),q.updateMultisampleRenderTarget(y)),U.buffers.depth.setTest(!0),U.buffers.depth.setMask(!0),U.buffers.color.setMask(!0),U.setPolygonOffset(!1),p.pop(),d=p.length>0?p[p.length-1]:null,u=null},this.setFramebuffer=function(t){g!==t&&null===y&&ct.bindFramebuffer(36160,t),g=t},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return v},this.getRenderList=function(){return u},this.setRenderList=function(t){u=t},this.getRenderTarget=function(){return y},this.setRenderTarget=function(t,e=0,i=0){y=t,_=e,v=i,t&&void 0===G.get(t).__webglFramebuffer&&q.setupRenderTarget(t);let n=g,r=!1;if(t){const i=G.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=i[e],r=!0):n=t.isWebGLMultisampleRenderTarget?G.get(t).__webglMultisampledFramebuffer:i,S.copy(t.viewport),M.copy(t.scissor),T=t.scissorTest}else S.copy(R).multiplyScalar(I).floor(),M.copy(L).multiplyScalar(I).floor(),T=O;if(b!==n&&(ct.bindFramebuffer(36160,n),b=n),U.viewport(S),U.scissor(M),U.setScissorTest(T),r){const n=G.get(t.texture);ct.framebufferTexture2D(36160,36064,34069+e,n.__webglTexture,i)}},this.readRenderTargetPixels=function(t,e,i,n,r,s,o){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let a=G.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==o&&(a=a[o]),a){let o=!1;a!==b&&(ct.bindFramebuffer(36160,a),o=!0);try{const a=t.texture,c=a.format,h=a.type;if(c!==zi&&ot.convert(c)!==ct.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=h===Di&&(j.has("EXT_color_buffer_half_float")||H.isWebGL2&&j.has("EXT_color_buffer_float"));if(!(h===Ri||ot.convert(h)===ct.getParameter(35738)||h===Ni&&(H.isWebGL2||j.has("OES_texture_float")||j.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ct.checkFramebufferStatus(36160)?e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&ct.readPixels(e,i,n,r,ot.convert(c),ot.convert(h),s):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{o&&ct.bindFramebuffer(36160,b)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),r=Math.floor(e.image.width*n),s=Math.floor(e.image.height*n),o=ot.convert(e.format);q.setTexture2D(e,0),ct.copyTexImage2D(3553,i,o,t.x,t.y,r,s,0),U.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const r=e.image.width,s=e.image.height,o=ot.convert(i.format),a=ot.convert(i.type);q.setTexture2D(i,0),ct.pixelStorei(37440,i.flipY),ct.pixelStorei(37441,i.premultiplyAlpha),ct.pixelStorei(3317,i.unpackAlignment),e.isDataTexture?ct.texSubImage2D(3553,n,t.x,t.y,r,s,o,a,e.image.data):e.isCompressedTexture?ct.compressedTexSubImage2D(3553,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):ct.texSubImage2D(3553,n,t.x,t.y,o,a,e.image),0===n&&i.generateMipmaps&&ct.generateMipmap(3553),U.unbindTexture()},this.initTexture=function(t){q.setTexture2D(t,0),U.unbindTexture()},this.resetState=function(){U.reset(),at.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Ka(t){Ja.call(this,t)}qa.prototype=Object.assign(Object.create(Ds.prototype),{constructor:qa,isArrayCamera:!0}),Wa.prototype=Object.assign(Object.create(pr.prototype),{constructor:Wa,isGroup:!0}),Object.assign(Xa.prototype,{constructor:Xa,getHandSpace:function(){return null===this._hand&&(this._hand=new Wa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new Wa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new Wa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this},disconnect:function(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(t,e,i){let n=null,r=null,s=null;const o=this._targetRay,a=this._grip,c=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState)if(c&&t.hand){s=!0;for(const n of t.hand.values()){const t=e.getJointPose(n,i);if(void 0===c.joints[n.jointName]){const t=new Wa;t.matrixAutoUpdate=!1,t.visible=!1,c.joints[n.jointName]=t,c.add(t)}const r=c.joints[n.jointName];null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=t.radius),r.visible=null!==t}const n=c.joints["index-finger-tip"],r=c.joints["thumb-tip"],o=n.position.distanceTo(r.position),a=.02,h=.005;c.inputState.pinching&&o>a+h?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&o<=a-h&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&(n=e.getPose(t.targetRaySpace,i),null!==n&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale))),null!==a&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale)));return null!==o&&(o.visible=null!==n),null!==a&&(a.visible=null!==r),null!==c&&(c.visible=null!==s),this}}),Object.assign(Ya.prototype,Qi.prototype),Ka.prototype=Object.assign(Object.create(Ja.prototype),{constructor:Ka,isWebGL1Renderer:!0});class Qa extends pr{constructor(){super(),Object.defineProperty(this,"isScene",{value:!0}),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.environment&&(e.object.environment=this.environment.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}function tc(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Zi,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=nn.generateUUID()}Object.defineProperty(tc.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(tc.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;n<r;n++)this.array[t+n]=e.array[i+n];return this},set:function(t,e=0){return this.array.set(t,e),this},clone:function(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=nn.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new tc(new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),this.stride);return e.setUsage(this.usage),e},onUpload:function(t){return this.onUploadCallback=t,this},toJSON:function(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=nn.generateUUID()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}});const ec=new fn;function ic(t,e,i,n){this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=!0===n}function nc(t){zr.call(this),this.type="SpriteMaterial",this.color=new Dr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}let rc;Object.defineProperties(ic.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}},needsUpdate:{set:function(t){this.data.needsUpdate=t}}}),Object.assign(ic.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(let e=0,i=this.data.count;e<i;e++)ec.x=this.getX(e),ec.y=this.getY(e),ec.z=this.getZ(e),ec.applyMatrix4(t),this.setXYZ(e,ec.x,ec.y,ec.z);return this},setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this},setXYZ:function(t,e,i,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this},setXYZW:function(t,e,i,n,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=r,this},clone:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new Hr(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new ic(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)},toJSON:function(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}),nc.prototype=Object.create(zr.prototype),nc.prototype.constructor=nc,nc.prototype.isSpriteMaterial=!0,nc.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};const sc=new fn,oc=new fn,ac=new fn,cc=new rn,hc=new rn,lc=new Hn,uc=new fn,dc=new fn,pc=new fn,fc=new rn,mc=new rn,gc=new rn;function _c(t){if(pr.call(this),this.type="Sprite",void 0===rc){rc=new hs;const t=new tc(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);rc.setIndex([0,1,2,0,2,3]),rc.setAttribute("position",new ic(t,3,0,!1)),rc.setAttribute("uv",new ic(t,2,3,!1))}this.geometry=rc,this.material=void 0!==t?t:new nc,this.center=new rn(.5,.5)}function vc(t,e,i,n,r,s){cc.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(hc.x=s*cc.x-r*cc.y,hc.y=r*cc.x+s*cc.y):hc.copy(cc),t.copy(e),t.x+=hc.x,t.y+=hc.y,t.applyMatrix4(lc)}_c.prototype=Object.assign(Object.create(pr.prototype),{constructor:_c,isSprite:!0,raycast:function(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),oc.setFromMatrixScale(this.matrixWorld),lc.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ac.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&oc.multiplyScalar(-ac.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const s=this.center;vc(uc.set(-.5,-.5,0),ac,s,oc,n,r),vc(dc.set(.5,-.5,0),ac,s,oc,n,r),vc(pc.set(.5,.5,0),ac,s,oc,n,r),fc.set(0,0),mc.set(1,0),gc.set(1,1);let o=t.ray.intersectTriangle(uc,dc,pc,!1,sc);if(null===o&&(vc(dc.set(-.5,.5,0),ac,s,oc,n,r),mc.set(0,1),o=t.ray.intersectTriangle(uc,pc,dc,!1,sc),null===o))return;const a=t.ray.origin.distanceTo(sc);a<t.near||a>t.far||e.push({distance:a,point:sc.clone(),uv:Ir.getUV(sc,uc,dc,pc,fc,mc,gc,new rn),face:null,object:this})},copy:function(t){return pr.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}});const yc=new fn,bc=new fn;function xc(){pr.call(this),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}xc.prototype=Object.assign(Object.create(pr.prototype),{constructor:xc,isLOD:!0,copy:function(t){pr.prototype.copy.call(this,t,!1);const e=t.levels;for(let t=0,i=e.length;t<i;t++){const i=e[t];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=t.autoUpdate,this},addLevel:function(t,e=0){e=Math.abs(e);const i=this.levels;let n;for(n=0;n<i.length&&!(e<i[n].distance);n++);return i.splice(n,0,{distance:e,object:t}),this.add(t),this},getCurrentLevel:function(){return this._currentLevel},getObjectForDistance:function(t){const e=this.levels;if(e.length>0){let i,n;for(i=1,n=e.length;i<n&&!(t<e[i].distance);i++);return e[i-1].object}return null},raycast:function(t,e){if(this.levels.length>0){yc.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(yc);this.getObjectForDistance(i).raycast(t,e)}},update:function(t){const e=this.levels;if(e.length>1){yc.setFromMatrixPosition(t.matrixWorld),bc.setFromMatrixPosition(this.matrixWorld);const i=yc.distanceTo(bc)/t.zoom;let n,r;for(e[0].object.visible=!0,n=1,r=e.length;n<r&&i>=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;n<r;n++)e[n].object.visible=!1}},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);!1===this.autoUpdate&&(e.object.autoUpdate=!1),e.object.levels=[];const i=this.levels;for(let t=0,n=i.length;t<n;t++){const n=i[t];e.object.levels.push({object:n.object.uuid,distance:n.distance})}return e}});const wc=new fn,Sc=new un,Mc=new un,Tc=new fn,Cc=new Hn;function Ec(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Es.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}function Ic(){pr.call(this),this.type="Bone"}Ec.prototype=Object.assign(Object.create(Es.prototype),{constructor:Ec,isSkinnedMesh:!0,copy:function(t){return Es.prototype.copy.call(this,t),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,this},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){const t=new un,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.x=e.getX(i),t.y=e.getY(i),t.z=e.getZ(i),t.w=e.getW(i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}},updateMatrixWorld:function(t){Es.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},boneTransform:function(t,e){const i=this.skeleton,n=this.geometry;Sc.fromBufferAttribute(n.attributes.skinIndex,t),Mc.fromBufferAttribute(n.attributes.skinWeight,t),wc.fromBufferAttribute(n.attributes.position,t).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const n=Mc.getComponent(t);if(0!==n){const r=Sc.getComponent(t);Cc.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),e.addScaledVector(Tc.copy(wc).applyMatrix4(Cc),n)}}return e.applyMatrix4(this.bindMatrixInverse)}}),Ic.prototype=Object.assign(Object.create(pr.prototype),{constructor:Ic,isBone:!0});const Ac=new Hn,Pc=new Hn;function Rc(t=[],e=[]){this.uuid=nn.generateUUID(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}Object.assign(Rc.prototype,{init:function(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(16*t.length),0===e.length)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let t=0,e=this.bones.length;t<e;t++)this.boneInverses.push(new Hn)}},calculateInverses:function(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const e=new Hn;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}},pose:function(){for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const e=this.bones[t];e&&(e.parent&&e.parent.isBone?(e.matrix.copy(e.parent.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))}},update:function(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=t.length;n<r;n++){const r=t[n]?t[n].matrixWorld:Pc;Ac.multiplyMatrices(r,e[n]),Ac.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)},clone:function(){return new Rc(this.bones,this.boneInverses)},getBoneByName:function(t){for(let e=0,i=this.bones.length;e<i;e++){const i=this.bones[e];if(i.name===t)return i}},dispose:function(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)},fromJSON:function(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const n=t.bones[i];let r=e[n];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new Ic),this.bones.push(r),this.boneInverses.push((new Hn).fromArray(t.boneInverses[i]))}return this.init(),this},toJSON:function(){const t={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,r=e.length;n<r;n++){const r=e[n];t.bones.push(r.uuid);const s=i[n];t.boneInverses.push(s.toArray())}return t}});const Lc=new Hn,Oc=new Hn,Nc=[],Dc=new Es;function $c(t,e,i){Es.call(this,t,e),this.instanceMatrix=new Hr(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}function kc(t){zr.call(this),this.type="LineBasicMaterial",this.color=new Dr(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,this.setValues(t)}$c.prototype=Object.assign(Object.create(Es.prototype),{constructor:$c,isInstancedMesh:!0,copy:function(t){return Es.prototype.copy.call(this,t),this.instanceMatrix.copy(t.instanceMatrix),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,this},getColorAt:function(t,e){e.fromArray(this.instanceColor.array,3*t)},getMatrixAt:function(t,e){e.fromArray(this.instanceMatrix.array,16*t)},raycast:function(t,e){const i=this.matrixWorld,n=this.count;if(Dc.geometry=this.geometry,Dc.material=this.material,void 0!==Dc.material)for(let r=0;r<n;r++){this.getMatrixAt(r,Lc),Oc.multiplyMatrices(i,Lc),Dc.matrixWorld=Oc,Dc.raycast(t,Nc);for(let t=0,i=Nc.length;t<i;t++){const i=Nc[t];i.instanceId=r,i.object=this,e.push(i)}Nc.length=0}},setColorAt:function(t,e){null===this.instanceColor&&(this.instanceColor=new Hr(new Float32Array(3*this.count),3)),e.toArray(this.instanceColor.array,3*t)},setMatrixAt:function(t,e){e.toArray(this.instanceMatrix.array,16*t)},updateMorphTargets:function(){},dispose:function(){this.dispatchEvent({type:"dispose"})}}),kc.prototype=Object.create(zr.prototype),kc.prototype.constructor=kc,kc.prototype.isLineBasicMaterial=!0,kc.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.morphTargets=t.morphTargets,this};const zc=new fn,Fc=new fn,Bc=new Hn,jc=new jn,Hc=new On;function Uc(t=new hs,e=new kc){pr.call(this),this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}Uc.prototype=Object.assign(Object.create(pr.prototype),{constructor:Uc,isLine:!0,copy:function(t){return pr.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,i=[0];for(let t=1,n=e.count;t<n;t++)zc.fromBufferAttribute(e,t-1),Fc.fromBufferAttribute(e,t),i[t]=i[t-1],i[t]+=zc.distanceTo(Fc);t.setAttribute("lineDistance",new Jr(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this},raycast:function(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Line.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Hc.copy(i.boundingSphere),Hc.applyMatrix4(n),Hc.radius+=r,!1===t.ray.intersectsSphere(Hc))return;Bc.copy(n).invert(),jc.copy(t.ray).applyMatrix4(Bc);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,a=new fn,c=new fn,h=new fn,l=new fn,u=this.isLineSegments?2:1;if(i.isBufferGeometry){const n=i.index,r=i.attributes.position;if(null!==n){const i=n.array;for(let n=0,s=i.length-1;n<s;n+=u){const s=i[n],u=i[n+1];a.fromBufferAttribute(r,s),c.fromBufferAttribute(r,u);if(jc.distanceSqToSegment(a,c,l,h)>o)continue;l.applyMatrix4(this.matrixWorld);const d=t.ray.origin.distanceTo(l);d<t.near||d>t.far||e.push({distance:d,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else for(let i=0,n=r.count-1;i<n;i+=u){a.fromBufferAttribute(r,i),c.fromBufferAttribute(r,i+1);if(jc.distanceSqToSegment(a,c,l,h)>o)continue;l.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(l);n<t.near||n>t.far||e.push({distance:n,point:h.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const Vc=new fn,Gc=new fn;function qc(t,e){Uc.call(this,t,e),this.type="LineSegments"}function Wc(t,e){Uc.call(this,t,e),this.type="LineLoop"}function Xc(t){zr.call(this),this.type="PointsMaterial",this.color=new Dr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}qc.prototype=Object.assign(Object.create(Uc.prototype),{constructor:qc,isLineSegments:!0,computeLineDistances:function(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,i=[];for(let t=0,n=e.count;t<n;t+=2)Vc.fromBufferAttribute(e,t),Gc.fromBufferAttribute(e,t+1),i[t]=0===t?0:i[t-1],i[t+1]=i[t]+Vc.distanceTo(Gc);t.setAttribute("lineDistance",new Jr(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else t.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}),Wc.prototype=Object.assign(Object.create(Uc.prototype),{constructor:Wc,isLineLoop:!0}),Xc.prototype=Object.create(zr.prototype),Xc.prototype.constructor=Xc,Xc.prototype.isPointsMaterial=!0,Xc.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this};const Yc=new Hn,Zc=new jn,Jc=new On,Kc=new fn;function Qc(t=new hs,e=new Xc){pr.call(this),this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}function th(t,e,i,n,r,s,o){const a=Zc.distanceSqToPoint(t);if(a<i){const i=new fn;Zc.closestPointToPoint(t,i),i.applyMatrix4(n);const c=r.ray.origin.distanceTo(i);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:i,index:e,face:null,object:o})}}function eh(t,e,i,n,r,s,o,a,c){hn.call(this,t,e,i,n,r,s,o,a,c),this.format=void 0!==o?o:ki,this.minFilter=void 0!==s?s:Ai,this.magFilter=void 0!==r?r:Ai,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){h.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}function ih(t,e,i,n,r,s,o,a,c,h,l,u){hn.call(this,null,s,o,a,c,h,n,r,l,u),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function nh(t,e,i,n,r,s,o,a,c){hn.call(this,t,e,i,n,r,s,o,a,c),this.needsUpdate=!0}function rh(t,e,i,n,r,s,o,a,c,h){if((h=void 0!==h?h:Fi)!==Fi&&h!==Bi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Fi&&(i=Li),void 0===i&&h===Bi&&(i=$i),hn.call(this,null,n,r,s,o,a,h,i,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:Ii,this.minFilter=void 0!==a?a:Ii,this.flipY=!1,this.generateMipmaps=!1}Qc.prototype=Object.assign(Object.create(pr.prototype),{constructor:Qc,isPoints:!0,copy:function(t){return pr.prototype.copy.call(this,t),this.material=t.material,this.geometry=t.geometry,this},raycast:function(t,e){const i=this.geometry,n=this.matrixWorld,r=t.params.Points.threshold;if(null===i.boundingSphere&&i.computeBoundingSphere(),Jc.copy(i.boundingSphere),Jc.applyMatrix4(n),Jc.radius+=r,!1===t.ray.intersectsSphere(Jc))return;Yc.copy(n).invert(),Zc.copy(t.ray).applyMatrix4(Yc);const s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position;if(null!==r){const i=r.array;for(let r=0,a=i.length;r<a;r++){const a=i[r];Kc.fromBufferAttribute(s,a),th(Kc,a,o,n,t,e,this)}}else for(let i=0,r=s.count;i<r;i++)Kc.fromBufferAttribute(s,i),th(Kc,i,o,n,t,e,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e<i;e++){const i=t[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{const e=t.morphTargets;void 0!==e&&e.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}),eh.prototype=Object.assign(Object.create(hn.prototype),{constructor:eh,clone:function(){return new this.constructor(this.image).copy(this)},isVideoTexture:!0,update:function(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),ih.prototype=Object.create(hn.prototype),ih.prototype.constructor=ih,ih.prototype.isCompressedTexture=!0,nh.prototype=Object.create(hn.prototype),nh.prototype.constructor=nh,nh.prototype.isCanvasTexture=!0,rh.prototype=Object.create(hn.prototype),rh.prototype.constructor=rh,rh.prototype.isDepthTexture=!0;class sh extends hs{constructor(t=1,e=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const r=[],s=[],o=[],a=[],c=new fn,h=new rn;s.push(0,0,0),o.push(0,0,1),a.push(.5,.5);for(let r=0,l=3;r<=e;r++,l+=3){const u=i+r/e*n;c.x=t*Math.cos(u),c.y=t*Math.sin(u),s.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(s[l]/t+1)/2,h.y=(s[l+1]/t+1)/2,a.push(h.x,h.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new Jr(s,3)),this.setAttribute("normal",new Jr(o,3)),this.setAttribute("uv",new Jr(a,2))}}new fn,new fn,new fn,new Ir;const oh=function(t,e,i){i=i||2;const n=e&&e.length,r=n?e[0]*i:t.length;let s=ah(t,0,r,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,h,l,u,d,p;if(n&&(s=function(t,e,i,n){const r=[];let s,o,a,c,h;for(s=0,o=e.length;s<o;s++)a=e[s]*n,c=s<o-1?e[s+1]*n:t.length,h=ah(t,a,c,n,!1),h===h.next&&(h.steiner=!0),r.push(vh(h));for(r.sort(fh),s=0;s<r.length;s++)mh(r[s],i),i=ch(i,i.next);return i}(t,e,s,i)),t.length>80*i){a=h=t[0],c=l=t[1];for(let e=i;e<r;e+=i)u=t[e],d=t[e+1],u<a&&(a=u),d<c&&(c=d),u>h&&(h=u),d>l&&(l=d);p=Math.max(h-a,l-c),p=0!==p?1/p:0}return hh(s,o,i,a,c,p),o};function ah(t,e,i,n,r){let s,o;if(r===function(t,e,i,n){let r=0;for(let s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}(t,e,i,n)>0)for(s=e;s<i;s+=n)o=Ih(s,t[s],t[s+1],o);else for(s=i-n;s>=e;s-=n)o=Ih(s,t[s],t[s+1],o);return o&&wh(o,o.next)&&(Ah(o),o=o.next),o}function ch(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!wh(n,n.next)&&0!==xh(n.prev,n,n.next))n=n.next;else{if(Ah(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function hh(t,e,i,n,r,s,o){if(!t)return;!o&&s&&function(t,e,i,n){let r=t;do{null===r.z&&(r.z=_h(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i,n,r,s,o,a,c,h=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e<h&&(a++,n=n.nextZ,n);e++);for(c=h;a>0||c>0&&n;)0!==a&&(0===c||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,h*=2}while(o>1)}(r)}(t,n,r,s);let a,c,h=t;for(;t.prev!==t.next;)if(a=t.prev,c=t.next,s?uh(t,n,r,s):lh(t))e.push(a.i/i),e.push(t.i/i),e.push(c.i/i),Ah(t),t=c.next,h=c.next;else if((t=c)===h){o?1===o?hh(t=dh(ch(t),e,i),e,i,n,r,s,2):2===o&&ph(t,e,i,n,r,s):hh(ch(t),e,i,n,r,s,1);break}}function lh(t){const e=t.prev,i=t,n=t.next;if(xh(e,i,n)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(yh(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&xh(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function uh(t,e,i,n){const r=t.prev,s=t,o=t.next;if(xh(r,s,o)>=0)return!1;const a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,c=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,h=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,u=_h(a,c,e,i,n),d=_h(h,l,e,i,n);let p=t.prevZ,f=t.nextZ;for(;p&&p.z>=u&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&xh(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&xh(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&xh(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&yh(r.x,r.y,s.x,s.y,o.x,o.y,f.x,f.y)&&xh(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function dh(t,e,i){let n=t;do{const r=n.prev,s=n.next.next;!wh(r,s)&&Sh(r,n,n.next,s)&&Ch(r,s)&&Ch(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),Ah(n),Ah(n.next),n=t=s),n=n.next}while(n!==t);return ch(n)}function ph(t,e,i,n,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&bh(o,t)){let a=Eh(o,t);return o=ch(o,o.next),a=ch(a,a.next),hh(o,e,i,n,r,s),void hh(a,e,i,n,r,s)}t=t.next}o=o.next}while(o!==t)}function fh(t,e){return t.x-e.x}function mh(t,e){if(e=function(t,e){let i=e;const n=t.x,r=t.y;let s,o=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o){if(o=t,t===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!s)return null;if(n===o)return s;const a=s,c=s.x,h=s.y;let l,u=1/0;i=s;do{n>=i.x&&i.x>=c&&n!==i.x&&yh(r<h?n:o,r,c,h,r<h?o:n,r,i.x,i.y)&&(l=Math.abs(r-i.y)/(n-i.x),Ch(i,t)&&(l<u||l===u&&(i.x>s.x||i.x===s.x&&gh(s,i)))&&(s=i,u=l)),i=i.next}while(i!==a);return s}(t,e)){const i=Eh(e,t);ch(e,e.next),ch(i,i.next)}}function gh(t,e){return xh(t.prev,t,e.prev)<0&&xh(e.next,t,t.next)<0}function _h(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function vh(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function yh(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function bh(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Sh(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Ch(t,e)&&Ch(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(xh(t.prev,t,e.prev)||xh(t,e.prev,e))||wh(t,e)&&xh(t.prev,t,t.next)>0&&xh(e.prev,e,e.next)>0)}function xh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function wh(t,e){return t.x===e.x&&t.y===e.y}function Sh(t,e,i,n){const r=Th(xh(t,e,i)),s=Th(xh(t,e,n)),o=Th(xh(i,n,t)),a=Th(xh(i,n,e));return r!==s&&o!==a||(!(0!==r||!Mh(t,i,e))||(!(0!==s||!Mh(t,n,e))||(!(0!==o||!Mh(i,t,n))||!(0!==a||!Mh(i,e,n)))))}function Mh(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Th(t){return t>0?1:t<0?-1:0}function Ch(t,e){return xh(t.prev,t,t.next)<0?xh(t,e,t.next)>=0&&xh(t,t.prev,e)>=0:xh(t,e,t.prev)<0||xh(t,t.next,e)<0}function Eh(t,e){const i=new Ph(t.i,t.x,t.y),n=new Ph(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Ih(t,e,i,n){const r=new Ph(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Ah(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ph(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}const Rh={area:function(t){const e=t.length;let i=0;for(let n=e-1,r=0;r<e;n=r++)i+=t[n].x*t[r].y-t[r].x*t[n].y;return.5*i},isClockWise:function(t){return Rh.area(t)<0},triangulateShape:function(t,e){const i=[],n=[],r=[];Lh(t),Oh(i,t);let s=t.length;e.forEach(Lh);for(let t=0;t<e.length;t++)n.push(s),s+=e[t].length,Oh(i,e[t]);const o=oh(i,n);for(let t=0;t<o.length;t+=3)r.push(o.slice(t,t+3));return r}};function Lh(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function Oh(t,e){for(let i=0;i<e.length;i++)t.push(e[i].x),t.push(e[i].y)}class Nh extends hs{constructor(t,e){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,n=[],r=[];for(let e=0,i=t.length;e<i;e++){s(t[e])}function s(t){const s=[],o=void 0!==e.curveSegments?e.curveSegments:12,a=void 0!==e.steps?e.steps:1;let c=void 0!==e.depth?e.depth:100,h=void 0===e.bevelEnabled||e.bevelEnabled,l=void 0!==e.bevelThickness?e.bevelThickness:6,u=void 0!==e.bevelSize?e.bevelSize:l-2,d=void 0!==e.bevelOffset?e.bevelOffset:0,p=void 0!==e.bevelSegments?e.bevelSegments:3;const f=e.extrudePath,m=void 0!==e.UVGenerator?e.UVGenerator:Dh;void 0!==e.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),c=e.amount);let g,_,v,y,b,x=!1;f&&(g=f.getSpacedPoints(a),x=!0,h=!1,_=f.computeFrenetFrames(a,!1),v=new fn,y=new fn,b=new fn),h||(p=0,l=0,u=0,d=0);const w=t.extractPoints(o);let S=w.shape;const M=w.holes;if(!Rh.isClockWise(S)){S=S.reverse();for(let t=0,e=M.length;t<e;t++){const e=M[t];Rh.isClockWise(e)&&(M[t]=e.reverse())}}const T=Rh.triangulateShape(S,M),C=S;for(let t=0,e=M.length;t<e;t++){const e=M[t];S=S.concat(e)}function E(t,e,i){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(i).add(t)}const I=S.length,A=T.length;function P(t,e,i){let n,r,s;const o=t.x-e.x,a=t.y-e.y,c=i.x-t.x,h=i.y-t.y,l=o*o+a*a,u=o*h-a*c;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(l),d=Math.sqrt(c*c+h*h),p=e.x-a/u,f=e.y+o/u,m=((i.x-h/d-p)*h-(i.y+c/d-f)*c)/(o*h-a*c);n=p+o*m-t.x,r=f+a*m-t.y;const g=n*n+r*r;if(g<=2)return new rn(n,r);s=Math.sqrt(g/2)}else{let t=!1;o>Number.EPSILON?c>Number.EPSILON&&(t=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(t=!0):Math.sign(a)===Math.sign(h)&&(t=!0),t?(n=-a,r=o,s=Math.sqrt(l)):(n=o,r=a,s=Math.sqrt(l/2))}return new rn(n/s,r/s)}const R=[];for(let t=0,e=C.length,i=e-1,n=t+1;t<e;t++,i++,n++)i===e&&(i=0),n===e&&(n=0),R[t]=P(C[t],C[i],C[n]);const L=[];let O,N=R.concat();for(let t=0,e=M.length;t<e;t++){const e=M[t];O=[];for(let t=0,i=e.length,n=i-1,r=t+1;t<i;t++,n++,r++)n===i&&(n=0),r===i&&(r=0),O[t]=P(e[t],e[n],e[r]);L.push(O),N=N.concat(O)}for(let t=0;t<p;t++){const e=t/p,i=l*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=C.length;t<e;t++){const e=E(C[t],R[t],n);k(e.x,e.y,-i)}for(let t=0,e=M.length;t<e;t++){const e=M[t];O=L[t];for(let t=0,r=e.length;t<r;t++){const r=E(e[t],O[t],n);k(r.x,r.y,-i)}}}const D=u+d;for(let t=0;t<I;t++){const e=h?E(S[t],N[t],D):S[t];x?(y.copy(_.normals[0]).multiplyScalar(e.x),v.copy(_.binormals[0]).multiplyScalar(e.y),b.copy(g[0]).add(y).add(v),k(b.x,b.y,b.z)):k(e.x,e.y,0)}for(let t=1;t<=a;t++)for(let e=0;e<I;e++){const i=h?E(S[e],N[e],D):S[e];x?(y.copy(_.normals[t]).multiplyScalar(i.x),v.copy(_.binormals[t]).multiplyScalar(i.y),b.copy(g[t]).add(y).add(v),k(b.x,b.y,b.z)):k(i.x,i.y,c/a*t)}for(let t=p-1;t>=0;t--){const e=t/p,i=l*Math.cos(e*Math.PI/2),n=u*Math.sin(e*Math.PI/2)+d;for(let t=0,e=C.length;t<e;t++){const e=E(C[t],R[t],n);k(e.x,e.y,c+i)}for(let t=0,e=M.length;t<e;t++){const e=M[t];O=L[t];for(let t=0,r=e.length;t<r;t++){const r=E(e[t],O[t],n);x?k(r.x,r.y+g[a-1].y,g[a-1].x+i):k(r.x,r.y,c+i)}}}function $(t,e){let i=t.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=a+2*p;t<i;t++){const i=I*t,s=I*(t+1);F(e+n+i,e+r+i,e+r+s,e+n+s)}}}function k(t,e,i){s.push(t),s.push(e),s.push(i)}function z(t,e,r){B(t),B(e),B(r);const s=n.length/3,o=m.generateTopUV(i,n,s-3,s-2,s-1);j(o[0]),j(o[1]),j(o[2])}function F(t,e,r,s){B(t),B(e),B(s),B(e),B(r),B(s);const o=n.length/3,a=m.generateSideWallUV(i,n,o-6,o-3,o-2,o-1);j(a[0]),j(a[1]),j(a[3]),j(a[1]),j(a[2]),j(a[3])}function B(t){n.push(s[3*t+0]),n.push(s[3*t+1]),n.push(s[3*t+2])}function j(t){r.push(t.x),r.push(t.y)}!function(){const t=n.length/3;if(h){let t=0,e=I*t;for(let t=0;t<A;t++){const i=T[t];z(i[2]+e,i[1]+e,i[0]+e)}t=a+2*p,e=I*t;for(let t=0;t<A;t++){const i=T[t];z(i[0]+e,i[1]+e,i[2]+e)}}else{for(let t=0;t<A;t++){const e=T[t];z(e[2],e[1],e[0])}for(let t=0;t<A;t++){const e=T[t];z(e[0]+I*a,e[1]+I*a,e[2]+I*a)}}i.addGroup(t,n.length/3-t,0)}(),function(){const t=n.length/3;let e=0;$(C,e),e+=C.length;for(let t=0,i=M.length;t<i;t++){const i=M[t];$(i,e),e+=i.length}i.addGroup(t,n.length/3-t,1)}()}this.setAttribute("position",new Jr(n,3)),this.setAttribute("uv",new Jr(r,2)),this.computeVertexNormals()}toJSON(){const t=hs.prototype.toJSON.call(this);return function(t,e,i){if(i.shapes=[],Array.isArray(t))for(let e=0,n=t.length;e<n;e++){const n=t[e];i.shapes.push(n.uuid)}else i.shapes.push(t.uuid);void 0!==e.extrudePath&&(i.options.extrudePath=e.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,t)}}const Dh={generateTopUV:function(t,e,i,n,r){const s=e[3*i],o=e[3*i+1],a=e[3*n],c=e[3*n+1],h=e[3*r],l=e[3*r+1];return[new rn(s,o),new rn(a,c),new rn(h,l)]},generateSideWallUV:function(t,e,i,n,r,s){const o=e[3*i],a=e[3*i+1],c=e[3*i+2],h=e[3*n],l=e[3*n+1],u=e[3*n+2],d=e[3*r],p=e[3*r+1],f=e[3*r+2],m=e[3*s],g=e[3*s+1],_=e[3*s+2];return Math.abs(a-l)<.01?[new rn(o,1-c),new rn(h,1-u),new rn(d,1-f),new rn(m,1-_)]:[new rn(a,1-c),new rn(l,1-u),new rn(p,1-f),new rn(g,1-_)]}};function $h(t,e,i){hs.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:i};const n=[],r=[],s=[],o=[],a=1e-5,c=new fn,h=new fn,l=new fn,u=new fn,d=new fn;t.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const p=e+1;for(let n=0;n<=i;n++){const p=n/i;for(let i=0;i<=e;i++){const n=i/e;t(n,p,h),r.push(h.x,h.y,h.z),n-a>=0?(t(n-a,p,l),u.subVectors(h,l)):(t(n+a,p,l),u.subVectors(l,h)),p-a>=0?(t(n,p-a,l),d.subVectors(h,l)):(t(n,p+a,l),d.subVectors(l,h)),c.crossVectors(u,d).normalize(),s.push(c.x,c.y,c.z),o.push(n,p)}}for(let t=0;t<i;t++)for(let i=0;i<e;i++){const e=t*p+i,r=t*p+i+1,s=(t+1)*p+i+1,o=(t+1)*p+i;n.push(e,r,o),n.push(r,s,o)}this.setIndex(n),this.setAttribute("position",new Jr(r,3)),this.setAttribute("normal",new Jr(s,3)),this.setAttribute("uv",new Jr(o,2))}$h.prototype=Object.create(hs.prototype),$h.prototype.constructor=$h;class kh extends hs{constructor(t,e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],n=[],r=[],s=[];let o=0,a=0;if(!1===Array.isArray(t))c(t);else for(let e=0;e<t.length;e++)c(t[e]),this.addGroup(o,a,e),o+=a,a=0;function c(t){const o=n.length/3,c=t.extractPoints(e);let h=c.shape;const l=c.holes;!1===Rh.isClockWise(h)&&(h=h.reverse());for(let t=0,e=l.length;t<e;t++){const e=l[t];!0===Rh.isClockWise(e)&&(l[t]=e.reverse())}const u=Rh.triangulateShape(h,l);for(let t=0,e=l.length;t<e;t++){const e=l[t];h=h.concat(e)}for(let t=0,e=h.length;t<e;t++){const e=h[t];n.push(e.x,e.y,0),r.push(0,0,1),s.push(e.x,e.y)}for(let t=0,e=u.length;t<e;t++){const e=u[t],n=e[0]+o,r=e[1]+o,s=e[2]+o;i.push(n,r,s),a+=3}}this.setIndex(i),this.setAttribute("position",new Jr(n,3)),this.setAttribute("normal",new Jr(r,3)),this.setAttribute("uv",new Jr(s,2))}toJSON(){const t=hs.prototype.toJSON.call(this);return function(t,e){if(e.shapes=[],Array.isArray(t))for(let i=0,n=t.length;i<n;i++){const n=t[i];e.shapes.push(n.uuid)}else e.shapes.push(t.uuid);return e}(this.parameters.shapes,t)}}class zh extends hs{constructor(t=1,e=8,i=6,n=0,r=2*Math.PI,s=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const a=Math.min(s+o,Math.PI);let c=0;const h=[],l=new fn,u=new fn,d=[],p=[],f=[],m=[];for(let d=0;d<=i;d++){const g=[],_=d/i;let v=0;0==d&&0==s?v=.5/e:d==i&&a==Math.PI&&(v=-.5/e);for(let i=0;i<=e;i++){const a=i/e;l.x=-t*Math.cos(n+a*r)*Math.sin(s+_*o),l.y=t*Math.cos(s+_*o),l.z=t*Math.sin(n+a*r)*Math.sin(s+_*o),p.push(l.x,l.y,l.z),u.copy(l).normalize(),f.push(u.x,u.y,u.z),m.push(a+v,1-_),g.push(c++)}h.push(g)}for(let t=0;t<i;t++)for(let n=0;n<e;n++){const e=h[t][n+1],r=h[t][n],o=h[t+1][n],c=h[t+1][n+1];(0!==t||s>0)&&d.push(e,r,c),(t!==i-1||a<Math.PI)&&d.push(r,o,c)}this.setIndex(d),this.setAttribute("position",new Jr(p,3)),this.setAttribute("normal",new Jr(f,3)),this.setAttribute("uv",new Jr(m,2))}}function Fh(t){zr.call(this),this.type="ShadowMaterial",this.color=new Dr(0),this.transparent=!0,this.setValues(t)}function Bh(t){Os.call(this,t),this.type="RawShaderMaterial"}function jh(t){zr.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Dr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(t)}function Hh(t){jh.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new rn(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=nn.clamp(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.setValues(t)}function Uh(t){zr.call(this),this.type="MeshPhongMaterial",this.color=new Dr(16777215),this.specular=new Dr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Vh(t){zr.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Dr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gh(t){zr.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function qh(t){zr.call(this),this.type="MeshLambertMaterial",this.color=new Dr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Wh(t){zr.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Dr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Xh(t){kc.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Fh.prototype=Object.create(zr.prototype),Fh.prototype.constructor=Fh,Fh.prototype.isShadowMaterial=!0,Fh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this},Bh.prototype=Object.create(Os.prototype),Bh.prototype.constructor=Bh,Bh.prototype.isRawShaderMaterial=!0,jh.prototype=Object.create(zr.prototype),jh.prototype.constructor=jh,jh.prototype.isMeshStandardMaterial=!0,jh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.vertexTangents=t.vertexTangents,this},Hh.prototype=Object.create(jh.prototype),Hh.prototype.constructor=Hh,Hh.prototype.isMeshPhysicalMaterial=!0,Hh.prototype.copy=function(t){return jh.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new Dr).copy(t.sheen):this.sheen=null,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this},Uh.prototype=Object.create(zr.prototype),Uh.prototype.constructor=Uh,Uh.prototype.isMeshPhongMaterial=!0,Uh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Vh.prototype=Object.create(zr.prototype),Vh.prototype.constructor=Vh,Vh.prototype.isMeshToonMaterial=!0,Vh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Gh.prototype=Object.create(zr.prototype),Gh.prototype.constructor=Gh,Gh.prototype.isMeshNormalMaterial=!0,Gh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},qh.prototype=Object.create(zr.prototype),qh.prototype.constructor=qh,qh.prototype.isMeshLambertMaterial=!0,qh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Wh.prototype=Object.create(zr.prototype),Wh.prototype.constructor=Wh,Wh.prototype.isMeshMatcapMaterial=!0,Wh.prototype.copy=function(t){return zr.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Xh.prototype=Object.create(kc.prototype),Xh.prototype.constructor=Xh,Xh.prototype.isLineDashedMaterial=!0,Xh.prototype.copy=function(t){return kc.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Yh=Object.freeze({__proto__:null,ShadowMaterial:Fh,SpriteMaterial:nc,RawShaderMaterial:Bh,ShaderMaterial:Os,PointsMaterial:Xc,MeshPhysicalMaterial:Hh,MeshStandardMaterial:jh,MeshPhongMaterial:Uh,MeshToonMaterial:Vh,MeshNormalMaterial:Gh,MeshLambertMaterial:qh,MeshDepthMaterial:Ba,MeshDistanceMaterial:ja,MeshBasicMaterial:Fr,MeshMatcapMaterial:Wh,LineDashedMaterial:Xh,LineBasicMaterial:kc,Material:zr});const Zh={arraySlice:function(t,e,i){return Zh.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i},sortedArray:function(t,e,i){const n=t.length,r=new t.constructor(n);for(let s=0,o=0;o!==n;++s){const n=i[s]*e;for(let i=0;i!==e;++i)r[o++]=t[n+i]}return r},flattenJSON:function(t,e,i,n){let r=1,s=t[0];for(;void 0!==s&&void 0===s[n];)s=t[r++];if(void 0===s)return;let o=s[n];if(void 0!==o)if(Array.isArray(o))do{o=s[n],void 0!==o&&(e.push(s.time),i.push.apply(i,o)),s=t[r++]}while(void 0!==s);else if(void 0!==o.toArray)do{o=s[n],void 0!==o&&(e.push(s.time),o.toArray(i,i.length)),s=t[r++]}while(void 0!==s);else do{o=s[n],void 0!==o&&(e.push(s.time),i.push(o)),s=t[r++]}while(void 0!==s)},subclip:function(t,e,i,n,r=30){const s=t.clone();s.name=e;const o=[];for(let t=0;t<s.tracks.length;++t){const e=s.tracks[t],a=e.getValueSize(),c=[],h=[];for(let t=0;t<e.times.length;++t){const s=e.times[t]*r;if(!(s<i||s>=n)){c.push(e.times[t]);for(let i=0;i<a;++i)h.push(e.values[t*a+i])}}0!==c.length&&(e.times=Zh.convertArray(c,e.times.constructor),e.values=Zh.convertArray(h,e.values.constructor),o.push(e))}s.tracks=o;let a=1/0;for(let t=0;t<s.tracks.length;++t)a>s.tracks[t].times[0]&&(a=s.tracks[t].times[0]);for(let t=0;t<s.tracks.length;++t)s.tracks[t].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(t,e=0,i=t,n=30){n<=0&&(n=30);const r=i.tracks.length,s=e/n;for(let e=0;e<r;++e){const n=i.tracks[e],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const o=t.tracks.find((function(t){return t.name===n.name&&t.ValueTypeName===r}));if(void 0===o)continue;let a=0;const c=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(a=c/3);let h=0;const l=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=l/3);const u=n.times.length-1;let d;if(s<=n.times[0]){const t=a,e=c-a;d=Zh.arraySlice(n.values,t,e)}else if(s>=n.times[u]){const t=u*c+a,e=t+c-a;d=Zh.arraySlice(n.values,t,e)}else{const t=n.createInterpolant(),e=a,i=c-a;t.evaluate(s),d=Zh.arraySlice(t.resultBuffer,e,i)}if("quaternion"===r){(new pn).fromArray(d).normalize().conjugate().toArray(d)}const p=o.times.length;for(let t=0;t<p;++t){const e=t*l+h;if("quaternion"===r)pn.multiplyQuaternionsFlat(o.values,e,d,0,o.values,e);else{const t=l-2*h;for(let i=0;i<t;++i)o.values[e+i]-=d[i]}}}return t.blendMode=2501,t}};function Jh(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i}function Kh(t,e,i,n){Jh.call(this,t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Qh(t,e,i,n){Jh.call(this,t,e,i,n)}function tl(t,e,i,n){Jh.call(this,t,e,i,n)}function el(t,e,i,n){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Zh.convertArray(e,this.TimeBufferType),this.values=Zh.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}function il(t,e,i){el.call(this,t,e,i)}function nl(t,e,i,n){el.call(this,t,e,i,n)}function rl(t,e,i,n){el.call(this,t,e,i,n)}function sl(t,e,i,n){Jh.call(this,t,e,i,n)}function ol(t,e,i,n){el.call(this,t,e,i,n)}function al(t,e,i,n){el.call(this,t,e,i,n)}function cl(t,e,i,n){el.call(this,t,e,i,n)}function hl(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=nn.generateUUID(),this.duration<0&&this.resetDuration()}function ll(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return rl;case"vector":case"vector2":case"vector3":case"vector4":return cl;case"color":return nl;case"quaternion":return ol;case"bool":case"boolean":return il;case"string":return al}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){const e=[],i=[];Zh.flattenJSON(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)}Object.assign(Jh.prototype,{evaluate:function(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{let s;i:{n:if(!(t<n)){for(let s=i+2;;){if(void 0===n){if(t<r)break n;return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,t,r)}if(i===s)break;if(r=n,n=e[++i],t<n)break e}s=e.length;break i}if(t>=r)break t;{const o=e[1];t<o&&(i=2,r=o);for(let s=i-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(i===s)break;if(n=r,r=e[--i-1],t>=r)break e}s=i,i=0}}for(;i<s;){const n=i+s>>>1;t<e[n]?s=n:i=n+1}if(n=e[i],r=e[i-1],void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return i=e.length,this._cachedIndex=i,this.afterEnd_(i-1,r,t)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,t,n)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n;for(let t=0;t!==n;++t)e[t]=i[r+t];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Jh.prototype,{beforeStart_:Jh.prototype.copySampleValue_,afterEnd_:Jh.prototype.copySampleValue_}),Kh.prototype=Object.assign(Object.create(Jh.prototype),{constructor:Kh,DefaultSettings_:{endingStart:Vi,endingEnd:Vi},intervalChanged_:function(t,e,i){const n=this.parameterPositions;let r=t-2,s=t+1,o=n[r],a=n[s];if(void 0===o)switch(this.getSettings_().endingStart){case Gi:r=t,o=2*e-i;break;case qi:r=n.length-2,o=e+n[r]-n[r+1];break;default:r=t,o=i}if(void 0===a)switch(this.getSettings_().endingEnd){case Gi:s=t,a=2*i-e;break;case qi:s=1,a=i+n[1]-n[0];break;default:s=t-1,a=e}const c=.5*(i-e),h=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(a-i),this._offsetPrev=r*h,this._offsetNext=s*h},interpolate_:function(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,c=a-o,h=this._offsetPrev,l=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-e)/(n-e),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,_=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,v=(-1-d)*m+(1.5+d)*f+.5*p,y=d*m-d*f;for(let t=0;t!==o;++t)r[t]=g*s[h+t]+_*s[c+t]+v*s[a+t]+y*s[l+t];return r}}),Qh.prototype=Object.assign(Object.create(Jh.prototype),{constructor:Qh,interpolate_:function(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=t*o,c=a-o,h=(i-e)/(n-e),l=1-h;for(let t=0;t!==o;++t)r[t]=s[c+t]*l+s[a+t]*h;return r}}),tl.prototype=Object.assign(Object.create(Jh.prototype),{constructor:tl,interpolate_:function(t){return this.copySampleValue_(t-1)}}),Object.assign(el,{toJSON:function(t){const e=t.constructor;let i;if(void 0!==e.toJSON)i=e.toJSON(t);else{i={name:t.name,times:Zh.convertArray(t.times,Array),values:Zh.convertArray(t.values,Array)};const e=t.getInterpolation();e!==t.DefaultInterpolation&&(i.interpolation=e)}return i.type=t.ValueTypeName,i}}),Object.assign(el.prototype,{constructor:el,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:Hi,InterpolantFactoryMethodDiscrete:function(t){return new tl(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new Qh(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Kh(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){let e;switch(t){case ji:e=this.InterpolantFactoryMethodDiscrete;break;case Hi:e=this.InterpolantFactoryMethodLinear;break;case Ui:e=this.InterpolantFactoryMethodSmooth}if(void 0===e){const e="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(e);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",e),this}return this.createInterpolant=e,this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ji;case this.InterpolantFactoryMethodLinear:return Hi;case this.InterpolantFactoryMethodSmooth:return Ui}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this},scale:function(t){if(1!==t){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this},trim:function(t,e){const i=this.times,n=i.length;let r=0,s=n-1;for(;r!==n&&i[r]<t;)++r;for(;-1!==s&&i[s]>e;)--s;if(++s,0!==r||s!==n){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=Zh.arraySlice(i,r,s),this.values=Zh.arraySlice(this.values,r*t,s*t)}return this},validate:function(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==s&&s>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,s),t=!1;break}s=n}if(void 0!==n&&Zh.isTypedArray(n))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t},optimize:function(){const t=Zh.arraySlice(this.times),e=Zh.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===Ui,r=t.length-1;let s=1;for(let o=1;o<r;++o){let r=!1;const a=t[o];if(a!==t[o+1]&&(1!==o||a!==t[0]))if(n)r=!0;else{const t=o*i,n=t-i,s=t+i;for(let o=0;o!==i;++o){const i=e[t+o];if(i!==e[n+o]||i!==e[s+o]){r=!0;break}}}if(r){if(o!==s){t[s]=t[o];const n=o*i,r=s*i;for(let t=0;t!==i;++t)e[r+t]=e[n+t]}++s}}if(r>0){t[s]=t[r];for(let t=r*i,n=s*i,o=0;o!==i;++o)e[n+o]=e[t+o];++s}return s!==t.length?(this.times=Zh.arraySlice(t,0,s),this.values=Zh.arraySlice(e,0,s*i)):(this.times=t,this.values=e),this},clone:function(){const t=Zh.arraySlice(this.times,0),e=Zh.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}),il.prototype=Object.assign(Object.create(el.prototype),{constructor:il,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:ji,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),nl.prototype=Object.assign(Object.create(el.prototype),{constructor:nl,ValueTypeName:"color"}),rl.prototype=Object.assign(Object.create(el.prototype),{constructor:rl,ValueTypeName:"number"}),sl.prototype=Object.assign(Object.create(Jh.prototype),{constructor:sl,interpolate_:function(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=(i-e)/(n-e);let c=t*o;for(let t=c+o;c!==t;c+=4)pn.slerpFlat(r,0,s,c-o,s,c,a);return r}}),ol.prototype=Object.assign(Object.create(el.prototype),{constructor:ol,ValueTypeName:"quaternion",DefaultInterpolation:Hi,InterpolantFactoryMethodLinear:function(t){return new sl(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),al.prototype=Object.assign(Object.create(el.prototype),{constructor:al,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:ji,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),cl.prototype=Object.assign(Object.create(el.prototype),{constructor:cl,ValueTypeName:"vector"}),Object.assign(hl,{parse:function(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(ll(i[t]).scale(n));const r=new hl(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r},toJSON:function(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=i.length;t!==n;++t)e.push(el.toJSON(i[t]));return n},CreateFromMorphTargetSequence:function(t,e,i,n){const r=e.length,s=[];for(let t=0;t<r;t++){let o=[],a=[];o.push((t+r-1)%r,t,(t+1)%r),a.push(0,1,0);const c=Zh.getKeyframeOrder(o);o=Zh.sortedArray(o,1,c),a=Zh.sortedArray(a,1,c),n||0!==o[0]||(o.push(r),a.push(a[0])),s.push(new rl(".morphTargetInfluences["+e[t].name+"]",o,a).scale(1/i))}return new hl(t,-1,s)},findByName:function(t,e){let i=t;if(!Array.isArray(t)){const e=t;i=e.geometry&&e.geometry.animations||e.animations}for(let t=0;t<i.length;t++)if(i[t].name===e)return i[t];return null},CreateClipsFromMorphTargetSequences:function(t,e,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let e=0,i=t.length;e<i;e++){const i=t[e],s=i.name.match(r);if(s&&s.length>1){const t=s[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const s=[];for(const t in n)s.push(hl.CreateFromMorphTargetSequence(t,n[t],e,i));return s},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,r){if(0!==i.length){const s=[],o=[];Zh.flattenJSON(i,s,o,n),0!==s.length&&r.push(new t(e,s,o))}},n=[],r=t.name||"default",s=t.fps||30,o=t.blendMode;let a=t.length||-1;const c=t.hierarchy||[];for(let t=0;t<c.length;t++){const r=c[t].keys;if(r&&0!==r.length)if(r[0].morphTargets){const t={};let e;for(e=0;e<r.length;e++)if(r[e].morphTargets)for(let i=0;i<r[e].morphTargets.length;i++)t[r[e].morphTargets[i]]=-1;for(const i in t){const t=[],s=[];for(let n=0;n!==r[e].morphTargets.length;++n){const n=r[e];t.push(n.time),s.push(n.morphTarget===i?1:0)}n.push(new rl(".morphTargetInfluence["+i+"]",t,s))}a=t.length*(s||1)}else{const s=".bones["+e[t].name+"]";i(cl,s+".position",r,"pos",n),i(ol,s+".quaternion",r,"rot",n),i(cl,s+".scale",r,"scl",n)}}if(0===n.length)return null;return new hl(r,a,n,o)}}),Object.assign(hl.prototype,{resetDuration:function(){let t=0;for(let e=0,i=this.tracks.length;e!==i;++e){const i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}return this.duration=t,this},trim:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},validate:function(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t},optimize:function(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this},clone:function(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new hl(this.name,this.duration,t,this.blendMode)},toJSON:function(){return hl.toJSON(this)}});const ul={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};const dl=new function(t,e,i){const n=this;let r,s=!1,o=0,a=0;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(t){a++,!1===s&&void 0!==n.onStart&&n.onStart(t,o,a),s=!0},this.itemEnd=function(t){o++,void 0!==n.onProgress&&n.onProgress(t,o,a),o===a&&(s=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(t){void 0!==n.onError&&n.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return c.push(t,e),this},this.removeHandler=function(t){const e=c.indexOf(t);return-1!==e&&c.splice(e,2),this},this.getHandler=function(t){for(let e=0,i=c.length;e<i;e+=2){const i=c[e],n=c[e+1];if(i.global&&(i.lastIndex=0),i.test(t))return n}return null}};function pl(t){this.manager=void 0!==t?t:dl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}Object.assign(pl.prototype,{load:function(){},loadAsync:function(t,e){const i=this;return new Promise((function(n,r){i.load(t,n,e,r)}))},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}});const fl={};function ml(t){pl.call(this,t)}function gl(t){pl.call(this,t)}function _l(t){pl.call(this,t)}function vl(t){pl.call(this,t)}function yl(t){pl.call(this,t)}function bl(t){pl.call(this,t)}function xl(t){pl.call(this,t)}function wl(){this.type="Curve",this.arcLengthDivisions=200}function Sl(t,e,i,n,r,s,o,a){wl.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=i||1,this.yRadius=n||1,this.aStartAngle=r||0,this.aEndAngle=s||2*Math.PI,this.aClockwise=o||!1,this.aRotation=a||0}function Ml(t,e,i,n,r,s){Sl.call(this,t,e,i,i,n,r,s),this.type="ArcCurve"}function Tl(){let t=0,e=0,i=0,n=0;function r(r,s,o,a){t=r,e=o,i=-3*r+3*s-2*o-a,n=2*r-2*s+o+a}return{initCatmullRom:function(t,e,i,n,s){r(e,i,s*(i-t),s*(n-e))},initNonuniformCatmullRom:function(t,e,i,n,s,o,a){let c=(e-t)/s-(i-t)/(s+o)+(i-e)/o,h=(i-e)/o-(n-e)/(o+a)+(n-i)/a;c*=o,h*=o,r(e,i,c,h)},calc:function(r){const s=r*r;return t+e*r+i*s+n*(s*r)}}}ml.prototype=Object.assign(Object.create(pl.prototype),{constructor:ml,load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=ul.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;if(void 0!==fl[t])return void fl[t].push({onLoad:e,onProgress:i,onError:n});const o=t.match(/^data:(.*?)(;base64)?,(.*)$/);let a;if(o){const i=o[1],s=!!o[2];let a=o[3];a=decodeURIComponent(a),s&&(a=atob(a));try{let n;const s=(this.responseType||"").toLowerCase();switch(s){case"arraybuffer":case"blob":const t=new Uint8Array(a.length);for(let e=0;e<a.length;e++)t[e]=a.charCodeAt(e);n="blob"===s?new Blob([t.buffer],{type:i}):t.buffer;break;case"document":const e=new DOMParser;n=e.parseFromString(a,i);break;case"json":n=JSON.parse(a);break;default:n=a}setTimeout((function(){e&&e(n),r.manager.itemEnd(t)}),0)}catch(e){setTimeout((function(){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}),0)}}else{fl[t]=[],fl[t].push({onLoad:e,onProgress:i,onError:n}),a=new XMLHttpRequest,a.open("GET",t,!0),a.addEventListener("load",(function(e){const i=this.response,n=fl[t];if(delete fl[t],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),ul.add(t,i);for(let t=0,e=n.length;t<e;t++){const e=n[t];e.onLoad&&e.onLoad(i)}r.manager.itemEnd(t)}else{for(let t=0,i=n.length;t<i;t++){const i=n[t];i.onError&&i.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}}),!1),a.addEventListener("progress",(function(e){const i=fl[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onProgress&&n.onProgress(e)}}),!1),a.addEventListener("error",(function(e){const i=fl[t];delete fl[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),a.addEventListener("abort",(function(e){const i=fl[t];delete fl[t];for(let t=0,n=i.length;t<n;t++){const n=i[t];n.onError&&n.onError(e)}r.manager.itemError(t),r.manager.itemEnd(t)}),!1),void 0!==this.responseType&&(a.responseType=this.responseType),void 0!==this.withCredentials&&(a.withCredentials=this.withCredentials),a.overrideMimeType&&a.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(const t in this.requestHeader)a.setRequestHeader(t,this.requestHeader[t]);a.send(null)}return r.manager.itemStart(t),a},setResponseType:function(t){return this.responseType=t,this},setMimeType:function(t){return this.mimeType=t,this}}),gl.prototype=Object.assign(Object.create(pl.prototype),{constructor:gl,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)},parse:function(t){const e=[];for(let i=0;i<t.length;i++){const n=hl.parse(t[i]);e.push(n)}return e}}),_l.prototype=Object.assign(Object.create(pl.prototype),{constructor:_l,load:function(t,e,i,n){const r=this,s=[],o=new ih,a=new ml(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let c=0;function h(h){a.load(t[h],(function(t){const i=r.parse(t,!0);s[h]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},c+=1,6===c&&(1===i.mipmapCount&&(o.minFilter=Ai),o.image=s,o.format=i.format,o.needsUpdate=!0,e&&e(o))}),i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)h(e);else a.load(t,(function(t){const i=r.parse(t,!0);if(i.isCubemap){const t=i.mipmaps.length/i.mipmapCount;for(let e=0;e<t;e++){s[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)s[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),s[e].format=i.format,s[e].width=i.width,s[e].height=i.height}o.image=s}else o.image.width=i.width,o.image.height=i.height,o.mipmaps=i.mipmaps;1===i.mipmapCount&&(o.minFilter=Ai),o.format=i.format,o.needsUpdate=!0,e&&e(o)}),i,n);return o}}),vl.prototype=Object.assign(Object.create(pl.prototype),{constructor:vl,load:function(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=ul.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function a(){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1),ul.add(t,this),e&&e(this),r.manager.itemEnd(t)}function c(e){o.removeEventListener("load",a,!1),o.removeEventListener("error",c,!1),n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}return o.addEventListener("load",a,!1),o.addEventListener("error",c,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(t),o.src=t,o}}),yl.prototype=Object.assign(Object.create(pl.prototype),{constructor:yl,load:function(t,e,i,n){const r=new zs,s=new vl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let o=0;function a(i){s.load(t[i],(function(t){r.images[i]=t,o++,6===o&&(r.needsUpdate=!0,e&&e(r))}),void 0,n)}for(let e=0;e<t.length;++e)a(e);return r}}),bl.prototype=Object.assign(Object.create(pl.prototype),{constructor:bl,load:function(t,e,i,n){const r=this,s=new Bs,o=new ml(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(t,(function(t){const i=r.parse(t);i&&(void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:Ci,s.wrapT=void 0!==i.wrapT?i.wrapT:Ci,s.magFilter=void 0!==i.magFilter?i.magFilter:Ai,s.minFilter=void 0!==i.minFilter?i.minFilter:Ai,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.encoding&&(s.encoding=i.encoding),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=Pi),1===i.mipmapCount&&(s.minFilter=Ai),s.needsUpdate=!0,e&&e(s,i))}),i,n),s}}),xl.prototype=Object.assign(Object.create(pl.prototype),{constructor:xl,load:function(t,e,i,n){const r=new hn,s=new vl(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(i){r.image=i;const n=t.search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/);r.format=n?ki:zi,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r}}),Object.assign(wl.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getSpacedPoints:function(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e},getLength:function(){const t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let i,n=this.getPoint(0),r=0;e.push(0);for(let s=1;s<=t;s++)i=this.getPoint(s/t),r+=i.distanceTo(n),e.push(r),n=i;return this.cacheArcLengths=e,e},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){const i=this.getLengths();let n=0;const r=i.length;let s;s=e||t*i[r-1];let o,a=0,c=r-1;for(;a<=c;)if(n=Math.floor(a+(c-a)/2),o=i[n]-s,o<0)a=n+1;else{if(!(o>0)){c=n;break}c=n-1}if(n=c,i[n]===s)return n/(r-1);const h=i[n];return(n+(s-h)/(i[n+1]-h))/(r-1)},getTangent:function(t,e){const i=1e-4;let n=t-i,r=t+i;n<0&&(n=0),r>1&&(r=1);const s=this.getPoint(n),o=this.getPoint(r),a=e||(s.isVector2?new rn:new fn);return a.copy(o).sub(s).normalize(),a},getTangentAt:function(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)},computeFrenetFrames:function(t,e){const i=new fn,n=[],r=[],s=[],o=new fn,a=new Hn;for(let e=0;e<=t;e++){const i=e/t;n[e]=this.getTangentAt(i,new fn),n[e].normalize()}r[0]=new fn,s[0]=new fn;let c=Number.MAX_VALUE;const h=Math.abs(n[0].x),l=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=c&&(c=h,i.set(1,0,0)),l<=c&&(c=l,i.set(0,1,0)),u<=c&&i.set(0,0,1),o.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],o),s[0].crossVectors(n[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),s[e]=s[e-1].clone(),o.crossVectors(n[e-1],n[e]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos(nn.clamp(n[e-1].dot(n[e]),-1,1));r[e].applyMatrix4(a.makeRotationAxis(o,t))}s[e].crossVectors(n[e],r[e])}if(!0===e){let e=Math.acos(nn.clamp(r[0].dot(r[t]),-1,1));e/=t,n[0].dot(o.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(a.makeRotationAxis(n[i],e*i)),s[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:s}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),Sl.prototype=Object.create(wl.prototype),Sl.prototype.constructor=Sl,Sl.prototype.isEllipseCurve=!0,Sl.prototype.getPoint=function(t,e){const i=e||new rn,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);const o=this.aStartAngle+t*r;let a=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),i=a-this.aX,n=c-this.aY;a=i*t-n*e+this.aX,c=i*e+n*t+this.aY}return i.set(a,c)},Sl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Sl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t},Sl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Ml.prototype=Object.create(Sl.prototype),Ml.prototype.constructor=Ml,Ml.prototype.isArcCurve=!0;const Cl=new fn,El=new Tl,Il=new Tl,Al=new Tl;function Pl(t=[],e=!1,i="centripetal",n=.5){wl.call(this),this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=n}function Rl(t,e,i,n,r){const s=.5*(n-e),o=.5*(r-i),a=t*t;return(2*i-2*n+s+o)*(t*a)+(-3*i+3*n-2*s-o)*a+s*t+i}function Ll(t,e,i,n){return function(t,e){const i=1-t;return i*i*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,i)+function(t,e){return t*t*e}(t,n)}function Ol(t,e,i,n,r){return function(t,e){const i=1-t;return i*i*i*e}(t,e)+function(t,e){const i=1-t;return 3*i*i*t*e}(t,i)+function(t,e){return 3*(1-t)*t*t*e}(t,n)+function(t,e){return t*t*t*e}(t,r)}function Nl(t=new rn,e=new rn,i=new rn,n=new rn){wl.call(this),this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=n}function Dl(t=new fn,e=new fn,i=new fn,n=new fn){wl.call(this),this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=n}function $l(t=new rn,e=new rn){wl.call(this),this.type="LineCurve",this.v1=t,this.v2=e}function kl(t=new fn,e=new fn){wl.call(this),this.type="LineCurve3",this.v1=t,this.v2=e}function zl(t=new rn,e=new rn,i=new rn){wl.call(this),this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}function Fl(t=new fn,e=new fn,i=new fn){wl.call(this),this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}function Bl(t=[]){wl.call(this),this.type="SplineCurve",this.points=t}Pl.prototype=Object.create(wl.prototype),Pl.prototype.constructor=Pl,Pl.prototype.isCatmullRomCurve3=!0,Pl.prototype.getPoint=function(t,e=new fn){const i=e,n=this.points,r=n.length,s=(r-(this.closed?0:1))*t;let o,a,c=Math.floor(s),h=s-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/r)+1)*r:0===h&&c===r-1&&(c=r-2,h=1),this.closed||c>0?o=n[(c-1)%r]:(Cl.subVectors(n[0],n[1]).add(n[0]),o=Cl);const l=n[c%r],u=n[(c+1)%r];if(this.closed||c+2<r?a=n[(c+2)%r]:(Cl.subVectors(n[r-1],n[r-2]).add(n[r-1]),a=Cl),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(o.distanceToSquared(l),t),i=Math.pow(l.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(a),t);i<1e-4&&(i=1),e<1e-4&&(e=i),n<1e-4&&(n=i),El.initNonuniformCatmullRom(o.x,l.x,u.x,a.x,e,i,n),Il.initNonuniformCatmullRom(o.y,l.y,u.y,a.y,e,i,n),Al.initNonuniformCatmullRom(o.z,l.z,u.z,a.z,e,i,n)}else"catmullrom"===this.curveType&&(El.initCatmullRom(o.x,l.x,u.x,a.x,this.tension),Il.initCatmullRom(o.y,l.y,u.y,a.y,this.tension),Al.initCatmullRom(o.z,l.z,u.z,a.z,this.tension));return i.set(El.calc(h),Il.calc(h),Al.calc(h)),i},Pl.prototype.copy=function(t){wl.prototype.copy.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},Pl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t},Pl.prototype.fromJSON=function(t){wl.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new fn).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},Nl.prototype=Object.create(wl.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isCubicBezierCurve=!0,Nl.prototype.getPoint=function(t,e=new rn){const i=e,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(Ol(t,n.x,r.x,s.x,o.x),Ol(t,n.y,r.y,s.y,o.y)),i},Nl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Nl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Nl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},Dl.prototype=Object.create(wl.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isCubicBezierCurve3=!0,Dl.prototype.getPoint=function(t,e=new fn){const i=e,n=this.v0,r=this.v1,s=this.v2,o=this.v3;return i.set(Ol(t,n.x,r.x,s.x,o.x),Ol(t,n.y,r.y,s.y,o.y),Ol(t,n.z,r.z,s.z,o.z)),i},Dl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},Dl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},Dl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},$l.prototype=Object.create(wl.prototype),$l.prototype.constructor=$l,$l.prototype.isLineCurve=!0,$l.prototype.getPoint=function(t,e=new rn){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},$l.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},$l.prototype.getTangent=function(t,e){const i=e||new rn;return i.copy(this.v2).sub(this.v1).normalize(),i},$l.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},$l.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},$l.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},kl.prototype=Object.create(wl.prototype),kl.prototype.constructor=kl,kl.prototype.isLineCurve3=!0,kl.prototype.getPoint=function(t,e=new fn){const i=e;return 1===t?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i},kl.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},kl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},kl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},kl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},zl.prototype=Object.create(wl.prototype),zl.prototype.constructor=zl,zl.prototype.isQuadraticBezierCurve=!0,zl.prototype.getPoint=function(t,e=new rn){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(Ll(t,n.x,r.x,s.x),Ll(t,n.y,r.y,s.y)),i},zl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},zl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},zl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Fl.prototype=Object.create(wl.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isQuadraticBezierCurve3=!0,Fl.prototype.getPoint=function(t,e=new fn){const i=e,n=this.v0,r=this.v1,s=this.v2;return i.set(Ll(t,n.x,r.x,s.x),Ll(t,n.y,r.y,s.y),Ll(t,n.z,r.z,s.z)),i},Fl.prototype.copy=function(t){return wl.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},Fl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},Fl.prototype.fromJSON=function(t){return wl.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},Bl.prototype=Object.create(wl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isSplineCurve=!0,Bl.prototype.getPoint=function(t,e=new rn){const i=e,n=this.points,r=(n.length-1)*t,s=Math.floor(r),o=r-s,a=n[0===s?s:s-1],c=n[s],h=n[s>n.length-2?n.length-1:s+1],l=n[s>n.length-3?n.length-1:s+2];return i.set(Rl(o,a.x,c.x,h.x,l.x),Rl(o,a.y,c.y,h.y,l.y)),i},Bl.prototype.copy=function(t){wl.prototype.copy.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push(i.clone())}return this},Bl.prototype.toJSON=function(){const t=wl.prototype.toJSON.call(this);t.points=[];for(let e=0,i=this.points.length;e<i;e++){const i=this.points[e];t.points.push(i.toArray())}return t},Bl.prototype.fromJSON=function(t){wl.prototype.fromJSON.call(this,t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const i=t.points[e];this.points.push((new rn).fromArray(i))}return this};var jl=Object.freeze({__proto__:null,ArcCurve:Ml,CatmullRomCurve3:Pl,CubicBezierCurve:Nl,CubicBezierCurve3:Dl,EllipseCurve:Sl,LineCurve:$l,LineCurve3:kl,QuadraticBezierCurve:zl,QuadraticBezierCurve3:Fl,SplineCurve:Bl});function Hl(){wl.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function Ul(t){Hl.call(this),this.type="Path",this.currentPoint=new rn,t&&this.setFromPoints(t)}function Vl(t){Ul.call(this,t),this.uuid=nn.generateUUID(),this.type="Shape",this.holes=[]}function Gl(t,e=1){pr.call(this),this.type="Light",this.color=new Dr(t),this.intensity=e}function ql(t,e,i){Gl.call(this,t,i),this.type="HemisphereLight",this.position.copy(pr.DefaultUp),this.updateMatrix(),this.groundColor=new Dr(e)}function Wl(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new rn(512,512),this.map=null,this.mapPass=null,this.matrix=new Hn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Us,this._frameExtents=new rn(1,1),this._viewportCount=1,this._viewports=[new un(0,0,1,1)]}function Xl(){Wl.call(this,new Ds(50,1,.5,500)),this.focus=1}function Yl(t,e,i,n,r,s){Gl.call(this,t,e),this.type="SpotLight",this.position.copy(pr.DefaultUp),this.updateMatrix(),this.target=new pr,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==i?i:0,this.angle=void 0!==n?n:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==s?s:1,this.shadow=new Xl}function Zl(){Wl.call(this,new Ds(90,1,.5,500)),this._frameExtents=new rn(4,2),this._viewportCount=6,this._viewports=[new un(2,1,1,1),new un(0,1,1,1),new un(3,1,1,1),new un(1,1,1,1),new un(3,0,1,1),new un(1,0,1,1)],this._cubeDirections=[new fn(1,0,0),new fn(-1,0,0),new fn(0,0,1),new fn(0,0,-1),new fn(0,1,0),new fn(0,-1,0)],this._cubeUps=[new fn(0,1,0),new fn(0,1,0),new fn(0,1,0),new fn(0,1,0),new fn(0,0,1),new fn(0,0,-1)]}function Jl(t,e,i,n){Gl.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==i?i:0,this.decay=void 0!==n?n:1,this.shadow=new Zl}function Kl(t=-1,e=1,i=1,n=-1,r=.1,s=2e3){Ns.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}function Ql(){Wl.call(this,new Kl(-5,5,5,-5,.5,500))}function tu(t,e){Gl.call(this,t,e),this.type="DirectionalLight",this.position.copy(pr.DefaultUp),this.updateMatrix(),this.target=new pr,this.shadow=new Ql}function eu(t,e){Gl.call(this,t,e),this.type="AmbientLight"}function iu(t,e,i,n){Gl.call(this,t,e),this.type="RectAreaLight",this.width=void 0!==i?i:10,this.height=void 0!==n?n:10}Hl.prototype=Object.assign(Object.create(wl.prototype),{constructor:Hl,add:function(t){this.curves.push(t)},closePath:function(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new $l(e,t))},getPoint:function(t){const e=t*this.getLength(),i=this.getCurveLengths();let n=0;for(;n<i.length;){if(i[n]>=e){const t=i[n]-e,r=this.curves[n],s=r.getLength(),o=0===s?0:1-t/s;return r.getPointAt(o)}n++}return null},getLength:function(){const t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,n=this.curves.length;i<n;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t=12){const e=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const s=r[n],o=s&&s.isEllipseCurve?2*t:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?t*s.points.length:t,a=s.getPoints(o);for(let t=0;t<a.length;t++){const n=a[t];i&&i.equals(n)||(e.push(n),i=n)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e},copy:function(t){wl.prototype.copy.call(this,t),this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){const t=wl.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t},fromJSON:function(t){wl.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const i=t.curves[e];this.curves.push((new jl[i.type]).fromJSON(i))}return this}}),Ul.prototype=Object.assign(Object.create(Hl.prototype),{constructor:Ul,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y);return this},moveTo:function(t,e){return this.currentPoint.set(t,e),this},lineTo:function(t,e){const i=new $l(this.currentPoint.clone(),new rn(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this},quadraticCurveTo:function(t,e,i,n){const r=new zl(this.currentPoint.clone(),new rn(t,e),new rn(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this},bezierCurveTo:function(t,e,i,n,r,s){const o=new Nl(this.currentPoint.clone(),new rn(t,e),new rn(i,n),new rn(r,s));return this.curves.push(o),this.currentPoint.set(r,s),this},splineThru:function(t){const e=new Bl([this.currentPoint.clone()].concat(t));return this.curves.push(e),this.currentPoint.copy(t[t.length-1]),this},arc:function(t,e,i,n,r,s){const o=this.currentPoint.x,a=this.currentPoint.y;return this.absarc(t+o,e+a,i,n,r,s),this},absarc:function(t,e,i,n,r,s){return this.absellipse(t,e,i,i,n,r,s),this},ellipse:function(t,e,i,n,r,s,o,a){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,i,n,r,s,o,a),this},absellipse:function(t,e,i,n,r,s,o,a){const c=new Sl(t,e,i,n,r,s,o,a);if(this.curves.length>0){const t=c.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this},copy:function(t){return Hl.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){const t=Hl.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Hl.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Vl.prototype=Object.assign(Object.create(Ul.prototype),{constructor:Vl,getPointsHoles:function(t){const e=[];for(let i=0,n=this.holes.length;i<n;i++)e[i]=this.holes[i].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){Ul.prototype.copy.call(this,t),this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push(i.clone())}return this},toJSON:function(){const t=Ul.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t},fromJSON:function(t){Ul.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const i=t.holes[e];this.holes.push((new Ul).fromJSON(i))}return this}}),Gl.prototype=Object.assign(Object.create(pr.prototype),{constructor:Gl,isLight:!0,copy:function(t){return pr.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),ql.prototype=Object.assign(Object.create(Gl.prototype),{constructor:ql,isHemisphereLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(Wl.prototype,{_projScreenMatrix:new Hn,_lightPositionWorld:new fn,_lookTarget:new fn,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(t){const e=this.camera,i=this.matrix,n=this._projScreenMatrix,r=this._lookTarget,s=this._lightPositionWorld;s.setFromMatrixPosition(t.matrixWorld),e.position.copy(s),r.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(r),e.updateMatrixWorld(),n.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(n),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(e.projectionMatrix),i.multiply(e.matrixWorldInverse)},getViewport:function(t){return this._viewports[t]},getFrameExtents:function(){return this._frameExtents},copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),Xl.prototype=Object.assign(Object.create(Wl.prototype),{constructor:Xl,isSpotLightShadow:!0,updateMatrices:function(t){const e=this.camera,i=2*nn.RAD2DEG*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),Wl.prototype.updateMatrices.call(this,t)}}),Yl.prototype=Object.assign(Object.create(Gl.prototype),{constructor:Yl,isSpotLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Zl.prototype=Object.assign(Object.create(Wl.prototype),{constructor:Zl,isPointLightShadow:!0,updateMatrices:function(t,e=0){const i=this.camera,n=this.matrix,r=this._lightPositionWorld,s=this._lookTarget,o=this._projScreenMatrix;r.setFromMatrixPosition(t.matrixWorld),i.position.copy(r),s.copy(i.position),s.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(s),i.updateMatrixWorld(),n.makeTranslation(-r.x,-r.y,-r.z),o.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(o)}}),Jl.prototype=Object.assign(Object.create(Gl.prototype),{constructor:Jl,isPointLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Kl.prototype=Object.assign(Object.create(Ns.prototype),{constructor:Kl,isOrthographicCamera:!0,copy:function(t,e){return Ns.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,s=i+t,o=n+e,a=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,o-=e*this.view.offsetY,a=o-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,o,a,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(t){const e=pr.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),Ql.prototype=Object.assign(Object.create(Wl.prototype),{constructor:Ql,isDirectionalLightShadow:!0,updateMatrices:function(t){Wl.prototype.updateMatrices.call(this,t)}}),tu.prototype=Object.assign(Object.create(Gl.prototype),{constructor:tu,isDirectionalLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),eu.prototype=Object.assign(Object.create(Gl.prototype),{constructor:eu,isAmbientLight:!0}),iu.prototype=Object.assign(Object.create(Gl.prototype),{constructor:iu,isRectAreaLight:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){const e=Gl.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}});class nu{constructor(){Object.defineProperty(this,"isSphericalHarmonics3",{value:!0}),this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new fn)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScaledVector(s[1],.488603*n),e.addScaledVector(s[2],.488603*r),e.addScaledVector(s[3],.488603*i),e.addScaledVector(s[4],i*n*1.092548),e.addScaledVector(s[5],n*r*1.092548),e.addScaledVector(s[6],.315392*(3*r*r-1)),e.addScaledVector(s[7],i*r*1.092548),e.addScaledVector(s[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScaledVector(s[1],1.023328*n),e.addScaledVector(s[2],1.023328*r),e.addScaledVector(s[3],1.023328*i),e.addScaledVector(s[4],.858086*i*n),e.addScaledVector(s[5],.858086*n*r),e.addScaledVector(s[6],.743125*r*r-.247708),e.addScaledVector(s[7],.858086*i*r),e.addScaledVector(s[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,r=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*r,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*i*r,e[8]=.546274*(i*i-n*n)}}function ru(t,e){Gl.call(this,void 0,e),this.type="LightProbe",this.sh=void 0!==t?t:new nu}function su(t){pl.call(this,t),this.textures={}}ru.prototype=Object.assign(Object.create(Gl.prototype),{constructor:ru,isLightProbe:!0,copy:function(t){return Gl.prototype.copy.call(this,t),this.sh.copy(t.sh),this},fromJSON:function(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this},toJSON:function(t){const e=Gl.prototype.toJSON.call(this,t);return e.object.sh=this.sh.toArray(),e}}),su.prototype=Object.assign(Object.create(pl.prototype),{constructor:su,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)},parse:function(t){const e=this.textures;function i(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}const n=new Yh[t.type];if(void 0!==t.uuid&&(n.uuid=t.uuid),void 0!==t.name&&(n.name=t.name),void 0!==t.color&&void 0!==n.color&&n.color.setHex(t.color),void 0!==t.roughness&&(n.roughness=t.roughness),void 0!==t.metalness&&(n.metalness=t.metalness),void 0!==t.sheen&&(n.sheen=(new Dr).setHex(t.sheen)),void 0!==t.emissive&&void 0!==n.emissive&&n.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==n.specular&&n.specular.setHex(t.specular),void 0!==t.shininess&&(n.shininess=t.shininess),void 0!==t.clearcoat&&(n.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(n.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.fog&&(n.fog=t.fog),void 0!==t.flatShading&&(n.flatShading=t.flatShading),void 0!==t.blending&&(n.blending=t.blending),void 0!==t.combine&&(n.combine=t.combine),void 0!==t.side&&(n.side=t.side),void 0!==t.opacity&&(n.opacity=t.opacity),void 0!==t.transparent&&(n.transparent=t.transparent),void 0!==t.alphaTest&&(n.alphaTest=t.alphaTest),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(n.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(n.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(n.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(n.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(n.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(n.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(n.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(n.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(n.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(n.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(n.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(n.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(n.rotation=t.rotation),1!==t.linewidth&&(n.linewidth=t.linewidth),void 0!==t.dashSize&&(n.dashSize=t.dashSize),void 0!==t.gapSize&&(n.gapSize=t.gapSize),void 0!==t.scale&&(n.scale=t.scale),void 0!==t.polygonOffset&&(n.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(n.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(n.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.skinning&&(n.skinning=t.skinning),void 0!==t.morphTargets&&(n.morphTargets=t.morphTargets),void 0!==t.morphNormals&&(n.morphNormals=t.morphNormals),void 0!==t.dithering&&(n.dithering=t.dithering),void 0!==t.vertexTangents&&(n.vertexTangents=t.vertexTangents),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.toneMapped&&(n.toneMapped=t.toneMapped),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?n.vertexColors=t.vertexColors>0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(n.uniforms[e]={},r.type){case"t":n.uniforms[e].value=i(r.value);break;case"c":n.uniforms[e].value=(new Dr).setHex(r.value);break;case"v2":n.uniforms[e].value=(new rn).fromArray(r.value);break;case"v3":n.uniforms[e].value=(new fn).fromArray(r.value);break;case"v4":n.uniforms[e].value=(new un).fromArray(r.value);break;case"m3":n.uniforms[e].value=(new sn).fromArray(r.value);break;case"m4":n.uniforms[e].value=(new Hn).fromArray(r.value);break;default:n.uniforms[e].value=r.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(n.flatShading=1===t.shading),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new rn).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new rn).fromArray(t.clearcoatNormalScale)),void 0!==t.transmission&&(n.transmission=t.transmission),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),n},setTextures:function(t){return this.textures=t,this}});const ou=function(t){const e=t.lastIndexOf("/");return-1===e?"./":t.substr(0,e+1)};function au(){hs.call(this),this.type="InstancedBufferGeometry",this.instanceCount=1/0}function cu(t,e,i,n){"number"==typeof i&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),Hr.call(this,t,e,i),this.meshPerAttribute=n||1}function hu(t){pl.call(this,t)}function lu(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),pl.call(this,t),this.options={premultiplyAlpha:"none"}}function uu(){this.type="ShapePath",this.color=new Dr,this.subPaths=[],this.currentPath=null}au.prototype=Object.assign(Object.create(hs.prototype),{constructor:au,isInstancedBufferGeometry:!0,copy:function(t){return hs.prototype.copy.call(this,t),this.instanceCount=t.instanceCount,this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){const t=hs.prototype.toJSON.call(this);return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}),cu.prototype=Object.assign(Object.create(Hr.prototype),{constructor:cu,isInstancedBufferAttribute:!0,copy:function(t){return Hr.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},toJSON:function(){const t=Hr.prototype.toJSON.call(this);return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}),hu.prototype=Object.assign(Object.create(pl.prototype),{constructor:hu,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{e(r.parse(JSON.parse(i)))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)},parse:function(t){const e={},i={};function n(t,n){if(void 0!==e[n])return e[n];const r=t.interleavedBuffers[n],s=function(t,e){if(void 0!==i[e])return i[e];const n=t.arrayBuffers[e],r=new Uint32Array(n).buffer;return i[e]=r,r}(t,r.buffer),o=new tc(es(r.type,s),r.stride);return o.uuid=r.uuid,e[n]=o,o}const r=t.isInstancedBufferGeometry?new au:new hs,s=t.data.index;if(void 0!==s){const t=es(s.type,s.array);r.setIndex(new Hr(t,1))}const o=t.data.attributes;for(const e in o){const i=o[e];let s;if(i.isInterleavedBufferAttribute){s=new ic(n(t.data,i.data),i.itemSize,i.offset,i.normalized)}else{const t=es(i.type,i.array);s=new(i.isInstancedBufferAttribute?cu:Hr)(t,i.itemSize,i.normalized)}void 0!==i.name&&(s.name=i.name),r.setAttribute(e,s)}const a=t.data.morphAttributes;if(a)for(const e in a){const i=a[e],s=[];for(let e=0,r=i.length;e<r;e++){const r=i[e];let o;if(r.isInterleavedBufferAttribute){o=new ic(n(t.data,r.data),r.itemSize,r.offset,r.normalized)}else{o=new Hr(es(r.type,r.array),r.itemSize,r.normalized)}void 0!==r.name&&(o.name=r.name),s.push(o)}r.morphAttributes[e]=s}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const c=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==c)for(let t=0,e=c.length;t!==e;++t){const e=c[t];r.addGroup(e.start,e.count,e.materialIndex)}const h=t.data.boundingSphere;if(void 0!==h){const t=new fn;void 0!==h.center&&t.fromArray(h.center),r.boundingSphere=new On(t,h.radius)}return t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}),lu.prototype=Object.assign(Object.create(pl.prototype),{constructor:lu,isImageBitmapLoader:!0,setOptions:function(t){return this.options=t,this},load:function(t,e,i,n){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=ul.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",fetch(t,o).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,r.options)})).then((function(i){ul.add(t,i),e&&e(i),r.manager.itemEnd(t)})).catch((function(e){n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)})),r.manager.itemStart(t)}}),Object.assign(uu.prototype,{moveTo:function(t,e){return this.currentPath=new Ul,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this},lineTo:function(t,e){return this.currentPath.lineTo(t,e),this},quadraticCurveTo:function(t,e,i,n){return this.currentPath.quadraticCurveTo(t,e,i,n),this},bezierCurveTo:function(t,e,i,n,r,s){return this.currentPath.bezierCurveTo(t,e,i,n,r,s),this},splineThru:function(t){return this.currentPath.splineThru(t),this},toShapes:function(t,e){function i(t){const e=[];for(let i=0,n=t.length;i<n;i++){const n=t[i],r=new Vl;r.curves=n.curves,e.push(r)}return e}function n(t,e){const i=e.length;let n=!1;for(let r=i-1,s=0;s<i;r=s++){let i=e[r],o=e[s],a=o.x-i.x,c=o.y-i.y;if(Math.abs(c)>Number.EPSILON){if(c<0&&(i=e[s],a=-a,o=e[r],c=-c),t.y<i.y||t.y>o.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=c*(t.x-i.x)-a*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(o.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=o.x)return!0}}return n}const r=Rh.isClockWise,s=this.subPaths;if(0===s.length)return[];if(!0===e)return i(s);let o,a,c;const h=[];if(1===s.length)return a=s[0],c=new Vl,c.curves=a.curves,h.push(c),h;let l=!r(s[0].getPoints());l=t?!l:l;const u=[],d=[];let p,f,m=[],g=0;d[g]=void 0,m[g]=[];for(let e=0,i=s.length;e<i;e++)a=s[e],p=a.getPoints(),o=r(p),o=t?!o:o,o?(!l&&d[g]&&g++,d[g]={s:new Vl,p:p},d[g].s.curves=a.curves,l&&g++,m[g]=[]):m[g].push({h:a,p:p[0]});if(!d[0])return i(s);if(d.length>1){let t=!1;const e=[];for(let t=0,e=d.length;t<e;t++)u[t]=[];for(let i=0,r=d.length;i<r;i++){const r=m[i];for(let s=0;s<r.length;s++){const o=r[s];let a=!0;for(let r=0;r<d.length;r++)n(o.p,d[r].p)&&(i!==r&&e.push({froms:i,tos:r,hole:s}),a?(a=!1,u[r].push(o)):t=!0);a&&u[i].push(o)}}e.length>0&&(t||(m=u))}for(let t=0,e=d.length;t<e;t++){c=d[t].s,h.push(c),f=m[t];for(let t=0,e=f.length;t<e;t++)c.holes.push(f[t].h)}return h}});class du{constructor(t){Object.defineProperty(this,"isFont",{value:!0}),this.type="Font",this.data=t}generateShapes(t,e=100){const i=[],n=function(t,e,i){const n=Array.from?Array.from(t):String(t).split(""),r=e/i.resolution,s=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,o=[];let a=0,c=0;for(let t=0;t<n.length;t++){const e=n[t];if("\n"===e)a=0,c-=s;else{const t=pu(e,r,a,c,i);a+=t.offsetX,o.push(t.path)}}return o}(t,e,this.data);for(let t=0,e=n.length;t<e;t++)Array.prototype.push.apply(i,n[t].toShapes());return i}}function pu(t,e,i,n,r){const s=r.glyphs[t]||r.glyphs["?"];if(!s)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+r.familyName+".");const o=new uu;let a,c,h,l,u,d,p,f;if(s.o){const t=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let r=0,s=t.length;r<s;){switch(t[r++]){case"m":a=t[r++]*e+i,c=t[r++]*e+n,o.moveTo(a,c);break;case"l":a=t[r++]*e+i,c=t[r++]*e+n,o.lineTo(a,c);break;case"q":h=t[r++]*e+i,l=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,o.quadraticCurveTo(u,d,h,l);break;case"b":h=t[r++]*e+i,l=t[r++]*e+n,u=t[r++]*e+i,d=t[r++]*e+n,p=t[r++]*e+i,f=t[r++]*e+n,o.bezierCurveTo(u,d,p,f,h,l)}}}return{offsetX:s.ha*e,path:o}}function fu(t){pl.call(this,t)}let mu;fu.prototype=Object.assign(Object.create(pl.prototype),{constructor:fu,load:function(t,e,i,n){const r=this,s=new ml(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(t){let i;try{i=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(t.substring(65,t.length-2))}const n=r.parse(i);e&&e(n)}),i,n)},parse:function(t){return new du(t)}});const gu=function(){return void 0===mu&&(mu=new(window.AudioContext||window.webkitAudioContext)),mu};function _u(t){pl.call(this,t)}function vu(t,e,i){ru.call(this,void 0,i);const n=(new Dr).set(t),r=(new Dr).set(e),s=new fn(n.r,n.g,n.b),o=new fn(r.r,r.g,r.b),a=Math.sqrt(Math.PI),c=a*Math.sqrt(.75);this.sh.coefficients[0].copy(s).add(o).multiplyScalar(a),this.sh.coefficients[1].copy(s).sub(o).multiplyScalar(c)}function yu(t,e){ru.call(this,void 0,e);const i=(new Dr).set(t);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}_u.prototype=Object.assign(Object.create(pl.prototype),{constructor:_u,load:function(t,e,i,n){const r=this,s=new ml(r.manager);s.setResponseType("arraybuffer"),s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(t,(function(i){try{const t=i.slice(0);gu().decodeAudioData(t,(function(t){e(t)}))}catch(e){n?n(e):console.error(e),r.manager.itemError(t)}}),i,n)}}),vu.prototype=Object.assign(Object.create(ru.prototype),{constructor:vu,isHemisphereLightProbe:!0,copy:function(t){return ru.prototype.copy.call(this,t),this},toJSON:function(t){return ru.prototype.toJSON.call(this,t)}}),yu.prototype=Object.assign(Object.create(ru.prototype),{constructor:yu,isAmbientLightProbe:!0,copy:function(t){return ru.prototype.copy.call(this,t),this},toJSON:function(t){return ru.prototype.toJSON.call(this,t)}});const bu=new Hn,xu=new Hn;Object.assign(function(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ds,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ds,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}.prototype,{update:function(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep;const i=t.projectionMatrix.clone(),n=e.eyeSep/2,r=n*e.near/e.focus,s=e.near*Math.tan(nn.DEG2RAD*e.fov*.5)/e.zoom;let o,a;xu.elements[12]=-n,bu.elements[12]=n,o=-s*e.aspect+r,a=s*e.aspect+r,i.elements[0]=2*e.near/(a-o),i.elements[8]=(a+o)/(a-o),this.cameraL.projectionMatrix.copy(i),o=-s*e.aspect-r,a=s*e.aspect-r,i.elements[0]=2*e.near/(a-o),i.elements[8]=(a+o)/(a-o),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(xu),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(bu)}});function wu(t,e,i){let n,r,s;switch(this.binding=t,this.valueSize=i,e){case"quaternion":n=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}Object.assign(wu.prototype,{accumulate:function(t,e){const i=this.buffer,n=this.valueSize,r=t*n+n;let s=this.cumulativeWeight;if(0===s){for(let t=0;t!==n;++t)i[r+t]=i[t];s=e}else{s+=e;const t=e/s;this._mixBufferRegion(i,r,0,t,n)}this.cumulativeWeight=s},accumulateAdditive:function(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t},apply:function(t){const e=this.valueSize,i=this.buffer,n=t*e+e,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const t=e*this._origIndex;this._mixBufferRegion(i,n,t,1-r,e)}s>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){o.setValue(i,n);break}},saveOriginalState:function(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let t=i,r=n;t!==r;++t)e[t]=e[n+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0},restoreOriginalState:function(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_setAdditiveIdentityNumeric:function(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0},_setAdditiveIdentityQuaternion:function(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1},_setAdditiveIdentityOther:function(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]},_select:function(t,e,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)t[e+n]=t[i+n]},_slerp:function(t,e,i,n){pn.slerpFlat(t,e,t,e,t,i,n)},_slerpAdditive:function(t,e,i,n,r){const s=this._workIndex*r;pn.multiplyQuaternionsFlat(t,s,t,e,t,i),pn.slerpFlat(t,e,t,e,t,s,n)},_lerp:function(t,e,i,n,r){const s=1-n;for(let o=0;o!==r;++o){const r=e+o;t[r]=t[r]*s+t[i+o]*n}},_lerpAdditive:function(t,e,i,n,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[i+s]*n}}});const Su="\\[\\]\\.:\\/",Mu=new RegExp("[\\[\\]\\.:\\/]","g"),Tu="[^\\[\\]\\.:\\/]",Cu="[^"+Su.replace("\\.","")+"]",Eu=/((?:WC+[\/:])*)/.source.replace("WC",Tu),Iu=/(WCOD+)?/.source.replace("WCOD",Cu),Au=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Tu),Pu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Tu),Ru=new RegExp("^"+Eu+Iu+Au+Pu+"$"),Lu=["material","materials","bones"];function Ou(t,e,i){const n=i||Nu.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}function Nu(t,e,i){this.path=e,this.parsedPath=i||Nu.parseTrackName(e),this.node=Nu.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}Object.assign(Ou.prototype,{getValue:function(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(t,e)},setValue:function(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(t,e)},bind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()},unbind:function(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}),Object.assign(Nu,{Composite:Ou,create:function(t,e,i){return t&&t.isAnimationObjectGroup?new Nu.Composite(t,e,i):new Nu(t,e,i)},sanitizeNodeName:function(t){return t.replace(/\s/g,"_").replace(Mu,"")},parseTrackName:function(t){const e=Ru.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==Lu.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i},findNode:function(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.name===e||r.uuid===e)return r;const s=i(r.children);if(s)return s}return null},n=i(t.children);if(n)return n}return null}}),Object.assign(Nu.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)t[e++]=i[n]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++]},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let r=e.propertyIndex;if(t||(t=Nu.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=e.objectIndex;switch(i){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(let e=0;e<t.length;e++)if(t[e].name===n){n=e;break}break;default:if(void 0===t[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[i]}if(void 0!==n){if(void 0===t[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[n]}}const s=t[n];if(void 0===s){const i=e.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",t)}let o=this.Versioning.None;this.targetObject=t,void 0!==t.needsUpdate?o=this.Versioning.NeedsUpdate:void 0!==t.matrixWorldNeedsUpdate&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!t.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==t.morphTargetDictionary[r]&&(r=t.morphTargetDictionary[r])}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(a=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(a=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=n;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Nu.prototype,{_getValue_unbound:Nu.prototype.getValue,_setValue_unbound:Nu.prototype.setValue}),Object.assign(function(){this.uuid=nn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let e=0,i=arguments.length;e!==i;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}.prototype,{isAnimationObjectGroup:!0,add:function(){const t=this._objects,e=this._indicesByUUID,i=this._paths,n=this._parsedPaths,r=this._bindings,s=r.length;let o,a=t.length,c=this.nCachedObjects_;for(let h=0,l=arguments.length;h!==l;++h){const l=arguments[h],u=l.uuid;let d=e[u];if(void 0===d){d=a++,e[u]=d,t.push(l);for(let t=0,e=s;t!==e;++t)r[t].push(new Nu(l,i[t],n[t]))}else if(d<c){o=t[d];const a=--c,h=t[a];e[h.uuid]=d,t[d]=h,e[u]=a,t[a]=l;for(let t=0,e=s;t!==e;++t){const e=r[t],s=e[a];let o=e[d];e[d]=s,void 0===o&&(o=new Nu(l,i[t],n[t])),e[a]=o}}else t[d]!==o&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c},remove:function(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_;for(let s=0,o=arguments.length;s!==o;++s){const o=arguments[s],a=o.uuid,c=e[a];if(void 0!==c&&c>=r){const s=r++,h=t[s];e[h.uuid]=c,t[c]=h,e[a]=s,t[s]=o;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[s],r=e[c];e[c]=n,e[s]=r}}}this.nCachedObjects_=r},uncache:function(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,s=t.length;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o].uuid,c=e[a];if(void 0!==c)if(delete e[a],c<r){const o=--r,a=t[o],h=--s,l=t[h];e[a.uuid]=c,t[c]=a,e[l.uuid]=o,t[o]=l,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[o],r=e[h];e[c]=n,e[o]=r,e.pop()}}else{const r=--s,o=t[r];r>0&&(e[o.uuid]=c),t[c]=o,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[c]=e[r],e.pop()}}}this.nCachedObjects_=r},subscribe_:function(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const s=this._paths,o=this._parsedPaths,a=this._objects,c=a.length,h=this.nCachedObjects_,l=new Array(c);n=r.length,i[t]=n,s.push(t),o.push(e),r.push(l);for(let i=h,n=a.length;i!==n;++i){const n=a[i];l[i]=new Nu(n,t,e)}return l},unsubscribe_:function(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length-1,a=s[o];e[t[o]]=i,s[i]=a,s.pop(),r[i]=r[o],r.pop(),n[i]=n[o],n.pop()}}});class Du{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const r=e.tracks,s=r.length,o=new Array(s),a={endingStart:Vi,endingEnd:Vi};for(let t=0;t!==s;++t){const e=r[t].createInterpolant(null);o[t]=e,e.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){const i=this._clip.duration,n=t._clip.duration,r=n/i,s=i/n;t.warp(1,r,e),this.warp(s,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,r=n.time,s=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=r,a[1]=r+i,c[0]=t/s,c[1]=e/s,this}stopWarping(){const t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const n=(t-r)*i;if(n<0||0===i)return;this._startTime=null,e=i*n}e*=this._updateTimeScale(t);const s=this._updateTime(e),o=this._updateWeight(t);if(o>0){const t=this._interpolants,e=this._propertyBindings;switch(this.blendMode){case 2501:for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(s),e[i].accumulateAdditive(o);break;case Wi:default:for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(s),e[i].accumulate(n,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,r=this._loopCount;const s=2202===i;if(0===t)return-1===r?n:s&&1==(1&r)?e-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,r+=Math.abs(i);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===o){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(s&&1==(1&r))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=Gi,n.endingEnd=Gi):(n.endingStart=t?this.zeroSlopeAtStart?Gi:Vi:qi,n.endingEnd=e?this.zeroSlopeAtEnd?Gi:Vi:qi)}_scheduleFading(t,e,i){const n=this._mixer,r=n.time;let s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);const o=s.parameterPositions,a=s.sampleValues;return o[0]=r,a[0]=e,o[1]=r+t,a[1]=i,this}}function $u(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}$u.prototype=Object.assign(Object.create(Qi.prototype),{constructor:$u,_bindAction:function(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,o=t._interpolants,a=i.uuid,c=this._bindingsByRootAndName;let h=c[a];void 0===h&&(h={},c[a]=h);for(let t=0;t!==r;++t){const r=n[t],c=r.name;let l=h[c];if(void 0!==l)s[t]=l;else{if(l=s[t],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,a,c));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;l=new wu(Nu.create(i,c,n),r.ValueTypeName,r.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,a,c),s[t]=l}o[t].resultBuffer=l.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){const e=t._cacheIndex;return null!==e&&e<this._nActiveActions},_addInactiveAction:function(t,e,i){const n=this._actions,r=this._actionsByClip;let s=r[e];if(void 0===s)s={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=s;else{const e=s.knownActions;t._byClipCacheIndex=e.length,e.push(t)}t._cacheIndex=n.length,n.push(t),s.actionByRoot[i]=t},_removeInactiveAction:function(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const r=t._clip.uuid,s=this._actionsByClip,o=s[r],a=o.knownActions,c=a[a.length-1],h=t._byClipCacheIndex;c._byClipCacheIndex=h,a[h]=c,a.pop(),t._byClipCacheIndex=null;delete o.actionByRoot[(t._localRoot||this._root).uuid],0===a.length&&delete s[r],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.referenceCount&&this._removeInactiveBinding(i)}},_lendAction:function(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_takeBackAction:function(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_addInactiveBinding:function(t,e,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[e];void 0===s&&(s={},n[e]=s),s[i]=t,t._cacheIndex=r.length,r.push(t)},_removeInactiveBinding:function(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,o=s[n],a=e[e.length-1],c=t._cacheIndex;a._cacheIndex=c,e[c]=a,e.pop(),delete o[r],0===Object.keys(o).length&&delete s[n]},_lendBinding:function(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_takeBackBinding:function(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,r=e[n];t._cacheIndex=n,e[n]=t,r._cacheIndex=i,e[i]=r},_lendControlInterpolant:function(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return void 0===i&&(i=new Qh(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=e,t[e]=i),i},_takeBackControlInterpolant:function(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,r=e[n];t.__cacheIndex=n,e[n]=t,r.__cacheIndex=i,e[i]=r},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e,i){const n=e||this._root,r=n.uuid;let s="string"==typeof t?hl.findByName(n,t):t;const o=null!==s?s.uuid:t,a=this._actionsByClip[o];let c=null;if(void 0===i&&(i=null!==s?s.blendMode:Wi),void 0!==a){const t=a.actionByRoot[r];if(void 0!==t&&t.blendMode===i)return t;c=a.knownActions[0],null===s&&(s=c._clip)}if(null===s)return null;const h=new Du(this,s,e,i);return this._bindAction(h,c),this._addInactiveAction(h,o,r),h},existingAction:function(t,e){const i=e||this._root,n=i.uuid,r="string"==typeof t?hl.findByName(i,t):t,s=r?r.uuid:t,o=this._actionsByClip[s];return void 0!==o&&o.actionByRoot[n]||null},stopAllAction:function(){const t=this._actions;for(let e=this._nActiveActions-1;e>=0;--e)t[e].stop();return this},update:function(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let o=0;o!==i;++o){e[o]._update(n,t,r,s)}const o=this._bindings,a=this._nActiveBindings;for(let t=0;t!==a;++t)o[t].apply(s);return this},setTime:function(t){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(t)},getRoot:function(){return this._root},uncacheClip:function(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const t=r.knownActions;for(let i=0,n=t.length;i!==n;++i){const n=t[i];this._deactivateAction(n);const r=n._cacheIndex,s=e[e.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,e[r]=s,e.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}},uncacheRoot:function(t){const e=t.uuid,i=this._actionsByClip;for(const t in i){const n=i[t].actionByRoot[e];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[e];if(void 0!==n)for(const t in n){const e=n[t];e.restoreOriginalState(),this._removeInactiveBinding(e)}},uncacheAction:function(t,e){const i=this.existingAction(t,e);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}});class ku{constructor(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}clone(){return new ku(void 0===this.value.clone?this.value:this.value.clone())}}function zu(t,e,i){tc.call(this,t,e),this.meshPerAttribute=i||1}function Fu(t,e,i,n,r){this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=n,this.count=r,this.version=0}function Bu(t,e,i,n){this.ray=new jn(t,e),this.near=i||0,this.far=n||1/0,this.camera=null,this.layers=new Qn,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function ju(t,e){return t.distance-e.distance}function Hu(t,e,i,n){if(t.layers.test(e.layers)&&t.raycast(e,i),!0===n){const n=t.children;for(let t=0,r=n.length;t<r;t++)Hu(n[t],e,i,!0)}}zu.prototype=Object.assign(Object.create(tc.prototype),{constructor:zu,isInstancedInterleavedBuffer:!0,copy:function(t){return tc.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this},clone:function(t){const e=tc.prototype.clone.call(this,t);return e.meshPerAttribute=this.meshPerAttribute,e},toJSON:function(t){const e=tc.prototype.toJSON.call(this,t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}),Object.defineProperty(Fu.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Fu.prototype,{isGLBufferAttribute:!0,setBuffer:function(t){return this.buffer=t,this},setType:function(t,e){return this.type=t,this.elementSize=e,this},setItemSize:function(t){return this.itemSize=t,this},setCount:function(t){return this.count=t,this}}),Object.assign(Bu.prototype,{set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)},intersectObject:function(t,e,i){const n=i||[];return Hu(t,this,n,e),n.sort(ju),n},intersectObjects:function(t,e,i){const n=i||[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),n;for(let i=0,r=t.length;i<r;i++)Hu(t[i],this,n,e);return n.sort(ju),n}});const Uu=new rn;function Vu(t){pr.call(this),this.material=t,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}Vu.prototype=Object.create(pr.prototype),Vu.prototype.constructor=Vu,Vu.prototype.isImmediateRenderObject=!0;const Gu=new Fr({side:1,depthWrite:!1,depthTest:!1});function qu(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Pl.call(this,t),this.type="catmullrom"}new Es(new As,Gu),wl.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(wl.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Ul.prototype,{fromPoints:function(t){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}}),qu.prototype=Object.create(Pl.prototype),Object.assign(qu.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),Object.assign(pl.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),ou(t)}}),pl.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Object.assign(class{constructor(t,e){Object.defineProperty(this,"isBox2",{value:!0}),this.min=void 0!==t?t:new rn(1/0,1/0),this.max=void 0!==e?e:new rn(-1/0,-1/0)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Uu.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return void 0===t&&(console.warn("THREE.Box2: .getCenter() target is now required"),t=new rn),this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return void 0===t&&(console.warn("THREE.Box2: .getSize() target is now required"),t=new rn),this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new rn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new rn),e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Uu.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(_n.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(On.prototype,{empty:function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()}}),Us.prototype.setFromMatrix=function(t){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(t)},Object.assign(nn,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),nn.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),nn.ceilPowerOfTwo(t)}}),Object.assign(sn.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},getInverse:function(t){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()}}),Object.assign(Hn.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new fn).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBufferAttribute:function(t){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,i,n,r,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,n,i,r,s)},getInverse:function(t){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(t).invert()}}),_r.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Object.assign(pn.prototype,{multiplyVector3:function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},inverse:function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()}}),Object.assign(jn.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(Ir.prototype,{area:function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},barycoordFromPoint:function(t,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(t,e)},midpoint:function(t){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(t)},normal:function(t){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(t)},plane:function(t){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(t)}}),Object.assign(Ir,{barycoordFromPoint:function(t,e,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Ir.getBarycoord(t,e,i,n,r)},normal:function(t,e,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Ir.getNormal(t,e,i,n)}}),Object.assign(Vl.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Nh(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new kh(this,t)}}),Object.assign(rn.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(fn.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(un.prototype,{fromAttribute:function(t,e,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,i)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(pr.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},applyMatrix:function(t){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}}),Object.defineProperties(pr.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.assign(Es.prototype,{setDrawMode:function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}),Object.defineProperties(Es.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Object.defineProperties(xc.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(Rc.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Ec.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(wl.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),Ds.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(Gl.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(Hr.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Ji},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Ji)}}}),Object.assign(Hr.prototype,{setDynamic:function(t){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?Ji:Zi),this},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(hs.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addAttribute:function(t,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(t,e):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(t,new Hr(arguments[1],arguments[2])))},addDrawCall:function(t,e,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},removeAttribute:function(t){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(t)},applyMatrix:function(t){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}}),Object.defineProperties(hs.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(au.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(t){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=t}}}),Object.defineProperties(Bu.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(t){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=t}}}),Object.defineProperties(tc.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===Ji},set:function(t){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(t)}}}),Object.assign(tc.prototype,{setDynamic:function(t){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===t?Ji:Zi),this},setArray:function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")}}),Object.assign(Nh.prototype,{getArrays:function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")}}),Object.assign(Qa.prototype,{dispose:function(){console.error("THREE.Scene: .dispose() has been removed.")}}),Object.defineProperties(ku.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(zr.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Dr}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===t}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(t){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=t}}}),Object.defineProperties(Uh.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(Hh.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(t){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=t}}}),Object.defineProperties(Os.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(Ja.prototype,{clearTarget:function(t,e,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(t),this.clear(e,i,n)},animate:function(t){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(t)},getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()}}),Object.defineProperties(Ja.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(t){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===t?3001:Xi}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Ha.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(dn.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Object.defineProperties(class extends pr{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(t){return t||(t=[]),!0===this._connected?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){if(this.detune=t,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}}.prototype,{load:{value:function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const e=this;return(new _u).load(t,(function(t){e.setBuffer(t)})),this}},startTime:{set:function(){console.warn("THREE.Audio: .startTime is now .play( delay ).")}}}),ks.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)},ks.prototype.clear=function(t,e,i,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(t,e,i,n)},an.crossOrigin=void 0,an.loadTexture=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new xl;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,i,void 0,n);return e&&(s.mapping=e),s},an.loadTextureCube=function(t,e,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new yl;r.setCrossOrigin(this.crossOrigin);const s=r.load(t,i,void 0,n);return e&&(s.mapping=e),s},an.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},an.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"125"}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="125");const Wu=Math.PI/180,Xu=180/Math.PI,Yu=6378137,Zu=6356752.31424518;function Ju(t,e,i,n,r,s){const o=Qu(t,e,i);return function(t,e,i,n,r,s){const o=Qu(n,r,s),a=[t-o[0],e-o[1],i-o[2]];n*=Wu,r*=Wu;const c=Math.cos(n),h=Math.sin(n),l=Math.cos(r),u=Math.sin(r),d=-h*a[0]+c*a[1],p=-u*c*a[0]-u*h*a[1]+l*a[2],f=l*c*a[0]+l*h*a[1]+u*a[2];return[d,p,f]}(o[0],o[1],o[2],n,r,s)}function Ku(t,e,i,n,r,s){const o=function(t,e,i,n,r,s){const o=Qu(n,r,s);n*=Wu,r*=Wu;const a=Math.cos(n),c=Math.sin(n),h=Math.cos(r),l=Math.sin(r),u=-c*t-l*a*e+h*a*i+o[0],d=a*t-l*c*e+h*c*i+o[1],p=h*e+l*i+o[2];return[u,d,p]}(t,e,i,n,r,s);return function(t,e,i){const n=Yu,r=Zu,s=n*n,o=r*r,a=s-o,c=Math.sqrt(a/s),h=Math.sqrt(a/o),l=Math.sqrt(t*t+e*e),u=Math.atan2(i*n,l*r),d=Math.sin(u),p=Math.cos(u),f=Math.atan2(e,t),m=Math.atan2(i+h*h*r*d*d*d,l-c*c*n*p*p*p),g=Math.sin(m),_=Math.cos(m),v=n/Math.sqrt(1-c*c*g*g);return[f*Xu,m*Xu,l/_-v]}(o[0],o[1],o[2])}function Qu(t,e,i){const n=Yu,r=Zu;t*=Wu,e*=Wu;const s=Math.cos(t),o=Math.sin(t),a=Math.cos(e),c=Math.sin(e),h=n*n,l=r*r,u=1/Math.sqrt(h*a*a+l*c*c),d=(h*u+i)*a;return[d*s,d*o,(l*u+i)*c]}class td{boundingBoxCorners(t,e){const i=Ku(-e,-e,0,t.lng,t.lat,0),n=Ku(e,e,0,t.lng,t.lat,0);return[{lat:i[1],lng:i[0]},{lat:n[1],lng:n[0]}]}rotationFromCompass(t,e){let i=0,n=0,r=0;switch(e){case 1:i=Math.PI/2;break;case 3:i=-Math.PI/2,r=Math.PI;break;case 6:n=-Math.PI/2,r=-Math.PI/2;break;case 8:n=Math.PI/2,r=Math.PI/2}const s=(new Hn).makeRotationZ(r),o=new Zn(i,n,t*Math.PI/180,"XYZ"),a=(new Hn).makeRotationFromEuler(o),c=(new un).setAxisAngleFromRotationMatrix(a.multiply(s));return c.multiplyScalar(c.w).toArray().slice(0,3)}}class ed{constructor(t){if(!t)throw new Error(`Incorrect core image data ${t}`);this._cache=null,this._core=t,this._spatial=null}get assetsCached(){return null!=this._core&&null!=this._spatial&&null!=this._cache&&null!=this._cache.image&&null!=this._cache.mesh}get cameraParameters(){return this._spatial.camera_parameters}get cameraType(){return this._spatial.camera_type}get capturedAt(){return this._spatial.captured_at}get clusterId(){return this._spatial.cluster?this._spatial.cluster.id:null}get clusterUrl(){return this._spatial.cluster?this._spatial.cluster.url:null}get compassAngle(){return null!=this._spatial.computed_compass_angle?this._spatial.computed_compass_angle:this._spatial.compass_angle}get complete(){return null!=this._spatial}get computedAltitude(){return this._spatial.computed_altitude}get computedCompassAngle(){return this._spatial.computed_compass_angle}get computedLngLat(){return this._core.computed_geometry}get creatorId(){return this._spatial.creator.id}get creatorUsername(){return this._spatial.creator.username}get exifOrientation(){return this._spatial.exif_orientation}get height(){return this._spatial.height}get image(){return this._cache.image}get image$(){return this._cache.image$}get id(){return this._core.id}get lngLat(){return null!=this._core.computed_geometry?this._core.computed_geometry:this._core.geometry}get merged(){return null!=this._spatial&&null!=this._spatial.merge_id}get mergeId(){return this._spatial.merge_id}get mesh(){return this._cache.mesh}get originalAltitude(){return this._spatial.altitude}get originalCompassAngle(){return this._spatial.compass_angle}get originalLngLat(){return this._core.geometry}get ownerId(){return this._spatial.owner?this._spatial.owner.id:null}get private(){return this._spatial.private}get qualityScore(){return this._spatial.quality_score}get rotation(){return this._spatial.computed_rotation}get scale(){return this._spatial.atomic_scale}get sequenceId(){return this._core.sequence?this._core.sequence.id:null}get sequenceEdges(){return this._cache.sequenceEdges}get sequenceEdges$(){return this._cache.sequenceEdges$}get spatialEdges(){return this._cache.spatialEdges}get spatialEdges$(){return this._cache.spatialEdges$}get width(){return this._spatial.width}cacheAssets$(){return this._cache.cacheAssets$(this._spatial,this.merged).pipe(rt((()=>this)))}cacheImage$(){return this._cache.cacheImage$(this._spatial).pipe(rt((()=>this)))}cacheSequenceEdges(t){this._cache.cacheSequenceEdges(t)}cacheSpatialEdges(t){this._cache.cacheSpatialEdges(t)}dispose(){null!=this._cache&&(this._cache.dispose(),this._cache=null),this._core=null,this._spatial=null}initializeCache(t){if(null!=this._cache)throw new Error(`Image cache already initialized (${this.id}).`);this._cache=t}makeComplete(t){if(null==t)throw new Error("Fill can not be null.");this._spatial=t}resetSequenceEdges(){this._cache.resetSequenceEdges()}resetSpatialEdges(){this._cache.resetSpatialEdges()}uncache(){null!=this._cache&&(this._cache.dispose(),this._cache=null)}}class id{constructor(t){this._disposed=!1,this._provider=t,this._image=null,this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$=new T,this._image$=this._imageChanged$.pipe(ni(null),Ue(1),E()),this._iamgeSubscription=this._image$.subscribe(),this._sequenceEdgesChanged$=new T,this._sequenceEdges$=this._sequenceEdgesChanged$.pipe(ni(this._sequenceEdges),Ue(1),E()),this._sequenceEdgesSubscription=this._sequenceEdges$.subscribe((()=>{})),this._spatialEdgesChanged$=new T,this._spatialEdges$=this._spatialEdgesChanged$.pipe(ni(this._spatialEdges),Ue(1),E()),this._spatialEdgesSubscription=this._spatialEdges$.subscribe((()=>{})),this._cachingAssets$=null}get image(){return this._image}get image$(){return this._image$}get mesh(){return this._mesh}get sequenceEdges(){return this._sequenceEdges}get sequenceEdges$(){return this._sequenceEdges$}get spatialEdges(){return this._spatialEdges}get spatialEdges$(){return this._spatialEdges$}cacheAssets$(t,e){return null!=this._cachingAssets$||(this._cachingAssets$=gt(this._cacheImage$(t),this._cacheMesh$(t,e)).pipe(rt((([t,e])=>(this._image=t,this._mesh=e,this))),Me((()=>{this._cachingAssets$=null})),Ue(1),E()),this._cachingAssets$.pipe(Ee((t=>!!t._image))).subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{}))),this._cachingAssets$}cacheImage$(t){if(null!=this._image)return G(this);const e=this._cacheImage$(t).pipe(Ee((t=>!!t)),pi((t=>{this._disposeImage(),this._image=t})),rt((()=>this)),Ue(1),E());return e.subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{})),e}cacheSequenceEdges(t){this._sequenceEdges={cached:!0,edges:t},this._sequenceEdgesChanged$.next(this._sequenceEdges)}cacheSpatialEdges(t){this._spatialEdges={cached:!0,edges:t},this._spatialEdgesChanged$.next(this._spatialEdges)}dispose(){this._iamgeSubscription.unsubscribe(),this._sequenceEdgesSubscription.unsubscribe(),this._spatialEdgesSubscription.unsubscribe(),this._disposeImage(),this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$.next(null),this._sequenceEdgesChanged$.next(this._sequenceEdges),this._spatialEdgesChanged$.next(this._spatialEdges),this._disposed=!0,null!=this._imageAborter&&(this._imageAborter(),this._imageAborter=null),null!=this._meshAborter&&(this._meshAborter(),this._meshAborter=null)}resetSequenceEdges(){this._sequenceEdges={cached:!1,edges:[]},this._sequenceEdgesChanged$.next(this._sequenceEdges)}resetSpatialEdges(){this._spatialEdges={cached:!1,edges:[]},this._spatialEdgesChanged$.next(this._spatialEdges)}_cacheImage$(t){return b.create((e=>{const i=new Promise(((t,e)=>{this._imageAborter=e})),n=t.thumb.url;if(n)this._provider.getImageBuffer(n,i).then((t=>{this._imageAborter=null;const i=new Image;i.crossOrigin="Anonymous",i.onload=()=>{if(this._disposed){window.URL.revokeObjectURL(i.src);const t=`Image load was aborted (${n})`;e.error(new Error(t))}else e.next(i),e.complete()},i.onerror=()=>{this._imageAborter=null,e.error(new Error(`Failed to load image (${n})`))};const r=new Blob([t]);i.src=window.URL.createObjectURL(r)}),(t=>{this._imageAborter=null,e.error(t)}));else{const i=t.thumb.id,r=`Incorrect thumb URL for ${t.id} (${i}, ${n})`;e.error(new Error(r))}}))}_cacheMesh$(t,e){return b.create((i=>{if(!e)return i.next(this._createEmptyMesh()),void i.complete();const n=t.mesh.url;if(!n){const e=t.mesh.id,r=`Incorrect mesh URL for ${t.id} (${e}, ${n})`;return console.warn(r),i.next(this._createEmptyMesh()),void i.complete()}const r=new Promise(((t,e)=>{this._meshAborter=e}));this._provider.getMesh(n,r).then((t=>{this._meshAborter=null,this._disposed||(i.next(t),i.complete())}),(t=>{this._meshAborter=null,console.error(t),i.next(this._createEmptyMesh()),i.complete()}))}))}_createEmptyMesh(){return{faces:[],vertices:[]}}_disposeImage(){null!=this._image&&window.URL.revokeObjectURL(this._image.src),this._image=null}}class nd{constructor(t){this._id=t.id,this._imageIds=t.image_ids}get id(){return this._id}get imageIds(){return this._imageIds}dispose(){this._id=null,this._imageIds=null}findNext(t){let e=this._imageIds.indexOf(t);return e+1>=this._imageIds.length||-1===e?null:this._imageIds[e+1]}findPrev(t){let e=this._imageIds.indexOf(t);return 0===e||-1===e?null:this._imageIds[e-1]}}class rd{constructor(){this.sphericalPreferredDistance=2,this.sphericalMotion=2,this.sphericalSequencePenalty=1,this.sphericalMergeCCPenalty=4,this.stepPreferredDistance=4,this.stepMotion=3,this.stepRotation=4,this.stepSequencePenalty=2,this.stepMergeCCPenalty=6,this.similarDistance=2,this.similarRotation=3,this.turnDistance=4,this.turnMotion=2,this.turnSequencePenalty=1,this.turnMergeCCPenalty=4}}var sd;t.NavigationDirection=void 0,(sd=t.NavigationDirection||(t.NavigationDirection={}))[sd.Next=0]="Next",sd[sd.Prev=1]="Prev",sd[sd.StepLeft=2]="StepLeft",sd[sd.StepRight=3]="StepRight",sd[sd.StepForward=4]="StepForward",sd[sd.StepBackward=5]="StepBackward",sd[sd.TurnLeft=6]="TurnLeft",sd[sd.TurnRight=7]="TurnRight",sd[sd.TurnU=8]="TurnU",sd[sd.Spherical=9]="Spherical",sd[sd.Similar=10]="Similar";class od{constructor(){this.steps={},this.turns={},this.spherical={},this.steps[t.NavigationDirection.StepForward]={direction:t.NavigationDirection.StepForward,motionChange:0,useFallback:!0},this.steps[t.NavigationDirection.StepBackward]={direction:t.NavigationDirection.StepBackward,motionChange:Math.PI,useFallback:!0},this.steps[t.NavigationDirection.StepLeft]={direction:t.NavigationDirection.StepLeft,motionChange:Math.PI/2,useFallback:!1},this.steps[t.NavigationDirection.StepRight]={direction:t.NavigationDirection.StepRight,motionChange:-Math.PI/2,useFallback:!1},this.turns[t.NavigationDirection.TurnLeft]={direction:t.NavigationDirection.TurnLeft,directionChange:Math.PI/2,motionChange:Math.PI/4},this.turns[t.NavigationDirection.TurnRight]={direction:t.NavigationDirection.TurnRight,directionChange:-Math.PI/2,motionChange:-Math.PI/4},this.turns[t.NavigationDirection.TurnU]={direction:t.NavigationDirection.TurnU,directionChange:Math.PI,motionChange:null},this.spherical[t.NavigationDirection.StepForward]={direction:t.NavigationDirection.StepForward,directionChange:0,next:t.NavigationDirection.StepLeft,prev:t.NavigationDirection.StepRight},this.spherical[t.NavigationDirection.StepBackward]={direction:t.NavigationDirection.StepBackward,directionChange:Math.PI,next:t.NavigationDirection.StepRight,prev:t.NavigationDirection.StepLeft},this.spherical[t.NavigationDirection.StepLeft]={direction:t.NavigationDirection.StepLeft,directionChange:Math.PI/2,next:t.NavigationDirection.StepBackward,prev:t.NavigationDirection.StepForward},this.spherical[t.NavigationDirection.StepRight]={direction:t.NavigationDirection.StepRight,directionChange:-Math.PI/2,next:t.NavigationDirection.StepForward,prev:t.NavigationDirection.StepBackward}}}class ad{constructor(){this.sphericalMinDistance=.1,this.sphericalMaxDistance=20,this.sphericalPreferredDistance=5,this.sphericalMaxItems=4,this.sphericalMaxStepTurnChange=Math.PI/8,this.rotationMaxDistance=this.turnMaxRigDistance,this.rotationMaxDirectionChange=Math.PI/6,this.rotationMaxVerticalDirectionChange=Math.PI/8,this.similarMaxDirectionChange=Math.PI/8,this.similarMaxDistance=12,this.similarMinTimeDifference=432e5,this.stepMaxDistance=20,this.stepMaxDirectionChange=Math.PI/6,this.stepMaxDrift=Math.PI/6,this.stepPreferredDistance=4,this.turnMaxDistance=15,this.turnMaxDirectionChange=2*Math.PI/9,this.turnMaxRigDistance=.65,this.turnMinRigDirectionChange=Math.PI/6}get maxDistance(){return Math.max(this.sphericalMaxDistance,this.similarMaxDistance,this.stepMaxDistance,this.turnMaxDistance)}}class cd extends Error{constructor(t){super(t),Object.setPrototypeOf(this,cd.prototype),this.name="MapillaryError"}}class hd extends cd{constructor(t){super(null!=t?t:"The argument is not valid."),Object.setPrototypeOf(this,hd.prototype),this.name="ArgumentMapillaryError"}}class ld{constructor(){this._epsilon=1e-9}azimuthalToBearing(t){return-t+Math.PI/2}degToRad(t){return Math.PI*t/180}radToDeg(t){return 180*t/Math.PI}rotationMatrix(t){let e=new fn(t[0],t[1],t[2]),i=e.length();return i>0&&e.normalize(),(new Hn).makeRotationAxis(e,i)}rotate(t,e){let i=new fn(t[0],t[1],t[2]),n=this.rotationMatrix(e);return i.applyMatrix4(n),i}opticalCenter(t,e){let i=[-t[0],-t[1],-t[2]],n=[-e[0],-e[1],-e[2]];return this.rotate(n,i)}viewingDirection(t){let e=[-t[0],-t[1],-t[2]];return this.rotate([0,0,1],e)}wrap(t,e,i){if(i<e)throw new Error("Invalid arguments: max must be larger than min.");let n=i-e;for(;t>i||t<e;)t>i?t-=n:t<e&&(t+=n);return t}wrapAngle(t){return this.wrap(t,-Math.PI,Math.PI)}clamp(t,e,i){return t<e?e:t>i?i:t}angleBetweenVector2(t,e,i,n){let r=Math.atan2(n,i)-Math.atan2(e,t);return this.wrapAngle(r)}angleDifference(t,e){let i=e-t;return this.wrapAngle(i)}relativeRotationAngle(t,e){let i=this.rotationMatrix([-t[0],-t[1],-t[2]]),n=this.rotationMatrix(e),r=i.multiply(n).elements,s=r[0]+r[5]+r[10];return Math.acos(Math.max(Math.min((s-1)/2,1),-1))}angleToPlane(t,e){let i=(new fn).fromArray(t),n=i.length();if(n<this._epsilon)return 0;let r=i.dot((new fn).fromArray(e));return Math.asin(r/n)}azimuthal(t,e){const i=(new fn).fromArray(t),n=(new fn).fromArray(e),r=i.clone().dot(n),s=i.clone().sub(n.clone().multiplyScalar(r));return Math.atan2(s.y,s.x)}distanceFromLngLat(t,e,i,n){let r=this.degToRad(n-e),s=this.degToRad(i-t),o=Math.sin(r/2)*Math.sin(r/2)+Math.cos(this.degToRad(e))*Math.cos(this.degToRad(n))*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))}}const ud=new ld;function dd(t){return"spherical"===t}function pd(t){return"fisheye"===t}function fd(t,e,i){const n=Ju(t.lng,t.lat,t.alt,i.lng,i.lat,i.alt),r=ud.rotate(n,e);return[-r.x,-r.y,-r.z]}function md(t,e,i,n,r){const s=[];for(let t=0;t<e.length;++t){const r=e[t],o=i[t];for(let t=0;t<=n;++t)s.push([r[0]+o[0]*t/n,r[1]+o[1]*t/n])}const o=new Ns;o.up.copy(t.upVector()),o.position.copy((new fn).fromArray(t.unprojectSfM([0,0],0))),o.lookAt((new fn).fromArray(t.unprojectSfM([0,0],10))),o.updateMatrix(),o.updateMatrixWorld(!0);return s.map((e=>{const i=t.unprojectBasic(e,1e4),n=r.worldToCamera(i,o);return[Math.abs(n[0]/n[2]),Math.abs(n[1]/n[2])]}))}class gd{constructor(t,e,i){this._spatial=new ld,this._settings=null!=t?t:new ad,this._directions=null!=e?e:new od,this._coefficients=null!=i?i:new rd}getPotentialEdges(t,e,i){if(!t.complete)throw new hd("Image has to be full.");if(!t.merged)return[];let n=this._spatial.viewingDirection(t.rotation),r=this._spatial.angleToPlane(n.toArray(),[0,0,1]),s=[];for(let o of e){if(!o.merged||o.id===t.id)continue;let e=Ju(o.lngLat.lng,o.lngLat.lat,o.computedAltitude,t.lngLat.lng,t.lngLat.lat,t.computedAltitude),a=new fn(e[0],e[1],e[2]),c=a.length();if(c>this._settings.maxDistance&&i.indexOf(o.id)<0)continue;let h=this._spatial.angleBetweenVector2(n.x,n.y,a.x,a.y),l=this._spatial.angleToPlane(a.toArray(),[0,0,1]),u=this._spatial.viewingDirection(o.rotation),d=this._spatial.angleBetweenVector2(n.x,n.y,u.x,u.y),p=this._spatial.angleToPlane(u.toArray(),[0,0,1])-r,f=this._spatial.relativeRotationAngle(t.rotation,o.rotation),m=this._spatial.angleBetweenVector2(1,0,a.x,a.y),g=null!=o.sequenceId&&null!=t.sequenceId&&o.sequenceId===t.sequenceId,_=o.mergeId===t.mergeId,v=o.creatorId===t.creatorId,y={capturedAt:o.capturedAt,directionChange:d,distance:c,spherical:dd(o.cameraType),id:o.id,motionChange:h,rotation:f,sameMergeCC:_,sameSequence:g,sameUser:v,sequenceId:o.sequenceId,verticalDirectionChange:p,verticalMotion:l,worldMotionAzimuth:m};s.push(y)}return s}computeSequenceEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");if(e.sequenceId!==i.id)throw new hd("Image and sequence does not correspond.");let n=[],r=i.findNext(e.id);null!=r&&n.push({data:{direction:t.NavigationDirection.Next,worldMotionAzimuth:Number.NaN},source:e.id,target:r});let s=i.findPrev(e.id);return null!=s&&n.push({data:{direction:t.NavigationDirection.Prev,worldMotionAzimuth:Number.NaN},source:e.id,target:s}),n}computeSimilarEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");let n=dd(e.cameraType),r={};for(let t of i)if(null!=t.sequenceId&&!t.sameSequence){if(n){if(!t.spherical)continue}else if(!t.spherical&&Math.abs(t.directionChange)>this._settings.similarMaxDirectionChange)continue;t.distance>this._settings.similarMaxDistance||t.sameUser&&Math.abs(t.capturedAt-e.capturedAt)<this._settings.similarMinTimeDifference||(null==r[t.sequenceId]&&(r[t.sequenceId]=[]),r[t.sequenceId].push(t))}let s=[],o=dd(e.cameraType)?t=>t.distance:t=>this._coefficients.similarDistance*t.distance+this._coefficients.similarRotation*t.rotation;for(let t in r){if(!r.hasOwnProperty(t))continue;let e=Number.MAX_VALUE,i=null;for(let n of r[t]){let t=o(n);t<e&&(e=t,i=n)}null!=i&&s.push(i)}return s.map((i=>({data:{direction:t.NavigationDirection.Similar,worldMotionAzimuth:i.worldMotionAzimuth},source:e.id,target:i.id})))}computeStepEdges(t,e,i,n){if(!t.complete)throw new hd("Image has to be full.");let r=[];if(dd(t.cameraType))return r;for(let s in this._directions.steps){if(!this._directions.steps.hasOwnProperty(s))continue;let o=this._directions.steps[s],a=Number.MAX_VALUE,c=null,h=null;for(let t of e){if(t.spherical)continue;if(Math.abs(t.directionChange)>this._settings.stepMaxDirectionChange)continue;let e=this._spatial.angleDifference(o.motionChange,t.motionChange),r=this._spatial.angleDifference(t.directionChange,e),s=Math.max(Math.abs(e),Math.abs(r));if(Math.abs(s)>this._settings.stepMaxDrift)continue;let l=t.id;if(!o.useFallback||l!==i&&l!==n||(h=t),t.distance>this._settings.stepMaxDistance)continue;e=Math.sqrt(e*e+t.verticalMotion*t.verticalMotion);let u=this._coefficients.stepPreferredDistance*Math.abs(t.distance-this._settings.stepPreferredDistance)/this._settings.stepMaxDistance+this._coefficients.stepMotion*e/this._settings.stepMaxDrift+this._coefficients.stepRotation*t.rotation/this._settings.stepMaxDirectionChange+this._coefficients.stepSequencePenalty*(t.sameSequence?0:1)+this._coefficients.stepMergeCCPenalty*(t.sameMergeCC?0:1);u<a&&(a=u,c=t)}c=null==c?h:c,null!=c&&r.push({data:{direction:o.direction,worldMotionAzimuth:c.worldMotionAzimuth},source:t.id,target:c.id})}return r}computeTurnEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");let n=[];if(dd(e.cameraType))return n;for(let r in this._directions.turns){if(!this._directions.turns.hasOwnProperty(r))continue;let s=this._directions.turns[r],o=Number.MAX_VALUE,a=null;for(let e of i){if(e.spherical)continue;if(e.distance>this._settings.turnMaxDistance)continue;let i,n=s.direction!==t.NavigationDirection.TurnU&&e.distance<this._settings.turnMaxRigDistance&&Math.abs(e.directionChange)>this._settings.turnMinRigDirectionChange,r=this._spatial.angleDifference(s.directionChange,e.directionChange);if(n&&e.directionChange*s.directionChange>0&&Math.abs(e.directionChange)<Math.abs(s.directionChange))i=-Math.PI/2+Math.abs(e.directionChange);else{if(Math.abs(r)>this._settings.turnMaxDirectionChange)continue;let t=s.motionChange?this._spatial.angleDifference(s.motionChange,e.motionChange):0;t=Math.sqrt(t*t+e.verticalMotion*e.verticalMotion),i=this._coefficients.turnDistance*e.distance/this._settings.turnMaxDistance+this._coefficients.turnMotion*t/Math.PI+this._coefficients.turnSequencePenalty*(e.sameSequence?0:1)+this._coefficients.turnMergeCCPenalty*(e.sameMergeCC?0:1)}i<o&&(o=i,a=e)}null!=a&&n.push({data:{direction:s.direction,worldMotionAzimuth:a.worldMotionAzimuth},source:e.id,target:a.id})}return n}computePerspectiveToSphericalEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");if(dd(e.cameraType))return[];let n=Number.MAX_VALUE,r=null;for(let t of i){if(!t.spherical)continue;let e=this._coefficients.sphericalPreferredDistance*Math.abs(t.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(t.motionChange)/Math.PI+this._coefficients.sphericalMergeCCPenalty*(t.sameMergeCC?0:1);e<n&&(n=e,r=t)}return null==r?[]:[{data:{direction:t.NavigationDirection.Spherical,worldMotionAzimuth:r.worldMotionAzimuth},source:e.id,target:r.id}]}computeSphericalEdges(e,i){if(!e.complete)throw new hd("Image has to be full.");if(!dd(e.cameraType))return[];let n=[],r=[],s=[];for(let t of i)if(!(t.distance>this._settings.sphericalMaxDistance))if(t.spherical){if(t.distance<this._settings.sphericalMinDistance)continue;r.push(t)}else for(let e in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(e))continue;let i=this._directions.spherical[e],n=this._spatial.angleDifference(t.directionChange,t.motionChange),r=this._spatial.angleDifference(i.directionChange,n);if(!(Math.abs(r)>this._settings.sphericalMaxStepTurnChange)){s.push([i.direction,t]);break}}let o=Math.PI/this._settings.sphericalMaxItems,a=[],c=[];for(let i=0;i<this._settings.sphericalMaxItems;i++){let s=i/this._settings.sphericalMaxItems*2*Math.PI,h=Number.MAX_VALUE,l=null;for(let t of r){let e=this._spatial.angleDifference(s,t.motionChange);if(Math.abs(e)>o)continue;let i=Number.MAX_VALUE;for(let e of a){let n=Math.abs(this._spatial.angleDifference(e,t.motionChange));n<i&&(i=n)}if(i<=o)continue;let n=this._coefficients.sphericalPreferredDistance*Math.abs(t.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(e)/o+this._coefficients.sphericalSequencePenalty*(t.sameSequence?0:1)+this._coefficients.sphericalMergeCCPenalty*(t.sameMergeCC?0:1);n<h&&(h=n,l=t)}null!=l?(a.push(l.motionChange),n.push({data:{direction:t.NavigationDirection.Spherical,worldMotionAzimuth:l.worldMotionAzimuth},source:e.id,target:l.id})):c.push(s)}let h={};h[t.NavigationDirection.Spherical]=a,h[t.NavigationDirection.StepForward]=[],h[t.NavigationDirection.StepLeft]=[],h[t.NavigationDirection.StepBackward]=[],h[t.NavigationDirection.StepRight]=[];for(let i of c){let r=[];for(let a in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(a))continue;let c=this._directions.spherical[a],l=h[t.NavigationDirection.Spherical].concat(h[c.direction]).concat(h[c.prev]).concat(h[c.next]),u=Number.MAX_VALUE,d=null;for(let t of s){if(t[0]!==c.direction)continue;let e=this._spatial.angleDifference(i,t[1].motionChange);if(Math.abs(e)>o)continue;let n=Number.MAX_VALUE;for(let e of l){let i=Math.abs(this._spatial.angleDifference(e,t[1].motionChange));i<n&&(n=i)}if(n<=o)continue;let r=this._coefficients.sphericalPreferredDistance*Math.abs(t[1].distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(e)/o+this._coefficients.sphericalMergeCCPenalty*(t[1].sameMergeCC?0:1);r<u&&(u=r,d=t)}null!=d&&(r.push(d),n.push({data:{direction:d[0],worldMotionAzimuth:d[1].worldMotionAzimuth},source:e.id,target:d[1].id}))}for(let t of r)h[t[0]].push(t[1].motionChange)}return n}}class _d extends cd{constructor(t){super(t),Object.setPrototypeOf(this,_d.prototype),this.name="GraphMapillaryError"}}class vd{constructor(t,e,i,n,r,s){this._api=t,this._cachedNodes={},this._cachedNodeTiles={},this._cachedSequenceNodes={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequenceNodes$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._changed$=new T,this._filterCreator=null!=r?r:new Si,this._filter=this._filterCreator.createFilter(void 0),this._filterSubject$=new T,this._filter$=At(G(this._filter),this._filterSubject$).pipe(Ue(1),E()),this._filterSubscription=this._filter$.subscribe((()=>{})),this._defaultAlt=2,this._edgeCalculator=null!=n?n:new gd,this._graphCalculator=null!=i?i:new td,this._configuration=null!=s?s:{maxSequences:50,maxUnusedImages:100,maxUnusedPreStoredImages:30,maxUnusedTiles:20},this._nodes={},this._nodeIndex=null!=e?e:new vd._spatialIndex(16),this._nodeIndexTiles={},this._nodeToTile={},this._preStored={},this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._tileThreshold=20}static register(t){vd._spatialIndex=t}get api(){return this._api}get changed$(){return this._changed$}get filter$(){return this._filter$}cacheBoundingBox$(t,e){const i=this._api.data.geometry.bboxToCellIds(t,e).filter((t=>!(t in this._cachedTiles))).map((t=>t in this._cachingTiles$?this._cachingTiles$[t]:this._cacheTile$(t)));return 0===i.length&&i.push(G(this)),bt(i).pipe(Et(),Re(),Mt((()=>{const i=this._nodeIndex.search({maxX:e.lng,maxY:e.lat,minX:t.lng,minY:t.lat}).map((t=>t.node)),n=[],r=[];for(const t of i)t.complete?n.push(t):r.push(t.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return Ot(G(n),bt(s.map((t=>this._api.getSpatialImages$(t).pipe(rt((t=>{const e=[];for(const i of t){if(!this.hasNode(i.node_id))continue;const t=this.getNode(i.node_id);t.complete||this._makeFull(t,i.node),e.push(t)}return e})))))).pipe(Et()))})),De(((t,e)=>t.concat(e))))}cacheCell$(t){return(t in this._cachedTiles?G(this):t in this._cachingTiles$?this._cachingTiles$[t]:this._cacheTile$(t)).pipe(Mt((()=>{const e=this._cachedTiles[t];e.accessed=(new Date).getTime();const i=e.nodes,n=[],r=[];for(const t of i)t.complete?n.push(t):r.push(t.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return Ot(G(n),bt(s.map((t=>this._api.getSpatialImages$(t).pipe(rt((t=>{const e=[];for(const i of t){if(!i.node){console.warn(`Image is empty (${i.node})`);continue}const t=i.node_id;if(!this.hasNode(t))continue;const n=this.getNode(t);n.complete||this._makeFull(n,i.node),e.push(n)}return e})))))).pipe(Et()))})),De(((t,e)=>t.concat(e))))}cacheFill$(t){if(t in this._cachingFull$)throw new _d(`Cannot fill node while caching full (${t}).`);if(!this.hasNode(t))throw new _d(`Cannot fill node that does not exist in graph (${t}).`);if(t in this._cachingFill$)return this._cachingFill$[t];const e=this.getNode(t);if(e.complete)throw new _d(`Cannot fill node that is already full (${t}).`);return this._cachingFill$[t]=this._api.getSpatialImages$([t]).pipe(pi((t=>{for(const i of t)i.node||console.warn(`Image is empty ${i.node_id}`),e.complete||this._makeFull(e,i.node),delete this._cachingFill$[i.node_id]})),rt((()=>this)),Me((()=>{t in this._cachingFill$&&delete this._cachingFill$[t],this._changed$.next(this)})),He(),E()),this._cachingFill$[t]}cacheFull$(t){if(t in this._cachingFull$)return this._cachingFull$[t];if(this.hasNode(t))throw new _d(`Cannot cache full node that already exist in graph (${t}).`);return this._cachingFull$[t]=this._api.getImages$([t]).pipe(pi((e=>{for(const i of e){if(!i.node)throw new _d(`Image does not exist (${t}, ${i.node}).`);const e=i.node_id;if(this.hasNode(e)){const e=this.getNode(t);e.complete||this._makeFull(e,i.node)}else{if(null==i.node.sequence.id)throw new _d(`Image has no sequence key (${t}).`);const n=new ed(i.node);this._makeFull(n,i.node);const r=this._api.data.geometry.lngLatToCellId(n.originalLngLat);this._preStore(r,n),this._setNode(n),delete this._cachingFull$[e]}}})),rt((()=>this)),Me((()=>{t in this._cachingFull$&&delete this._cachingFull$[t],this._changed$.next(this)})),He(),E()),this._cachingFull$[t]}cacheNodeSequence$(t){if(!this.hasNode(t))throw new _d(`Cannot cache sequence edges of node that does not exist in graph (${t}).`);let e=this.getNode(t);if(e.sequenceId in this._sequences)throw new _d(`Sequence already cached (${t}), (${e.sequenceId}).`);return this._cacheSequence$(e.sequenceId)}cacheSequence$(t){if(t in this._sequences)throw new _d(`Sequence already cached (${t})`);return this._cacheSequence$(t)}cacheSequenceEdges(t){let e=this.getNode(t);if(!(e.sequenceId in this._sequences))throw new _d(`Sequence is not cached (${t}), (${e.sequenceId})`);let i=this._sequences[e.sequenceId].sequence,n=this._edgeCalculator.computeSequenceEdges(e,i);e.cacheSequenceEdges(n)}cacheSequenceNodes$(t,e){if(!this.hasSequence(t))throw new _d(`Cannot cache sequence nodes of sequence that does not exist in graph (${t}).`);if(this.hasSequenceNodes(t))throw new _d(`Sequence nodes already cached (${t}).`);const i=this.getSequence(t);if(i.id in this._cachingSequenceNodes$)return this._cachingSequenceNodes$[i.id];const n=[],r=i.imageIds.slice();if(e&&r.length>50){const t=r.indexOf(e),i=Math.max(0,Math.min(t-25,r.length-50));n.push(r.splice(i,50))}for(;r.length>0;)n.push(r.splice(0,200));let s=n.length;const o=bt(n).pipe(Mt((t=>this._api.getImages$(t).pipe(pi((t=>{for(const e of t){if(!e.node){console.warn(`Image empty (${e.node_id})`);continue}const t=e.node_id;if(this.hasNode(t)){const i=this.getNode(t);i.complete||this._makeFull(i,e.node)}else{null==e.node.sequence.id&&console.warn(`Sequence missing, discarding node (${e.node_id})`);const t=new ed(e.node);this._makeFull(t,e.node);const i=this._api.data.geometry.lngLatToCellId(t.originalLngLat);this._preStore(i,t),this._setNode(t)}}s--})),rt((()=>this)))),6),Re(),Me((()=>{delete this._cachingSequenceNodes$[i.id],0===s&&(this._cachedSequenceNodes[i.id]=!0)})),He(),E());return this._cachingSequenceNodes$[i.id]=o,o}cacheSpatialArea$(t){if(!this.hasNode(t))throw new _d(`Cannot cache spatial area of node that does not exist in graph (${t}).`);if(t in this._cachedSpatialEdges)throw new _d(`Image already spatially cached (${t}).`);if(!(t in this._requiredSpatialArea))throw new _d(`Spatial area not determined (${t}).`);let e=this._requiredSpatialArea[t];if(0===Object.keys(e.cacheNodes).length)throw new _d(`Spatial nodes already cached (${t}).`);if(t in this._cachingSpatialArea$)return this._cachingSpatialArea$[t];let i=[];for(;e.cacheKeys.length>0;)i.push(e.cacheKeys.splice(0,200));let n=i.length,r=[];for(let s of i){let i=this._api.getSpatialImages$(s).pipe(pi((i=>{for(const t of i){if(!t.node){console.warn(`Image is empty (${t.node_id})`);continue}const i=t.node_id,n=e.cacheNodes[i];n.complete?delete e.cacheNodes[i]:(this._makeFull(n,t.node),delete e.cacheNodes[i])}0==--n&&delete this._cachingSpatialArea$[t]})),rt((()=>this)),te((i=>{for(let t of s)t in e.all&&delete e.all[t],t in e.cacheNodes&&delete e.cacheNodes[t];throw 0==--n&&delete this._cachingSpatialArea$[t],i})),Me((()=>{0===Object.keys(e.cacheNodes).length&&this._changed$.next(this)})),He(),E());r.push(i)}return this._cachingSpatialArea$[t]=r,r}cacheSpatialEdges(t){if(t in this._cachedSpatialEdges)throw new _d(`Spatial edges already cached (${t}).`);let e=this.getNode(t),i=this._sequences[e.sequenceId].sequence,n=[],r=i.findPrev(e.id);null!=r&&n.push(r);let s=i.findNext(e.id);null!=s&&n.push(s);let o=this._requiredSpatialArea[t].all,a=[],c=this._filter;for(let t in o){if(!o.hasOwnProperty(t))continue;let e=o[t];c(e)&&a.push(e)}let h=this._edgeCalculator.getPotentialEdges(e,a,n),l=this._edgeCalculator.computeStepEdges(e,h,r,s);l=l.concat(this._edgeCalculator.computeTurnEdges(e,h)),l=l.concat(this._edgeCalculator.computeSphericalEdges(e,h)),l=l.concat(this._edgeCalculator.computePerspectiveToSphericalEdges(e,h)),l=l.concat(this._edgeCalculator.computeSimilarEdges(e,h)),e.cacheSpatialEdges(l),this._cachedSpatialEdges[t]=e,delete this._requiredSpatialArea[t],delete this._cachedNodeTiles[t]}cacheTiles$(t){if(t in this._cachedNodeTiles)throw new _d(`Tiles already cached (${t}).`);if(t in this._cachedSpatialEdges)throw new _d(`Spatial edges already cached so tiles considered cached (${t}).`);if(!(t in this._requiredNodeTiles))throw new _d(`Tiles have not been determined (${t}).`);let e=this._requiredNodeTiles[t];if(0===e.cache.length&&0===e.caching.length)throw new _d(`Tiles already cached (${t}).`);if(!this.hasNode(t))throw new _d(`Cannot cache tiles of node that does not exist in graph (${t}).`);let i=e.cache.slice();e.caching=this._requiredNodeTiles[t].caching.concat(i),e.cache=[];let n=[];for(let i of e.caching){const r=i in this._cachingTiles$?this._cachingTiles$[i]:this._cacheTile$(i);n.push(r.pipe(pi((n=>{let r=e.caching.indexOf(i);r>-1&&e.caching.splice(r,1),0===e.caching.length&&0===e.cache.length&&(delete this._requiredNodeTiles[t],this._cachedNodeTiles[t]=!0)})),te((n=>{let r=e.caching.indexOf(i);throw r>-1&&e.caching.splice(r,1),0===e.caching.length&&0===e.cache.length&&(delete this._requiredNodeTiles[t],this._cachedNodeTiles[t]=!0),n})),Me((()=>{this._changed$.next(this)})),He(),E()))}return n}initializeCache(t){if(t in this._cachedNodes)throw new _d(`Image already in cache (${t}).`);const e=this.getNode(t),i=this._api.data;e.initializeCache(new id(i));const n=(new Date).getTime();this._cachedNodes[t]={accessed:n,node:e},this._updateCachedTileAccess(t,n)}isCachingFill(t){return t in this._cachingFill$}isCachingFull(t){return t in this._cachingFull$}isCachingNodeSequence(t){return this.getNode(t).sequenceId in this._cachingSequences$}isCachingSequence(t){return t in this._cachingSequences$}isCachingSequenceNodes(t){return t in this._cachingSequenceNodes$}isCachingTiles(t){return t in this._requiredNodeTiles&&0===this._requiredNodeTiles[t].cache.length&&this._requiredNodeTiles[t].caching.length>0}hasInitializedCache(t){return t in this._cachedNodes}hasNode(t){let e=(new Date).getTime();return this._updateCachedNodeAccess(t,e),this._updateCachedTileAccess(t,e),t in this._nodes}hasNodeSequence(t){let e=this.getNode(t).sequenceId,i=e in this._sequences;return i&&(this._sequences[e].accessed=(new Date).getTime()),i}hasSequence(t){let e=t in this._sequences;return e&&(this._sequences[t].accessed=(new Date).getTime()),e}hasSequenceNodes(t){return t in this._cachedSequenceNodes}hasSpatialArea(t){if(!this.hasNode(t))throw new _d(`Spatial area nodes cannot be determined if node not in graph (${t}).`);if(t in this._cachedSpatialEdges)return!0;if(t in this._requiredSpatialArea)return 0===Object.keys(this._requiredSpatialArea[t].cacheNodes).length;let e=this.getNode(t),i=this._graphCalculator.boundingBoxCorners(e.lngLat,this._tileThreshold),n=this._nodeIndex.search({maxX:i[1].lng,maxY:i[1].lat,minX:i[0].lng,minY:i[0].lat}),r={all:{},cacheKeys:[],cacheNodes:{}};for(let t of n)r.all[t.node.id]=t.node,t.node.complete||(r.cacheKeys.push(t.node.id),r.cacheNodes[t.node.id]=t.node);return this._requiredSpatialArea[t]=r,0===r.cacheKeys.length}hasTiles(t){if(t in this._cachedNodeTiles)return!0;if(t in this._cachedSpatialEdges)return!0;if(!this.hasNode(t))throw new _d(`Image does not exist in graph (${t}).`);let e={cache:[],caching:[]};if(t in this._requiredNodeTiles)e=this._requiredNodeTiles[t];else{const i=this.getNode(t),[n,r]=this._graphCalculator.boundingBoxCorners(i.lngLat,this._tileThreshold);e.cache=this._api.data.geometry.bboxToCellIds(n,r).filter((t=>!(t in this._cachedTiles))),e.cache.length>0&&(this._requiredNodeTiles[t]=e)}return 0===e.cache.length&&0===e.caching.length}getNode(t){let e=(new Date).getTime();return this._updateCachedNodeAccess(t,e),this._updateCachedTileAccess(t,e),this._nodes[t]}getSequence(t){let e=this._sequences[t];return e.accessed=(new Date).getTime(),e.sequence}resetSpatialEdges(){let t=Object.keys(this._cachedSpatialEdges);for(let e of t){this._cachedSpatialEdges[e].resetSpatialEdges(),delete this._cachedSpatialEdges[e]}}reset(t){const e=[];for(const i of t){if(!this.hasNode(i))throw new Error(`Image does not exist ${i}`);const t=this.getNode(i);t.resetSequenceEdges(),t.resetSpatialEdges(),e.push(t)}for(let e of Object.keys(this._cachedNodes))-1===t.indexOf(e)&&(this._cachedNodes[e].node.dispose(),delete this._cachedNodes[e]);this._cachedNodeTiles={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._nodes={},this._nodeToTile={},this._preStored={};for(const t of e){this._nodes[t.id]=t;const e=this._api.data.geometry.lngLatToCellId(t.originalLngLat);this._preStore(e,t)}this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._nodeIndexTiles={},this._nodeIndex.clear()}setFilter(t){this._filter=this._filterCreator.createFilter(t),this._filterSubject$.next(this._filter)}uncache(t,e,i){const n={};this._addNewKeys(n,this._cachingFull$),this._addNewKeys(n,this._cachingFill$),this._addNewKeys(n,this._cachingSpatialArea$),this._addNewKeys(n,this._requiredNodeTiles),this._addNewKeys(n,this._requiredSpatialArea);for(const e of t)e in n||(n[e]=!0);const r=this._tileThreshold,s=this._graphCalculator,o=this._api.data.geometry,a=new Set(e);for(let t in n){if(!n.hasOwnProperty(t))continue;const e=this._nodes[t],[i,c]=s.boundingBoxCorners(e.lngLat,r),h=o.bboxToCellIds(i,c);for(const t of h)a.has(t)||a.add(t)}const c=[];for(let t in this._cachedTiles)this._cachedTiles.hasOwnProperty(t)&&!a.has(t)&&c.push([t,this._cachedTiles[t]]);const h=c.sort(((t,e)=>e[1].accessed-t[1].accessed)).slice(this._configuration.maxUnusedTiles).map((t=>t[0]));for(let t of h)this._uncacheTile(t,i);const l=[],u=[];for(let t in this._preStored){if(!this._preStored.hasOwnProperty(t)||t in this._cachingTiles$)continue;const e=this._preStored[t];for(let r in e)e.hasOwnProperty(r)&&!(r in n)&&e[r].sequenceId!==i&&(r in this._cachedNodes?l.push([this._cachedNodes[r],t]):u.push([r,t]))}const d=l.sort((([t],[e])=>e.accessed-t.accessed)).slice(this._configuration.maxUnusedPreStoredImages).map((([t,e])=>[t.node.id,e]));this._uncachePreStored(u),this._uncachePreStored(d);const p=[];for(let t in this._cachedNodes)this._cachedNodes.hasOwnProperty(t)&&!(t in n)&&p.push(this._cachedNodes[t]);const f=p.sort(((t,e)=>e.accessed-t.accessed)).slice(this._configuration.maxUnusedImages);for(const t of f){t.node.uncache();const e=t.node.id;delete this._cachedNodes[e],e in this._cachedNodeTiles&&delete this._cachedNodeTiles[e],e in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[e]}const m=[];for(let t in this._sequences)this._sequences.hasOwnProperty(t)&&!(t in this._cachingSequences$)&&t!==i&&m.push(this._sequences[t]);const g=m.sort(((t,e)=>e.accessed-t.accessed)).slice(this._configuration.maxSequences);for(const t of g){const e=t.sequence.id;delete this._sequences[e],e in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[e],t.sequence.dispose()}}updateCells$(t){const e=this._cachedTiles,i=this._cachingTiles$;return bt(t).pipe(Mt((t=>t in e?this._updateCell$(t):t in i?i[t].pipe(te((()=>G(this))),Mt((()=>this._updateCell$(t)))):B())))}unsubscribe(){this._filterSubscription.unsubscribe()}_addNewKeys(t,e){for(let i in e)e.hasOwnProperty(i)&&this.hasNode(i)&&(i in t||(t[i]=!0))}_cacheSequence$(t){return t in this._cachingSequences$||(this._cachingSequences$[t]=this._api.getSequence$(t).pipe(pi((e=>{e?(e.id in this._sequences||(this._sequences[e.id]={accessed:(new Date).getTime(),sequence:new nd(e)}),delete this._cachingSequences$[t]):console.warn(`Sequence does not exist (${t})`)})),rt((()=>this)),Me((()=>{t in this._cachingSequences$&&delete this._cachingSequences$[t],this._changed$.next(this)})),He(),E())),this._cachingSequences$[t]}_cacheTile$(t){return this._cachingTiles$[t]=this._api.getCoreImages$(t).pipe(pi((e=>{if(t in this._cachedTiles)return;const i=e.images;this._nodeIndexTiles[t]=[],this._cachedTiles[t]={accessed:(new Date).getTime(),nodes:[]};const n=this._cachedTiles[t].nodes,r=this._removeFromPreStore(t);for(const e of i){if(!e)break;if(null==e.sequence.id){console.warn(`Sequence missing, discarding node (${e.id})`);continue}if(null!=r&&e.id in r){const i=r[e.id];delete r[e.id],n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[t].push(s),this._nodeToTile[i.id]=t;continue}const i=new ed(e);n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[t].push(s),this._nodeToTile[i.id]=t,this._setNode(i)}delete this._cachingTiles$[t]})),rt((()=>this)),te((e=>{throw delete this._cachingTiles$[t],e})),He(),E()),this._cachingTiles$[t]}_makeFull(t,e){null==e.computed_altitude&&(e.computed_altitude=this._defaultAlt),null==e.computed_rotation&&(e.computed_rotation=this._graphCalculator.rotationFromCompass(e.compass_angle,e.exif_orientation)),t.makeComplete(e)}_preStore(t,e){t in this._preStored||(this._preStored[t]={}),this._preStored[t][e.id]=e}_removeFromPreStore(t){let e=null;return t in this._preStored&&(e=this._preStored[t],delete this._preStored[t]),e}_setNode(t){let e=t.id;if(this.hasNode(e))throw new _d(`Image already exist (${e}).`);this._nodes[e]=t}_uncacheTile(t,e){for(let i of this._cachedTiles[t].nodes){let n=i.id;delete this._nodeToTile[n],n in this._cachedNodes&&delete this._cachedNodes[n],n in this._cachedNodeTiles&&delete this._cachedNodeTiles[n],n in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[n],i.sequenceId===e?(this._preStore(t,i),i.uncache()):(delete this._nodes[n],i.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[i.sequenceId],i.dispose())}for(let e of this._nodeIndexTiles[t])this._nodeIndex.remove(e);delete this._nodeIndexTiles[t],delete this._cachedTiles[t]}_uncachePreStored(t){let e={};for(let[i,n]of t){i in this._nodes&&delete this._nodes[i],i in this._cachedNodes&&delete this._cachedNodes[i];let t=this._preStored[n][i];t.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[t.sequenceId],delete this._preStored[n][i],t.dispose(),e[n]=!0}for(let t in e)e.hasOwnProperty(t)&&0===Object.keys(this._preStored[t]).length&&delete this._preStored[t]}_updateCachedTileAccess(t,e){t in this._nodeToTile&&(this._cachedTiles[this._nodeToTile[t]].accessed=e)}_updateCachedNodeAccess(t,e){t in this._cachedNodes&&(this._cachedNodes[t].accessed=e)}_updateCell$(t){return this._api.getCoreImages$(t).pipe(Mt((e=>{if(!(t in this._cachedTiles))return B();const i=this._nodeIndex,n=this._nodeIndexTiles[t],r=this._nodeToTile,s=this._cachedTiles[t];s.accessed=(new Date).getTime();const o=s.nodes,a=e.images;for(const e of a){if(null==e)break;if(this.hasNode(e.id))continue;if(null==e.sequence.id){console.warn(`Sequence missing, discarding node (${e.id})`);continue}const s=new ed(e);o.push(s);const a={lat:s.lngLat.lat,lng:s.lngLat.lng,node:s};i.insert(a),n.push(a),r[s.id]=t,this._setNode(s)}return G(t)})),te((t=>(console.error(t),B()))))}}class yd{constructor(){this._hash={},this._index=new yd._spatialIndex(16),this._indexChanged$=new T,this._updated$=new T}static register(t){yd._spatialIndex=t}get changed$(){return this._indexChanged$}get updated$(){return this._updated$}add(t){const e=[],i=this._hash,n=this._index;for(const r of t){const t=r.id;t in i&&(n.remove(i[t]),e.push(r));const s={lat:r.lngLat.lat,lng:r.lngLat.lng,marker:r};i[t]=s,n.insert(s)}e.length>0&&this._updated$.next(e),t.length>e.length&&this._indexChanged$.next(this)}has(t){return t in this._hash}get(t){return this.has(t)?this._hash[t].marker:void 0}getAll(){return this._index.all().map((t=>t.marker))}remove(t){const e=this._hash,i=this._index;let n=!1;for(const r of t){if(!(r in e))continue;const t=e[r];i.remove(t),delete e[r],n=!0}n&&this._indexChanged$.next(this)}removeAll(){this._hash={},this._index.clear(),this._indexChanged$.next(this)}search([t,e]){return this._index.search({maxX:e.lng,maxY:e.lat,minX:t.lng,minY:t.lat}).map((t=>t.marker))}update(t){const e=this._hash,i=this._index,n=t.id;if(!(n in e))return;i.remove(e[n]);const r={lat:t.lngLat.lat,lng:t.lngLat.lng,marker:t};e[n]=r,i.insert(r)}}function bd(t,e,i,n,r){xd(t,e,i||0,n||t.length-1,r||Sd)}function xd(t,e,i,n,r){for(;n>i;){if(n-i>600){var s=n-i+1,o=e-i+1,a=Math.log(s),c=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*c*(s-c)/s)*(o-s/2<0?-1:1);xd(t,e,Math.max(i,Math.floor(e-o*c/s+h)),Math.min(n,Math.floor(e+(s-o)*c/s+h)),r)}var l=t[e],u=i,d=n;for(wd(t,i,e),r(t[n],l)>0&&wd(t,i,n);u<d;){for(wd(t,u,d),u++,d--;r(t[u],l)<0;)u++;for(;r(t[d],l)>0;)d--}0===r(t[i],l)?wd(t,i,d):wd(t,++d,n),d<=e&&(i=d+1),e<=d&&(n=d-1)}}function wd(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Sd(t,e){return t<e?-1:t>e?1:0}function Md(t,e,i){if(!i)return e.indexOf(t);for(let n=0;n<e.length;n++)if(i(t,e[n]))return n;return-1}function Td(t,e){Cd(t,0,t.children.length,e,t)}function Cd(t,e,i,n,r){r||(r=Dd(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<i;s++){const e=t.children[s];Ed(r,t.leaf?n(e):e)}return r}function Ed(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Id(t,e){return t.minX-e.minX}function Ad(t,e){return t.minY-e.minY}function Pd(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Rd(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Ld(t,e){const i=Math.max(t.minX,e.minX),n=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function Od(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Nd(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Dd(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function $d(t,e,i,n,r){const s=[e,i];for(;s.length;){if((i=s.pop())-(e=s.pop())<=n)continue;const o=e+Math.ceil((i-e)/n/2)*n;bd(t,o,e,i,r),s.push(e,o,o,i)}}class kd extends class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Nd(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let s=0;s<e.children.length;s++){const o=e.children[s],a=e.leaf?n(o):o;Nd(t,a)&&(e.leaf?i.push(o):Od(t,a)?this._all(o,i):r.push(o))}e=r.pop()}return i}collides(t){let e=this.data;if(!Nd(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const r=e.children[n],s=e.leaf?this.toBBox(r):r;if(Nd(t,s)){if(e.leaf||Od(t,s))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Dd([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),r=[],s=[];let o,a,c;for(;i||r.length;){if(i||(i=r.pop(),a=r[r.length-1],o=s.pop(),c=!0),i.leaf){const n=Md(t,i.children,e);if(-1!==n)return i.children.splice(n,1),r.push(i),this._condense(r),this}c||i.leaf||!Od(i,n)?a?(o++,i=a.children[o],c=!1):i=null:(r.push(i),s.push(o),o=0,a=i,i=i.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,n){const r=i-e+1;let s,o=this._maxEntries;if(r<=o)return s=Dd(t.slice(e,i+1)),Td(s,this.toBBox),s;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),s=Dd([]),s.leaf=!1,s.height=n;const a=Math.ceil(r/o),c=a*Math.ceil(Math.sqrt(o));$d(t,e,i,c,this.compareMinX);for(let r=e;r<=i;r+=c){const e=Math.min(r+c-1,i);$d(t,r,e,a,this.compareMinY);for(let i=r;i<=e;i+=a){const r=Math.min(i+a-1,e);s.children.push(this._build(t,i,r,n-1))}}return Td(s,this.toBBox),s}_chooseSubtree(t,e,i,n){for(;n.push(e),!e.leaf&&n.length-1!==i;){let i,n=1/0,o=1/0;for(let a=0;a<e.children.length;a++){const c=e.children[a],h=Pd(c),l=(r=t,s=c,(Math.max(s.maxX,r.maxX)-Math.min(s.minX,r.minX))*(Math.max(s.maxY,r.maxY)-Math.min(s.minY,r.minY))-h);l<o?(o=l,n=h<n?h:n,i=c):l===o&&h<n&&(n=h,i=c)}e=i||e.children[0]}var r,s;return e}_insert(t,e,i){const n=i?t:this.toBBox(t),r=[],s=this._chooseSubtree(n,this.data,e,r);for(s.children.push(t),Ed(s,n);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const s=this._chooseSplitIndex(i,r,n),o=Dd(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,Td(i,this.toBBox),Td(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=Dd([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Td(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,s=1/0;for(let o=e;o<=i-e;o++){const e=Cd(t,0,o,this.toBBox),a=Cd(t,o,i,this.toBBox),c=Ld(e,a),h=Pd(e)+Pd(a);c<r?(r=c,n=o,s=h<s?h:s):c===r&&h<s&&(s=h,n=o)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:Id,r=t.leaf?this.compareMinY:Ad;this._allDistMargin(t,e,i,n)<this._allDistMargin(t,e,i,r)&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const r=this.toBBox,s=Cd(t,0,e,r),o=Cd(t,i-e,i,r);let a=Rd(s)+Rd(o);for(let n=e;n<i-e;n++){const e=t.children[n];Ed(s,t.leaf?r(e):e),a+=Rd(s)}for(let n=i-e-1;n>=e;n--){const e=t.children[n];Ed(o,t.leaf?r(e):e),a+=Rd(o)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Ed(e[n],t)}_condense(t){for(let e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children,e.splice(e.indexOf(t[i]),1)):this.clear():Td(t[i],this.toBBox)}}{compareMinX(t,e){return t.lng-e.lng}compareMinY(t,e){return t.lat-e.lat}toBBox(t){return{minX:t.lng,minY:t.lat,maxX:t.lng,maxY:t.lat}}}var zd,Fd=Bd;function Bd(t,e,i,n){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=i,this.p2y=n}Bd.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},Bd.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},Bd.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},Bd.prototype.solveCurveX=function(t,e){var i,n,r,s,o;for(void 0===e&&(e=1e-6),r=t,o=0;o<8;o++){if(s=this.sampleCurveX(r)-t,Math.abs(s)<e)return r;var a=this.sampleCurveDerivativeX(r);if(Math.abs(a)<1e-6)break;r-=s/a}if((r=t)<(i=0))return i;if(r>(n=1))return n;for(;i<n;){if(s=this.sampleCurveX(r),Math.abs(s-t)<e)return r;t>s?i=r:n=r,r=.5*(n-i)+i}return r},Bd.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))},t.TransitionMode=void 0,(zd=t.TransitionMode||(t.TransitionMode={}))[zd.Default=0]="Default",zd[zd.Instantaneous=1]="Instantaneous";class jd{constructor(t){null!=t?(this._position=(new fn).fromArray(t.unprojectSfM([0,0],0)),this._lookat=(new fn).fromArray(t.unprojectSfM([0,0],10)),this._up=t.upVector(),this._focal=this._getFocal(t)):(this._position=new fn(0,0,0),this._lookat=new fn(1,0,0),this._up=new fn(0,0,1),this._focal=1)}get position(){return this._position}get lookat(){return this._lookat}get up(){return this._up}get focal(){return this._focal}set focal(t){this._focal=t}lerpCameras(t,e,i){this._position.subVectors(e.position,t.position).multiplyScalar(i).add(t.position),this._lookat.subVectors(e.lookat,t.lookat).multiplyScalar(i).add(t.lookat),this._up.subVectors(e.up,t.up).multiplyScalar(i).add(t.up),this._focal=(1-i)*t.focal+i*e.focal}copy(t){this._position.copy(t.position),this._lookat.copy(t.lookat),this._up.copy(t.up),this._focal=t.focal}clone(){let t=new jd;return t.position.copy(this._position),t.lookat.copy(this._lookat),t.up.copy(this._up),t.focal=this._focal,t}diff(t){let e=this._position.distanceToSquared(t.position),i=this._lookat.distanceToSquared(t.lookat),n=this._up.distanceToSquared(t.up),r=100*Math.abs(this._focal-t.focal);return Math.max(e,i,n,r)}_getFocal(t){return dd(t.cameraType)?.5/Math.tan(Math.PI/2):t.focal}}class Hd{constructor(t,e,i,n,r,s,o,a,c,h){this._orientation=this._getValue(t,1);let l=null!=o?o.width:4,u=null!=o?o.height:3,d=this._orientation<5;this._width=this._getValue(e,d?l:u),this._height=this._getValue(i,d?u:l),this._basicAspect=d?this._width/this._height:this._height/this._width,this._basicWidth=d?e:i,this._basicHeight=d?i:e;const p=this._getCameraParameters(c,h),f=p[0],m=p[1],g=p[2];this._focal=this._getValue(f,1),this._scale=this._getValue(n,0),this._worldToCamera=this.createWorldToCamera(r,s),this._worldToCameraInverse=(new Hn).copy(this._worldToCamera).invert(),this._scaledWorldToCamera=this._createScaledWorldToCamera(this._worldToCamera,this._scale),this._scaledWorldToCameraInverse=(new Hn).copy(this._scaledWorldToCamera).invert(),this._basicWorldToCamera=this._createBasicWorldToCamera(this._worldToCamera,t),this._textureScale=a||[1,1],this._ck1=m||0,this._ck2=g||0,this._cameraType=h||"perspective",this._radialPeak=this._getRadialPeak(this._ck1,this._ck2)}get ck1(){return this._ck1}get ck2(){return this._ck2}get cameraType(){return this._cameraType}get basicAspect(){return this._basicAspect}get basicHeight(){return this._basicHeight}get basicRt(){return this._basicWorldToCamera}get basicWidth(){return this._basicWidth}get focal(){return this._focal}get height(){return this._height}get orientation(){return this._orientation}get rt(){return this._worldToCamera}get srt(){return this._scaledWorldToCamera}get srtInverse(){return this._scaledWorldToCameraInverse}get scale(){return this._scale}get hasValidScale(){return this._scale>.01&&this._scale<50}get radialPeak(){return this._radialPeak}get width(){return this._width}upVector(){let t=this._worldToCamera.elements;switch(this._orientation){case 1:return new fn(-t[1],-t[5],-t[9]);case 3:return new fn(t[1],t[5],t[9]);case 6:return new fn(-t[0],-t[4],-t[8]);case 8:return new fn(t[0],t[4],t[8]);default:return new fn(-t[1],-t[5],-t[9])}}projectorMatrix(){let t=this._normalizedToTextureMatrix(),e=this._focal,i=(new Hn).set(e,0,0,0,0,e,0,0,0,0,0,0,0,0,1,0);return t.multiply(i),t.multiply(this._worldToCamera),t}projectBasic(t){let e=this.projectSfM(t);return this._sfmToBasic(e)}unprojectBasic(t,e,i){let n=this._basicToSfm(t);return this.unprojectSfM(n,e,i)}projectSfM(t){let e=new un(t[0],t[1],t[2],1);return e.applyMatrix4(this._worldToCamera),this._bearingToSfm([e.x,e.y,e.z])}unprojectSfM(t,e,i){const n=this._sfmToBearing(t),r=(i&&!dd(this._cameraType)?new un(e*n[0]/n[2],e*n[1]/n[2],e,1):new un(e*n[0],e*n[1],e*n[2],1)).applyMatrix4(this._worldToCameraInverse);return[r.x/r.w,r.y/r.w,r.z/r.w]}_sfmToBearing(t){if(dd(this._cameraType)){let e=2*t[0]*Math.PI,i=2*-t[1]*Math.PI;return[Math.cos(i)*Math.sin(e),-Math.sin(i),Math.cos(i)*Math.cos(e)]}if(pd(this._cameraType)){let[e,i]=[t[0]/this._focal,t[1]/this._focal];const n=Math.sqrt(e*e+i*i);let r=n/this._distortionFromDistortedRadius(n,this._ck1,this._ck2,this._radialPeak),s=Math.cos(r),o=Math.sin(r);const a=n>1e-8?1/n:1;return[o*e*a,o*i*a,s]}{let[e,i]=[t[0]/this._focal,t[1]/this._focal];const n=Math.sqrt(e*e+i*i);let r=this._distortionFromDistortedRadius(n,this._ck1,this._ck2,this._radialPeak);let s=new fn(e/r,i/r,1);return s.normalize(),[s.x,s.y,s.z]}}_distortionFromDistortedRadius(t,e,i,n){let r=1;for(let s=0;s<10;s++){let s=t/r;s>n&&(s=n),r=1+e*Math.pow(s,2)+i*Math.pow(s,4)}return r}_bearingToSfm(t){if(dd(this._cameraType)){let e=t[0],i=t[1],n=t[2],r=Math.atan2(e,n),s=Math.atan2(-i,Math.sqrt(e*e+n*n));return[r/(2*Math.PI),-s/(2*Math.PI)]}if(pd(this._cameraType)){if(t[2]>0){const[e,i,n]=t,r=Math.sqrt(e*e+i*i);let s=Math.atan2(r,n);s>this._radialPeak&&(s=this._radialPeak);const o=1+Math.pow(s,2)*(this._ck1+Math.pow(s,2)*this._ck2),a=this._focal*o*s/r;return[a*e,a*i]}return[t[0]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,t[1]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY]}if(t[2]>0){let[e,i]=[t[0]/t[2],t[1]/t[2]],n=e*e+i*i;const r=Math.pow(this._radialPeak,2);n>r&&(n=r);const s=1+this._ck1*n+this._ck2*Math.pow(n,2);return[this._focal*s*e,this._focal*s*i]}return[t[0]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,t[1]<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY]}_basicToSfm(t){let e,i;switch(this._orientation){case 1:e=t[0],i=t[1];break;case 3:e=1-t[0],i=1-t[1];break;case 6:e=t[1],i=1-t[0];break;case 8:e=1-t[1],i=t[0];break;default:e=t[0],i=t[1]}let n=this._width,r=this._height,s=Math.max(n,r);return[e*n/s-n/s/2,i*r/s-r/s/2]}_sfmToBasic(t){let e,i,n=this._width,r=this._height,s=Math.max(n,r),o=(t[0]+n/s/2)/n*s,a=(t[1]+r/s/2)/r*s;switch(this._orientation){case 1:e=o,i=a;break;case 3:e=1-o,i=1-a;break;case 6:e=1-a,i=o;break;case 8:e=a,i=1-o;break;default:e=o,i=a}return[e,i]}_getValue(t,e){return null!=t&&t>0?t:e}_getCameraParameters(t,e){if(dd(e))return[];if(!t||0===t.length)return[1,0,0];const i=3-t.length;return i<=0?t:t.concat(new Array(i).fill(0))}createWorldToCamera(t,e){const i=new fn(t[0],t[1],t[2]),n=i.length();n>0&&i.normalize();const r=new Hn;return r.makeRotationAxis(i,n),r.setPosition(new fn(e[0],e[1],e[2])),r}_createScaledWorldToCamera(t,e){const i=t.clone(),n=i.elements;return n[12]=e*n[12],n[13]=e*n[13],n[14]=e*n[14],i.scale(new fn(e,e,e)),i}_createBasicWorldToCamera(t,e){const i=new fn(0,0,1);let n=0;switch(e){case 3:n=Math.PI;break;case 6:n=Math.PI/2;break;case 8:n=3*Math.PI/2}return(new Hn).makeRotationAxis(i,n).multiply(t)}_getRadialPeak(t,e){const i=5*e,n=3*t,r=Math.pow(n,2)-4*i*1;if(r<0)return;const s=(-n-Math.sqrt(r))/2/i,o=(-n+Math.sqrt(r))/2/i,a=Math.min(s,o),c=Math.max(s,o);return a>0?Math.sqrt(a):c>0?Math.sqrt(c):void 0}_normalizedToTextureMatrix(){const t=Math.max(this._width,this._height),e=this._orientation<5?this._textureScale[0]:this._textureScale[1],i=this._orientation<5?this._textureScale[1]:this._textureScale[0],n=t/this._width*e,r=t/this._height*i;switch(this._orientation){case 1:return(new Hn).set(n,0,0,.5,0,-r,0,.5,0,0,1,0,0,0,0,1);case 3:return(new Hn).set(-n,0,0,.5,0,r,0,.5,0,0,1,0,0,0,0,1);case 6:return(new Hn).set(0,-r,0,.5,-n,0,0,.5,0,0,1,0,0,0,0,1);case 8:return(new Hn).set(0,r,0,.5,n,0,0,.5,0,0,1,0,0,0,0,1);default:return(new Hn).set(n,0,0,.5,0,-r,0,.5,0,0,1,0,0,0,0,1)}}}class Ud{constructor(t){this._spatial=new ld,this._referenceThreshold=.01,this._transitionMode=t.transitionMode,this._reference=t.reference,this._alpha=t.alpha,this._camera=t.camera.clone(),this._zoom=t.zoom,this._currentIndex=t.currentIndex,this._trajectory=t.trajectory.slice(),this._trajectoryTransforms=[],this._trajectoryCameras=[];for(let t of this._trajectory){let e=this._imageToTranslation(t,this._reference),i=new Hd(t.exifOrientation,t.width,t.height,t.scale,t.rotation,e,t.image,void 0,t.cameraParameters,t.cameraType);this._trajectoryTransforms.push(i),this._trajectoryCameras.push(new jd(i))}this._currentImage=this._trajectory.length>0?this._trajectory[this._currentIndex]:null,this._previousImage=this._trajectory.length>1&&this.currentIndex>0?this._trajectory[this._currentIndex-1]:null,this._currentCamera=this._trajectoryCameras.length>0?this._trajectoryCameras[this._currentIndex].clone():new jd,this._previousCamera=this._trajectoryCameras.length>1&&this.currentIndex>0?this._trajectoryCameras[this._currentIndex-1].clone():this._currentCamera.clone()}get reference(){return this._reference}get alpha(){return this._getAlpha()}get camera(){return this._camera}get zoom(){return this._zoom}get trajectory(){return this._trajectory}get currentIndex(){return this._currentIndex}get currentImage(){return this._currentImage}get previousImage(){return this._previousImage}get currentCamera(){return this._currentCamera}get currentTransform(){return this._trajectoryTransforms.length>0?this._trajectoryTransforms[this.currentIndex]:null}get previousTransform(){return this._trajectoryTransforms.length>1&&this.currentIndex>0?this._trajectoryTransforms[this.currentIndex-1]:null}get motionless(){return this._motionless}get transitionMode(){return this._transitionMode}move(t){}moveTo(t){}rotate(t){}rotateUnbounded(t){}rotateWithoutInertia(t){}rotateBasic(t){}rotateBasicUnbounded(t){}rotateBasicWithoutInertia(t){}rotateToBasic(t){}setSpeed(t){}zoomIn(t,e){}update(t){}setCenter(t){}setZoom(t){}dolly(t){}orbit(t){}setViewMatrix(t){}truck(t){}append(t){if(t.length<1)throw Error("Trajectory can not be empty");this._currentIndex<0?this.set(t):(this._trajectory=this._trajectory.concat(t),this._appendToTrajectories(t))}prepend(t){if(t.length<1)throw Error("Trajectory can not be empty");this._trajectory=t.slice().concat(this._trajectory),this._currentIndex+=t.length,this._setCurrentImage(),this._setReference(this._currentImage)?this._setTrajectories():this._prependToTrajectories(t),this._setCurrentCamera()}remove(t){if(t<0)throw Error("n must be a positive integer");if(this._currentIndex-1<t)throw Error("Current and previous images can not be removed");for(let e=0;e<t;e++)this._trajectory.shift(),this._trajectoryTransforms.shift(),this._trajectoryCameras.shift(),this._currentIndex--;this._setCurrentImage()}clearPrior(){this._currentIndex>0&&this.remove(this._currentIndex-1)}clear(){this.cut(),this._currentIndex>0&&this.remove(this._currentIndex-1)}cut(){for(;this._trajectory.length-1>this._currentIndex;)this._trajectory.pop(),this._trajectoryTransforms.pop(),this._trajectoryCameras.pop()}set(t){this._setTrajectory(t),this._setCurrentImage(),this._setReference(this._currentImage),this._setTrajectories(),this._setCurrentCamera()}getCenter(){return null!=this._currentImage?this.currentTransform.projectBasic(this._camera.lookat.toArray()):[.5,.5]}setTransitionMode(t){this._transitionMode=t}_getAlpha(){return 1}_setCurrent(){this._setCurrentImage(),this._setReference(this._currentImage)&&this._setTrajectories(),this._setCurrentCamera()}_setCurrentCamera(){this._currentCamera=this._trajectoryCameras[this._currentIndex].clone(),this._previousCamera=this._currentIndex>0?this._trajectoryCameras[this._currentIndex-1].clone():this._currentCamera.clone()}_motionlessTransition(){return null!=this._currentImage&&null!=this._previousImage&&(this._transitionMode===t.TransitionMode.Instantaneous||!(this._currentImage.merged&&this._previousImage.merged&&this._withinOriginalDistance()&&this._sameConnectedComponent()))}_setReference(t){return!(Math.abs(t.lngLat.lat-this.reference.lat)<this._referenceThreshold&&Math.abs(t.lngLat.lng-this.reference.lng)<this._referenceThreshold)&&(!(null!=this._previousImage&&!this._motionlessTransition())&&(this._reference.lat=t.lngLat.lat,this._reference.lng=t.lngLat.lng,this._reference.alt=t.computedAltitude,!0))}_setCurrentImage(){this._currentImage=this._trajectory.length>0?this._trajectory[this._currentIndex]:null,this._previousImage=this._currentIndex>0?this._trajectory[this._currentIndex-1]:null}_setTrajectory(t){if(t.length<1)throw new hd("Trajectory can not be empty");null!=this._currentImage?(this._trajectory=[this._currentImage].concat(t),this._currentIndex=1):(this._trajectory=t.slice(),this._currentIndex=0)}_setTrajectories(){this._trajectoryTransforms.length=0,this._trajectoryCameras.length=0,this._appendToTrajectories(this._trajectory)}_appendToTrajectories(t){for(let e of t){if(!e.assetsCached)throw new hd("Assets must be cached when image is added to trajectory");let t=this._imageToTranslation(e,this.reference),i=new Hd(e.exifOrientation,e.width,e.height,e.scale,e.rotation,t,e.image,void 0,e.cameraParameters,e.cameraType);this._trajectoryTransforms.push(i),this._trajectoryCameras.push(new jd(i))}}_prependToTrajectories(t){for(let e of t.reverse()){if(!e.assetsCached)throw new hd("Assets must be cached when added to trajectory");let t=this._imageToTranslation(e,this.reference),i=new Hd(e.exifOrientation,e.width,e.height,e.scale,e.rotation,t,e.image,void 0,e.cameraParameters,e.cameraType);this._trajectoryTransforms.unshift(i),this._trajectoryCameras.unshift(new jd(i))}}_imageToTranslation(t,e){return fd({alt:t.computedAltitude,lat:t.lngLat.lat,lng:t.lngLat.lng},t.rotation,e)}_sameConnectedComponent(){let t=this._currentImage,e=this._previousImage;return!!t&&!!e&&t.mergeId===e.mergeId}_withinOriginalDistance(){let t=this._currentImage,e=this._previousImage;return!t||!e||this._spatial.distanceFromLngLat(t.originalLngLat.lng,t.originalLngLat.lat,e.originalLngLat.lng,e.originalLngLat.lat)<25}}class Vd{constructor(t,e){this._phi=t,this._theta=e}get phi(){return this._phi}set phi(t){this._phi=t}get theta(){return this._theta}set theta(t){this._theta=t}get isZero(){return 0===this._phi&&0===this._theta}copy(t){this._phi=t.phi,this._theta=t.theta}lerp(t,e){this._phi=(1-e)*this._phi+e*t.phi,this._theta=(1-e)*this._theta+e*t.theta}multiply(t){this._phi*=t,this._theta*=t}threshold(t){this._phi=Math.abs(this._phi)>t?this._phi:0,this._theta=Math.abs(this._theta)>t?this._theta:0}lengthSquared(){return this._phi*this._phi+this._theta*this._theta}reset(){this._phi=0,this._theta=0}}class Gd extends Ud{constructor(t){super(t),this._animationSpeed=1/40,this._rotationDelta=new Vd(0,0),this._requestedRotationDelta=null,this._basicRotation=[0,0],this._requestedBasicRotation=null,this._requestedBasicRotationUnbounded=null,this._rotationAcceleration=.86,this._rotationIncreaseAlpha=.97,this._rotationDecreaseAlpha=.9,this._rotationThreshold=.001,this._unboundedRotationAlpha=.8,this._desiredZoom=t.zoom,this._minZoom=0,this._maxZoom=3,this._lookatDepth=10,this._desiredLookat=null,this._desiredCenter=null}rotate(t){null!=this._currentImage&&(0===t.phi&&0===t.theta||(this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedBasicRotation=null,null!=this._requestedRotationDelta?(this._requestedRotationDelta.phi=this._requestedRotationDelta.phi+t.phi,this._requestedRotationDelta.theta=this._requestedRotationDelta.theta+t.theta):this._requestedRotationDelta=new Vd(t.phi,t.theta)))}rotateUnbounded(t){if(null==this._currentImage)return;if(this._requestedBasicRotation=null,this._requestedRotationDelta=null,this._applyRotation(t,this._currentCamera),this._applyRotation(t,this._previousCamera),!this._desiredLookat)return;const e=(new pn).setFromUnitVectors(this._currentCamera.up,new fn(0,0,1)),i=e.clone().invert(),n=(new fn).copy(this._desiredLookat).sub(this._camera.position).applyQuaternion(e),r=n.length();let s=Math.atan2(n.y,n.x);s+=t.phi;let o=Math.atan2(Math.sqrt(n.x*n.x+n.y*n.y),n.z);o+=t.theta,o=Math.max(.1,Math.min(Math.PI-.1,o)),n.x=Math.sin(o)*Math.cos(s),n.y=Math.sin(o)*Math.sin(s),n.z=Math.cos(o),n.applyQuaternion(i),this._desiredLookat.copy(this._camera.position).add(n.multiplyScalar(r))}rotateWithoutInertia(t){if(null==this._currentImage)return;this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedBasicRotation=null,this._requestedRotationDelta=null;const e=Math.PI/(10*Math.pow(2,this._zoom)),i={phi:this._spatial.clamp(t.phi,-e,e),theta:this._spatial.clamp(t.theta,-e,e)};this._applyRotation(i,this._currentCamera),this._applyRotation(i,this._previousCamera)}rotateBasic(t){if(null!=this._currentImage)if(this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedRotationDelta=null,null!=this._requestedBasicRotation){this._requestedBasicRotation[0]+=t[0],this._requestedBasicRotation[1]+=t[1];let e=.05/Math.pow(2,this._zoom);this._requestedBasicRotation[0]=this._spatial.clamp(this._requestedBasicRotation[0],-e,e),this._requestedBasicRotation[1]=this._spatial.clamp(this._requestedBasicRotation[1],-e,e)}else this._requestedBasicRotation=t.slice()}rotateBasicUnbounded(t){null!=this._currentImage&&(null!=this._requestedBasicRotationUnbounded?(this._requestedBasicRotationUnbounded[0]+=t[0],this._requestedBasicRotationUnbounded[1]+=t[1]):this._requestedBasicRotationUnbounded=t.slice())}rotateBasicWithoutInertia(t){if(null==this._currentImage)return;this._desiredZoom=this._zoom,this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null;const e=.05/Math.pow(2,this._zoom),i=t.slice();i[0]=this._spatial.clamp(i[0],-e,e),i[1]=this._spatial.clamp(i[1],-e,e),this._applyRotationBasic(i)}rotateToBasic(t){if(null==this._currentImage)return;this._desiredZoom=this._zoom,this._desiredLookat=null,t[0]=this._spatial.clamp(t[0],0,1),t[1]=this._spatial.clamp(t[1],0,1);let e=this.currentTransform.unprojectBasic(t,this._lookatDepth);this._currentCamera.lookat.fromArray(e)}zoomIn(t,e){if(null==this._currentImage)return;this._desiredZoom=Math.max(this._minZoom,Math.min(this._maxZoom,this._desiredZoom+t));let i=this.currentTransform.projectBasic(this._currentCamera.lookat.toArray()),n=i[0],r=i[1],s=Math.pow(2,this._zoom),o=Math.pow(2,this._desiredZoom),a=e[0],c=e[1];dd(this.currentTransform.cameraType)&&(a-n>.5?a-=1:n-a>.5&&(a=1+a));let h=a-s/o*(a-n),l=c-s/o*(c-r);dd(this._currentImage.cameraType)?(h=this._spatial.wrap(h+this._basicRotation[0],0,1),l=this._spatial.clamp(l+this._basicRotation[1],.05,.95)):(h=this._spatial.clamp(h,0,1),l=this._spatial.clamp(l,0,1)),this._desiredLookat=(new fn).fromArray(this.currentTransform.unprojectBasic([h,l],this._lookatDepth))}setCenter(t){this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null,this._desiredZoom=this._zoom;let e=[this._spatial.clamp(t[0],0,1),this._spatial.clamp(t[1],0,1)];if(null==this._currentImage)return void(this._desiredCenter=e);this._desiredCenter=null;let i=(new fn).fromArray(this.currentTransform.unprojectBasic(e,this._lookatDepth)),n=null!=this.previousTransform?this.previousTransform:this.currentTransform,r=(new fn).fromArray(n.unprojectBasic(e,this._lookatDepth));this._currentCamera.lookat.copy(i),this._previousCamera.lookat.copy(r)}setZoom(t){this._desiredLookat=null,this._requestedRotationDelta=null,this._requestedBasicRotation=null,this._zoom=this._spatial.clamp(t,this._minZoom,this._maxZoom),this._desiredZoom=this._zoom}_applyRotation(t,e){if(null==e)return;let i=(new pn).setFromUnitVectors(e.up,new fn(0,0,1)),n=i.clone().invert(),r=new fn;r.copy(e.lookat).sub(e.position),r.applyQuaternion(i);let s=r.length(),o=Math.atan2(r.y,r.x);o+=t.phi;let a=Math.atan2(Math.sqrt(r.x*r.x+r.y*r.y),r.z);a+=t.theta,a=Math.max(.1,Math.min(Math.PI-.1,a)),r.x=Math.sin(a)*Math.cos(o),r.y=Math.sin(a)*Math.sin(o),r.z=Math.cos(a),r.applyQuaternion(n),e.lookat.copy(e.position).add(r.multiplyScalar(s))}_applyRotationBasic(t){let e=this._currentImage,i=null!=this._previousImage?this.previousImage:this.currentImage,n=this._currentCamera,r=this._previousCamera,s=this.currentTransform,o=null!=this.previousTransform?this.previousTransform:this.currentTransform,a=s.projectBasic(n.lookat.toArray()),c=o.projectBasic(r.lookat.toArray());dd(e.cameraType)?(a[0]=this._spatial.wrap(a[0]+t[0],0,1),a[1]=this._spatial.clamp(a[1]+t[1],.05,.95)):(a[0]=this._spatial.clamp(a[0]+t[0],0,1),a[1]=this._spatial.clamp(a[1]+t[1],0,1)),dd(i.cameraType)?(c[0]=this._spatial.wrap(c[0]+t[0],0,1),c[1]=this._spatial.clamp(c[1]+t[1],.05,.95)):(c[0]=this._spatial.clamp(c[0]+t[0],0,1),c[1]=this._spatial.clamp(a[1]+t[1],0,1));let h=s.unprojectBasic(a,this._lookatDepth);n.lookat.fromArray(h);let l=o.unprojectBasic(c,this._lookatDepth);r.lookat.fromArray(l)}_updateZoom(t){let e=this._desiredZoom-this._zoom,i=e>0?1:e<0?-1:0;0!==e&&(Math.abs(e)<.002?(this._zoom=this._desiredZoom,null!=this._desiredLookat&&(this._desiredLookat=null)):this._zoom+=i*Math.max(Math.abs(5*t*e),.002))}_updateLookat(t){if(null===this._desiredLookat)return;let e=this._desiredLookat.distanceToSquared(this._currentCamera.lookat);Math.abs(e)<1e-6?(this._currentCamera.lookat.copy(this._desiredLookat),this._desiredLookat=null):this._currentCamera.lookat.lerp(this._desiredLookat,5*t)}_updateRotation(){if(null!=this._requestedRotationDelta){let t=this._rotationDelta.lengthSquared();return this._requestedRotationDelta.lengthSquared()>t?this._rotationDelta.lerp(this._requestedRotationDelta,this._rotationIncreaseAlpha):this._rotationDelta.lerp(this._requestedRotationDelta,this._rotationDecreaseAlpha),void(this._requestedRotationDelta=null)}if(this._rotationDelta.isZero)return;const t=dd(this.currentImage.cameraType)?1:this._alpha;this._rotationDelta.multiply(this._rotationAcceleration*t),this._rotationDelta.threshold(this._rotationThreshold)}_updateRotationBasic(){if(null!=this._requestedBasicRotation){let t=this._basicRotation[0],e=this._basicRotation[1],i=this._requestedBasicRotation[0],n=this._requestedBasicRotation[1];return Math.abs(i)>Math.abs(t)?this._basicRotation[0]=(1-this._rotationIncreaseAlpha)*t+this._rotationIncreaseAlpha*i:this._basicRotation[0]=(1-this._rotationDecreaseAlpha)*t+this._rotationDecreaseAlpha*i,Math.abs(n)>Math.abs(e)?this._basicRotation[1]=(1-this._rotationIncreaseAlpha)*e+this._rotationIncreaseAlpha*n:this._basicRotation[1]=(1-this._rotationDecreaseAlpha)*e+this._rotationDecreaseAlpha*n,void(this._requestedBasicRotation=null)}if(null!=this._requestedBasicRotationUnbounded){let t=this._requestedBasicRotationUnbounded[0],e=this._requestedBasicRotationUnbounded[1];if(Math.abs(t)>0&&(this._basicRotation[0]=(1-this._unboundedRotationAlpha)*this._basicRotation[0]+this._unboundedRotationAlpha*t),Math.abs(e)>0&&(this._basicRotation[1]=(1-this._unboundedRotationAlpha)*this._basicRotation[1]+this._unboundedRotationAlpha*e),null!=this._desiredLookat){let i=this.currentTransform.projectBasic(this._desiredLookat.toArray());i[0]+=t,i[1]+=e,this._desiredLookat=(new fn).fromArray(this.currentTransform.unprojectBasic(i,this._lookatDepth))}this._requestedBasicRotationUnbounded=null}0===this._basicRotation[0]&&0===this._basicRotation[1]||(this._basicRotation[0]=this._rotationAcceleration*this._basicRotation[0],this._basicRotation[1]=this._rotationAcceleration*this._basicRotation[1],Math.abs(this._basicRotation[0])<this._rotationThreshold/Math.pow(2,this._zoom)&&Math.abs(this._basicRotation[1])<this._rotationThreshold/Math.pow(2,this._zoom)&&(this._basicRotation=[0,0]))}_clearRotation(){dd(this._currentImage.cameraType)||(null!=this._requestedRotationDelta&&(this._requestedRotationDelta=null),this._rotationDelta.isZero||this._rotationDelta.reset(),null!=this._requestedBasicRotation&&(this._requestedBasicRotation=null),(this._basicRotation[0]>0||this._basicRotation[1]>0)&&(this._basicRotation=[0,0]))}_setDesiredCenter(){if(null==this._desiredCenter)return;let t=(new fn).fromArray(this.currentTransform.unprojectBasic(this._desiredCenter,this._lookatDepth)).sub(this._currentCamera.position);this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(t)),this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(t)),this._desiredCenter=null}_setDesiredZoom(){this._desiredZoom=dd(this._currentImage.cameraType)||null==this._previousImage?this._zoom:0}}class qd extends Gd{constructor(t){super(t),this._adjustCameras(),this._motionless=this._motionlessTransition(),this._baseAlpha=this._alpha,this._speedCoefficient=1,this._unitBezier=new qd._interpolator(.74,.67,.38,.96),this._useBezier=!1}static register(t){qd._interpolator=t}append(t){let e=0===this._trajectory.length;e&&this._resetTransition(),super.append(t),e&&(this._setDesiredCenter(),this._setDesiredZoom())}prepend(t){let e=0===this._trajectory.length;e&&this._resetTransition(),super.prepend(t),e&&(this._setDesiredCenter(),this._setDesiredZoom())}set(t){super.set(t),this._desiredLookat=null,this._resetTransition(),this._clearRotation(),this._setDesiredCenter(),this._setDesiredZoom(),this._trajectory.length<3&&(this._useBezier=!0)}setSpeed(t){this._speedCoefficient=this._spatial.clamp(t,0,10)}update(t){1===this._alpha&&this._currentIndex+this._alpha<this._trajectory.length&&(this._currentIndex+=1,this._useBezier=this._trajectory.length<3&&this._currentIndex+1===this._trajectory.length,this._setCurrent(),this._resetTransition(),this._clearRotation(),this._desiredZoom=dd(this._currentImage.cameraType)?this._zoom:0,this._desiredLookat=null);let e=this._animationSpeed*(60/t);this._baseAlpha=Math.min(1,this._baseAlpha+this._speedCoefficient*e),this._useBezier?this._alpha=this._unitBezier.solve(this._baseAlpha):this._alpha=this._baseAlpha,this._updateRotation(),this._rotationDelta.isZero||(this._applyRotation(this._rotationDelta,this._previousCamera),this._applyRotation(this._rotationDelta,this._currentCamera)),this._updateRotationBasic(),0===this._basicRotation[0]&&0===this._basicRotation[1]||this._applyRotationBasic(this._basicRotation),this._updateZoom(e),this._updateLookat(e),this._camera.lerpCameras(this._previousCamera,this._currentCamera,this.alpha)}_getAlpha(){return this._motionless?Math.ceil(this._alpha):this._alpha}_setCurrentCamera(){super._setCurrentCamera(),this._adjustCameras()}_adjustCameras(){if(null==this._previousImage)return;let t=this._camera.lookat.clone().sub(this._camera.position);this._previousCamera.lookat.copy(t.clone().add(this._previousCamera.position)),dd(this._currentImage.cameraType)&&this._currentCamera.lookat.copy(t.clone().add(this._currentCamera.position))}_resetTransition(){this._alpha=0,this._baseAlpha=0,this._motionless=this._motionlessTransition()}}class Wd{constructor(t,e){this._components={};for(const i in Wd.registeredComponents){if(!Wd.registeredComponents.hasOwnProperty(i))continue;const n=Wd.registeredComponents[i];this._components[i]={active:!1,component:new n(i,t,e)}}this._coverComponent=new Wd.registeredCoverComponent("cover",t,e),this._coverComponent.activate(),this._coverActivated=!0}static register(t){void 0===Wd.registeredComponents[t.componentName]&&(Wd.registeredComponents[t.componentName]=t)}static registerCover(t){Wd.registeredCoverComponent=t}get coverActivated(){return this._coverActivated}activateCover(){if(!this._coverActivated){this._coverActivated=!0;for(const t in this._components){if(!this._components.hasOwnProperty(t))continue;const e=this._components[t];e.active&&e.component.deactivate()}}}deactivateCover(){if(this._coverActivated){this._coverActivated=!1;for(const t in this._components){if(!this._components.hasOwnProperty(t))continue;const e=this._components[t];e.active&&e.component.activate()}}}activate(t){this._checkName(t),this._components[t].active=!0,this._coverActivated||this.get(t).activate()}configure(t,e){this._checkName(t),this.get(t).configure(e)}deactivate(t){this._checkName(t),this._components[t].active=!1,this._coverActivated||this.get(t).deactivate()}get(t){return this._components[t].component}getCover(){return this._coverComponent}remove(){this._coverComponent.deactivate();for(const t in this._components)this._components.hasOwnProperty(t)&&this._components[t].component.deactivate()}_checkName(t){if(!(t in this._components))throw new hd(`Component does not exist: ${t}`)}}Wd.registeredComponents={};var Xd=Array.isArray,Yd=Object.prototype.toString,Zd=Xd||function(t){return"[object Array]"===Yd.call(t)};var Jd="2";Qd.NONE=0,Qd.VTEXT=1,Qd.VNODE=2,Qd.WIDGET=3,Qd.PROPS=4,Qd.ORDER=5,Qd.INSERT=6,Qd.REMOVE=7,Qd.THUNK=8;var Kd=Qd;function Qd(t,e,i){this.type=Number(t),this.vNode=e,this.patch=i}Qd.prototype.version=Jd,Qd.prototype.type="VirtualPatch";var tp=function(t){return t&&"VirtualNode"===t.type&&t.version===Jd};var ep=function(t){return t&&"VirtualText"===t.type&&t.version===Jd};var ip=function(t){return t&&"Widget"===t.type};var np=function(t){return t&&"Thunk"===t.type};var rp=function(t,e){var i=t,n=e;np(e)&&(n=sp(e,t));np(t)&&(i=sp(t,null));return{a:i,b:n}};function sp(t,e){var i=t.vnode;if(i||(i=t.vnode=t.render(e)),!(tp(i)||ep(i)||ip(i)))throw new Error("thunk did not return a valid node");return i}var op=function(t){return"object"==typeof t&&null!==t},ap=function(t){return t&&("function"==typeof t.hook&&!t.hasOwnProperty("hook")||"function"==typeof t.unhook&&!t.hasOwnProperty("unhook"))};var cp=function t(e,i){var n;for(var r in e){r in i||((n=n||{})[r]=void 0);var s=e[r],o=i[r];if(s!==o)if(op(s)&&op(o))if(hp(o)!==hp(s))(n=n||{})[r]=o;else if(ap(o))(n=n||{})[r]=o;else{var a=t(s,o);a&&((n=n||{})[r]=a)}else(n=n||{})[r]=o}for(var c in i)c in e||((n=n||{})[c]=i[c]);return n};function hp(t){return Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__?t.__proto__:t.constructor?t.constructor.prototype:void 0}function lp(t,e){var i={a:t};return up(t,e,i,0),i}function up(t,e,i,n){if(t!==e){var r=i[n],s=!1;if(np(t)||np(e))fp(t,e,i,n);else if(null==e)ip(t)||(dp(t,i,n),r=i[n]),r=vp(r,new Kd(Kd.REMOVE,t,e));else if(tp(e))if(tp(t))if(t.tagName===e.tagName&&t.namespace===e.namespace&&t.key===e.key){var o=cp(t.properties,e.properties);o&&(r=vp(r,new Kd(Kd.PROPS,t,o))),r=function(t,e,i,n,r){for(var s=t.children,o=function(t,e){var i=_p(e),n=i.keys,r=i.free;if(r.length===e.length)return{children:e,moves:null};var s=_p(t),o=s.keys;if(s.free.length===t.length)return{children:e,moves:null};for(var a=[],c=0,h=r.length,l=0,u=0;u<t.length;u++){var d,p=t[u];p.key?n.hasOwnProperty(p.key)?(d=n[p.key],a.push(e[d])):(d=u-l++,a.push(null)):c<h?(d=r[c++],a.push(e[d])):(d=u-l++,a.push(null))}for(var f=c>=r.length?e.length:r[c],m=0;m<e.length;m++){var g=e[m];g.key?o.hasOwnProperty(g.key)||a.push(g):m>=f&&a.push(g)}for(var _,v=a.slice(),y=0,b=[],x=[],w=0;w<e.length;){var S=e[w];for(_=v[y];null===_&&v.length;)b.push(gp(v,y,null)),_=v[y];_&&_.key===S.key?(y++,w++):S.key?(_&&_.key&&n[_.key]!==w+1?(b.push(gp(v,y,_.key)),(_=v[y])&&_.key===S.key?y++:x.push({key:S.key,to:w})):x.push({key:S.key,to:w}),w++):_&&_.key&&b.push(gp(v,y,_.key))}for(;y<v.length;)_=v[y],b.push(gp(v,y,_&&_.key));if(b.length===l&&!x.length)return{children:a,moves:null};return{children:a,moves:{removes:b,inserts:x}}}(s,e.children),a=o.children,c=s.length,h=a.length,l=c>h?c:h,u=0;u<l;u++){var d=s[u],p=a[u];r+=1,d?up(d,p,i,r):p&&(n=vp(n,new Kd(Kd.INSERT,null,p))),tp(d)&&d.count&&(r+=d.count)}o.moves&&(n=vp(n,new Kd(Kd.ORDER,t,o.moves)));return n}(t,e,i,r,n)}else r=vp(r,new Kd(Kd.VNODE,t,e)),s=!0;else r=vp(r,new Kd(Kd.VNODE,t,e)),s=!0;else ep(e)?ep(t)?t.text!==e.text&&(r=vp(r,new Kd(Kd.VTEXT,t,e))):(r=vp(r,new Kd(Kd.VTEXT,t,e)),s=!0):ip(e)&&(ip(t)||(s=!0),r=vp(r,new Kd(Kd.WIDGET,t,e)));r&&(i[n]=r),s&&dp(t,i,n)}}function dp(t,e,i){mp(t,e,i),pp(t,e,i)}function pp(t,e,i){if(ip(t))"function"==typeof t.destroy&&(e[i]=vp(e[i],new Kd(Kd.REMOVE,t,null)));else if(tp(t)&&(t.hasWidgets||t.hasThunks))for(var n=t.children,r=n.length,s=0;s<r;s++){var o=n[s];pp(o,e,i+=1),tp(o)&&o.count&&(i+=o.count)}else np(t)&&fp(t,null,e,i)}function fp(t,e,i,n){var r=rp(t,e),s=lp(r.a,r.b);(function(t){for(var e in t)if("a"!==e)return!0;return!1})(s)&&(i[n]=new Kd(Kd.THUNK,null,s))}function mp(t,e,i){if(tp(t)){if(t.hooks&&(e[i]=vp(e[i],new Kd(Kd.PROPS,t,function(t){var e={};for(var i in t)e[i]=void 0;return e}(t.hooks)))),t.descendantHooks||t.hasThunks)for(var n=t.children,r=n.length,s=0;s<r;s++){var o=n[s];mp(o,e,i+=1),tp(o)&&o.count&&(i+=o.count)}}else np(t)&&fp(t,null,e,i)}function gp(t,e,i){return t.splice(e,1),{from:e,key:i}}function _p(t){for(var e={},i=[],n=t.length,r=0;r<n;r++){var s=t[r];s.key?e[s.key]=r:i.push(r)}return{keys:e,free:i}}function vp(t,e){return t?(Zd(t)?t.push(e):t=[t,e],t):e}var yp=lp,bp="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function xp(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})})),e}function wp(t){var e={exports:{}};return t(e,e.exports),e.exports}var Sp=Array.prototype.slice,Mp=function(t,e){"length"in t||(t=[t]);t=Sp.call(t);for(;t.length;){var i=t.shift(),n=e(i);if(n)return n;i.childNodes&&i.childNodes.length&&(t=Sp.call(i.childNodes).concat(t))}};var Tp=Cp;function Cp(t,e){if(!(this instanceof Cp))return new Cp(t,e);this.data=t,this.nodeValue=t,this.length=t.length,this.ownerDocument=e||null}Cp.prototype.nodeType=8,Cp.prototype.nodeName="#comment",Cp.prototype.toString=function(){return"[object Comment]"};var Ep=Ip;function Ip(t,e){if(!(this instanceof Ip))return new Ip(t);this.data=t||"",this.length=this.data.length,this.ownerDocument=e||null}Ip.prototype.type="DOMTextNode",Ip.prototype.nodeType=3,Ip.prototype.nodeName="#text",Ip.prototype.toString=function(){return this.data},Ip.prototype.replaceData=function(t,e,i){var n=this.data,r=n.substring(0,t),s=n.substring(t+e,n.length);this.data=r+i+s,this.length=this.data.length};var Ap=function(t){var e=this,i=t.type;t.target||(t.target=e);e.listeners||(e.listeners={});var n=e.listeners[i];if(n)return n.forEach((function(i){t.currentTarget=e,"function"==typeof i?i(t):i.handleEvent(t)}));e.parentNode&&e.parentNode.dispatchEvent(t)};var Pp=function(t,e){var i=this;i.listeners||(i.listeners={});i.listeners[t]||(i.listeners[t]=[]);-1===i.listeners[t].indexOf(e)&&i.listeners[t].push(e)};var Rp=function(t,e){var i=this;if(!i.listeners)return;if(!i.listeners[t])return;var n=i.listeners[t],r=n.indexOf(e);-1!==r&&n.splice(r,1)};var Lp=Np,Op=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function Np(t){switch(t.nodeType){case 3:return kp(t.data);case 8:return"\x3c!--"+t.data+"--\x3e";default:return function(t){var e=[],i=t.tagName;"http://www.w3.org/1999/xhtml"===t.namespaceURI&&(i=i.toLowerCase());e.push("<"+i+function(t){var e=[];for(var i in t)Dp(t,i)&&e.push({name:i,value:t[i]});for(var n in t._attributes)for(var r in t._attributes[n]){var s=t._attributes[n][r],o=(s.prefix?s.prefix+":":"")+r;e.push({name:o,value:s.value})}t.className&&e.push({name:"class",value:t.className});return e.length?$p(e):""}(t)+function(t){var e=t.dataset,i=[];for(var n in e)i.push({name:"data-"+n,value:e[n]});return i.length?$p(i):""}(t)),Op.indexOf(i)>-1?e.push(" />"):(e.push(">"),t.childNodes.length?e.push.apply(e,t.childNodes.map(Np)):t.textContent||t.innerText?e.push(kp(t.textContent||t.innerText)):t.innerHTML&&e.push(t.innerHTML),e.push("</"+i+">"));return e.join("")}(t)}}function Dp(t,e){var i=typeof t[e];return"style"===e&&Object.keys(t.style).length>0||t.hasOwnProperty(e)&&("string"===i||"boolean"===i||"number"===i)&&"nodeName"!==e&&"className"!==e&&"tagName"!==e&&"textContent"!==e&&"innerText"!==e&&"namespaceURI"!==e&&"innerHTML"!==e}function $p(t){var e=[];return t.forEach((function(t){var i=t.name,n=t.value;"style"===i&&(n=function(t){if("string"==typeof t)return t;var e="";return Object.keys(t).forEach((function(i){var n=t[i];i=i.replace(/[A-Z]/g,(function(t){return"-"+t.toLowerCase()})),e+=i+":"+n+";"})),e}(n)),e.push(i+'="'+(kp(n).replace(/"/g,""")+'"'))})),e.length?" "+e.join(" "):""}function kp(t){var e="";return"string"==typeof t?e=t:t&&(e=t.toString()),e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var zp="http://www.w3.org/1999/xhtml",Fp=Bp;function Bp(t,e,i){if(!(this instanceof Bp))return new Bp(t);var n=void 0===i?zp:i||null;this.tagName=n===zp?String(t).toUpperCase():t,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=e||null,this.namespaceURI=n,this._attributes={},"INPUT"===this.tagName&&(this.type="text")}Bp.prototype.type="DOMElement",Bp.prototype.nodeType=1,Bp.prototype.appendChild=function(t){return t.parentNode&&t.parentNode.removeChild(t),this.childNodes.push(t),t.parentNode=this,t},Bp.prototype.replaceChild=function(t,e){t.parentNode&&t.parentNode.removeChild(t);var i=this.childNodes.indexOf(e);return e.parentNode=null,this.childNodes[i]=t,t.parentNode=this,e},Bp.prototype.removeChild=function(t){var e=this.childNodes.indexOf(t);return this.childNodes.splice(e,1),t.parentNode=null,t},Bp.prototype.insertBefore=function(t,e){t.parentNode&&t.parentNode.removeChild(t);var i=null==e?-1:this.childNodes.indexOf(e);return i>-1?this.childNodes.splice(i,0,t):this.childNodes.push(t),t.parentNode=this,t},Bp.prototype.setAttributeNS=function(t,e,i){var n=null,r=e,s=e.indexOf(":");(s>-1&&(n=e.substr(0,s),r=e.substr(s+1)),"INPUT"===this.tagName&&"type"===e)?this.type=i:(this._attributes[t]||(this._attributes[t]={}))[r]={value:i,prefix:n}},Bp.prototype.getAttributeNS=function(t,e){var i=this._attributes[t],n=i&&i[e]&&i[e].value;return"INPUT"===this.tagName&&"type"===e?this.type:"string"!=typeof n?null:n},Bp.prototype.removeAttributeNS=function(t,e){var i=this._attributes[t];i&&delete i[e]},Bp.prototype.hasAttributeNS=function(t,e){var i=this._attributes[t];return!!i&&e in i},Bp.prototype.setAttribute=function(t,e){return this.setAttributeNS(null,t,e)},Bp.prototype.getAttribute=function(t){return this.getAttributeNS(null,t)},Bp.prototype.removeAttribute=function(t){return this.removeAttributeNS(null,t)},Bp.prototype.hasAttribute=function(t){return this.hasAttributeNS(null,t)},Bp.prototype.removeEventListener=Rp,Bp.prototype.addEventListener=Pp,Bp.prototype.dispatchEvent=Ap,Bp.prototype.focus=function(){},Bp.prototype.toString=function(){return Lp(this)},Bp.prototype.getElementsByClassName=function(t){var e=t.split(" "),i=[];return Mp(this,(function(t){if(1===t.nodeType){var n=(t.className||"").split(" ");e.every((function(t){return-1!==n.indexOf(t)}))&&i.push(t)}})),i},Bp.prototype.getElementsByTagName=function(t){t=t.toLowerCase();var e=[];return Mp(this.childNodes,(function(i){1!==i.nodeType||"*"!==t&&i.tagName.toLowerCase()!==t||e.push(i)})),e},Bp.prototype.contains=function(t){return Mp(this,(function(e){return t===e}))||!1};var jp=Hp;function Hp(t){if(!(this instanceof Hp))return new Hp;this.childNodes=[],this.parentNode=null,this.ownerDocument=t||null}Hp.prototype.type="DocumentFragment",Hp.prototype.nodeType=11,Hp.prototype.nodeName="#document-fragment",Hp.prototype.appendChild=Fp.prototype.appendChild,Hp.prototype.replaceChild=Fp.prototype.replaceChild,Hp.prototype.removeChild=Fp.prototype.removeChild,Hp.prototype.toString=function(){return this.childNodes.map((function(t){return String(t)})).join("")};var Up=Vp;function Vp(t){}Vp.prototype.initEvent=function(t,e,i){this.type=t,this.bubbles=e,this.cancelable=i},Vp.prototype.preventDefault=function(){};var Gp=qp;function qp(){if(!(this instanceof qp))return new qp;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var Wp=qp.prototype;Wp.createTextNode=function(t){return new Ep(t,this)},Wp.createElementNS=function(t,e){var i=null===t?null:String(t);return new Fp(e,this,i)},Wp.createElement=function(t){return new Fp(t,this)},Wp.createDocumentFragment=function(){return new jp(this)},Wp.createEvent=function(t){return new Up(t)},Wp.createComment=function(t){return new Tp(t,this)},Wp.getElementById=function(t){return t=String(t),Mp(this.childNodes,(function(e){if(String(e.id)===t)return e}))||null},Wp.getElementsByClassName=Fp.prototype.getElementsByClassName,Wp.getElementsByTagName=Fp.prototype.getElementsByTagName,Wp.contains=Fp.prototype.contains,Wp.removeEventListener=Rp,Wp.addEventListener=Pp,Wp.dispatchEvent=Ap;var Xp,Yp=new Gp,Zp=void 0!==bp?bp:"undefined"!=typeof window?window:{};"undefined"!=typeof document?Xp=document:(Xp=Zp["__GLOBAL_DOCUMENT_CACHE@4"])||(Xp=Zp["__GLOBAL_DOCUMENT_CACHE@4"]=Yp);var Jp=Xp,Kp=function(t,e,i){for(var n in e){var r=e[n];void 0===r?Qp(t,n,r,i):ap(r)?(Qp(t,n,r,i),r.hook&&r.hook(t,n,i?i[n]:void 0)):op(r)?tf(t,e,i,n,r):t[n]=r}};function Qp(t,e,i,n){if(n){var r=n[e];if(ap(r))r.unhook&&r.unhook(t,e,i);else if("attributes"===e)for(var s in r)t.removeAttribute(s);else if("style"===e)for(var o in r)t.style[o]="";else t[e]="string"==typeof r?"":null}}function tf(t,e,i,n,r){var s=i?i[n]:void 0;if("attributes"!==n)if(s&&op(s)&&ef(s)!==ef(r))t[n]=r;else{op(t[n])||(t[n]={});var o="style"===n?"":void 0;for(var a in r){var c=r[a];t[n][a]=void 0===c?o:c}}else for(var h in r){var l=r[h];void 0===l?t.removeAttribute(h):t.setAttribute(h,l)}}function ef(t){return Object.getPrototypeOf?Object.getPrototypeOf(t):t.__proto__?t.__proto__:t.constructor?t.constructor.prototype:void 0}var nf=function t(e,i){var n=i&&i.document||Jp,r=i?i.warn:null;if(e=rp(e).a,ip(e))return e.init();if(ep(e))return n.createTextNode(e.text);if(!tp(e))return r&&r("Item is not a valid virtual dom node",e),null;var s=null===e.namespace?n.createElement(e.tagName):n.createElementNS(e.namespace,e.tagName),o=e.properties;Kp(s,o);for(var a=e.children,c=0;c<a.length;c++){var h=t(a[c],i);h&&s.appendChild(h)}return s};var rf={},sf=function(t,e,i,n){return i&&0!==i.length?(i.sort(cf),of(t,e,i,n,0)):{}};function of(t,e,i,n,r){if(n=n||{},t){af(i,r,r)&&(n[r]=t);var s=e.children;if(s)for(var o=t.childNodes,a=0;a<e.children.length;a++){r+=1;var c=s[a]||rf,h=r+(c.count||0);af(i,r,h)&&of(o[a],c,i,n,r),r=h}}return n}function af(t,e,i){if(0===t.length)return!1;for(var n,r,s=0,o=t.length-1;s<=o;){if(r=t[n=(o+s)/2>>0],s===o)return r>=e&&r<=i;if(r<e)s=n+1;else{if(!(r>i))return!0;o=n-1}}return!1}function cf(t,e){return t>e?1:-1}var hf=function(t,e){if(ip(t)&&ip(e))return"name"in t&&"name"in e?t.id===e.id:t.init===e.init;return!1};var lf=function(t,e,i){var n=t.type,r=t.vNode,s=t.patch;switch(n){case Kd.REMOVE:return function(t,e){var i=t.parentNode;i&&i.removeChild(t);return uf(t,e),null}(e,r);case Kd.INSERT:return function(t,e,i){var n=i.render(e,i);t&&t.appendChild(n);return t}(e,s,i);case Kd.VTEXT:return function(t,e,i,n){var r;if(3===t.nodeType)t.replaceData(0,t.length,i.text),r=t;else{var s=t.parentNode;r=n.render(i,n),s&&r!==t&&s.replaceChild(r,t)}return r}(e,0,s,i);case Kd.WIDGET:return function(t,e,i,n){var r,s=hf(e,i);r=s?i.update(e,t)||t:n.render(i,n);var o=t.parentNode;o&&r!==t&&o.replaceChild(r,t);s||uf(t,e);return r}(e,r,s,i);case Kd.VNODE:return function(t,e,i,n){var r=t.parentNode,s=n.render(i,n);r&&s!==t&&r.replaceChild(s,t);return s}(e,0,s,i);case Kd.ORDER:return function(t,e){for(var i,n,r,s=t.childNodes,o={},a=0;a<e.removes.length;a++)i=s[(n=e.removes[a]).from],n.key&&(o[n.key]=i),t.removeChild(i);for(var c=s.length,h=0;h<e.inserts.length;h++)i=o[(r=e.inserts[h]).key],t.insertBefore(i,r.to>=c++?null:s[r.to])}(e,s),e;case Kd.PROPS:return Kp(e,s,r.properties),e;case Kd.THUNK:return function(t,e){t&&e&&t!==e&&t.parentNode&&t.parentNode.replaceChild(e,t);return e}(e,i.patch(e,s,i));default:return e}};function uf(t,e){"function"==typeof e.destroy&&ip(e)&&e.destroy(t)}function df(t,e,i){var n=function(t){var e=[];for(var i in t)"a"!==i&&e.push(Number(i));return e}(e);if(0===n.length)return t;var r=sf(t,e.a,n),s=t.ownerDocument;i.document||s===Jp||(i.document=s);for(var o=0;o<n.length;o++){var a=n[o];t=pf(t,r[a],e[a],i)}return t}function pf(t,e,i,n){if(!e)return t;var r;if(Zd(i))for(var s=0;s<i.length;s++)r=lf(i[s],e,n),e===t&&(t=r);else r=lf(i,e,n),e===t&&(t=r);return t}var ff=function t(e,i,n){return(n=n||{}).patch=n.patch&&n.patch!==t?n.patch:df,n.render=n.render||nf,n.patch(e,i,n)},mf=vf,gf={},_f=[];function vf(t,e,i,n,r){this.tagName=t,this.properties=e||gf,this.children=i||_f,this.key=null!=n?String(n):void 0,this.namespace="string"==typeof r?r:null;var s,o=i&&i.length||0,a=0,c=!1,h=!1,l=!1;for(var u in e)if(e.hasOwnProperty(u)){var d=e[u];ap(d)&&d.unhook&&(s||(s={}),s[u]=d)}for(var p=0;p<o;p++){var f=i[p];tp(f)?(a+=f.count||0,!c&&f.hasWidgets&&(c=!0),!h&&f.hasThunks&&(h=!0),l||!f.hooks&&!f.descendantHooks||(l=!0)):!c&&ip(f)?"function"==typeof f.destroy&&(c=!0):!h&&np(f)&&(h=!0)}this.count=o+a,this.hasWidgets=c,this.hasThunks=h,this.hooks=s,this.descendantHooks=l}vf.prototype.version=Jd,vf.prototype.type="VirtualNode";var yf=bf;function bf(t){this.text=String(t)}bf.prototype.version=Jd,bf.prototype.type="VirtualText";
+ ***************************************************************************** */var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,i)};function i(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}function n(e,t,i,n){return new(i||(i=Promise))((function(r,s){function a(e){try{h(n.next(e))}catch(e){s(e)}}function o(e){try{h(n.throw(e))}catch(e){s(e)}}function h(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}h((n=n.apply(e,t||[])).next())}))}function r(e,t){var i,n,r,s,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,n&&(r=2&s[0]?n.return:s[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,s[1])).done)return r;switch(n=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{i=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}}function s(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],n=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var n,r,s=i.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return a}function o(e,t){for(var i=0,n=t.length,r=e.length;i<n;i++,r++)e[r]=t[i];return e}function h(e){return this instanceof h?(this.v=e,this):new h(e)}function c(e,t,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,r=i.apply(e,t||[]),s=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){r[e]&&(n[e]=function(t){return new Promise((function(i,n){s.push([e,t,i,n])>1||o(e,t)}))})}function o(e,t){try{(i=r[e](t)).value instanceof h?Promise.resolve(i.value.v).then(c,l):u(s[0][2],i)}catch(e){u(s[0][3],e)}var i}function c(e){o("next",e)}function l(e){o("throw",e)}function u(e,t){e(t),s.shift(),s.length&&o(s[0][0],s[0][1])}}function l(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,i=e[Symbol.asyncIterator];return i?i.call(e):(e=s(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=e[i]&&function(t){return new Promise((function(n,r){(function(e,t,i,n){Promise.resolve(n).then((function(t){e({value:t,done:i})}),t)})(n,r,(t=e[i](t)).done,t.value)}))}}}function u(e){return"function"==typeof e}function d(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var p=d((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function m(e,t){if(e){var i=e.indexOf(t);0<=i&&e.splice(i,1)}}var f=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._teardowns=null}return e.prototype.unsubscribe=function(){var e,t,i,n,r;if(!this.closed){this.closed=!0;var h=this._parentage;if(h)if(this._parentage=null,Array.isArray(h))try{for(var c=s(h),l=c.next();!l.done;l=c.next()){l.value.remove(this)}}catch(t){e={error:t}}finally{try{l&&!l.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else h.remove(this);var d=this.initialTeardown;if(u(d))try{d()}catch(e){r=e instanceof p?e.errors:[e]}var m=this._teardowns;if(m){this._teardowns=null;try{for(var f=s(m),g=f.next();!g.done;g=f.next()){var _=g.value;try{v(_)}catch(e){r=null!=r?r:[],e instanceof p?r=o(o([],a(r)),a(e.errors)):r.push(e)}}}catch(e){i={error:e}}finally{try{g&&!g.done&&(n=f.return)&&n.call(f)}finally{if(i)throw i.error}}}if(r)throw new p(r)}},e.prototype.add=function(t){var i;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._teardowns=null!==(i=this._teardowns)&&void 0!==i?i:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&m(t,e)},e.prototype.remove=function(t){var i=this._teardowns;i&&m(i,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),g=f.EMPTY;function _(e){return e instanceof f||e&&"closed"in e&&u(e.remove)&&u(e.add)&&u(e.unsubscribe)}function v(e){u(e)?e():e.unsubscribe()}var y={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},b={setTimeout:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=b.delegate;return((null==i?void 0:i.setTimeout)||setTimeout).apply(void 0,o([],a(e)))},clearTimeout:function(e){var t=b.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function x(e){b.setTimeout((function(){throw e}))}function w(){}var M=S("C",void 0,void 0);function S(e,t,i){return{kind:e,value:t,error:i}}var T=null;function C(e){if(y.useDeprecatedSynchronousErrorHandling){var t=!T;if(t&&(T={errorThrown:!1,error:null}),e(),t){var i=T,n=i.errorThrown,r=i.error;if(T=null,n)throw r}}else e()}var E=function(e){function t(t){var i=e.call(this)||this;return i.isStopped=!1,t?(i.destination=t,_(t)&&t.add(i)):i.destination=L,i}return i(t,e),t.create=function(e,t,i){return new A(e,t,i)},t.prototype.next=function(e){this.isStopped?P(function(e){return S("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?P(S("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?P(M,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(f),A=function(e){function t(t,i,n){var r,s=e.call(this)||this;if(u(t))r=t;else if(t){var a;r=t.next,i=t.error,n=t.complete,s&&y.useDeprecatedNextContext?(a=Object.create(t)).unsubscribe=function(){return s.unsubscribe()}:a=t,r=null==r?void 0:r.bind(a),i=null==i?void 0:i.bind(a),n=null==n?void 0:n.bind(a)}return s.destination={next:r?I(r):w,error:I(null!=i?i:R),complete:n?I(n):w},s}return i(t,e),t}(E);function I(e,t){return function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];try{e.apply(void 0,o([],a(t)))}catch(e){x(e)}}}function R(e){throw e}function P(e,t){var i=y.onStoppedNotification;i&&b.setTimeout((function(){return i(e,t)}))}var L={closed:!0,next:w,error:R,complete:w},D="function"==typeof Symbol&&Symbol.observable||"@@observable";function N(e){return e}function $(e){return 0===e.length?N:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var k=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var i=new e;return i.source=this,i.operator=t,i},e.prototype.subscribe=function(e,t,i){var n,r=this,s=(n=e)&&n instanceof E||function(e){return e&&u(e.next)&&u(e.error)&&u(e.complete)}(n)&&_(n)?e:new A(e,t,i);return C((function(){var e=r,t=e.operator,i=e.source;s.add(t?t.call(s,i):i?r._subscribe(s):r._trySubscribe(s))})),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var i=this;return new(t=O(t))((function(t,n){var r;r=i.subscribe((function(t){try{e(t)}catch(e){n(e),null==r||r.unsubscribe()}}),n,t)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[D]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return $(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=O(e))((function(e,i){var n;t.subscribe((function(e){return n=e}),(function(e){return i(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function O(e){var t;return null!==(t=null!=e?e:y.Promise)&&void 0!==t?t:Promise}function z(e){return u(null==e?void 0:e.lift)}function F(e){return function(t){if(z(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var B=function(e){function t(t,i,n,r,s){var a=e.call(this,t)||this;return a.onFinalize=s,a._next=i?function(e){try{i(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=r?function(e){try{r(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return i(t,e),t.prototype.unsubscribe=function(){var t,i=this.closed;e.prototype.unsubscribe.call(this),!i&&(null===(t=this.onFinalize)||void 0===t||t.call(this))},t}(E);function U(){return F((function(e,t){var i=null;e._refCount++;var n=new B(t,void 0,void 0,void 0,(function(){if(!e||e._refCount<=0||0<--e._refCount)i=null;else{var n=e._connection,r=i;i=null,!n||r&&n!==r||n.unsubscribe(),t.unsubscribe()}}));e.subscribe(n),n.closed||(i=e.connect())}))}var V=function(e){function t(t,i){var n=e.call(this)||this;return n.source=t,n.subjectFactory=i,n._subject=null,n._refCount=0,n._connection=null,z(t)&&(n.lift=t.lift),n}return i(t,e),t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return e&&!e.isStopped||(this._subject=this.subjectFactory()),this._subject},t.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,null==e||e.unsubscribe()},t.prototype.connect=function(){var e=this,t=this._connection;if(!t){t=this._connection=new f;var i=this.getSubject();t.add(this.source.subscribe(new B(i,void 0,(function(){e._teardown(),i.complete()}),(function(t){e._teardown(),i.error(t)}),(function(){return e._teardown()})))),t.closed&&(this._connection=null,t=f.EMPTY)}return t},t.prototype.refCount=function(){return U()(this)},t}(k),H=d((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),j=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return i(t,e),t.prototype.lift=function(e){var t=new G(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new H},t.prototype.next=function(e){var t=this;C((function(){var i,n;if(t._throwIfClosed(),!t.isStopped){var r=t.observers.slice();try{for(var a=s(r),o=a.next();!o.done;o=a.next()){o.value.next(e)}}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}}}))},t.prototype.error=function(e){var t=this;C((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var i=t.observers;i.length;)i.shift().error(e)}}))},t.prototype.complete=function(){var e=this;C((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,i=t.hasError,n=t.isStopped,r=t.observers;return i||n?g:(r.push(e),new f((function(){return m(r,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,i=t.hasError,n=t.thrownError,r=t.isStopped;i?e.error(n):r&&e.complete()},t.prototype.asObservable=function(){var e=new k;return e.source=this,e},t.create=function(e,t){return new G(e,t)},t}(k),G=function(e){function t(t,i){var n=e.call(this)||this;return n.destination=t,n.source=i,n}return i(t,e),t.prototype.next=function(e){var t,i;null===(i=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===i||i.call(t,e)},t.prototype.error=function(e){var t,i;null===(i=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===i||i.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,i;return null!==(i=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==i?i:g},t}(j),W=function(e){function t(t){var i=e.call(this)||this;return i._value=t,i}return i(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var i=e.prototype._subscribe.call(this,t);return!i.closed&&t.next(this._value),i},t.prototype.getValue=function(){var e=this,t=e.hasError,i=e.thrownError,n=e._value;if(t)throw i;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(j),q={now:function(){return(q.delegate||Date).now()},delegate:void 0},X=function(e){function t(t,i,n){void 0===t&&(t=1/0),void 0===i&&(i=1/0),void 0===n&&(n=q);var r=e.call(this)||this;return r._bufferSize=t,r._windowTime=i,r._timestampProvider=n,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=i===1/0,r._bufferSize=Math.max(1,t),r._windowTime=Math.max(1,i),r}return i(t,e),t.prototype.next=function(t){var i=this,n=i.isStopped,r=i._buffer,s=i._infiniteTimeWindow,a=i._timestampProvider,o=i._windowTime;n||(r.push(t),!s&&r.push(a.now()+o)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),i=this._infiniteTimeWindow,n=this._buffer.slice(),r=0;r<n.length&&!e.closed;r+=i?1:2)e.next(n[r]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,i=e._timestampProvider,n=e._buffer,r=e._infiniteTimeWindow,s=(r?1:2)*t;if(t<1/0&&s<n.length&&n.splice(0,n.length-s),!r){for(var a=i.now(),o=0,h=1;h<n.length&&n[h]<=a;h+=2)o=h;o&&n.splice(0,o+1)}},t}(j),Z=function(e){function t(t,i){return e.call(this)||this}return i(t,e),t.prototype.schedule=function(e,t){return this},t}(f),Y={setInterval:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Y.delegate;return((null==i?void 0:i.setInterval)||setInterval).apply(void 0,o([],a(e)))},clearInterval:function(e){var t=Y.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},J=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.scheduler=t,n.work=i,n.pending=!1,n}return i(t,e),t.prototype.schedule=function(e,t){if(void 0===t&&(t=0),this.closed)return this;this.state=e;var i=this.id,n=this.scheduler;return null!=i&&(this.id=this.recycleAsyncId(n,i,t)),this.pending=!0,this.delay=t,this.id=this.id||this.requestAsyncId(n,this.id,t),this},t.prototype.requestAsyncId=function(e,t,i){return void 0===i&&(i=0),Y.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,t,i){if(void 0===i&&(i=0),null!=i&&this.delay===i&&!1===this.pending)return t;Y.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,t);if(i)return i;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var i,n=!1;try{this.work(e)}catch(e){n=!0,i=!!e&&e||new Error(e)}if(n)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,i=this.scheduler,n=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,m(n,this),null!=t&&(this.id=this.recycleAsyncId(i,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Z),K=function(){function e(t,i){void 0===i&&(i=e.now),this.schedulerActionCtor=t,this.now=i}return e.prototype.schedule=function(e,t,i){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(i,t)},e.now=q.now,e}(),Q=new(function(e){function t(t,i){void 0===i&&(i=K.now);var n=e.call(this,t,i)||this;return n.actions=[],n._active=!1,n._scheduled=void 0,n}return i(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var i;this._active=!0;do{if(i=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,i){for(;e=t.shift();)e.unsubscribe();throw i}}},t}(K))(J),ee=Q,te=new k((function(e){return e.complete()}));function ie(e){return e?function(e){return new k((function(t){return e.schedule((function(){return t.complete()}))}))}(e):te}function ne(e,t){return new k((function(i){var n=0;return t.schedule((function(){n===e.length?i.complete():(i.next(e[n++]),i.closed||this.schedule())}))}))}var re=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function se(e){return u(null==e?void 0:e.then)}var ae="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function oe(e,t,i,n){void 0===n&&(n=0);var r=t.schedule((function(){try{i.call(this)}catch(t){e.error(t)}}),n);return e.add(r),r}function he(e,t){if(!e)throw new Error("Iterable cannot be null");return new k((function(i){var n=new f;return n.add(t.schedule((function(){var r=e[Symbol.asyncIterator]();n.add(t.schedule((function(){var e=this;r.next().then((function(t){t.done?i.complete():(i.next(t.value),e.schedule())}))})))}))),n}))}function ce(e){return u(e[D])}function le(e){return u(null==e?void 0:e[ae])}function ue(e){return Symbol.asyncIterator&&u(null==e?void 0:e[Symbol.asyncIterator])}function de(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function pe(e){return c(this,arguments,(function(){var t,i,n;return r(this,(function(r){switch(r.label){case 0:t=e.getReader(),r.label=1;case 1:r.trys.push([1,,9,10]),r.label=2;case 2:return[4,h(t.read())];case 3:return i=r.sent(),n=i.value,i.done?[4,h(void 0)]:[3,5];case 4:return[2,r.sent()];case 5:return[4,h(n)];case 6:return[4,r.sent()];case 7:return r.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function me(e){return u(null==e?void 0:e.getReader)}function fe(e,t){if(null!=e){if(ce(e))return function(e,t){return new k((function(i){var n=new f;return n.add(t.schedule((function(){var r=e[D]();n.add(r.subscribe({next:function(e){n.add(t.schedule((function(){return i.next(e)})))},error:function(e){n.add(t.schedule((function(){return i.error(e)})))},complete:function(){n.add(t.schedule((function(){return i.complete()})))}}))}))),n}))}(e,t);if(re(e))return ne(e,t);if(se(e))return function(e,t){return new k((function(i){return t.schedule((function(){return e.then((function(e){i.add(t.schedule((function(){i.next(e),i.add(t.schedule((function(){return i.complete()})))})))}),(function(e){i.add(t.schedule((function(){return i.error(e)})))}))}))}))}(e,t);if(ue(e))return he(e,t);if(le(e))return function(e,t){return new k((function(i){var n;return i.add(t.schedule((function(){n=e[ae](),oe(i,t,(function(){var e=n.next(),t=e.value;e.done?i.complete():(i.next(t),this.schedule())}))}))),function(){return u(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(me(e))return function(e,t){return he(pe(e),t)}(e,t)}throw de(e)}function ge(e,t){return t?fe(e,t):_e(e)}function _e(e){if(e instanceof k)return e;if(null!=e){if(ce(e))return n=e,new k((function(e){var t=n[D]();if(u(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(re(e))return ve(e);if(se(e))return i=e,new k((function(e){i.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,x)}));if(ue(e))return ye(e);if(le(e))return t=e,new k((function(e){var i,n;try{for(var r=s(t),a=r.next();!a.done;a=r.next()){var o=a.value;if(e.next(o),e.closed)return}}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}e.complete()}));if(me(e))return ye(pe(e))}var t,i,n;throw de(e)}function ve(e){return new k((function(t){for(var i=0;i<e.length&&!t.closed;i++)t.next(e[i]);t.complete()}))}function ye(e){return new k((function(t){(function(e,t){var i,s,a,o;return n(this,void 0,void 0,(function(){var n,h;return r(this,(function(r){switch(r.label){case 0:r.trys.push([0,5,6,11]),i=l(e),r.label=1;case 1:return[4,i.next()];case 2:if((s=r.sent()).done)return[3,4];if(n=s.value,t.next(n),t.closed)return[2];r.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return h=r.sent(),a={error:h},[3,11];case 6:return r.trys.push([6,,9,10]),s&&!s.done&&(o=i.return)?[4,o.call(i)]:[3,8];case 7:r.sent(),r.label=8;case 8:return[3,10];case 9:if(a)throw a.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function be(e,t){return t?ne(e,t):ve(e)}function xe(e){return e&&u(e.schedule)}function we(e){return e[e.length-1]}function Me(e){return u(we(e))?e.pop():void 0}function Se(e){return xe(we(e))?e.pop():void 0}function Te(e,t){return"number"==typeof we(e)?e.pop():t}function Ce(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Se(e);return i?ne(e,i):be(e)}function Ee(e,t){var i=u(e)?e:function(){return e},n=function(e){return e.error(i())};return new k(t?function(e){return t.schedule(n,0,e)}:n)}var Ae=d((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ie(e){return e instanceof Date&&!isNaN(e)}var Re=d((function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}}));function Pe(e,t){var i=Ie(e)?{first:e}:"number"==typeof e?{each:e}:e,n=i.first,r=i.each,s=i.with,a=void 0===s?Le:s,o=i.scheduler,h=void 0===o?null!=t?t:Q:o,c=i.meta,l=void 0===c?null:c;if(null==n&&null==r)throw new TypeError("No timeout provided.");return F((function(e,t){var i,s,o=null,c=0,u=function(e){s=oe(t,h,(function(){i.unsubscribe(),_e(a({meta:l,lastValue:o,seen:c})).subscribe(t)}),e)};i=e.subscribe(new B(t,(function(e){null==s||s.unsubscribe(),c++,t.next(o=e),r>0&&u(r)}),void 0,void 0,(function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),o=null}))),u(null!=n?"number"==typeof n?n:+n-h.now():r)}))}function Le(e){throw new Re(e)}function De(e,t){return F((function(i,n){var r=0;i.subscribe(new B(n,(function(i){n.next(e.call(t,i,r++))})))}))}var Ne=Array.isArray;function $e(e){return De((function(t){return function(e,t){return Ne(t)?e.apply(void 0,o([],a(t))):e(t)}(e,t)}))}var ke=Array.isArray,Oe=Object.getPrototypeOf,ze=Object.prototype,Fe=Object.keys;function Be(e){if(1===e.length){var t=e[0];if(ke(t))return{args:t,keys:null};if((n=t)&&"object"==typeof n&&Oe(n)===ze){var i=Fe(t);return{args:i.map((function(e){return t[e]})),keys:i}}}var n;return{args:e,keys:null}}function Ue(e,t){return e.reduce((function(e,i,n){return e[i]=t[n],e}),{})}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Se(e),n=Me(e),r=Be(e),s=r.args,a=r.keys;if(0===s.length)return ge([],i);var o=new k(He(s,i,a?function(e){return Ue(a,e)}:N));return n?o.pipe($e(n)):o}function He(e,t,i){return void 0===i&&(i=N),function(n){je(t,(function(){for(var r=e.length,s=new Array(r),a=r,o=r,h=function(r){je(t,(function(){var h=ge(e[r],t),c=!1;h.subscribe(new B(n,(function(e){s[r]=e,c||(c=!0,o--),o||n.next(i(s.slice()))}),(function(){--a||n.complete()})))}),n)},c=0;c<r;c++)h(c)}),n)}}function je(e,t,i){e?i.add(e.schedule(t)):t()}function Ge(e,t,i,n,r,s,a,o){var h=[],c=0,l=0,u=!1,d=function(){!u||h.length||c||t.complete()},p=function(e){return c<n?m(e):h.push(e)},m=function(e){s&&t.next(e),c++;var o=!1;_e(i(e,l++)).subscribe(new B(t,(function(e){null==r||r(e),s?p(e):t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{c--;for(var e=function(){var e=h.shift();a?t.add(a.schedule((function(){return m(e)}))):m(e)};h.length&&c<n;)e();d()}catch(e){t.error(e)}})))};return e.subscribe(new B(t,p,(function(){u=!0,d()}))),function(){null==o||o()}}function We(e,t,i){return void 0===i&&(i=1/0),u(t)?We((function(i,n){return De((function(e,r){return t(i,e,n,r)}))(_e(e(i,n)))}),i):("number"==typeof t&&(i=t),F((function(t,n){return Ge(t,n,e,i)})))}function qe(e){return void 0===e&&(e=1/0),We(N,e)}function Xe(){return qe(1)}function Ze(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe()(be(e,Se(e)))}var Ye=["addListener","removeListener"],Je=["addEventListener","removeEventListener"],Ke=["on","off"];function Qe(e,t,i,n){if(u(i)&&(n=i,i=void 0),n)return Qe(e,t,i).pipe($e(n));var r=a(function(e){return u(e.addEventListener)&&u(e.removeEventListener)}(e)?Je.map((function(n){return function(r){return e[n](t,r,i)}})):function(e){return u(e.addListener)&&u(e.removeListener)}(e)?Ye.map(et(e,t)):function(e){return u(e.on)&&u(e.off)}(e)?Ke.map(et(e,t)):[],2),s=r[0],o=r[1];if(!s&&re(e))return We((function(e){return Qe(e,t,i)}))(be(e));if(!s)throw new TypeError("Invalid event target");return new k((function(e){var t=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.next(1<t.length?t:t[0])};return s(t),function(){return o(t)}}))}function et(e,t){return function(i){return function(n){return e[i](t,n)}}}function tt(e,t,i){void 0===e&&(e=0),void 0===i&&(i=ee);var n=-1;return null!=t&&(xe(t)?i=t:n=t),new k((function(t){var r=Ie(e)?+e-i.now():e;r<0&&(r=0);var s=0;return i.schedule((function(){t.closed||(t.next(s++),0<=n?this.schedule(void 0,n):t.complete())}),r)}))}function it(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Se(e),n=Te(e,1/0),r=e;return r.length?1===r.length?_e(r[0]):qe(n)(be(r,i)):te}var nt=Array.isArray;function rt(e){return 1===e.length&&nt(e[0])?e[0]:e}function st(e,t){return F((function(i,n){var r=0;i.subscribe(new B(n,(function(i){return e.call(t,i,r++)&&n.next(i)})))}))}function at(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Me(e),n=rt(e);return n.length?new k((function(e){var t=n.map((function(){return[]})),r=n.map((function(){return!1}));e.add((function(){t=r=null}));for(var s=function(s){_e(n[s]).subscribe(new B(e,(function(n){if(t[s].push(n),t.every((function(e){return e.length}))){var h=t.map((function(e){return e.shift()}));e.next(i?i.apply(void 0,o([],a(h))):h),t.some((function(e,t){return!e.length&&r[t]}))&&e.complete()}}),(function(){r[s]=!0,!t[s].length&&e.complete()})))},h=0;!e.closed&&h<n.length;h++)s(h);return function(){t=r=null}})):te}function ot(e,t){return void 0===t&&(t=ee),i=function(){return tt(e,t)},F((function(e,t){var n=!1,r=null,s=null,a=!1,o=function(){if(null==s||s.unsubscribe(),s=null,n){n=!1;var e=r;r=null,t.next(e)}a&&t.complete()},h=function(){s=null,a&&t.complete()};e.subscribe(new B(t,(function(e){n=!0,r=e,s||_e(i(e)).subscribe(s=new B(t,o,h))}),(function(){a=!0,(!n||!s||s.closed)&&t.complete()})))}));var i}function ht(e,t){return void 0===t&&(t=null),t=null!=t?t:e,F((function(i,n){var r=[],a=0;i.subscribe(new B(n,(function(i){var o,h,c,l,u=null;a++%t==0&&r.push([]);try{for(var d=s(r),p=d.next();!p.done;p=d.next()){(_=p.value).push(i),e<=_.length&&(u=null!=u?u:[]).push(_)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(h=d.return)&&h.call(d)}finally{if(o)throw o.error}}if(u)try{for(var f=s(u),g=f.next();!g.done;g=f.next()){var _=g.value;m(r,_),n.next(_)}}catch(e){c={error:e}}finally{try{g&&!g.done&&(l=f.return)&&l.call(f)}finally{if(c)throw c.error}}}),(function(){var e,t;try{for(var i=s(r),a=i.next();!a.done;a=i.next()){var o=a.value;n.next(o)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}n.complete()}),void 0,(function(){r=null})))}))}function ct(e){return F((function(t,i){var n,r=null,s=!1;r=t.subscribe(new B(i,void 0,void 0,(function(a){n=_e(e(a,ct(e)(t))),r?(r.unsubscribe(),r=null,n.subscribe(i)):s=!0}))),s&&(r.unsubscribe(),r=null,n.subscribe(i))}))}function lt(e,t,i,n,r){return function(s,a){var o=i,h=t,c=0;s.subscribe(new B(a,(function(t){var i=c++;h=o?e(h,t,i):(o=!0,t),n&&a.next(h)}),r&&function(){o&&a.next(h),a.complete()}))}}function ut(e,t){return F(lt(e,t,arguments.length>=2,!1,!0))}function dt(e,t){return u(t)?We(e,t,1):We(e,1)}var pt={connector:function(){return new j}};function mt(e,t){void 0===t&&(t=pt);var i=t.connector;return F((function(t,n){var r,s=i();ge(e((r=s,new k((function(e){return r.subscribe(e)}))))).subscribe(n),n.add(t.subscribe(s))}))}function ft(e,t){return void 0===t&&(t=Q),F((function(i,n){var r=null,s=null,a=null,o=function(){if(r){r.unsubscribe(),r=null;var e=s;s=null,n.next(e)}};function h(){var i=a+e,s=t.now();if(s<i)return r=this.schedule(void 0,i-s),void n.add(r);o()}i.subscribe(new B(n,(function(i){s=i,a=t.now(),r||(r=t.schedule(h,e),n.add(r))}),(function(){o(),n.complete()}),void 0,(function(){s=r=null})))}))}function gt(e){return F((function(t,i){var n=!1;t.subscribe(new B(i,(function(e){n=!0,i.next(e)}),(function(){n||i.next(e),i.complete()})))}))}function _t(e){return e<=0?function(){return te}:F((function(t,i){var n=0;t.subscribe(new B(i,(function(t){++n<=e&&(i.next(t),e<=n&&i.complete())})))}))}function vt(e,t){return void 0===t&&(t=N),e=null!=e?e:yt,F((function(i,n){var r,s=!0;i.subscribe(new B(n,(function(i){var a=t(i);!s&&e(r,a)||(s=!1,r=a,n.next(i))})))}))}function yt(e,t){return e===t}function bt(e){return void 0===e&&(e=xt),F((function(t,i){var n=!1;t.subscribe(new B(i,(function(e){n=!0,i.next(e)}),(function(){return n?i.complete():i.error(e())})))}))}function xt(){return new Ae}function wt(e,t,i){return void 0===t&&(t=1/0),t=(t||0)<1?1/0:t,F((function(n,r){return Ge(n,r,e,t,void 0,!0,i)}))}function Mt(e){return F((function(t,i){try{t.subscribe(i)}finally{i.add(e)}}))}function St(e,t){var i=arguments.length>=2;return function(n){return n.pipe(e?st((function(t,i){return e(t,i,n)})):N,_t(1),i?gt(t):bt((function(){return new Ae})))}}function Tt(e){return e<=0?function(){return te}:F((function(t,i){var n=[];t.subscribe(new B(i,(function(t){n.push(t),e<n.length&&n.shift()}),(function(){var e,t;try{for(var r=s(n),a=r.next();!a.done;a=r.next()){var o=a.value;i.next(o)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}i.complete()}),void 0,(function(){n=null})))}))}function Ct(e,t){var i=arguments.length>=2;return function(n){return n.pipe(e?st((function(t,i){return e(t,i,n)})):N,Tt(1),i?gt(t):bt((function(){return new Ae})))}}function Et(e,t){var i=u(e)?e:function(){return e};return u(t)?mt(t,{connector:i}):function(e){return new V(e,i)}}function At(){return F((function(e,t){var i,n=!1;e.subscribe(new B(t,(function(e){var r=i;i=e,n&&t.next([r,e]),n=!0})))}))}function It(e){return e?function(t){return mt(e)(t)}:function(e){return Et(new j)(e)}}function Rt(e,t,i,n){i&&!u(i)&&(n=i);var r=u(i)?i:void 0;return function(i){return Et(new X(e,t,n),r)(i)}}function Pt(e){var t;void 0===e&&(e=1/0);var i=(t=e&&"object"==typeof e?e:{count:e}).count,n=void 0===i?1/0:i,r=t.delay,s=t.resetOnSuccess,a=void 0!==s&&s;return n<=0?N:F((function(e,t){var i,s=0,o=function(){var h=!1;i=e.subscribe(new B(t,(function(e){a&&(s=0),t.next(e)}),void 0,(function(e){if(s++<n){var a=function(){i?(i.unsubscribe(),i=null,o()):h=!0};if(null!=r){var c="number"==typeof r?tt(r):_e(r(e,s)),l=new B(t,(function(){l.unsubscribe(),a()}),(function(){t.complete()}));c.subscribe(l)}else a()}else t.error(e)}))),h&&(i.unsubscribe(),i=null,o())};o()}))}function Lt(e,t){return F(lt(e,t,arguments.length>=2,!0))}function Dt(e){void 0===e&&(e={});var t=e.connector,i=void 0===t?function(){return new j}:t,n=e.resetOnError,r=void 0===n||n,s=e.resetOnComplete,a=void 0===s||s,o=e.resetOnRefCountZero,h=void 0===o||o;return function(e){var t=null,n=null,s=null,o=0,c=!1,l=!1,u=function(){null==n||n.unsubscribe(),n=null},d=function(){u(),t=s=null,c=l=!1},p=function(){var e=t;d(),null==e||e.unsubscribe()};return F((function(e,m){o++,l||c||u();var f=s=null!=s?s:i();m.add((function(){0!==--o||l||c||(n=Nt(p,h))})),f.subscribe(m),t||(t=new A({next:function(e){return f.next(e)},error:function(e){l=!0,u(),n=Nt(d,r,e),f.error(e)},complete:function(){c=!0,u(),n=Nt(d,a),f.complete()}}),ge(e).subscribe(t))}))(e)}}function Nt(e,t){for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];return!0===t?(e(),null):!1===t?null:t.apply(void 0,o([],a(i))).pipe(_t(1)).subscribe((function(){return e()}))}function $t(e){return st((function(t,i){return e<=i}))}function kt(e){return F((function(t,i){var n=!1,r=0;t.subscribe(new B(i,(function(t){return(n||(n=!e(t,r++)))&&i.next(t)})))}))}function Ot(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Se(e);return F((function(t,n){(i?Ze(e,t,i):Ze(e,t)).subscribe(n)}))}function zt(e,t){return F((function(i,n){var r=null,s=0,a=!1,o=function(){return a&&!r&&n.complete()};i.subscribe(new B(n,(function(i){null==r||r.unsubscribe();var a=0,h=s++;_e(e(i,h)).subscribe(r=new B(n,(function(e){return n.next(t?t(i,e,h,a++):e)}),(function(){r=null,o()})))}),(function(){a=!0,o()})))}))}function Ft(e){return F((function(t,i){_e(e).subscribe(new B(i,(function(){return i.complete()}),w)),!i.closed&&t.subscribe(i)}))}function Bt(e,t){return void 0===t&&(t=!1),F((function(i,n){var r=0;i.subscribe(new B(n,(function(i){var s=e(i,r++);(s||t)&&n.next(i),!s&&n.complete()})))}))}function Ut(e,t,i){var n=u(e)||t||i?{next:e,error:t,complete:i}:e;return n?F((function(e,t){var i;null===(i=n.subscribe)||void 0===i||i.call(n);var r=!0;e.subscribe(new B(t,(function(e){var i;null===(i=n.next)||void 0===i||i.call(n,e),t.next(e)}),(function(){var e;r=!1,null===(e=n.complete)||void 0===e||e.call(n),t.complete()}),(function(e){var i;r=!1,null===(i=n.error)||void 0===i||i.call(n,e),t.error(e)}),(function(){var e,t;r&&(null===(e=n.unsubscribe)||void 0===e||e.call(n)),null===(t=n.finalize)||void 0===t||t.call(n)})))})):N}function Vt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=Me(e);return F((function(t,n){for(var r=e.length,s=new Array(r),h=e.map((function(){return!1})),c=!1,l=function(t){_e(e[t]).subscribe(new B(n,(function(e){s[t]=e,c||h[t]||(h[t]=!0,(c=h.every(N))&&(h=null))}),w))},u=0;u<r;u++)l(u);t.subscribe(new B(n,(function(e){if(c){var t=o([e],a(s));n.next(i?i.apply(void 0,o([],a(t))):t)}})))}))}class Ht{createFilter(e){return new Function("node","return "+this._compile(e)+";")}_compile(e){if(null==e||e.length<=1)return"true";const t=e[0];return"("+("=="===t?this._compileComparisonOp("===",e[1],e[2],!1):"!="===t?this._compileComparisonOp("!==",e[1],e[2],!1):">"===t||">="===t||"<"===t||"<="===t?this._compileComparisonOp(t,e[1],e[2],!0):"in"===t?this._compileInOp(e[1],e.slice(2)):"!in"===t?this._compileNegation(this._compileInOp(e[1],e.slice(2))):"all"===t?this._compileLogicalOp(e.slice(1),"&&"):"true")+")"}_compare(e,t){return e<t?-1:e>t?1:0}_compileComparisonOp(e,t,i,n){const r=this._compilePropertyReference(t),s=JSON.stringify(i);return(n?"typeof "+r+"===typeof "+s+"&&":"")+r+e+s}_compileInOp(e,t){const i=this._compare;return JSON.stringify(t.sort(i))+".indexOf("+this._compilePropertyReference(e)+")!==-1"}_compileLogicalOp(e,t){const i=this._compile.bind(this);return e.map(i).join(t)}_compileNegation(e){return"!("+e+")"}_compilePropertyReference(e){return"node["+JSON.stringify(e)+"]"}}
+/**
+ * @license
+ * Copyright 2010-2021 Three.js Authors
+ * SPDX-License-Identifier: MIT
+ */const jt=100,Gt=301,Wt=302,qt=306,Xt=1e3,Zt=1001,Yt=1002,Jt=1003,Kt=1006,Qt=1008,ei=1009,ti=1012,ii=1014,ni=1015,ri=1016,si=1020,ai=1022,oi=1023,hi=1026,ci=1027,li=2300,ui=2301,di=2302,pi=2400,mi=2401,fi=2402,gi=2500,_i=3e3,vi=3001,yi=3007,bi=3002,xi=7680,wi=35044,Mi=35048,Si="300 es";class Ti{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const i=this._listeners[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const i=t.slice(0);for(let t=0,n=i.length;t<n;t++)i[t].call(this,e);e.target=null}}}let Ci=1234567;const Ei=Math.PI/180,Ai=180/Math.PI,Ii=[];for(let e=0;e<256;e++)Ii[e]=(e<16?"0":"")+e.toString(16);const Ri="undefined"!=typeof crypto&&"randomUUID"in crypto;function Pi(){if(Ri)return crypto.randomUUID().toUpperCase();const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(Ii[255&e]+Ii[e>>8&255]+Ii[e>>16&255]+Ii[e>>24&255]+"-"+Ii[255&t]+Ii[t>>8&255]+"-"+Ii[t>>16&15|64]+Ii[t>>24&255]+"-"+Ii[63&i|128]+Ii[i>>8&255]+"-"+Ii[i>>16&255]+Ii[i>>24&255]+Ii[255&n]+Ii[n>>8&255]+Ii[n>>16&255]+Ii[n>>24&255]).toUpperCase()}function Li(e,t,i){return Math.max(t,Math.min(i,e))}function Di(e,t){return(e%t+t)%t}function Ni(e,t,i){return(1-i)*e+i*t}function $i(e){return 0==(e&e-1)&&0!==e}function ki(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var Oi=Object.freeze({__proto__:null,DEG2RAD:Ei,RAD2DEG:Ai,generateUUID:Pi,clamp:Li,euclideanModulo:Di,mapLinear:function(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},inverseLerp:function(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:Ni,damp:function(e,t,i,n){return Ni(e,t,1-Math.exp(-i*n))},pingpong:function(e,t=1){return t-Math.abs(Di(e,2*t)-t)},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-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())},seededRandom:function(e){return void 0!==e&&(Ci=e%2147483647),Ci=16807*Ci%2147483647,(Ci-1)/2147483646},degToRad:function(e){return e*Ei},radToDeg:function(e){return e*Ai},isPowerOfTwo:$i,ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:ki,setQuaternionFromProperEuler:function(e,t,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),h=a(i/2),c=s((t+n)/2),l=a((t+n)/2),u=s((t-n)/2),d=a((t-n)/2),p=s((n-t)/2),m=a((n-t)/2);switch(r){case"XYX":e.set(o*l,h*u,h*d,o*c);break;case"YZY":e.set(h*d,o*l,h*u,o*c);break;case"ZXZ":e.set(h*u,h*d,o*l,o*c);break;case"XZX":e.set(o*l,h*m,h*p,o*c);break;case"YXY":e.set(h*p,o*l,h*m,o*c);break;case"ZYZ":e.set(h*m,h*p,o*l,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}});class zi{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(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(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(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(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(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(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*i-s*n+e.x,this.y=r*n+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}zi.prototype.isVector2=!0;class Fi{constructor(){this.elements=[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.")}set(e,t,i,n,r,s,a,o,h){const c=this.elements;return c[0]=e,c[1]=n,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=i,c[7]=s,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const 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}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],a=i[3],o=i[6],h=i[1],c=i[4],l=i[7],u=i[2],d=i[5],p=i[8],m=n[0],f=n[3],g=n[6],_=n[1],v=n[4],y=n[7],b=n[2],x=n[5],w=n[8];return r[0]=s*m+a*_+o*b,r[3]=s*f+a*v+o*x,r[6]=s*g+a*y+o*w,r[1]=h*m+c*_+l*b,r[4]=h*f+c*v+l*x,r[7]=h*g+c*y+l*w,r[2]=u*m+d*_+p*b,r[5]=u*f+d*v+p*x,r[8]=u*g+d*y+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],a=e[5],o=e[6],h=e[7],c=e[8];return t*s*c-t*a*h-i*r*c+i*a*o+n*r*h-n*s*o}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],a=e[5],o=e[6],h=e[7],c=e[8],l=c*s-a*h,u=a*o-c*r,d=h*r-s*o,p=t*l+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=l*m,e[1]=(n*h-c*i)*m,e[2]=(a*i-n*s)*m,e[3]=u*m,e[4]=(c*t-n*o)*m,e[5]=(n*r-a*t)*m,e[6]=d*m,e[7]=(i*o-h*t)*m,e[8]=(s*t-i*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,s,a){const o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*s+h*a)+s+e,-n*h,n*o,-n*(-h*s+o*a)+a+t,0,0,1),this}scale(e,t){const i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=t,i[4]*=t,i[7]*=t,this}rotate(e){const t=Math.cos(e),i=Math.sin(e),n=this.elements,r=n[0],s=n[3],a=n[6],o=n[1],h=n[4],c=n[7];return n[0]=t*r+i*o,n[3]=t*s+i*h,n[6]=t*a+i*c,n[1]=-i*r+t*o,n[4]=-i*s+t*h,n[7]=-i*a+t*c,this}translate(e,t){const i=this.elements;return i[0]+=e*i[2],i[3]+=e*i[5],i[6]+=e*i[8],i[1]+=t*i[2],i[4]+=t*i[5],i[7]+=t*i[8],this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function Bi(e){if(0===e.length)return-1/0;let t=e[0];for(let i=1,n=e.length;i<n;++i)e[i]>t&&(t=e[i]);return t}function Ui(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Vi(e,t=0){let i=3735928559^t,n=1103547991^t;for(let t,r=0;r<e.length;r++)t=e.charCodeAt(r),i=Math.imul(i^t,2654435761),n=Math.imul(n^t,1597334677);return i=Math.imul(i^i>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(i^i>>>13,3266489909),4294967296*(2097151&n)+(i>>>0)}let Hi;Fi.prototype.isMatrix3=!0;class ji{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Hi&&(Hi=Ui("canvas")),Hi.width=e.width,Hi.height=e.height;const i=Hi.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Hi}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let Gi=0;class Wi extends Ti{constructor(e=Wi.DEFAULT_IMAGE,t=Wi.DEFAULT_MAPPING,i=1001,n=1001,r=1006,s=1008,a=1023,o=1009,h=1,c=3e3){super(),Object.defineProperty(this,"id",{value:Gi++}),this.uuid=Pi(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=s,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new zi(0,0),this.repeat=new zi(1,1),this.center=new zi(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fi,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,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.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const i={metadata:{version:4.5,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],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const n=this.image;if(void 0===n.uuid&&(n.uuid=Pi()),!t&&void 0===e.images[n.uuid]){let t;if(Array.isArray(n)){t=[];for(let e=0,i=n.length;e<i;e++)n[e].isDataTexture?t.push(qi(n[e].image)):t.push(qi(n[e]))}else t=qi(n);e.images[n.uuid]={uuid:n.uuid,url:t}}i.image=n.uuid}return"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xt:e.x=e.x-Math.floor(e.x);break;case Zt:e.x=e.x<0?0:1;break;case Yt: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 Xt:e.y=e.y-Math.floor(e.y);break;case Zt:e.y=e.y<0?0:1;break;case Yt:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function qi(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ji.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}Wi.DEFAULT_IMAGE=void 0,Wi.DEFAULT_MAPPING=300,Wi.prototype.isTexture=!0;class Xi{constructor(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(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(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(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(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(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(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(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(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}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*t+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*t+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*t+s[7]*i+s[11]*n+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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(e){let t,i,n,r;const s=.01,a=.1,o=e.elements,h=o[0],c=o[4],l=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)<s&&Math.abs(l-m)<s&&Math.abs(p-f)<s){if(Math.abs(c+u)<a&&Math.abs(l+m)<a&&Math.abs(p+f)<a&&Math.abs(h+d+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(h+1)/2,o=(d+1)/2,_=(g+1)/2,v=(c+u)/4,y=(l+m)/4,b=(p+f)/4;return e>o&&e>_?e<s?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(e),n=v/i,r=y/i):o>_?o<s?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(o),i=v/n,r=b/n):_<s?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(_),i=y/r,n=b/r),this.set(i,n,r,t),this}let _=Math.sqrt((f-p)*(f-p)+(l-m)*(l-m)+(u-c)*(u-c));return Math.abs(_)<.001&&(_=1),this.x=(f-p)/_,this.y=(l-m)/_,this.z=(u-c)/_,this.w=Math.acos((h+d+g-1)/2),this}min(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(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(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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){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(){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(){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(){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(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(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(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,i){return void 0!==i&&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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}Xi.prototype.isVector4=!0;class Zi extends Ti{constructor(e,t,i={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Xi(0,0,e,t),this.scissorTest=!1,this.viewport=new Xi(0,0,e,t),this.texture=new Wi(void 0,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:Kt,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,i=1){this.width===e&&this.height===t&&this.depth===i||(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Zi.prototype.isWebGLRenderTarget=!0;(class extends Zi{constructor(e,t,i){super(e,t);const n=this.texture;this.texture=[];for(let e=0;e<i;e++)this.texture[e]=n.clone()}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,r=this.texture.length;n<r;n++)this.texture[n].image.width=e,this.texture[n].image.height=t,this.texture[n].image.depth=i;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this.texture.length=0;for(let t=0,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone();return this}}).prototype.isWebGLMultipleRenderTargets=!0;class Yi extends Zi{constructor(e,t,i){super(e,t,i),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Yi.prototype.isWebGLMultisampleRenderTarget=!0;class Ji{constructor(e=0,t=0,i=0,n=1){this._x=e,this._y=t,this._z=i,this._w=n}static slerp(e,t,i,n){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(e,t,n)}static slerpFlat(e,t,i,n,r,s,a){let o=i[n+0],h=i[n+1],c=i[n+2],l=i[n+3];const u=r[s+0],d=r[s+1],p=r[s+2],m=r[s+3];if(0===a)return e[t+0]=o,e[t+1]=h,e[t+2]=c,void(e[t+3]=l);if(1===a)return e[t+0]=u,e[t+1]=d,e[t+2]=p,void(e[t+3]=m);if(l!==m||o!==u||h!==d||c!==p){let e=1-a;const t=o*u+h*d+c*p+l*m,i=t>=0?1:-1,n=1-t*t;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,t*i);e=Math.sin(e*s)/r,a=Math.sin(a*s)/r}const r=a*i;if(o=o*e+u*r,h=h*e+d*r,c=c*e+p*r,l=l*e+m*r,e===1-a){const e=1/Math.sqrt(o*o+h*h+c*c+l*l);o*=e,h*=e,c*=e,l*=e}}e[t]=o,e[t+1]=h,e[t+2]=c,e[t+3]=l}static multiplyQuaternionsFlat(e,t,i,n,r,s){const a=i[n],o=i[n+1],h=i[n+2],c=i[n+3],l=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*l+o*d-h*u,e[t+1]=o*p+c*u+h*l-a*d,e[t+2]=h*p+c*d+a*u-o*l,e[t+3]=c*p-a*l-o*u-h*d,e}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(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=e._x,n=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,h=a(i/2),c=a(n/2),l=a(r/2),u=o(i/2),d=o(n/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p;break;case"YXZ":this._x=u*c*l+h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p;break;case"ZXY":this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l-u*d*p;break;case"ZYX":this._x=u*c*l-h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l+u*d*p;break;case"YZX":this._x=u*c*l+h*d*p,this._y=h*d*l+u*c*p,this._z=h*c*p-u*d*l,this._w=h*c*l-u*d*p;break;case"XZY":this._x=u*c*l-h*d*p,this._y=h*d*l-u*c*p,this._z=h*c*p+u*d*l,this._w=h*c*l+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],s=t[1],a=t[5],o=t[9],h=t[2],c=t[6],l=t[10],u=i+a+l;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-h)*e,this._z=(s-n)*e}else if(i>a&&i>l){const e=2*Math.sqrt(1+i-a-l);this._w=(c-o)/e,this._x=.25*e,this._y=(n+s)/e,this._z=(r+h)/e}else if(a>l){const e=2*Math.sqrt(1+a-i-l);this._w=(r-h)/e,this._x=(n+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+l-i-a);this._w=(s-n)/e,this._x=(r+h)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Li(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(0===i)return this;const n=Math.min(1,t/i);return this.slerp(e,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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(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(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,s=e._w,a=t._x,o=t._y,h=t._z,c=t._w;return this._x=i*c+s*a+n*h-r*o,this._y=n*c+s*o+r*a-i*h,this._z=r*c+s*h+i*o-n*a,this._w=s*c-i*a-n*o-r*h,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const i=this._x,n=this._y,r=this._z,s=this._w;let a=s*e._w+i*e._x+n*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=s,this._x=i,this._y=n,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*i+t*this._x,this._y=e*n+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const h=Math.sqrt(o),c=Math.atan2(h,a),l=Math.sin((1-t)*c)/h,u=Math.sin(t*c)/h;return this._w=s*l+this._w*u,this._x=i*l+this._x*u,this._y=n*l+this._y*u,this._z=r*l+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,i){this.copy(e).slerp(t,i)}random(){const e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(n),i*Math.sin(r),i*Math.cos(r),t*Math.sin(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Ji.prototype.isQuaternion=!0;class Ki{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(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(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(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(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(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(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(en.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(en.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,s=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,s=e.y,a=e.z,o=e.w,h=o*t+s*n-a*i,c=o*i+a*t-r*n,l=o*n+r*i-s*t,u=-r*t-s*i-a*n;return this.x=h*o+u*-r+c*-a-l*-s,this.y=c*o+u*-s+l*-r-h*-a,this.z=l*o+u*-a+h*-s-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(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(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(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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(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(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Qi.copy(this).projectOnVector(e),this.sub(Qi)}reflect(e){return this.sub(Qi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Li(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,i){return void 0!==i&&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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Ki.prototype.isVector3=!0;const Qi=new Ki,en=new Ji;class tn{constructor(e=new Ki(1/0,1/0,1/0),t=new Ki(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,h=e.length;o<h;o+=3){const h=e[o],c=e[o+1],l=e[o+2];h<t&&(t=h),c<i&&(i=c),l<n&&(n=l),h>r&&(r=h),c>s&&(s=c),l>a&&(a=l)}return this.min.set(t,i,n),this.max.set(r,s,a),this}setFromBufferAttribute(e){let t=1/0,i=1/0,n=1/0,r=-1/0,s=-1/0,a=-1/0;for(let o=0,h=e.count;o<h;o++){const h=e.getX(o),c=e.getY(o),l=e.getZ(o);h<t&&(t=h),c<i&&(i=c),l<n&&(n=l),h>r&&(r=h),c>s&&(s=c),l>a&&(a=l)}return this.min.set(t,i,n),this.max.set(r,s,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=rn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e){e.updateWorldMatrix(!1,!1);const t=e.geometry;void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),sn.copy(t.boundingBox),sn.applyMatrix4(e.matrixWorld),this.union(sn));const i=e.children;for(let e=0,t=i.length;e<t;e++)this.expandByObject(i[e]);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(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(e,t){return t.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(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,rn),rn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(dn),pn.subVectors(this.max,dn),an.subVectors(e.a,dn),on.subVectors(e.b,dn),hn.subVectors(e.c,dn),cn.subVectors(on,an),ln.subVectors(hn,on),un.subVectors(an,hn);let t=[0,-cn.z,cn.y,0,-ln.z,ln.y,0,-un.z,un.y,cn.z,0,-cn.x,ln.z,0,-ln.x,un.z,0,-un.x,-cn.y,cn.x,0,-ln.y,ln.x,0,-un.y,un.x,0];return!!gn(t,an,on,hn,pn)&&(t=[1,0,0,0,1,0,0,0,1],!!gn(t,an,on,hn,pn)&&(mn.crossVectors(cn,ln),t=[mn.x,mn.y,mn.z],gn(t,an,on,hn,pn)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return rn.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(rn).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(nn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),nn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),nn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),nn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),nn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),nn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),nn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),nn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(nn)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}tn.prototype.isBox3=!0;const nn=[new Ki,new Ki,new Ki,new Ki,new Ki,new Ki,new Ki,new Ki],rn=new Ki,sn=new tn,an=new Ki,on=new Ki,hn=new Ki,cn=new Ki,ln=new Ki,un=new Ki,dn=new Ki,pn=new Ki,mn=new Ki,fn=new Ki;function gn(e,t,i,n,r){for(let s=0,a=e.length-3;s<=a;s+=3){fn.fromArray(e,s);const a=r.x*Math.abs(fn.x)+r.y*Math.abs(fn.y)+r.z*Math.abs(fn.z),o=t.dot(fn),h=i.dot(fn),c=n.dot(fn);if(Math.max(-Math.max(o,h,c),Math.min(o,h,c))>a)return!1}return!0}const _n=new tn,vn=new Ki,yn=new Ki,bn=new Ki;class xn{constructor(e=new Ki,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;void 0!==t?i.copy(t):_n.setFromPoints(e).getCenter(i);let n=0;for(let t=0,r=e.length;t<r;t++)n=Math.max(n,i.distanceToSquared(e[t]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){bn.subVectors(e,this.center);const t=bn.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),i=.5*(e-this.radius);this.center.add(bn.multiplyScalar(i/e)),this.radius+=i}return this}union(e){return yn.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(vn.copy(e.center).add(yn)),this.expandByPoint(vn.copy(e.center).sub(yn)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const wn=new Ki,Mn=new Ki,Sn=new Ki,Tn=new Ki,Cn=new Ki,En=new Ki,An=new Ki;class In{constructor(e=new Ki,t=new Ki(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(i).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(wn.copy(this.direction).multiplyScalar(t).add(this.origin),wn.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){Mn.copy(e).add(t).multiplyScalar(.5),Sn.copy(t).sub(e).normalize(),Tn.copy(this.origin).sub(Mn);const r=.5*e.distanceTo(t),s=-this.direction.dot(Sn),a=Tn.dot(this.direction),o=-Tn.dot(Sn),h=Tn.lengthSq(),c=Math.abs(1-s*s);let l,u,d,p;if(c>0)if(l=s*o-a,u=s*a-o,p=r*c,l>=0)if(u>=-p)if(u<=p){const e=1/c;l*=e,u*=e,d=l*(l+s*u+2*a)+u*(s*l+u+2*o)+h}else u=r,l=Math.max(0,-(s*u+a)),d=-l*l+u*(u+2*o)+h;else u=-r,l=Math.max(0,-(s*u+a)),d=-l*l+u*(u+2*o)+h;else u<=-p?(l=Math.max(0,-(-s*r+a)),u=l>0?-r:Math.min(Math.max(-r,-o),r),d=-l*l+u*(u+2*o)+h):u<=p?(l=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+h):(l=Math.max(0,-(s*r+a)),u=l>0?r:Math.min(Math.max(-r,-o),r),d=-l*l+u*(u+2*o)+h);else u=s>0?-r:r,l=Math.max(0,-(s*u+a)),d=-l*l+u*(u+2*o)+h;return i&&i.copy(this.direction).multiplyScalar(l).add(this.origin),n&&n.copy(Sn).multiplyScalar(u).add(Mn),d}intersectSphere(e,t){wn.subVectors(e.center,this.origin);const i=wn.dot(this.direction),n=wn.dot(wn)-i*i,r=e.radius*e.radius;if(n>r)return null;const s=Math.sqrt(r-n),a=i-s,o=i+s;return a<0&&o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,s,a,o;const h=1/this.direction.x,c=1/this.direction.y,l=1/this.direction.z,u=this.origin;return h>=0?(i=(e.min.x-u.x)*h,n=(e.max.x-u.x)*h):(i=(e.max.x-u.x)*h,n=(e.min.x-u.x)*h),c>=0?(r=(e.min.y-u.y)*c,s=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,s=(e.min.y-u.y)*c),i>s||r>n?null:((r>i||i!=i)&&(i=r),(s<n||n!=n)&&(n=s),l>=0?(a=(e.min.z-u.z)*l,o=(e.max.z-u.z)*l):(a=(e.max.z-u.z)*l,o=(e.min.z-u.z)*l),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o<n||n!=n)&&(n=o),n<0?null:this.at(i>=0?i:n,t)))}intersectsBox(e){return null!==this.intersectBox(e,wn)}intersectTriangle(e,t,i,n,r){Cn.subVectors(t,e),En.subVectors(i,e),An.crossVectors(Cn,En);let s,a=this.direction.dot(An);if(a>0){if(n)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Tn.subVectors(this.origin,e);const o=s*this.direction.dot(En.crossVectors(Tn,En));if(o<0)return null;const h=s*this.direction.dot(Cn.cross(Tn));if(h<0)return null;if(o+h>a)return null;const c=-s*Tn.dot(An);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Rn{constructor(){this.elements=[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.")}set(e,t,i,n,r,s,a,o,h,c,l,u,d,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=h,g[6]=c,g[10]=l,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Rn).fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/Pn.setFromMatrixColumn(e,0).length(),r=1/Pn.setFromMatrixColumn(e,1).length(),s=1/Pn.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,i=e.x,n=e.y,r=e.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(n),h=Math.sin(n),c=Math.cos(r),l=Math.sin(r);if("XYZ"===e.order){const e=s*c,i=s*l,n=a*c,r=a*l;t[0]=o*c,t[4]=-o*l,t[8]=h,t[1]=i+n*h,t[5]=e-r*h,t[9]=-a*o,t[2]=r-e*h,t[6]=n+i*h,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,i=o*l,n=h*c,r=h*l;t[0]=e+r*a,t[4]=n*a-i,t[8]=s*h,t[1]=s*l,t[5]=s*c,t[9]=-a,t[2]=i*a-n,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,i=o*l,n=h*c,r=h*l;t[0]=e-r*a,t[4]=-s*l,t[8]=n+i*a,t[1]=i+n*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*h,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,i=s*l,n=a*c,r=a*l;t[0]=o*c,t[4]=n*h-i,t[8]=e*h+r,t[1]=o*l,t[5]=r*h+e,t[9]=i*h-n,t[2]=-h,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,i=s*h,n=a*o,r=a*h;t[0]=o*c,t[4]=r-e*l,t[8]=n*l+i,t[1]=l,t[5]=s*c,t[9]=-a*c,t[2]=-h*c,t[6]=i*l+n,t[10]=e-r*l}else if("XZY"===e.order){const e=s*o,i=s*h,n=a*o,r=a*h;t[0]=o*c,t[4]=-l,t[8]=h*c,t[1]=e*l+r,t[5]=s*c,t[9]=i*l-n,t[2]=n*l-i,t[6]=a*c,t[10]=r*l+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Dn,e,Nn)}lookAt(e,t,i){const n=this.elements;return On.subVectors(e,t),0===On.lengthSq()&&(On.z=1),On.normalize(),$n.crossVectors(i,On),0===$n.lengthSq()&&(1===Math.abs(i.z)?On.x+=1e-4:On.z+=1e-4,On.normalize(),$n.crossVectors(i,On)),$n.normalize(),kn.crossVectors(On,$n),n[0]=$n.x,n[4]=kn.x,n[8]=On.x,n[1]=$n.y,n[5]=kn.y,n[9]=On.y,n[2]=$n.z,n[6]=kn.z,n[10]=On.z,this}multiply(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(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,s=i[0],a=i[4],o=i[8],h=i[12],c=i[1],l=i[5],u=i[9],d=i[13],p=i[2],m=i[6],f=i[10],g=i[14],_=i[3],v=i[7],y=i[11],b=i[15],x=n[0],w=n[4],M=n[8],S=n[12],T=n[1],C=n[5],E=n[9],A=n[13],I=n[2],R=n[6],P=n[10],L=n[14],D=n[3],N=n[7],$=n[11],k=n[15];return r[0]=s*x+a*T+o*I+h*D,r[4]=s*w+a*C+o*R+h*N,r[8]=s*M+a*E+o*P+h*$,r[12]=s*S+a*A+o*L+h*k,r[1]=c*x+l*T+u*I+d*D,r[5]=c*w+l*C+u*R+d*N,r[9]=c*M+l*E+u*P+d*$,r[13]=c*S+l*A+u*L+d*k,r[2]=p*x+m*T+f*I+g*D,r[6]=p*w+m*C+f*R+g*N,r[10]=p*M+m*E+f*P+g*$,r[14]=p*S+m*A+f*L+g*k,r[3]=_*x+v*T+y*I+b*D,r[7]=_*w+v*C+y*R+b*N,r[11]=_*M+v*E+y*P+b*$,r[15]=_*S+v*A+y*L+b*k,this}multiplyScalar(e){const 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}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],s=e[1],a=e[5],o=e[9],h=e[13],c=e[2],l=e[6],u=e[10],d=e[14];return e[3]*(+r*o*l-n*h*l-r*a*u+i*h*u+n*a*d-i*o*d)+e[7]*(+t*o*d-t*h*u+r*s*u-n*s*d+n*h*c-r*o*c)+e[11]*(+t*h*l-t*a*d-r*s*l+i*s*d+r*a*c-i*h*c)+e[15]*(-n*a*c-t*o*l+t*a*u+n*s*l-i*s*u+i*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],s=e[4],a=e[5],o=e[6],h=e[7],c=e[8],l=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],_=l*f*h-m*u*h+m*o*d-a*f*d-l*o*g+a*u*g,v=p*u*h-c*f*h-p*o*d+s*f*d+c*o*g-s*u*g,y=c*m*h-p*l*h+p*a*d-s*m*d-c*a*g+s*l*g,b=p*l*o-c*m*o-p*a*u+s*m*u+c*a*f-s*l*f,x=t*_+i*v+n*y+r*b;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/x;return e[0]=_*w,e[1]=(m*u*r-l*f*r-m*n*d+i*f*d+l*n*g-i*u*g)*w,e[2]=(a*f*r-m*o*r+m*n*h-i*f*h-a*n*g+i*o*g)*w,e[3]=(l*o*r-a*u*r-l*n*h+i*u*h+a*n*d-i*o*d)*w,e[4]=v*w,e[5]=(c*f*r-p*u*r+p*n*d-t*f*d-c*n*g+t*u*g)*w,e[6]=(p*o*r-s*f*r-p*n*h+t*f*h+s*n*g-t*o*g)*w,e[7]=(s*u*r-c*o*r+c*n*h-t*u*h-s*n*d+t*o*d)*w,e[8]=y*w,e[9]=(p*l*r-c*m*r-p*i*d+t*m*d+c*i*g-t*l*g)*w,e[10]=(s*m*r-p*a*r+p*i*h-t*m*h-s*i*g+t*a*g)*w,e[11]=(c*a*r-s*l*r-c*i*h+t*l*h+s*i*d-t*a*d)*w,e[12]=b*w,e[13]=(c*m*n-p*l*n+p*i*u-t*m*u-c*i*f+t*l*f)*w,e[14]=(p*a*n-s*m*n-p*i*o+t*m*o+s*i*f-t*a*f)*w,e[15]=(s*l*n-c*a*n+c*i*o-t*l*o-s*i*u+t*a*u)*w,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,s=e.x,a=e.y,o=e.z,h=r*s,c=r*a;return this.set(h*s+i,h*a-n*o,h*o+n*a,0,h*a+n*o,c*a+i,c*o-n*s,0,h*o-n*a,c*o+n*s,r*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,s){return this.set(1,i,r,0,e,1,s,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,h=r+r,c=s+s,l=a+a,u=r*h,d=r*c,p=r*l,m=s*c,f=s*l,g=a*l,_=o*h,v=o*c,y=o*l,b=i.x,x=i.y,w=i.z;return n[0]=(1-(m+g))*b,n[1]=(d+y)*b,n[2]=(p-v)*b,n[3]=0,n[4]=(d-y)*x,n[5]=(1-(u+g))*x,n[6]=(f+_)*x,n[7]=0,n[8]=(p+v)*w,n[9]=(f-_)*w,n[10]=(1-(u+m))*w,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let r=Pn.set(n[0],n[1],n[2]).length();const s=Pn.set(n[4],n[5],n[6]).length(),a=Pn.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],Ln.copy(this);const o=1/r,h=1/s,c=1/a;return Ln.elements[0]*=o,Ln.elements[1]*=o,Ln.elements[2]*=o,Ln.elements[4]*=h,Ln.elements[5]*=h,Ln.elements[6]*=h,Ln.elements[8]*=c,Ln.elements[9]*=c,Ln.elements[10]*=c,t.setFromRotationMatrix(Ln),i.x=r,i.y=s,i.z=a,this}makePerspective(e,t,i,n,r,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,o=2*r/(t-e),h=2*r/(i-n),c=(t+e)/(t-e),l=(i+n)/(i-n),u=-(s+r)/(s-r),d=-2*s*r/(s-r);return a[0]=o,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=h,a[9]=l,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=d,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,i,n,r,s){const a=this.elements,o=1/(t-e),h=1/(i-n),c=1/(s-r),l=(t+e)*o,u=(i+n)*h,d=(s+r)*c;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-l,a[1]=0,a[5]=2*h,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-d,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}Rn.prototype.isMatrix4=!0;const Pn=new Ki,Ln=new Rn,Dn=new Ki(0,0,0),Nn=new Ki(1,1,1),$n=new Ki,kn=new Ki,On=new Ki,zn=new Rn,Fn=new Ji;class Bn{constructor(e=0,t=0,i=0,n=Bn.DefaultOrder){this._x=e,this._y=t,this._z=i,this._order=n}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(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],s=n[4],a=n[8],o=n[1],h=n[5],c=n[9],l=n[2],u=n[6],d=n[10];switch(t){case"XYZ":this._y=Math.asin(Li(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Li(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-l,r),this._z=0);break;case"ZXY":this._x=Math.asin(Li(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Li(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(Li(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-l,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Li(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return zn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(zn,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Fn.setFromEuler(this),this.setFromQuaternion(Fn,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(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(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new Ki(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Bn.prototype.isEuler=!0,Bn.DefaultOrder="XYZ",Bn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Un{constructor(){this.mask=1}set(e){this.mask=1<<e|0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}}let Vn=0;const Hn=new Ki,jn=new Ji,Gn=new Rn,Wn=new Ki,qn=new Ki,Xn=new Ki,Zn=new Ji,Yn=new Ki(1,0,0),Jn=new Ki(0,1,0),Kn=new Ki(0,0,1),Qn={type:"added"},er={type:"removed"};class tr extends Ti{constructor(){super(),Object.defineProperty(this,"id",{value:Vn++}),this.uuid=Pi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tr.DefaultUp.clone();const e=new Ki,t=new Bn,i=new Ji,n=new Ki(1,1,1);t._onChange((function(){i.setFromEuler(t,!1)})),i._onChange((function(){t.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Rn},normalMatrix:{value:new Fi}}),this.matrix=new Rn,this.matrixWorld=new Rn,this.matrixAutoUpdate=tr.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Un,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return jn.setFromAxisAngle(e,t),this.quaternion.multiply(jn),this}rotateOnWorldAxis(e,t){return jn.setFromAxisAngle(e,t),this.quaternion.premultiply(jn),this}rotateX(e){return this.rotateOnAxis(Yn,e)}rotateY(e){return this.rotateOnAxis(Jn,e)}rotateZ(e){return this.rotateOnAxis(Kn,e)}translateOnAxis(e,t){return Hn.copy(e).applyQuaternion(this.quaternion),this.position.add(Hn.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Yn,e)}translateY(e){return this.translateOnAxis(Jn,e)}translateZ(e){return this.translateOnAxis(Kn,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Gn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Wn.copy(e):Wn.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),qn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Gn.lookAt(qn,Wn,this.up):Gn.lookAt(Wn,qn,this.up),this.quaternion.setFromRotationMatrix(Gn),n&&(Gn.extractRotation(n.matrixWorld),jn.setFromRotationMatrix(Gn),this.quaternion.premultiply(jn.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Qn)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(er)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(er)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Gn.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Gn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Gn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qn,e,Xn),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(qn,Zn,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(!0===e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,i=e.length;t<i;t++)e[t].updateWorldMatrix(!1,!0)}}toJSON(e){const t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},i.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const n={};function r(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const i=t.shapes;if(Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const n=i[t];r(e.shapes,n)}else r(e.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let i=0,n=this.material.length;i<n;i++)t.push(r(e.materials,this.material[i]));n.material=t}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let t=0;t<this.children.length;t++)n.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let t=0;t<this.animations.length;t++){const i=this.animations[t];n.animations.push(r(e.animations,i))}}if(t){const t=s(e.geometries),n=s(e.materials),r=s(e.textures),a=s(e.images),o=s(e.shapes),h=s(e.skeletons),c=s(e.animations);t.length>0&&(i.geometries=t),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),h.length>0&&(i.skeletons=h),c.length>0&&(i.animations=c)}return i.object=n,i;function s(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,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(let t=0;t<e.children.length;t++){const i=e.children[t];this.add(i.clone())}return this}}tr.DefaultUp=new Ki(0,1,0),tr.DefaultMatrixAutoUpdate=!0,tr.prototype.isObject3D=!0;const ir=new Ki,nr=new Ki,rr=new Ki,sr=new Ki,ar=new Ki,or=new Ki,hr=new Ki,cr=new Ki,lr=new Ki,ur=new Ki;class dr{constructor(e=new Ki,t=new Ki,i=new Ki){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),ir.subVectors(e,t),n.cross(ir);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){ir.subVectors(n,t),nr.subVectors(i,t),rr.subVectors(e,t);const s=ir.dot(ir),a=ir.dot(nr),o=ir.dot(rr),h=nr.dot(nr),c=nr.dot(rr),l=s*h-a*a;if(0===l)return r.set(-2,-1,-1);const u=1/l,d=(h*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,sr),sr.x>=0&&sr.y>=0&&sr.x+sr.y<=1}static getUV(e,t,i,n,r,s,a,o){return this.getBarycoord(e,t,i,n,sr),o.set(0,0),o.addScaledVector(r,sr.x),o.addScaledVector(s,sr.y),o.addScaledVector(a,sr.z),o}static isFrontFacing(e,t,i,n){return ir.subVectors(i,t),nr.subVectors(e,t),ir.cross(nr).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ir.subVectors(this.c,this.b),nr.subVectors(this.a,this.b),.5*ir.cross(nr).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return dr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return dr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return dr.getUV(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return dr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let s,a;ar.subVectors(n,i),or.subVectors(r,i),cr.subVectors(e,i);const o=ar.dot(cr),h=or.dot(cr);if(o<=0&&h<=0)return t.copy(i);lr.subVectors(e,n);const c=ar.dot(lr),l=or.dot(lr);if(c>=0&&l<=c)return t.copy(n);const u=o*l-c*h;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(i).addScaledVector(ar,s);ur.subVectors(e,r);const d=ar.dot(ur),p=or.dot(ur);if(p>=0&&d<=p)return t.copy(r);const m=d*h-o*p;if(m<=0&&h>=0&&p<=0)return a=h/(h-p),t.copy(i).addScaledVector(or,a);const f=c*p-d*l;if(f<=0&&l-c>=0&&d-p>=0)return hr.subVectors(r,n),a=(l-c)/(l-c+(d-p)),t.copy(n).addScaledVector(hr,a);const g=1/(f+m+u);return s=m*g,a=u*g,t.copy(i).addScaledVector(ar,s).addScaledVector(or,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let pr=0;class mr extends Ti{constructor(){super(),Object.defineProperty(this,"id",{value:pr++}),this.uuid=Pi(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=oi,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=jt,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=xi,this.stencilZFail=xi,this.stencilZPass=xi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const i=e[t];if(void 0===i){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i;continue}const n=this[t];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.format!==oi&&(i.format=this.format),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){const t=n(e.textures),r=n(e.images);t.length>0&&(i.textures=t),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.format=e.format,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.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(null!==t){const e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}mr.prototype.isMaterial=!0;const fr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},gr={h:0,s:0,l:0},_r={h:0,s:0,l:0};function vr(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}function yr(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function br(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class xr{constructor(e,t,i){return void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(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(e,t,i){return this.r=e,this.g=t,this.b=i,this}setHSL(e,t,i){if(e=Di(e,1),t=Li(t,0,1),i=Li(i,0,1),0===t)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=vr(r,n,e+1/3),this.g=vr(r,n,e),this.b=vr(r,n,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(e[1])/360,n=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=i[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=fr[e.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){const i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=yr(e.r),this.g=yr(e.g),this.b=yr(e.b),this}copyLinearToSRGB(e){return this.r=br(e.r),this.g=br(e.g),this.b=br(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,i=this.g,n=this.b,r=Math.max(t,i,n),s=Math.min(t,i,n);let a,o;const h=(s+r)/2;if(s===r)a=0,o=0;else{const e=r-s;switch(o=h<=.5?e/(r+s):e/(2-r-s),r){case t:a=(i-n)/e+(i<n?6:0);break;case i:a=(n-t)/e+2;break;case n:a=(t-i)/e+4}a/=6}return e.h=a,e.s=o,e.l=h,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,i){return this.getHSL(gr),gr.h+=e,gr.s+=t,gr.l+=i,this.setHSL(gr.h,gr.s,gr.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(gr),e.getHSL(_r);const i=Ni(gr.h,_r.h,t),n=Ni(gr.s,_r.s,t),r=Ni(gr.l,_r.l,t);return this.setHSL(i,n,r),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}xr.NAMES=fr,xr.prototype.isColor=!0,xr.prototype.r=1,xr.prototype.g=1,xr.prototype.b=1;class wr extends mr{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new xr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}wr.prototype.isMeshBasicMaterial=!0;const Mr=new Ki,Sr=new zi;class Tr{constructor(e,t,i){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===i,this.usage=wi,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",n),r=new xr),t[i++]=r.r,t[i++]=r.g,t[i++]=r.b}return this}copyVector2sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",n),r=new zi),t[i++]=r.x,t[i++]=r.y}return this}copyVector3sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",n),r=new Ki),t[i++]=r.x,t[i++]=r.y,t[i++]=r.z}return this}copyVector4sArray(e){const t=this.array;let i=0;for(let n=0,r=e.length;n<r;n++){let r=e[n];void 0===r&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",n),r=new Xi),t[i++]=r.x,t[i++]=r.y,t[i++]=r.z,t[i++]=r.w}return this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)Sr.fromBufferAttribute(this,t),Sr.applyMatrix3(e),this.setXY(t,Sr.x,Sr.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)Mr.fromBufferAttribute(this,t),Mr.applyMatrix3(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Mr.x=this.getX(t),Mr.y=this.getY(t),Mr.z=this.getZ(t),Mr.applyMatrix4(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Mr.x=this.getX(t),Mr.y=this.getY(t),Mr.z=this.getZ(t),Mr.applyNormalMatrix(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Mr.x=this.getX(t),Mr.y=this.getY(t),Mr.z=this.getZ(t),Mr.transformDirection(e),this.setXYZ(t,Mr.x,Mr.y,Mr.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==wi&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}Tr.prototype.isBufferAttribute=!0;class Cr extends Tr{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Er extends Tr{constructor(e,t,i){super(new Uint32Array(e),t,i)}}(class extends Tr{constructor(e,t,i){super(new Uint16Array(e),t,i)}}).prototype.isFloat16BufferAttribute=!0;class Ar extends Tr{constructor(e,t,i){super(new Float32Array(e),t,i)}}let Ir=0;const Rr=new Rn,Pr=new tr,Lr=new Ki,Dr=new tn,Nr=new tn,$r=new Ki;class kr extends Ti{constructor(){super(),Object.defineProperty(this,"id",{value:Ir++}),this.uuid=Pi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Bi(e)>65535?Er:Cr)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const t=(new Fi).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Rr.makeRotationFromQuaternion(e),this.applyMatrix4(Rr),this}rotateX(e){return Rr.makeRotationX(e),this.applyMatrix4(Rr),this}rotateY(e){return Rr.makeRotationY(e),this.applyMatrix4(Rr),this}rotateZ(e){return Rr.makeRotationZ(e),this.applyMatrix4(Rr),this}translate(e,t,i){return Rr.makeTranslation(e,t,i),this.applyMatrix4(Rr),this}scale(e,t,i){return Rr.makeScale(e,t,i),this.applyMatrix4(Rr),this}lookAt(e){return Pr.lookAt(e),Pr.updateMatrix(),this.applyMatrix4(Pr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Lr).negate(),this.translate(Lr.x,Lr.y,Lr.z),this}setFromPoints(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i];t.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new Ar(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new tn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Ki(-1/0,-1/0,-1/0),new Ki(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];Dr.setFromBufferAttribute(i),this.morphTargetsRelative?($r.addVectors(this.boundingBox.min,Dr.min),this.boundingBox.expandByPoint($r),$r.addVectors(this.boundingBox.max,Dr.max),this.boundingBox.expandByPoint($r)):(this.boundingBox.expandByPoint(Dr.min),this.boundingBox.expandByPoint(Dr.max))}}else 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(){null===this.boundingSphere&&(this.boundingSphere=new xn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Ki,1/0);if(e){const i=this.boundingSphere.center;if(Dr.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];Nr.setFromBufferAttribute(i),this.morphTargetsRelative?($r.addVectors(Dr.min,Nr.min),Dr.expandByPoint($r),$r.addVectors(Dr.max,Nr.max),Dr.expandByPoint($r)):(Dr.expandByPoint(Nr.min),Dr.expandByPoint(Nr.max))}Dr.getCenter(i);let n=0;for(let t=0,r=e.count;t<r;t++)$r.fromBufferAttribute(e,t),n=Math.max(n,i.distanceToSquared($r));if(t)for(let r=0,s=t.length;r<s;r++){const s=t[r],a=this.morphTargetsRelative;for(let t=0,r=s.count;t<r;t++)$r.fromBufferAttribute(s,t),a&&(Lr.fromBufferAttribute(e,t),$r.add(Lr)),n=Math.max(n,i.distanceToSquared($r))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=e.array,n=t.position.array,r=t.normal.array,s=t.uv.array,a=n.length/3;void 0===t.tangent&&this.setAttribute("tangent",new Tr(new Float32Array(4*a),4));const o=t.tangent.array,h=[],c=[];for(let e=0;e<a;e++)h[e]=new Ki,c[e]=new Ki;const l=new Ki,u=new Ki,d=new Ki,p=new zi,m=new zi,f=new zi,g=new Ki,_=new Ki;function v(e,t,i){l.fromArray(n,3*e),u.fromArray(n,3*t),d.fromArray(n,3*i),p.fromArray(s,2*e),m.fromArray(s,2*t),f.fromArray(s,2*i),u.sub(l),d.sub(l),m.sub(p),f.sub(p);const r=1/(m.x*f.y-f.x*m.y);isFinite(r)&&(g.copy(u).multiplyScalar(f.y).addScaledVector(d,-m.y).multiplyScalar(r),_.copy(d).multiplyScalar(m.x).addScaledVector(u,-f.x).multiplyScalar(r),h[e].add(g),h[t].add(g),h[i].add(g),c[e].add(_),c[t].add(_),c[i].add(_))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let e=0,t=y.length;e<t;++e){const t=y[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)v(i[e+0],i[e+1],i[e+2])}const b=new Ki,x=new Ki,w=new Ki,M=new Ki;function S(e){w.fromArray(r,3*e),M.copy(w);const t=h[e];b.copy(t),b.sub(w.multiplyScalar(w.dot(t))).normalize(),x.crossVectors(M,t);const i=x.dot(c[e])<0?-1:1;o[4*e]=b.x,o[4*e+1]=b.y,o[4*e+2]=b.z,o[4*e+3]=i}for(let e=0,t=y.length;e<t;++e){const t=y[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)S(i[e+0]),S(i[e+1]),S(i[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let i=this.getAttribute("normal");if(void 0===i)i=new Tr(new Float32Array(3*t.count),3),this.setAttribute("normal",i);else for(let e=0,t=i.count;e<t;e++)i.setXYZ(e,0,0,0);const n=new Ki,r=new Ki,s=new Ki,a=new Ki,o=new Ki,h=new Ki,c=new Ki,l=new Ki;if(e)for(let u=0,d=e.count;u<d;u+=3){const d=e.getX(u+0),p=e.getX(u+1),m=e.getX(u+2);n.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),s.fromBufferAttribute(t,m),c.subVectors(s,r),l.subVectors(n,r),c.cross(l),a.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),h.fromBufferAttribute(i,m),a.add(c),o.add(c),h.add(c),i.setXYZ(d,a.x,a.y,a.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,h.x,h.y,h.z)}else for(let e=0,a=t.count;e<a;e+=3)n.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),s.fromBufferAttribute(t,e+2),c.subVectors(s,r),l.subVectors(n,r),c.cross(l),i.setXYZ(e+0,c.x,c.y,c.z),i.setXYZ(e+1,c.x,c.y,c.z),i.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}merge(e,t){if(!e||!e.isBufferGeometry)return void console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const i=this.attributes;for(const n in i){if(void 0===e.attributes[n])continue;const r=i[n].array,s=e.attributes[n],a=s.array,o=s.itemSize*t,h=Math.min(a.length,r.length-o);for(let e=0,t=o;e<h;e++,t++)r[t]=a[e]}return this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)$r.fromBufferAttribute(e,t),$r.normalize(),e.setXYZ(t,$r.x,$r.y,$r.z)}toNonIndexed(){function e(e,t){const i=e.array,n=e.itemSize,r=e.normalized,s=new i.constructor(t.length*n);let a=0,o=0;for(let r=0,h=t.length;r<h;r++){a=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*n;for(let e=0;e<n;e++)s[o++]=i[a++]}return new Tr(s,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new kr,i=this.index.array,n=this.attributes;for(const r in n){const s=e(n[r],i);t.setAttribute(r,s)}const r=this.morphAttributes;for(const n in r){const s=[],a=r[n];for(let t=0,n=a.length;t<n;t++){const n=e(a[t],i);s.push(n)}t.morphAttributes[n]=s}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let e=0,i=s.length;e<i;e++){const i=s[e];t.addGroup(i.start,i.count,i.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const t in i){const n=i[t];e.data.attributes[t]=n.toJSON(e.data)}const n={};let r=!1;for(const t in this.morphAttributes){const i=this.morphAttributes[t],s=[];for(let t=0,n=i.length;t<n;t++){const n=i[t];s.push(n.toJSON(e.data))}s.length>0&&(n[t]=s,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;null!==i&&this.setIndex(i.clone(t));const n=e.attributes;for(const e in n){const i=n[e];this.setAttribute(e,i.clone(t))}const r=e.morphAttributes;for(const e in r){const i=[],n=r[e];for(let e=0,r=n.length;e<r;e++)i.push(n[e].clone(t));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let e=0,t=s.length;e<t;e++){const t=s[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}kr.prototype.isBufferGeometry=!0;const Or=new Rn,zr=new In,Fr=new xn,Br=new Ki,Ur=new Ki,Vr=new Ki,Hr=new Ki,jr=new Ki,Gr=new Ki,Wr=new Ki,qr=new Ki,Xr=new Ki,Zr=new zi,Yr=new zi,Jr=new zi,Kr=new Ki,Qr=new Ki;class es extends tr{constructor(e=new kr,t=new wr){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Fr.copy(i.boundingSphere),Fr.applyMatrix4(r),!1===e.ray.intersectsSphere(Fr))return;if(Or.copy(r).invert(),zr.copy(e.ray).applyMatrix4(Or),null!==i.boundingBox&&!1===zr.intersectsBox(i.boundingBox))return;let s;if(i.isBufferGeometry){const r=i.index,a=i.attributes.position,o=i.morphAttributes.position,h=i.morphTargetsRelative,c=i.attributes.uv,l=i.attributes.uv2,u=i.groups,d=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,p=u.length;i<p;i++){const p=u[i],m=n[p.materialIndex];for(let i=Math.max(p.start,d.start),n=Math.min(r.count,Math.min(p.start+p.count,d.start+d.count));i<n;i+=3){const n=r.getX(i),u=r.getX(i+1),d=r.getX(i+2);s=ts(this,m,e,zr,a,o,h,c,l,n,u,d),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{for(let i=Math.max(0,d.start),u=Math.min(r.count,d.start+d.count);i<u;i+=3){const u=r.getX(i),d=r.getX(i+1),p=r.getX(i+2);s=ts(this,n,e,zr,a,o,h,c,l,u,d,p),s&&(s.faceIndex=Math.floor(i/3),t.push(s))}}else if(void 0!==a)if(Array.isArray(n))for(let i=0,r=u.length;i<r;i++){const r=u[i],p=n[r.materialIndex];for(let i=Math.max(r.start,d.start),n=Math.min(a.count,Math.min(r.start+r.count,d.start+d.count));i<n;i+=3){s=ts(this,p,e,zr,a,o,h,c,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),s.face.materialIndex=r.materialIndex,t.push(s))}}else{for(let i=Math.max(0,d.start),r=Math.min(a.count,d.start+d.count);i<r;i+=3){s=ts(this,n,e,zr,a,o,h,c,l,i,i+1,i+2),s&&(s.faceIndex=Math.floor(i/3),t.push(s))}}}else i.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}function ts(e,t,i,n,r,s,a,o,h,c,l,u){Br.fromBufferAttribute(r,c),Ur.fromBufferAttribute(r,l),Vr.fromBufferAttribute(r,u);const d=e.morphTargetInfluences;if(s&&d){Wr.set(0,0,0),qr.set(0,0,0),Xr.set(0,0,0);for(let e=0,t=s.length;e<t;e++){const t=d[e],i=s[e];0!==t&&(Hr.fromBufferAttribute(i,c),jr.fromBufferAttribute(i,l),Gr.fromBufferAttribute(i,u),a?(Wr.addScaledVector(Hr,t),qr.addScaledVector(jr,t),Xr.addScaledVector(Gr,t)):(Wr.addScaledVector(Hr.sub(Br),t),qr.addScaledVector(jr.sub(Ur),t),Xr.addScaledVector(Gr.sub(Vr),t)))}Br.add(Wr),Ur.add(qr),Vr.add(Xr)}e.isSkinnedMesh&&(e.boneTransform(c,Br),e.boneTransform(l,Ur),e.boneTransform(u,Vr));const p=function(e,t,i,n,r,s,a,o){let h;if(h=1===t.side?n.intersectTriangle(a,s,r,!0,o):n.intersectTriangle(r,s,a,2!==t.side,o),null===h)return null;Qr.copy(o),Qr.applyMatrix4(e.matrixWorld);const c=i.ray.origin.distanceTo(Qr);return c<i.near||c>i.far?null:{distance:c,point:Qr.clone(),object:e}}(e,t,i,n,Br,Ur,Vr,Kr);if(p){o&&(Zr.fromBufferAttribute(o,c),Yr.fromBufferAttribute(o,l),Jr.fromBufferAttribute(o,u),p.uv=dr.getUV(Kr,Br,Ur,Vr,Zr,Yr,Jr,new zi)),h&&(Zr.fromBufferAttribute(h,c),Yr.fromBufferAttribute(h,l),Jr.fromBufferAttribute(h,u),p.uv2=dr.getUV(Kr,Br,Ur,Vr,Zr,Yr,Jr,new zi));const e={a:c,b:l,c:u,normal:new Ki,materialIndex:0};dr.getNormal(Br,Ur,Vr,e.normal),p.face=e}return p}es.prototype.isMesh=!0;class is extends kr{constructor(e=1,t=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const a=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const o=[],h=[],c=[],l=[];let u=0,d=0;function p(e,t,i,n,r,s,p,m,f,g,_){const v=s/f,y=p/g,b=s/2,x=p/2,w=m/2,M=f+1,S=g+1;let T=0,C=0;const E=new Ki;for(let s=0;s<S;s++){const a=s*y-x;for(let o=0;o<M;o++){const u=o*v-b;E[e]=u*n,E[t]=a*r,E[i]=w,h.push(E.x,E.y,E.z),E[e]=0,E[t]=0,E[i]=m>0?1:-1,c.push(E.x,E.y,E.z),l.push(o/f),l.push(1-s/g),T+=1}}for(let e=0;e<g;e++)for(let t=0;t<f;t++){const i=u+t+M*e,n=u+t+M*(e+1),r=u+(t+1)+M*(e+1),s=u+(t+1)+M*e;o.push(i,n,s),o.push(n,r,s),C+=6}a.addGroup(d,C,_),d+=C,u+=T}p("z","y","x",-1,-1,i,t,e,s,r,0),p("z","y","x",1,-1,i,t,-e,s,r,1),p("x","z","y",1,1,e,i,t,n,s,2),p("x","z","y",1,-1,e,i,-t,n,s,3),p("x","y","z",1,-1,e,t,i,n,r,4),p("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(o),this.setAttribute("position",new Ar(h,3)),this.setAttribute("normal",new Ar(c,3)),this.setAttribute("uv",new Ar(l,2))}static fromJSON(e){return new is(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ns(e){const t={};for(const i in e){t[i]={};for(const n in e[i]){const r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function rs(e){const t={};for(let i=0;i<e.length;i++){const n=ns(e[i]);for(const e in n)t[e]=n[e]}return t}const ss={clone:ns,merge:rs};class as extends mr{constructor(e){super(),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.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,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ns(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?t.uniforms[i]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[i]={type:"m4",value:n.toArray()}:t.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}as.prototype.isShaderMaterial=!0;class os extends tr{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Rn,this.projectionMatrix=new Rn,this.projectionMatrixInverse=new Rn}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}os.prototype.isCamera=!0;class hs extends os{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*Ai*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Ei*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Ai*Math.atan(Math.tan(.5*Ei*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Ei*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*n/e,t-=s.offsetY*i/a,n*=s.width/e,i*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}hs.prototype.isPerspectiveCamera=!0;const cs=90;class ls extends tr{constructor(e,t,i){if(super(),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new hs(cs,1,e,t);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new Ki(1,0,0)),this.add(n);const r=new hs(cs,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Ki(-1,0,0)),this.add(r);const s=new hs(cs,1,e,t);s.layers=this.layers,s.up.set(0,0,1),s.lookAt(new Ki(0,1,0)),this.add(s);const a=new hs(cs,1,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new Ki(0,-1,0)),this.add(a);const o=new hs(cs,1,e,t);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new Ki(0,0,1)),this.add(o);const h=new hs(cs,1,e,t);h.layers=this.layers,h.up.set(0,-1,0),h.lookAt(new Ki(0,0,-1)),this.add(h)}update(e,t){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,r,s,a,o,h]=this.children,c=e.xr.enabled,l=e.getRenderTarget();e.xr.enabled=!1;const u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,r),e.setRenderTarget(i,2),e.render(t,s),e.setRenderTarget(i,3),e.render(t,a),e.setRenderTarget(i,4),e.render(t,o),i.texture.generateMipmaps=u,e.setRenderTarget(i,5),e.render(t,h),e.setRenderTarget(l),e.xr.enabled=c}}class us extends Wi{constructor(e,t,i,n,r,s,a,o,h,c){super(e=void 0!==e?e:[],t=void 0!==t?t:Gt,i,n,r,s,a,o,h,c),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}us.prototype.isCubeTexture=!0;class ds extends Zi{constructor(e,t,i){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=i),super(e,e,t),t=t||{},this.texture=new us(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Kt,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=oi,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new is(5,5,5),r=new as({name:"CubemapFromEquirect",uniforms:ns(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;const s=new es(n,r),a=t.minFilter;t.minFilter===Qt&&(t.minFilter=Kt);return new ls(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,i,n){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(r)}}ds.prototype.isWebGLCubeRenderTarget=!0;const ps=new Ki,ms=new Ki,fs=new Fi;class gs{constructor(e=new Ki(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=ps.subVectors(i,t).cross(ms.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const i=e.delta(ps),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(i).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||fs.getNormalMatrix(e),n=this.coplanarPoint(ps).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}gs.prototype.isPlane=!0;const _s=new xn,vs=new Ki;class ys{constructor(e=new gs,t=new gs,i=new gs,n=new gs,r=new gs,s=new gs){this.planes=[e,t,i,n,r,s]}set(e,t,i,n,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){const t=this.planes,i=e.elements,n=i[0],r=i[1],s=i[2],a=i[3],o=i[4],h=i[5],c=i[6],l=i[7],u=i[8],d=i[9],p=i[10],m=i[11],f=i[12],g=i[13],_=i[14],v=i[15];return t[0].setComponents(a-n,l-o,m-u,v-f).normalize(),t[1].setComponents(a+n,l+o,m+u,v+f).normalize(),t[2].setComponents(a+r,l+h,m+d,v+g).normalize(),t[3].setComponents(a-r,l-h,m-d,v-g).normalize(),t[4].setComponents(a-s,l-c,m-p,v-_).normalize(),t[5].setComponents(a+s,l+c,m+p,v+_).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),_s.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(_s)}intersectsSprite(e){return _s.center.set(0,0,0),_s.radius=.7071067811865476,_s.applyMatrix4(e.matrixWorld),this.intersectsSphere(_s)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(i)<n)return!1}return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if(vs.x=n.normal.x>0?e.max.x:e.min.x,vs.y=n.normal.y>0?e.max.y:e.min.y,vs.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(vs)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function bs(){let e=null,t=!1,i=null,n=null;function r(t,s){i(t,s),n=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function xs(e,t){const i=t.isWebGL2,n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const i=n.get(t);i&&(e.deleteBuffer(i.buffer),n.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=n.get(t);return void((!e||e.version<t.version)&&n.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const s=n.get(t);void 0===s?n.set(t,function(t,n){const r=t.array,s=t.usage,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,r,s),t.onUploadCallback();let o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?t.isFloat16BufferAttribute?i?o=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:(r instanceof Uint8Array||r instanceof Uint8ClampedArray)&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(t,r)):s.version<t.version&&(!function(t,n,r){const s=n.array,a=n.updateRange;e.bindBuffer(r,t),-1===a.count?e.bufferSubData(r,0,s):(i?e.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s,a.offset,a.count):e.bufferSubData(r,a.offset*s.BYTES_PER_ELEMENT,s.subarray(a.offset,a.offset+a.count)),a.count=-1)}(s.buffer,t,r),s.version=t.version)}}}class ws extends kr{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,s=t/2,a=Math.floor(i),o=Math.floor(n),h=a+1,c=o+1,l=e/a,u=t/o,d=[],p=[],m=[],f=[];for(let e=0;e<c;e++){const t=e*u-s;for(let i=0;i<h;i++){const n=i*l-r;p.push(n,-t,0),m.push(0,0,1),f.push(i/a),f.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<a;t++){const i=t+h*e,n=t+h*(e+1),r=t+1+h*(e+1),s=t+1+h*e;d.push(i,n,s),d.push(n,r,s)}this.setIndex(d),this.setAttribute("position",new Ar(p,3)),this.setAttribute("normal",new Ar(m,3)),this.setAttribute("uv",new Ar(f,2))}static fromJSON(e){return new ws(e.width,e.height,e.widthSegments,e.heightSegments)}}const Ms={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_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_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, 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\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\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_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",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, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\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 ) * faceDirection;\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",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( 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 max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\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}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\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#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\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}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",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.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\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.a );\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.a );\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.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, 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.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.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 = cLogLuvM * value.rgb;\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 = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\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",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\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",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = 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\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = 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\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = 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\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.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};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.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};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.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 ltc_1;\tuniform sampler2D ltc_2;\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 vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, 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_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, 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 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\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 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\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#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\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_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\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\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}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * 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 defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#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 );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\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}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\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}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\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( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), 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( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), 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 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\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, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\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",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\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",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\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",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\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\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}\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}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).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\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_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_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},Ss={common:{diffuse:{value:new xr(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Fi},uv2Transform:{value:new Fi},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new zi(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Fi}},sprite:{diffuse:{value:new xr(16777215)},opacity:{value:1},center:{value:new zi(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Fi}}},Ts={basic:{uniforms:rs([Ss.common,Ss.specularmap,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.fog]),vertexShader:Ms.meshbasic_vert,fragmentShader:Ms.meshbasic_frag},lambert:{uniforms:rs([Ss.common,Ss.specularmap,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)}}]),vertexShader:Ms.meshlambert_vert,fragmentShader:Ms.meshlambert_frag},phong:{uniforms:rs([Ss.common,Ss.specularmap,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)},specular:{value:new xr(1118481)},shininess:{value:30}}]),vertexShader:Ms.meshphong_vert,fragmentShader:Ms.meshphong_frag},standard:{uniforms:rs([Ss.common,Ss.envmap,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.roughnessmap,Ss.metalnessmap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ms.meshphysical_vert,fragmentShader:Ms.meshphysical_frag},toon:{uniforms:rs([Ss.common,Ss.aomap,Ss.lightmap,Ss.emissivemap,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.gradientmap,Ss.fog,Ss.lights,{emissive:{value:new xr(0)}}]),vertexShader:Ms.meshtoon_vert,fragmentShader:Ms.meshtoon_frag},matcap:{uniforms:rs([Ss.common,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,Ss.fog,{matcap:{value:null}}]),vertexShader:Ms.meshmatcap_vert,fragmentShader:Ms.meshmatcap_frag},points:{uniforms:rs([Ss.points,Ss.fog]),vertexShader:Ms.points_vert,fragmentShader:Ms.points_frag},dashed:{uniforms:rs([Ss.common,Ss.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ms.linedashed_vert,fragmentShader:Ms.linedashed_frag},depth:{uniforms:rs([Ss.common,Ss.displacementmap]),vertexShader:Ms.depth_vert,fragmentShader:Ms.depth_frag},normal:{uniforms:rs([Ss.common,Ss.bumpmap,Ss.normalmap,Ss.displacementmap,{opacity:{value:1}}]),vertexShader:Ms.meshnormal_vert,fragmentShader:Ms.meshnormal_frag},sprite:{uniforms:rs([Ss.sprite,Ss.fog]),vertexShader:Ms.sprite_vert,fragmentShader:Ms.sprite_frag},background:{uniforms:{uvTransform:{value:new Fi},t2D:{value:null}},vertexShader:Ms.background_vert,fragmentShader:Ms.background_frag},cube:{uniforms:rs([Ss.envmap,{opacity:{value:1}}]),vertexShader:Ms.cube_vert,fragmentShader:Ms.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ms.equirect_vert,fragmentShader:Ms.equirect_frag},distanceRGBA:{uniforms:rs([Ss.common,Ss.displacementmap,{referencePosition:{value:new Ki},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ms.distanceRGBA_vert,fragmentShader:Ms.distanceRGBA_frag},shadow:{uniforms:rs([Ss.lights,Ss.fog,{color:{value:new xr(0)},opacity:{value:1}}]),vertexShader:Ms.shadow_vert,fragmentShader:Ms.shadow_frag}};function Cs(e,t,i,n,r){const s=new xr(0);let a,o,h=0,c=null,l=0,u=null;function d(e,t){i.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),h=t,d(s,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,d(s,h)},render:function(i,r){let p=!1,m=!0===r.isScene?r.background:null;m&&m.isTexture&&(m=t.get(m));const f=e.xr,g=f.getSession&&f.getSession();g&&"additive"===g.environmentBlendMode&&(m=null),null===m?d(s,h):m&&m.isColor&&(d(m,1),p=!0),(e.autoClear||p)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),m&&(m.isCubeTexture||m.mapping===qt)?(void 0===o&&(o=new es(new is(1,1,1),new as({name:"BackgroundCubeMaterial",uniforms:ns(Ts.cube.uniforms),vertexShader:Ts.cube.vertexShader,fragmentShader:Ts.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),o.geometry.deleteAttribute("uv"),o.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(o.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(o)),o.material.uniforms.envMap.value=m,o.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,c===m&&l===m.version&&u===e.toneMapping||(o.material.needsUpdate=!0,c=m,l=m.version,u=e.toneMapping),i.unshift(o,o.geometry,o.material,0,0,null)):m&&m.isTexture&&(void 0===a&&(a=new es(new ws(2,2),new as({name:"BackgroundMaterial",uniforms:ns(Ts.background.uniforms),vertexShader:Ts.background.vertexShader,fragmentShader:Ts.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),Object.defineProperty(a.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(a)),a.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),a.material.uniforms.uvTransform.value.copy(m.matrix),c===m&&l===m.version&&u===e.toneMapping||(a.material.needsUpdate=!0,c=m,l=m.version,u=e.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null))}}}function Es(e,t,i,n){const r=e.getParameter(34921),s=n.isWebGL2?null:t.get("OES_vertex_array_object"),a=n.isWebGL2||null!==s,o={},h=d(null);let c=h;function l(t){return n.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function u(t){return n.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function d(e){const t=[],i=[],n=[];for(let e=0;e<r;e++)t[e]=0,i[e]=0,n[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:n,object:e,attributes:{},index:null}}function p(){const e=c.newAttributes;for(let t=0,i=e.length;t<i;t++)e[t]=0}function m(e){f(e,0)}function f(i,r){const s=c.newAttributes,a=c.enabledAttributes,o=c.attributeDivisors;if(s[i]=1,0===a[i]&&(e.enableVertexAttribArray(i),a[i]=1),o[i]!==r){(n.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),o[i]=r}}function g(){const t=c.newAttributes,i=c.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==t[n]&&(e.disableVertexAttribArray(n),i[n]=0)}function _(t,i,r,s,a,o){!0!==n.isWebGL2||5124!==r&&5125!==r?e.vertexAttribPointer(t,i,r,s,a,o):e.vertexAttribIPointer(t,i,r,a,o)}function v(){y(),c!==h&&(c=h,l(c.object))}function y(){h.geometry=null,h.program=null,h.wireframe=!1}return{setup:function(r,h,u,v,y){let b=!1;if(a){const t=function(t,i,r){const a=!0===r.wireframe;let h=o[t.id];void 0===h&&(h={},o[t.id]=h);let c=h[i.id];void 0===c&&(c={},h[i.id]=c);let l=c[a];void 0===l&&(l=d(n.isWebGL2?e.createVertexArray():s.createVertexArrayOES()),c[a]=l);return l}(v,u,h);c!==t&&(c=t,l(c.object)),b=function(e,t){const i=c.attributes,n=e.attributes;let r=0;for(const e in n){const t=i[e],s=n[e];if(void 0===t)return!0;if(t.attribute!==s)return!0;if(t.data!==s.data)return!0;r++}return c.attributesNum!==r||c.index!==t}(v,y),b&&function(e,t){const i={},n=e.attributes;let r=0;for(const e in n){const t=n[e],s={};s.attribute=t,t.data&&(s.data=t.data),i[e]=s,r++}c.attributes=i,c.attributesNum=r,c.index=t}(v,y)}else{const e=!0===h.wireframe;c.geometry===v.id&&c.program===u.id&&c.wireframe===e||(c.geometry=v.id,c.program=u.id,c.wireframe=e,b=!0)}!0===r.isInstancedMesh&&(b=!0),null!==y&&i.update(y,34963),b&&(!function(r,s,a,o){if(!1===n.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;p();const h=o.attributes,c=a.getAttributes(),l=s.defaultAttributeValues;for(const t in c){const n=c[t];if(n.location>=0){let s=h[t];if(void 0===s&&("instanceMatrix"===t&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){const t=s.normalized,a=s.itemSize,h=i.get(s);if(void 0===h)continue;const c=h.buffer,l=h.type,u=h.bytesPerElement;if(s.isInterleavedBufferAttribute){const i=s.data,h=i.stride,d=s.offset;if(i&&i.isInstancedInterleavedBuffer){for(let e=0;e<n.locationSize;e++)f(n.location+e,i.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let e=0;e<n.locationSize;e++)m(n.location+e);e.bindBuffer(34962,c);for(let e=0;e<n.locationSize;e++)_(n.location+e,a/n.locationSize,l,t,h*u,(d+a/n.locationSize*e)*u)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<n.locationSize;e++)f(n.location+e,s.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<n.locationSize;e++)m(n.location+e);e.bindBuffer(34962,c);for(let e=0;e<n.locationSize;e++)_(n.location+e,a/n.locationSize,l,t,a*u,a/n.locationSize*e*u)}}else if(void 0!==l){const i=l[t];if(void 0!==i)switch(i.length){case 2:e.vertexAttrib2fv(n.location,i);break;case 3:e.vertexAttrib3fv(n.location,i);break;case 4:e.vertexAttrib4fv(n.location,i);break;default:e.vertexAttrib1fv(n.location,i)}}}}g()}(r,h,u,v),null!==y&&e.bindBuffer(34963,i.get(y).buffer))},reset:v,resetDefaultState:y,dispose:function(){v();for(const e in o){const t=o[e];for(const e in t){const i=t[e];for(const e in i)u(i[e].object),delete i[e];delete t[e]}delete o[e]}},releaseStatesOfGeometry:function(e){if(void 0===o[e.id])return;const t=o[e.id];for(const e in t){const i=t[e];for(const e in i)u(i[e].object),delete i[e];delete t[e]}delete o[e.id]},releaseStatesOfProgram:function(e){for(const t in o){const i=o[t];if(void 0===i[e.id])continue;const n=i[e.id];for(const e in n)u(n[e].object),delete n[e];delete i[e.id]}},initAttributes:p,enableAttribute:m,disableUnusedAttributes:g}}function As(e,t,i,n){const r=n.isWebGL2;let s;this.setMode=function(e){s=e},this.render=function(t,n){e.drawArrays(s,t,n),i.update(n,s,1)},this.renderInstances=function(n,a,o){if(0===o)return;let h,c;if(r)h=e,c="drawArraysInstanced";else if(h=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===h)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");h[c](s,n,a,o),i.update(a,s,o)}}function Is(e,t,i){let n;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==i.precision?i.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const h=s||t.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,l=e.getParameter(34930),u=e.getParameter(35660),d=e.getParameter(3379),p=e.getParameter(34076),m=e.getParameter(34921),f=e.getParameter(36347),g=e.getParameter(36348),_=e.getParameter(36349),v=u>0,y=s||t.has("OES_texture_float");return{isWebGL2:s,drawBuffers:h,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===t.has("EXT_texture_filter_anisotropic")){const i=t.get("EXT_texture_filter_anisotropic");n=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:_,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:s?e.getParameter(36183):0}}function Rs(e){const t=this;let i=null,n=0,r=!1,s=!1;const a=new gs,o=new Fi,h={value:null,needsUpdate:!1};function c(){h.value!==i&&(h.value=i,h.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function l(e,i,n,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=h.value,!0!==r||null===c){const t=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length<t)&&(c=new Float32Array(t));for(let t=0,i=n;t!==s;++t,i+=4)a.copy(e[t]).applyMatrix4(r,o),a.normal.toArray(c,i),c[i+3]=a.constant}h.value=c,h.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,c}this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,s){const a=0!==e.length||t||0!==n||r;return r=t,i=l(e,s,0),n=e.length,a},this.beginShadows=function(){s=!0,l(null)},this.endShadows=function(){s=!1,c()},this.setState=function(t,a,o){const u=t.clippingPlanes,d=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!r||null===u||0===u.length||s&&!p)s?l(null):c();else{const e=s?0:n,t=4*e;let r=m.clippingState||null;h.value=r,r=l(u,a,t,o);for(let e=0;e!==t;++e)r[e]=i[e];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Ps(e){let t=new WeakMap;function i(e,t){return 303===t?e.mapping=Gt:304===t&&(e.mapping=Wt),e}function n(e){const i=e.target;i.removeEventListener("dispose",n);const r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(303===s||304===s){if(t.has(r)){return i(t.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=e.getRenderTarget(),o=new ds(s.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),e.setRenderTarget(a),r.addEventListener("dispose",n),i(o.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}Ts.physical={uniforms:rs([Ts.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new zi(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new xr(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new zi},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new xr(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new xr(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Ms.meshphysical_vert,fragmentShader:Ms.meshphysical_frag};class Ls extends os{constructor(e=-1,t=1,i=1,n=-1,r=.1,s=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,s=i+e,a=n+t,o=n-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}Ls.prototype.isOrthographicCamera=!0;class Ds extends as{constructor(e){super(e),this.type="RawShaderMaterial"}}Ds.prototype.isRawShaderMaterial=!0;const Ns=Math.pow(2,8),$s=[.125,.215,.35,.446,.526,.582],ks=5+$s.length,Os=20,zs={[_i]:0,[vi]:1,[bi]:2,3004:3,3005:4,3006:5,[yi]:6},Fs=new Ls,{_lodPlanes:Bs,_sizeLods:Us,_sigmas:Vs}=Ys(),Hs=new xr;let js=null;const Gs=(1+Math.sqrt(5))/2,Ws=1/Gs,qs=[new Ki(1,1,1),new Ki(-1,1,1),new Ki(1,1,-1),new Ki(-1,1,-1),new Ki(0,Gs,Ws),new Ki(0,Gs,-Ws),new Ki(Ws,0,Gs),new Ki(-Ws,0,Gs),new Ki(Gs,Ws,0),new Ki(-Gs,Ws,0)];class Xs{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=function(e){const t=new Float32Array(e),i=new Ki(0,1,0);return new Ds({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:zs[3e3]},outputEncoding:{value:zs[3e3]}},vertexShader:ta(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t${ia()}\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}(Os),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){js=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,i,n,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=ea(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Qs(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e<Bs.length;e++)Bs[e].dispose()}_cleanup(e){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(js),e.scissorTest=!1,Ks(e,0,0,e.width,e.height)}_fromTexture(e){js=this._renderer.getRenderTarget();const t=this._allocateTargets(e);return this._textureToCubeUV(e,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(e){const t={magFilter:Jt,minFilter:Jt,generateMipmaps:!1,type:ei,format:1023,encoding:Zs(e)?e.encoding:bi,depthBuffer:!1},i=Js(t);return i.depthBuffer=!e,this._pingPongRenderTarget=Js(t),i}_compileMaterial(e){const t=new es(Bs[0],e);this._renderer.compile(t,Fs)}_sceneToCubeUV(e,t,i,n){const r=new hs(90,1,t,i),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,h=o.autoClear,c=o.outputEncoding,l=o.toneMapping;o.getClearColor(Hs),o.toneMapping=0,o.outputEncoding=_i,o.autoClear=!1;const u=new wr({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new es(new is,u);let p=!1;const m=e.background;m?m.isColor&&(u.color.copy(m),e.background=null,p=!0):(u.color.copy(Hs),p=!0);for(let t=0;t<6;t++){const i=t%3;0==i?(r.up.set(0,s[t],0),r.lookAt(a[t],0,0)):1==i?(r.up.set(0,0,s[t]),r.lookAt(0,a[t],0)):(r.up.set(0,s[t],0),r.lookAt(0,0,a[t])),Ks(n,i*Ns,t>2?Ns:0,Ns,Ns),o.setRenderTarget(n),p&&o.render(d,r),o.render(e,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=l,o.outputEncoding=c,o.autoClear=h,e.background=m}_setEncoding(e,t){!0===this._renderer.capabilities.isWebGL2&&t.format===oi&&t.type===ei&&t.encoding===vi?e.value=zs[3e3]:e.value=zs[t.encoding]}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===Gt||e.mapping===Wt;n?null==this._cubemapShader&&(this._cubemapShader=ea()):null==this._equirectShader&&(this._equirectShader=Qs());const r=n?this._cubemapShader:this._equirectShader,s=new es(Bs[0],r),a=r.uniforms;a.envMap.value=e,n||a.texelSize.value.set(1/e.image.width,1/e.image.height),this._setEncoding(a.inputEncoding,e),this._setEncoding(a.outputEncoding,t.texture),Ks(t,0,0,3*Ns,2*Ns),i.setRenderTarget(t),i.render(s,Fs)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t<ks;t++){const i=Math.sqrt(Vs[t]*Vs[t]-Vs[t-1]*Vs[t-1]),n=qs[(t-1)%qs.length];this._blur(e,t-1,t,i,n)}t.autoClear=i}_blur(e,t,i,n,r){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,n,"latitudinal",r),this._halfBlur(s,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,s,a){const o=this._renderer,h=this._blurMaterial;"latitudinal"!==s&&"longitudinal"!==s&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new es(Bs[n],h),l=h.uniforms,u=Us[i]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/39,p=r/d,m=isFinite(r)?1+Math.floor(3*p):Os;m>Os&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let e=0;e<Os;++e){const t=e/p,i=Math.exp(-t*t/2);f.push(i),0==e?g+=i:e<m&&(g+=2*i)}for(let e=0;e<f.length;e++)f[e]=f[e]/g;l.envMap.value=e.texture,l.samples.value=m,l.weights.value=f,l.latitudinal.value="latitudinal"===s,a&&(l.poleAxis.value=a),l.dTheta.value=d,l.mipInt.value=8-i,this._setEncoding(l.inputEncoding,e.texture),this._setEncoding(l.outputEncoding,e.texture);const _=Us[n];Ks(t,3*Math.max(0,Ns-2*_),(0===n?0:2*Ns)+2*_*(n>4?n-8+4:0),3*_,2*_),o.setRenderTarget(t),o.render(c,Fs)}}function Zs(e){return void 0!==e&&e.type===ei&&(e.encoding===_i||e.encoding===vi||e.encoding===yi)}function Ys(){const e=[],t=[],i=[];let n=8;for(let r=0;r<ks;r++){const s=Math.pow(2,n);t.push(s);let a=1/s;r>4?a=$s[r-8+4-1]:0==r&&(a=0),i.push(a);const o=1/(s-1),h=-o/2,c=1+o/2,l=[h,h,c,h,c,c,h,h,c,c,h,c],u=6,d=6,p=3,m=2,f=1,g=new Float32Array(p*d*u),_=new Float32Array(m*d*u),v=new Float32Array(f*d*u);for(let e=0;e<u;e++){const t=e%3*2/3-1,i=e>2?0:-1,n=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0];g.set(n,p*d*e),_.set(l,m*d*e);const r=[e,e,e,e,e,e];v.set(r,f*d*e)}const y=new kr;y.setAttribute("position",new Tr(g,p)),y.setAttribute("uv",new Tr(_,m)),y.setAttribute("faceIndex",new Tr(v,f)),e.push(y),n>4&&n--}return{_lodPlanes:e,_sizeLods:t,_sigmas:i}}function Js(e){const t=new Zi(3*Ns,3*Ns,e);return t.texture.mapping=qt,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Ks(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function Qs(){const e=new zi(1,1);return new Ds({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:zs[3e3]},outputEncoding:{value:zs[3e3]}},vertexShader:ta(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t${ia()}\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}function ea(){return new Ds({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:zs[3e3]},outputEncoding:{value:zs[3e3]}},vertexShader:ta(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t${ia()}\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}function ta(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function ia(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}function na(e){let t=new WeakMap,i=null;function n(e){const i=e.target;i.removeEventListener("dispose",n);const r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping,a=303===s||304===s,o=s===Gt||s===Wt;if(a||o){if(t.has(r))return t.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(e){let t=0;const i=6;for(let n=0;n<i;n++)void 0!==e[n]&&t++;return t===i}(s)){const s=e.getRenderTarget();null===i&&(i=new Xs(e));const o=a?i.fromEquirectangular(r):i.fromCubemap(r);return t.set(r,o),e.setRenderTarget(s),r.addEventListener("dispose",n),o.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function ra(e){const t={};function i(i){if(void 0!==t[i])return t[i];let n;switch(i){case"WEBGL_depth_texture":n=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=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":n=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":n=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=e.getExtension(i)}return t[i]=n,n}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float")},get:function(e){const t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function sa(e,t,i,n){const r={},s=new WeakMap;function a(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",a),delete r[o.id];const h=s.get(o);h&&(t.remove(h),s.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(e){const i=[],n=e.index,r=e.attributes.position;let a=0;if(null!==n){const e=n.array;a=n.version;for(let t=0,n=e.length;t<n;t+=3){const n=e[t+0],r=e[t+1],s=e[t+2];i.push(n,r,r,s,s,n)}}else{const e=r.array;a=r.version;for(let t=0,n=e.length/3-1;t<n;t+=3){const e=t+0,n=t+1,r=t+2;i.push(e,n,n,r,r,e)}}const o=new(Bi(i)>65535?Er:Cr)(i,1);o.version=a;const h=s.get(e);h&&t.remove(h),s.set(e,o)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",a),r[t.id]=!0,i.memory.geometries++),t},update:function(e){const i=e.attributes;for(const e in i)t.update(i[e],34962);const n=e.morphAttributes;for(const e in n){const i=n[e];for(let e=0,n=i.length;e<n;e++)t.update(i[e],34962)}},getWireframeAttribute:function(e){const t=s.get(e);if(t){const i=e.index;null!==i&&t.version<i.version&&o(e)}else o(e);return s.get(e)}}}function aa(e,t,i,n){const r=n.isWebGL2;let s,a,o;this.setMode=function(e){s=e},this.setIndex=function(e){a=e.type,o=e.bytesPerElement},this.render=function(t,n){e.drawElements(s,n,a,t*o),i.update(n,s,1)},this.renderInstances=function(n,h,c){if(0===c)return;let l,u;if(r)l=e,u="drawElementsInstanced";else if(l=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===l)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[u](s,h,a,n*o,c),i.update(h,s,c)}}function oa(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(e,i,n){switch(t.calls++,i){case 4:t.triangles+=n*(e/3);break;case 1:t.lines+=n*(e/2);break;case 3:t.lines+=n*(e-1);break;case 2:t.lines+=n*e;break;case 0:t.points+=n*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",i)}}}}class ha extends Wi{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=Jt,this.minFilter=Jt,this.wrapR=Zt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}function ca(e,t){return e[0]-t[0]}function la(e,t){return Math.abs(t[1])-Math.abs(e[1])}function ua(e,t){let i=1;const n=t.isInterleavedBufferAttribute?t.data.array:t.array;n instanceof Int8Array?i=127:n instanceof Int16Array?i=32767:n instanceof Int32Array?i=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),e.divideScalar(i)}function da(e,t,i){const n={},r=new Float32Array(8),s=new WeakMap,a=new Ki,o=[];for(let e=0;e<8;e++)o[e]=[e,0];return{update:function(h,c,l,u){const d=h.morphTargetInfluences;if(!0===t.isWebGL2){const n=c.morphAttributes.position.length;let r=s.get(c);if(void 0===r||r.count!==n){void 0!==r&&r.texture.dispose();const e=void 0!==c.morphAttributes.normal,i=c.morphAttributes.position,o=c.morphAttributes.normal||[],h=!0===e?2:1;let l=c.attributes.position.count*h,u=1;l>t.maxTextureSize&&(u=Math.ceil(l/t.maxTextureSize),l=t.maxTextureSize);const d=new Float32Array(l*u*4*n),p=new ha(d,l,u,n);p.format=oi,p.type=ni;const m=4*h;for(let t=0;t<n;t++){const n=i[t],r=o[t],s=l*u*4*t;for(let t=0;t<n.count;t++){a.fromBufferAttribute(n,t),!0===n.normalized&&ua(a,n);const i=t*m;d[s+i+0]=a.x,d[s+i+1]=a.y,d[s+i+2]=a.z,d[s+i+3]=0,!0===e&&(a.fromBufferAttribute(r,t),!0===r.normalized&&ua(a,r),d[s+i+4]=a.x,d[s+i+5]=a.y,d[s+i+6]=a.z,d[s+i+7]=0)}}r={count:n,texture:p,size:new zi(l,u)},s.set(c,r)}let o=0;for(let e=0;e<d.length;e++)o+=d[e];const h=c.morphTargetsRelative?1:1-o;u.getUniforms().setValue(e,"morphTargetBaseInfluence",h),u.getUniforms().setValue(e,"morphTargetInfluences",d),u.getUniforms().setValue(e,"morphTargetsTexture",r.texture,i),u.getUniforms().setValue(e,"morphTargetsTextureSize",r.size)}else{const t=void 0===d?0:d.length;let i=n[c.id];if(void 0===i||i.length!==t){i=[];for(let e=0;e<t;e++)i[e]=[e,0];n[c.id]=i}for(let e=0;e<t;e++){const t=i[e];t[0]=e,t[1]=d[e]}i.sort(la);for(let e=0;e<8;e++)e<t&&i[e][1]?(o[e][0]=i[e][0],o[e][1]=i[e][1]):(o[e][0]=Number.MAX_SAFE_INTEGER,o[e][1]=0);o.sort(ca);const s=c.morphAttributes.position,a=c.morphAttributes.normal;let h=0;for(let e=0;e<8;e++){const t=o[e],i=t[0],n=t[1];i!==Number.MAX_SAFE_INTEGER&&n?(s&&c.getAttribute("morphTarget"+e)!==s[i]&&c.setAttribute("morphTarget"+e,s[i]),a&&c.getAttribute("morphNormal"+e)!==a[i]&&c.setAttribute("morphNormal"+e,a[i]),r[e]=n,h+=n):(s&&!0===c.hasAttribute("morphTarget"+e)&&c.deleteAttribute("morphTarget"+e),a&&!0===c.hasAttribute("morphNormal"+e)&&c.deleteAttribute("morphNormal"+e),r[e]=0)}const l=c.morphTargetsRelative?1:1-h;u.getUniforms().setValue(e,"morphTargetBaseInfluence",l),u.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function pa(e,t,i,n){let r=new WeakMap;function s(e){const t=e.target;t.removeEventListener("dispose",s),i.remove(t.instanceMatrix),null!==t.instanceColor&&i.remove(t.instanceColor)}return{update:function(e){const a=n.render.frame,o=e.geometry,h=t.get(e,o);return r.get(h)!==a&&(t.update(h),r.set(h,a)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",s)&&e.addEventListener("dispose",s),i.update(e.instanceMatrix,34962),null!==e.instanceColor&&i.update(e.instanceColor,34962)),h},dispose:function(){r=new WeakMap}}}ha.prototype.isDataTexture2DArray=!0;class ma extends Wi{constructor(e=null,t=1,i=1,n=1){super(null),this.image={data:e,width:t,height:i,depth:n},this.magFilter=Jt,this.minFilter=Jt,this.wrapR=Zt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}ma.prototype.isDataTexture3D=!0;const fa=new Wi,ga=new ha,_a=new ma,va=new us,ya=[],ba=[],xa=new Float32Array(16),wa=new Float32Array(9),Ma=new Float32Array(4);function Sa(e,t,i){const n=e[0];if(n<=0||n>0)return e;const r=t*i;let s=ya[r];if(void 0===s&&(s=new Float32Array(r),ya[r]=s),0!==t){n.toArray(s,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(s,r)}return s}function Ta(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function Ca(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function Ea(e,t){let i=ba[t];void 0===i&&(i=new Int32Array(t),ba[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function Aa(e,t){const i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function Ia(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Ta(i,t))return;e.uniform2fv(this.addr,t),Ca(i,t)}}function Ra(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(void 0!==t.r)i[0]===t.r&&i[1]===t.g&&i[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(Ta(i,t))return;e.uniform3fv(this.addr,t),Ca(i,t)}}function Pa(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Ta(i,t))return;e.uniform4fv(this.addr,t),Ca(i,t)}}function La(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(Ta(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ca(i,t)}else{if(Ta(i,n))return;Ma.set(n),e.uniformMatrix2fv(this.addr,!1,Ma),Ca(i,n)}}function Da(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(Ta(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ca(i,t)}else{if(Ta(i,n))return;wa.set(n),e.uniformMatrix3fv(this.addr,!1,wa),Ca(i,n)}}function Na(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(Ta(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ca(i,t)}else{if(Ta(i,n))return;xa.set(n),e.uniformMatrix4fv(this.addr,!1,xa),Ca(i,n)}}function $a(e,t){const i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function ka(e,t){const i=this.cache;Ta(i,t)||(e.uniform2iv(this.addr,t),Ca(i,t))}function Oa(e,t){const i=this.cache;Ta(i,t)||(e.uniform3iv(this.addr,t),Ca(i,t))}function za(e,t){const i=this.cache;Ta(i,t)||(e.uniform4iv(this.addr,t),Ca(i,t))}function Fa(e,t){const i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function Ba(e,t){const i=this.cache;Ta(i,t)||(e.uniform2uiv(this.addr,t),Ca(i,t))}function Ua(e,t){const i=this.cache;Ta(i,t)||(e.uniform3uiv(this.addr,t),Ca(i,t))}function Va(e,t){const i=this.cache;Ta(i,t)||(e.uniform4uiv(this.addr,t),Ca(i,t))}function Ha(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTexture2D(t||fa,r)}function ja(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(t||_a,r)}function Ga(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.safeSetTextureCube(t||va,r)}function Wa(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(t||ga,r)}function qa(e,t){e.uniform1fv(this.addr,t)}function Xa(e,t){const i=Sa(t,this.size,2);e.uniform2fv(this.addr,i)}function Za(e,t){const i=Sa(t,this.size,3);e.uniform3fv(this.addr,i)}function Ya(e,t){const i=Sa(t,this.size,4);e.uniform4fv(this.addr,i)}function Ja(e,t){const i=Sa(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function Ka(e,t){const i=Sa(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function Qa(e,t){const i=Sa(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function eo(e,t){e.uniform1iv(this.addr,t)}function to(e,t){e.uniform2iv(this.addr,t)}function io(e,t){e.uniform3iv(this.addr,t)}function no(e,t){e.uniform4iv(this.addr,t)}function ro(e,t){e.uniform1uiv(this.addr,t)}function so(e,t){e.uniform2uiv(this.addr,t)}function ao(e,t){e.uniform3uiv(this.addr,t)}function oo(e,t){e.uniform4uiv(this.addr,t)}function ho(e,t,i){const n=t.length,r=Ea(i,n);e.uniform1iv(this.addr,r);for(let e=0;e!==n;++e)i.safeSetTexture2D(t[e]||fa,r[e])}function co(e,t,i){const n=t.length,r=Ea(i,n);e.uniform1iv(this.addr,r);for(let e=0;e!==n;++e)i.safeSetTextureCube(t[e]||va,r[e])}function lo(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Aa;case 35664:return Ia;case 35665:return Ra;case 35666:return Pa;case 35674:return La;case 35675:return Da;case 35676:return Na;case 5124:case 35670:return $a;case 35667:case 35671:return ka;case 35668:case 35672:return Oa;case 35669:case 35673:return za;case 5125:return Fa;case 36294:return Ba;case 36295:return Ua;case 36296:return Va;case 35678:case 36198:case 36298:case 36306:case 35682:return Ha;case 35679:case 36299:case 36307:return ja;case 35680:case 36300:case 36308:case 36293:return Ga;case 36289:case 36303:case 36311:case 36292:return Wa}}(t.type)}function uo(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return qa;case 35664:return Xa;case 35665:return Za;case 35666:return Ya;case 35674:return Ja;case 35675:return Ka;case 35676:return Qa;case 5124:case 35670:return eo;case 35667:case 35671:return to;case 35668:case 35672:return io;case 35669:case 35673:return no;case 5125:return ro;case 36294:return so;case 36295:return ao;case 36296:return oo;case 35678:case 36198:case 36298:case 36306:case 35682:return ho;case 35680:case 36300:case 36308:case 36293:return co}}(t.type)}function po(e){this.id=e,this.seq=[],this.map={}}uo.prototype.updateCache=function(e){const t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Ca(t,e)},po.prototype.setValue=function(e,t,i){const n=this.seq;for(let r=0,s=n.length;r!==s;++r){const s=n[r];s.setValue(e,t[s.id],i)}};const mo=/(\w+)(\])?(\[|\.)?/g;function fo(e,t){e.seq.push(t),e.map[t.id]=t}function go(e,t,i){const n=e.name,r=n.length;for(mo.lastIndex=0;;){const s=mo.exec(n),a=mo.lastIndex;let o=s[1];const h="]"===s[2],c=s[3];if(h&&(o|=0),void 0===c||"["===c&&a+2===r){fo(i,void 0===c?new lo(o,e,t):new uo(o,e,t));break}{let e=i.map[o];void 0===e&&(e=new po(o),fo(i,e)),i=e}}}function _o(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,35718);for(let n=0;n<i;++n){const i=e.getActiveUniform(t,n);go(i,e.getUniformLocation(t,i.name),this)}}function vo(e,t,i){const n=e.createShader(t);return e.shaderSource(n,i),e.compileShader(n),n}_o.prototype.setValue=function(e,t,i,n){const r=this.map[t];void 0!==r&&r.setValue(e,i,n)},_o.prototype.setOptional=function(e,t,i){const n=t[i];void 0!==n&&this.setValue(e,i,n)},_o.upload=function(e,t,i,n){for(let r=0,s=t.length;r!==s;++r){const s=t[r],a=i[s.id];!1!==a.needsUpdate&&s.setValue(e,a.value,n)}},_o.seqWithValue=function(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const r=e[n];r.id in t&&i.push(r)}return i};let yo=0;function bo(e){switch(e){case _i:return["Linear","( value )"];case vi:return["sRGB","( value )"];case bi:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case yi:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function xo(e,t,i){const n=e.getShaderParameter(t,35713),r=e.getShaderInfoLog(t).trim();return n&&""===r?"":i.toUpperCase()+"\n\n"+r+"\n\n"+function(e){const t=e.split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}(e.getShaderSource(t))}function wo(e,t){const i=bo(t);return"vec4 "+e+"( vec4 value ) { return "+i[0]+"ToLinear"+i[1]+"; }"}function Mo(e,t){const i=bo(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function So(e,t){let i;switch(t){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function To(e){return""!==e}function Co(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Eo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ao=/^[ \t]*#include +<([\w\d./]+)>/gm;function Io(e){return e.replace(Ao,Ro)}function Ro(e,t){const i=Ms[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return Io(i)}const Po=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Lo=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Do(e){return e.replace(Lo,$o).replace(Po,No)}function No(e,t,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),$o(e,t,i,n)}function $o(e,t,i,n){let r="";for(let e=parseInt(t);e<parseInt(i);e++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function ko(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Oo(e,t,i,n){const r=e.getContext(),s=i.defines;let a=i.vertexShader,o=i.fragmentShader;const h=function(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(i),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Gt:case Wt:t="ENVMAP_TYPE_CUBE";break;case qt:case 307:t="ENVMAP_TYPE_CUBE_UV"}return t}(i),l=function(e){let t="ENVMAP_MODE_REFLECTION";if(e.envMap)switch(e.envMapMode){case Wt:case 307:t="ENVMAP_MODE_REFRACTION"}return t}(i),u=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(i),d=e.gammaFactor>0?e.gammaFactor:1,p=i.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(To).join("\n")}(i),m=function(e){const t=[];for(const i in e){const n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}(s),f=r.createProgram();let g,_,v=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(g=[m].filter(To).join("\n"),g.length>0&&(g+="\n"),_=[p,m].filter(To).join("\n"),_.length>0&&(_+="\n")):(g=[ko(i),"#define SHADER_NAME "+i.shaderName,m,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+l:"",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.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",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.morphTargets&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargets&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\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(To).join("\n"),_=[p,ko(i),"#define SHADER_NAME "+i.shaderName,m,"#define GAMMA_FACTOR "+d,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.envMap?"#define "+l:"",i.envMap?"#define "+u:"",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.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularColorMap?"#define USE_SPECULARCOLORMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEENCOLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?Ms.tonemapping_pars_fragment:"",0!==i.toneMapping?So("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.format===ai?"#define OPAQUE":"",Ms.encodings_pars_fragment,i.map?wo("mapTexelToLinear",i.mapEncoding):"",i.matcap?wo("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?wo("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?wo("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.specularColorMap?wo("specularColorMapTexelToLinear",i.specularColorMapEncoding):"",i.sheenColorMap?wo("sheenColorMapTexelToLinear",i.sheenColorMapEncoding):"",i.lightMap?wo("lightMapTexelToLinear",i.lightMapEncoding):"",Mo("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(To).join("\n")),a=Io(a),a=Co(a,i),a=Eo(a,i),o=Io(o),o=Co(o,i),o=Eo(o,i),a=Do(a),o=Do(o),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(v="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,_=["#define varying in",i.glslVersion===Si?"":"out highp vec4 pc_fragColor;",i.glslVersion===Si?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+_);const y=v+_+o,b=vo(r,35633,v+g+a),x=vo(r,35632,y);if(r.attachShader(f,b),r.attachShader(f,x),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const e=r.getProgramInfoLog(f).trim(),t=r.getShaderInfoLog(b).trim(),i=r.getShaderInfoLog(x).trim();let n=!0,s=!0;if(!1===r.getProgramParameter(f,35714)){n=!1;const t=xo(r,b,"vertex"),i=xo(r,x,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,35715)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+i)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==t&&""!==i||(s=!1);s&&(this.diagnostics={runnable:n,programLog:e,vertexShader:{log:t,prefix:g},fragmentShader:{log:i,prefix:_}})}let w,M;return r.deleteShader(b),r.deleteShader(x),this.getUniforms=function(){return void 0===w&&(w=new _o(r,f)),w},this.getAttributes=function(){return void 0===M&&(M=function(e,t){const i={},n=e.getProgramParameter(t,35721);for(let r=0;r<n;r++){const n=e.getActiveAttrib(t,r),s=n.name;let a=1;35674===n.type&&(a=2),35675===n.type&&(a=3),35676===n.type&&(a=4),i[s]={type:n.type,location:e.getAttribLocation(t,s),locationSize:a}}return i}(r,f)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.name=i.shaderName,this.id=yo++,this.cacheKey=t,this.usedTimes=1,this.program=f,this.vertexShader=b,this.fragmentShader=x,this}function zo(e,t,i,n,r,s,a){const o=[],h=r.isWebGL2,c=r.logarithmicDepthBuffer,l=r.floatVertexTextures,u=r.maxVertexUniforms,d=r.vertexTextures;let p=r.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},f=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoat","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap",,"roughnessMap","metalnessMap","gradientMap","alphaMap","alphaTest","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","morphTargetsCount","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","format","specularIntensityMap","specularColorMap","specularColorMapEncoding","transmission","transmissionMap","thicknessMap","sheen","sheenColorMap","sheenColorMapEncoding","sheenRoughnessMap"];function g(e){let t;return e&&e.isTexture?t=e.encoding:e&&e.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),t=e.texture.encoding):t=_i,h&&e&&e.isTexture&&e.format===oi&&e.type===ei&&e.encoding===vi&&(t=_i),t}return{getParameters:function(s,o,f,_,v){const y=_.fog,b=s.isMeshStandardMaterial?_.environment:null,x=(s.isMeshStandardMaterial?i:t).get(s.envMap||b),w=m[s.type],M=v.isSkinnedMesh?function(e){const t=e.skeleton.bones;if(l)return 1024;{const e=u,i=Math.floor((e-20)/4),n=Math.min(i,t.length);return n<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+n+"."),0):n}}(v):0;let S,T;if(null!==s.precision&&(p=r.getMaxPrecision(s.precision),p!==s.precision&&console.warn("THREE.WebGLProgram.getParameters:",s.precision,"not supported, using",p,"instead.")),w){const e=Ts[w];S=e.vertexShader,T=e.fragmentShader}else S=s.vertexShader,T=s.fragmentShader;const C=e.getRenderTarget(),E=s.alphaTest>0,A=s.clearcoat>0;return{isWebGL2:h,shaderID:w,shaderName:s.type,vertexShader:S,fragmentShader:T,defines:s.defines,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,instancing:!0===v.isInstancedMesh,instancingColor:!0===v.isInstancedMesh&&null!==v.instanceColor,supportsVertexTextures:d,outputEncoding:null!==C?g(C.texture):e.outputEncoding,map:!!s.map,mapEncoding:g(s.map),matcap:!!s.matcap,matcapEncoding:g(s.matcap),envMap:!!x,envMapMode:x&&x.mapping,envMapEncoding:g(x),envMapCubeUV:!!x&&(x.mapping===qt||307===x.mapping),lightMap:!!s.lightMap,lightMapEncoding:g(s.lightMap),aoMap:!!s.aoMap,emissiveMap:!!s.emissiveMap,emissiveMapEncoding:g(s.emissiveMap),bumpMap:!!s.bumpMap,normalMap:!!s.normalMap,objectSpaceNormalMap:1===s.normalMapType,tangentSpaceNormalMap:0===s.normalMapType,clearcoat:A,clearcoatMap:A&&!!s.clearcoatMap,clearcoatRoughnessMap:A&&!!s.clearcoatRoughnessMap,clearcoatNormalMap:A&&!!s.clearcoatNormalMap,displacementMap:!!s.displacementMap,roughnessMap:!!s.roughnessMap,metalnessMap:!!s.metalnessMap,specularMap:!!s.specularMap,specularIntensityMap:!!s.specularIntensityMap,specularColorMap:!!s.specularColorMap,specularColorMapEncoding:g(s.specularColorMap),alphaMap:!!s.alphaMap,alphaTest:E,gradientMap:!!s.gradientMap,sheen:s.sheen>0,sheenColorMap:!!s.sheenColorMap,sheenColorMapEncoding:g(s.sheenColorMap),sheenRoughnessMap:!!s.sheenRoughnessMap,transmission:s.transmission>0,transmissionMap:!!s.transmissionMap,thicknessMap:!!s.thicknessMap,combine:s.combine,vertexTangents:!!s.normalMap&&!!v.geometry&&!!v.geometry.attributes.tangent,vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!v.geometry&&!!v.geometry.attributes.color&&4===v.geometry.attributes.color.itemSize,vertexUvs:!!s.map||!!s.bumpMap||!!s.normalMap||!!s.specularMap||!!s.alphaMap||!!s.emissiveMap||!!s.roughnessMap||!!s.metalnessMap||!!s.clearcoatMap||!!s.clearcoatRoughnessMap||!!s.clearcoatNormalMap||!!s.displacementMap||!!s.transmissionMap||!!s.thicknessMap||!!s.specularIntensityMap||!!s.specularColorMap||!!s.sheenColorMap||s.sheenRoughnessMap,uvsVertexOnly:!(s.map||s.bumpMap||s.normalMap||s.specularMap||s.alphaMap||s.emissiveMap||s.roughnessMap||s.metalnessMap||s.clearcoatNormalMap||s.transmission>0||s.transmissionMap||s.thicknessMap||s.specularIntensityMap||s.specularColorMap||!!s.sheen>0||s.sheenColorMap||s.sheenRoughnessMap||!s.displacementMap),fog:!!y,useFog:s.fog,fogExp2:y&&y.isFogExp2,flatShading:!!s.flatShading,sizeAttenuation:s.sizeAttenuation,logarithmicDepthBuffer:c,skinning:!0===v.isSkinnedMesh&&M>0,maxBones:M,useVertexTexture:l,morphTargets:!!v.geometry&&!!v.geometry.morphAttributes.position,morphNormals:!!v.geometry&&!!v.geometry.morphAttributes.normal,morphTargetsCount:v.geometry&&v.geometry.morphAttributes.position?v.geometry.morphAttributes.position.length:0,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,format:s.format,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&f.length>0,shadowMapType:e.shadowMap.type,toneMapping:s.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:s.premultipliedAlpha,doubleSided:2===s.side,flipSided:1===s.side,depthPacking:void 0!==s.depthPacking&&s.depthPacking,index0AttributeName:s.index0AttributeName,extensionDerivatives:s.extensions&&s.extensions.derivatives,extensionFragDepth:s.extensions&&s.extensions.fragDepth,extensionDrawBuffers:s.extensions&&s.extensions.drawBuffers,extensionShaderTextureLOD:s.extensions&&s.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(t){const i=[];if(t.shaderID?i.push(t.shaderID):(i.push(Vi(t.fragmentShader)),i.push(Vi(t.vertexShader))),void 0!==t.defines)for(const e in t.defines)i.push(e),i.push(t.defines[e]);if(!1===t.isRawShaderMaterial){for(let e=0;e<f.length;e++)i.push(t[f[e]]);i.push(e.outputEncoding),i.push(e.gammaFactor)}return i.push(t.customProgramCacheKey),i.join()},getUniforms:function(e){const t=m[e.type];let i;if(t){const e=Ts[t];i=ss.clone(e.uniforms)}else i=e.uniforms;return i},acquireProgram:function(t,i){let n;for(let e=0,t=o.length;e<t;e++){const t=o[e];if(t.cacheKey===i){n=t,++n.usedTimes;break}}return void 0===n&&(n=new Oo(e,i,t,s),o.push(n)),n},releaseProgram:function(e){if(0==--e.usedTimes){const t=o.indexOf(e);o[t]=o[o.length-1],o.pop(),e.destroy()}},programs:o}}function Fo(){let e=new WeakMap;return{get:function(t){let i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,n){e.get(t)[i]=n},dispose:function(){e=new WeakMap}}}function Bo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Uo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Vo(e){const t=[];let i=0;const n=[],r=[],s=[],a={id:-1};function o(n,r,s,o,h,c){let l=t[i];const u=e.get(s);return void 0===l?(l={id:n.id,object:n,geometry:r,material:s,program:u.program||a,groupOrder:o,renderOrder:n.renderOrder,z:h,group:c},t[i]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=s,l.program=u.program||a,l.groupOrder=o,l.renderOrder=n.renderOrder,l.z=h,l.group=c),i++,l}return{opaque:n,transmissive:r,transparent:s,init:function(){i=0,n.length=0,r.length=0,s.length=0},push:function(e,t,i,a,h,c){const l=o(e,t,i,a,h,c);i.transmission>0?r.push(l):!0===i.transparent?s.push(l):n.push(l)},unshift:function(e,t,i,a,h,c){const l=o(e,t,i,a,h,c);i.transmission>0?r.unshift(l):!0===i.transparent?s.unshift(l):n.unshift(l)},finish:function(){for(let e=i,n=t.length;e<n;e++){const i=t[e];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.program=null,i.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Bo),r.length>1&&r.sort(t||Uo),s.length>1&&s.sort(t||Uo)}}}function Ho(e){let t=new WeakMap;return{get:function(i,n){let r;return!1===t.has(i)?(r=new Vo(e),t.set(i,[r])):n>=t.get(i).length?(r=new Vo(e),t.get(i).push(r)):r=t.get(i)[n],r},dispose:function(){t=new WeakMap}}}function jo(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new Ki,color:new xr};break;case"SpotLight":i={position:new Ki,direction:new Ki,color:new xr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ki,color:new xr,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ki,skyColor:new xr,groundColor:new xr};break;case"RectAreaLight":i={color:new xr,position:new Ki,halfWidth:new Ki,halfHeight:new Ki}}return e[t.id]=i,i}}}let Go=0;function Wo(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function qo(e,t){const i=new jo,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new zi};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new zi,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)r.probe.push(new Ki);const s=new Ki,a=new Rn,o=new Rn;return{setup:function(s,a){let o=0,h=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,d=0,p=0,m=0,f=0,g=0,_=0;s.sort(Wo);const v=!0!==a?Math.PI:1;for(let e=0,t=s.length;e<t;e++){const t=s[e],a=t.color,y=t.intensity,b=t.distance,x=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)o+=a.r*y*v,h+=a.g*y*v,c+=a.b*y*v;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],y);else if(t.isDirectionalLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*v),t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.directionalShadow[l]=i,r.directionalShadowMap[l]=x,r.directionalShadowMatrix[l]=t.shadow.matrix,f++}r.directional[l]=e,l++}else if(t.isSpotLight){const e=i.get(t);if(e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(a).multiplyScalar(y*v),e.distance=b,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.spotShadow[d]=i,r.spotShadowMap[d]=x,r.spotShadowMatrix[d]=t.shadow.matrix,_++}r.spot[d]=e,d++}else if(t.isRectAreaLight){const e=i.get(t);e.color.copy(a).multiplyScalar(y),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[p]=e,p++}else if(t.isPointLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*v),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,i.shadowCameraNear=e.camera.near,i.shadowCameraFar=e.camera.far,r.pointShadow[u]=i,r.pointShadowMap[u]=x,r.pointShadowMatrix[u]=t.shadow.matrix,g++}r.point[u]=e,u++}else if(t.isHemisphereLight){const e=i.get(t);e.skyColor.copy(t.color).multiplyScalar(y*v),e.groundColor.copy(t.groundColor).multiplyScalar(y*v),r.hemi[m]=e,m++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Ss.LTC_FLOAT_1,r.rectAreaLTC2=Ss.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Ss.LTC_HALF_1,r.rectAreaLTC2=Ss.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=h,r.ambient[2]=c;const y=r.hash;y.directionalLength===l&&y.pointLength===u&&y.spotLength===d&&y.rectAreaLength===p&&y.hemiLength===m&&y.numDirectionalShadows===f&&y.numPointShadows===g&&y.numSpotShadows===_||(r.directional.length=l,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=_,r.spotShadowMap.length=_,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotShadowMatrix.length=_,y.directionalLength=l,y.pointLength=u,y.spotLength=d,y.rectAreaLength=p,y.hemiLength=m,y.numDirectionalShadows=f,y.numPointShadows=g,y.numSpotShadows=_,r.version=Go++)},setupView:function(e,t){let i=0,n=0,h=0,c=0,l=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t<d;t++){const d=e[t];if(d.isDirectionalLight){const e=r.directional[i];e.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(s),e.direction.transformDirection(u),i++}else if(d.isSpotLight){const e=r.spot[h];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(d.matrixWorld),s.setFromMatrixPosition(d.target.matrixWorld),e.direction.sub(s),e.direction.transformDirection(u),h++}else if(d.isRectAreaLight){const e=r.rectArea[c];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),o.identity(),a.copy(d.matrixWorld),a.premultiply(u),o.extractRotation(a),e.halfWidth.set(.5*d.width,0,0),e.halfHeight.set(0,.5*d.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),c++}else if(d.isPointLight){const e=r.point[n];e.position.setFromMatrixPosition(d.matrixWorld),e.position.applyMatrix4(u),n++}else if(d.isHemisphereLight){const e=r.hemi[l];e.direction.setFromMatrixPosition(d.matrixWorld),e.direction.transformDirection(u),e.direction.normalize(),l++}}},state:r}}function Xo(e,t){const i=new qo(e,t),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(e){i.setup(n,e)},setupLightsView:function(e){i.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function Zo(e,t){let i=new WeakMap;return{get:function(n,r=0){let s;return!1===i.has(n)?(s=new Xo(e,t),i.set(n,[s])):r>=i.get(n).length?(s=new Xo(e,t),i.get(n).push(s)):s=i.get(n)[r],s},dispose:function(){i=new WeakMap}}}class Yo extends mr{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,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.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,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}}Yo.prototype.isMeshDepthMaterial=!0;class Jo extends mr{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Ki,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}Jo.prototype.isMeshDistanceMaterial=!0;function Ko(e,t,i){let n=new ys;const r=new zi,s=new zi,a=new Xi,o=new Yo({depthPacking:3201}),h=new Jo,c={},l=i.maxTextureSize,u={0:1,1:0,2:2},d=new as({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new zi},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new kr;m.setAttribute("position",new Tr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new es(m,d),g=this;function _(i,n){const r=t.update(f);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(n,null,r,d,f,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(n,null,r,p,f,null)}function v(t,i,n,r,s,a,l){let d=null;const p=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(d=void 0!==p?p:!0===r.isPointLight?h:o,e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const e=d.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=d.clone(),i[t]=r),d=r}return d.visible=n.visible,d.wireframe=n.wireframe,d.side=3===l?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],d.alphaMap=n.alphaMap,d.alphaTest=n.alphaTest,d.clipShadows=n.clipShadows,d.clippingPlanes=n.clippingPlanes,d.clipIntersection=n.clipIntersection,d.displacementMap=n.displacementMap,d.displacementScale=n.displacementScale,d.displacementBias=n.displacementBias,d.wireframeLinewidth=n.wireframeLinewidth,d.linewidth=n.linewidth,!0===r.isPointLight&&!0===d.isMeshDistanceMaterial&&(d.referencePosition.setFromMatrixPosition(r.matrixWorld),d.nearDistance=s,d.farDistance=a),d}function y(i,r,s,a,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===o)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=t.update(i),r=i.material;if(Array.isArray(r)){const t=n.groups;for(let h=0,c=t.length;h<c;h++){const c=t[h],l=r[c.materialIndex];if(l&&l.visible){const t=v(i,0,l,a,s.near,s.far,o);e.renderBufferDirect(s,null,n,t,i,c)}}}else if(r.visible){const t=v(i,0,r,a,s.near,s.far,o);e.renderBufferDirect(s,null,n,t,i,null)}}const h=i.children;for(let e=0,t=h.length;e<t;e++)y(h[e],r,s,a,o)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(t,i,o){if(!1===g.enabled)return;if(!1===g.autoUpdate&&!1===g.needsUpdate)return;if(0===t.length)return;const h=e.getRenderTarget(),c=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),d=e.state;d.setBlending(0),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);for(let h=0,c=t.length;h<c;h++){const c=t[h],u=c.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",c,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;r.copy(u.mapSize);const p=u.getFrameExtents();if(r.multiply(p),s.copy(u.mapSize),(r.x>l||r.y>l)&&(r.x>l&&(s.x=Math.floor(l/p.x),r.x=s.x*p.x,u.mapSize.x=s.x),r.y>l&&(s.y=Math.floor(l/p.y),r.y=s.y*p.y,u.mapSize.y=s.y)),null===u.map&&!u.isPointLightShadow&&3===this.type){const e={minFilter:Kt,magFilter:Kt,format:oi};u.map=new Zi(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.mapPass=new Zi(r.x,r.y,e),u.camera.updateProjectionMatrix()}if(null===u.map){const e={minFilter:Jt,magFilter:Jt,format:oi};u.map=new Zi(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const m=u.getViewportCount();for(let e=0;e<m;e++){const t=u.getViewport(e);a.set(s.x*t.x,s.y*t.y,s.x*t.z,s.y*t.w),d.viewport(a),u.updateMatrices(c,e),n=u.getFrustum(),y(i,o,u.camera,c,this.type)}u.isPointLightShadow||3!==this.type||_(u,o),u.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(h,c,u)}}function Qo(e,t,i){const n=i.isWebGL2;const r=new function(){let t=!1;const i=new Xi;let n=null;const r=new Xi(0,0,0,0);return{setMask:function(i){n===i||t||(e.colorMask(i,i,i,i),n=i)},setLocked:function(e){t=e},setClear:function(t,n,s,a,o){!0===o&&(t*=a,n*=a,s*=a),i.set(t,n,s,a),!1===r.equals(i)&&(e.clearColor(t,n,s,a),r.copy(i))},reset:function(){t=!1,n=null,r.set(-1,0,0,0)}}},s=new function(){let t=!1,i=null,n=null,r=null;return{setTest:function(e){e?O(2929):z(2929)},setMask:function(n){i===n||t||(e.depthMask(n),i=n)},setFunc:function(t){if(n!==t){if(t)switch(t){case 0:e.depthFunc(512);break;case 1:e.depthFunc(519);break;case 2:e.depthFunc(513);break;case 3:e.depthFunc(515);break;case 4:e.depthFunc(514);break;case 5:e.depthFunc(518);break;case 6:e.depthFunc(516);break;case 7:e.depthFunc(517);break;default:e.depthFunc(515)}else e.depthFunc(515);n=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,i=null,n=null,r=null}}},a=new function(){let t=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,c=null;return{setTest:function(e){t||(e?O(2960):z(2960))},setMask:function(n){i===n||t||(e.stencilMask(n),i=n)},setFunc:function(t,i,a){n===t&&r===i&&s===a||(e.stencilFunc(t,i,a),n=t,r=i,s=a)},setOp:function(t,i,n){a===t&&o===i&&h===n||(e.stencilOp(t,i,n),a=t,o=i,h=n)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,i=null,n=null,r=null,s=null,a=null,o=null,h=null,c=null}}};let o={},h=null,c={},l=null,u=!1,d=null,p=null,m=null,f=null,g=null,_=null,v=null,y=!1,b=null,x=null,w=null,M=null,S=null;const T=e.getParameter(35661);let C=!1,E=0;const A=e.getParameter(7938);-1!==A.indexOf("WebGL")?(E=parseFloat(/^WebGL (\d)/.exec(A)[1]),C=E>=1):-1!==A.indexOf("OpenGL ES")&&(E=parseFloat(/^OpenGL ES (\d)/.exec(A)[1]),C=E>=2);let I=null,R={};const P=e.getParameter(3088),L=e.getParameter(2978),D=(new Xi).fromArray(P),N=(new Xi).fromArray(L);function $(t,i,n){const r=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<n;t++)e.texImage2D(i+t,0,6408,1,1,0,6408,5121,r);return s}const k={};function O(t){!0!==o[t]&&(e.enable(t),o[t]=!0)}function z(t){!1!==o[t]&&(e.disable(t),o[t]=!1)}k[3553]=$(3553,3553,1),k[34067]=$(34067,34069,6),r.setClear(0,0,0,1),s.setClear(1),a.setClear(0),O(2929),s.setFunc(3),V(!1),H(1),O(2884),U(0);const F={[jt]:32774,101:32778,102:32779};if(n)F[103]=32775,F[104]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(F[103]=e.MIN_EXT,F[104]=e.MAX_EXT)}const B={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function U(t,i,n,r,s,a,o,h){if(0!==t){if(!1===u&&(O(3042),u=!0),5===t)s=s||i,a=a||n,o=o||r,i===p&&s===g||(e.blendEquationSeparate(F[i],F[s]),p=i,g=s),n===m&&r===f&&a===_&&o===v||(e.blendFuncSeparate(B[n],B[r],B[a],B[o]),m=n,f=r,_=a,v=o),d=t,y=null;else if(t!==d||h!==y){if(p===jt&&g===jt||(e.blendEquation(32774),p=jt,g=jt),h)switch(t){case 1:e.blendFuncSeparate(1,771,1,771);break;case 2:e.blendFunc(1,1);break;case 3:e.blendFuncSeparate(0,0,769,771);break;case 4:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(770,771,1,771);break;case 2:e.blendFunc(770,1);break;case 3:e.blendFunc(0,769);break;case 4:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}m=null,f=null,_=null,v=null,d=t,y=h}}else!0===u&&(z(3042),u=!1)}function V(t){b!==t&&(t?e.frontFace(2304):e.frontFace(2305),b=t)}function H(t){0!==t?(O(2884),t!==x&&(1===t?e.cullFace(1029):2===t?e.cullFace(1028):e.cullFace(1032))):z(2884),x=t}function j(t,i,n){t?(O(32823),M===i&&S===n||(e.polygonOffset(i,n),M=i,S=n)):z(32823)}function G(t){void 0===t&&(t=33984+T-1),I!==t&&(e.activeTexture(t),I=t)}return{buffers:{color:r,depth:s,stencil:a},enable:O,disable:z,bindFramebuffer:function(t,i){return null===i&&null!==h&&(i=h),c[t]!==i&&(e.bindFramebuffer(t,i),c[t]=i,n&&(36009===t&&(c[36160]=i),36160===t&&(c[36009]=i)),!0)},bindXRFramebuffer:function(t){t!==h&&(e.bindFramebuffer(36160,t),h=t)},useProgram:function(t){return l!==t&&(e.useProgram(t),l=t,!0)},setBlending:U,setMaterial:function(e,t){2===e.side?z(2884):O(2884);let i=1===e.side;t&&(i=!i),V(i),1===e.blending&&!1===e.transparent?U(0):U(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),s.setFunc(e.depthFunc),s.setTest(e.depthTest),s.setMask(e.depthWrite),r.setMask(e.colorWrite);const n=e.stencilWrite;a.setTest(n),n&&(a.setMask(e.stencilWriteMask),a.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),a.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),j(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?O(32926):z(32926)},setFlipSided:V,setCullFace:H,setLineWidth:function(t){t!==w&&(C&&e.lineWidth(t),w=t)},setPolygonOffset:j,setScissorTest:function(e){e?O(3089):z(3089)},activeTexture:G,bindTexture:function(t,i){null===I&&G();let n=R[I];void 0===n&&(n={type:void 0,texture:void 0},R[I]=n),n.type===t&&n.texture===i||(e.bindTexture(t,i||k[t]),n.type=t,n.texture=i)},unbindTexture:function(){const t=R[I];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===D.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),D.copy(t))},viewport:function(t){!1===N.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),N.copy(t))},reset:function(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===n&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),o={},I=null,R={},h=null,c={},l=null,u=!1,d=null,p=null,m=null,f=null,g=null,_=null,v=null,y=!1,b=null,x=null,w=null,M=null,S=null,D.set(0,0,e.canvas.width,e.canvas.height),N.set(0,0,e.canvas.width,e.canvas.height),r.reset(),s.reset(),a.reset()}}}function eh(e,t,i,n,r,s,a){const o=r.isWebGL2,h=r.maxTextures,c=r.maxCubemapSize,l=r.maxTextureSize,u=r.maxSamples,d=new WeakMap;let p,m=!1;try{m="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function f(e,t){return m?new OffscreenCanvas(e,t):Ui("canvas")}function g(e,t,i,n){let r=1;if((e.width>n||e.height>n)&&(r=n/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const n=t?ki:Math.floor,s=n(r*e.width),a=n(r*e.height);void 0===p&&(p=f(s,a));const o=i?f(s,a):p;o.width=s,o.height=a;return o.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function _(e){return $i(e.width)&&$i(e.height)}function v(e,t){return e.generateMipmaps&&t&&e.minFilter!==Jt&&e.minFilter!==Kt}function y(t,i,r,s,a=1){e.generateMipmap(t);n.get(i).__maxMipLevel=Math.log2(Math.max(r,s,a))}function b(i,n,r,s){if(!1===o)return n;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let a=n;return 6403===n&&(5126===r&&(a=33326),5131===r&&(a=33325),5121===r&&(a=33321)),6407===n&&(5126===r&&(a=34837),5131===r&&(a=34843),5121===r&&(a=32849)),6408===n&&(5126===r&&(a=34836),5131===r&&(a=34842),5121===r&&(a=s===vi?35907:32856)),33325!==a&&33326!==a&&34842!==a&&34836!==a||t.get("EXT_color_buffer_float"),a}function x(e){return e===Jt||1004===e||1005===e?9728:9729}function w(t){const i=t.target;i.removeEventListener("dispose",w),function(t){const i=n.get(t);if(void 0===i.__webglInit)return;e.deleteTexture(i.__webglTexture),n.remove(t)}(i),i.isVideoTexture&&d.delete(i),a.memory.textures--}function M(t){const i=t.target;i.removeEventListener("dispose",M),function(t){const i=t.texture,r=n.get(t),s=n.get(i);if(!t)return;void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);r.__webglTexture&&(e.deleteTexture(r.__webglTexture),a.memory.textures--),n.remove(i[t])}n.remove(i),n.remove(t)}(i)}let S=0;function T(e,t){const r=n.get(e);if(e.isVideoTexture&&function(e){const t=a.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(e),e.version>0&&r.__version!==e.version){const i=e.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void P(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+t),i.bindTexture(3553,r.__webglTexture)}function C(t,r){const a=n.get(t);t.version>0&&a.__version!==t.version?function(t,n,r){if(6!==n.image.length)return;R(t,n),i.activeTexture(33984+r),i.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const a=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),h=n.image[0]&&n.image[0].isDataTexture,l=[];for(let e=0;e<6;e++)l[e]=a||h?h?n.image[e].image:n.image[e]:g(n.image[e],!1,!0,c);const u=l[0],d=_(u)||o,p=s.convert(n.format),m=s.convert(n.type),f=b(n.internalFormat,p,m,n.encoding);let x;if(I(34067,n,d),a){for(let e=0;e<6;e++){x=l[e].mipmaps;for(let t=0;t<x.length;t++){const r=x[t];n.format!==oi&&n.format!==ai?null!==p?i.compressedTexImage2D(34069+e,t,f,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(34069+e,t,f,r.width,r.height,0,p,m,r.data)}}t.__maxMipLevel=x.length-1}else{x=n.mipmaps;for(let e=0;e<6;e++)if(h){i.texImage2D(34069+e,0,f,l[e].width,l[e].height,0,p,m,l[e].data);for(let t=0;t<x.length;t++){const n=x[t].image[e].image;i.texImage2D(34069+e,t+1,f,n.width,n.height,0,p,m,n.data)}}else{i.texImage2D(34069+e,0,f,p,m,l[e]);for(let t=0;t<x.length;t++){const n=x[t];i.texImage2D(34069+e,t+1,f,p,m,n.image[e])}}t.__maxMipLevel=x.length}v(n,d)&&y(34067,n,u.width,u.height);t.__version=n.version,n.onUpdate&&n.onUpdate(n)}(a,t,r):(i.activeTexture(33984+r),i.bindTexture(34067,a.__webglTexture))}const E={[Xt]:10497,[Zt]:33071,[Yt]:33648},A={[Jt]:9728,1004:9984,1005:9986,[Kt]:9729,1007:9985,[Qt]:9987};function I(i,s,a){if(a?(e.texParameteri(i,10242,E[s.wrapS]),e.texParameteri(i,10243,E[s.wrapT]),32879!==i&&35866!==i||e.texParameteri(i,32882,E[s.wrapR]),e.texParameteri(i,10240,A[s.magFilter]),e.texParameteri(i,10241,A[s.minFilter])):(e.texParameteri(i,10242,33071),e.texParameteri(i,10243,33071),32879!==i&&35866!==i||e.texParameteri(i,32882,33071),s.wrapS===Zt&&s.wrapT===Zt||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,10240,x(s.magFilter)),e.texParameteri(i,10241,x(s.minFilter)),s.minFilter!==Jt&&s.minFilter!==Kt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(s.type===ni&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&s.type===ri&&!1===t.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(e.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function R(t,i){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",w),t.__webglTexture=e.createTexture(),a.memory.textures++)}function P(t,n,r){let a=3553;n.isDataTexture2DArray&&(a=35866),n.isDataTexture3D&&(a=32879),R(t,n),i.activeTexture(33984+r),i.bindTexture(a,t.__webglTexture),e.pixelStorei(37440,n.flipY),e.pixelStorei(37441,n.premultiplyAlpha),e.pixelStorei(3317,n.unpackAlignment),e.pixelStorei(37443,0);const h=function(e){return!o&&(e.wrapS!==Zt||e.wrapT!==Zt||e.minFilter!==Jt&&e.minFilter!==Kt)}(n)&&!1===_(n.image),c=g(n.image,h,!1,l),u=_(c)||o,d=s.convert(n.format);let p,m=s.convert(n.type),f=b(n.internalFormat,d,m,n.encoding);I(a,n,u);const x=n.mipmaps;if(n.isDepthTexture)f=6402,o?f=n.type===ni?36012:n.type===ii?33190:n.type===si?35056:33189:n.type===ni&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===hi&&6402===f&&n.type!==ti&&n.type!==ii&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=ti,m=s.convert(n.type)),n.format===ci&&6402===f&&(f=34041,n.type!==si&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=si,m=s.convert(n.type))),i.texImage2D(3553,0,f,c.width,c.height,0,d,m,null);else if(n.isDataTexture)if(x.length>0&&u){for(let e=0,t=x.length;e<t;e++)p=x[e],i.texImage2D(3553,e,f,p.width,p.height,0,d,m,p.data);n.generateMipmaps=!1,t.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,f,c.width,c.height,0,d,m,c.data),t.__maxMipLevel=0;else if(n.isCompressedTexture){for(let e=0,t=x.length;e<t;e++)p=x[e],n.format!==oi&&n.format!==ai?null!==d?i.compressedTexImage2D(3553,e,f,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(3553,e,f,p.width,p.height,0,d,m,p.data);t.__maxMipLevel=x.length-1}else if(n.isDataTexture2DArray)i.texImage3D(35866,0,f,c.width,c.height,c.depth,0,d,m,c.data),t.__maxMipLevel=0;else if(n.isDataTexture3D)i.texImage3D(32879,0,f,c.width,c.height,c.depth,0,d,m,c.data),t.__maxMipLevel=0;else if(x.length>0&&u){for(let e=0,t=x.length;e<t;e++)p=x[e],i.texImage2D(3553,e,f,d,m,p);n.generateMipmaps=!1,t.__maxMipLevel=x.length-1}else i.texImage2D(3553,0,f,d,m,c),t.__maxMipLevel=0;v(n,u)&&y(a,n,c.width,c.height),t.__version=n.version,n.onUpdate&&n.onUpdate(n)}function L(t,r,a,o,h){const c=s.convert(a.format),l=s.convert(a.type),u=b(a.internalFormat,c,l,a.encoding);32879===h||35866===h?i.texImage3D(h,0,u,r.width,r.height,r.depth,0,c,l,null):i.texImage2D(h,0,u,r.width,r.height,0,c,l,null),i.bindFramebuffer(36160,t),e.framebufferTexture2D(36160,o,h,n.get(a).__webglTexture,0),i.bindFramebuffer(36160,null)}function D(t,i,n){if(e.bindRenderbuffer(36161,t),i.depthBuffer&&!i.stencilBuffer){let r=33189;if(n){const t=i.depthTexture;t&&t.isDepthTexture&&(t.type===ni?r=36012:t.type===ii&&(r=33190));const n=$(i);e.renderbufferStorageMultisample(36161,n,r,i.width,i.height)}else e.renderbufferStorage(36161,r,i.width,i.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(i.depthBuffer&&i.stencilBuffer){if(n){const t=$(i);e.renderbufferStorageMultisample(36161,t,35056,i.width,i.height)}else e.renderbufferStorage(36161,34041,i.width,i.height);e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===i.isWebGLMultipleRenderTargets?i.texture[0]:i.texture,r=s.convert(t.format),a=s.convert(t.type),o=b(t.internalFormat,r,a,t.encoding);if(n){const t=$(i);e.renderbufferStorageMultisample(36161,t,o,i.width,i.height)}else e.renderbufferStorage(36161,o,i.width,i.height)}e.bindRenderbuffer(36161,null)}function N(t){const r=n.get(t),s=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(s)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),T(r.depthTexture,0);const s=n.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===hi)e.framebufferTexture2D(36160,36096,3553,s,0);else{if(r.depthTexture.format!==ci)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,s,0)}}(r.__webglFramebuffer,t)}else if(s){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(36160,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=e.createRenderbuffer(),D(r.__webglDepthbuffer[n],t,!1)}else i.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),D(r.__webglDepthbuffer,t,!1);i.bindFramebuffer(36160,null)}function $(e){return o&&e.isWebGLMultisampleRenderTarget?Math.min(u,e.samples):0}let k=!1,O=!1;this.allocateTextureUnit=function(){const e=S;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),S+=1,e},this.resetTextureUnits=function(){S=0},this.setTexture2D=T,this.setTexture2DArray=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?P(r,e,t):(i.activeTexture(33984+t),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=n.get(e);e.version>0&&r.__version!==e.version?P(r,e,t):(i.activeTexture(33984+t),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=C,this.setupRenderTarget=function(t){const h=t.texture,c=n.get(t),l=n.get(h);t.addEventListener("dispose",M),!0!==t.isWebGLMultipleRenderTargets&&(l.__webglTexture=e.createTexture(),l.__version=h.version,a.memory.textures++);const u=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=!0===t.isWebGLMultisampleRenderTarget,m=h.isDataTexture3D||h.isDataTexture2DArray,f=_(t)||o;if(!o||h.format!==ai||h.type!==ni&&h.type!==ri||(h.format=oi,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),u){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else if(c.__webglFramebuffer=e.createFramebuffer(),d)if(r.drawBuffers){const i=t.texture;for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);void 0===r.__webglTexture&&(r.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(p)if(o){c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer);const n=s.convert(h.format),r=s.convert(h.type),a=b(h.internalFormat,n,r,h.encoding),o=$(t);e.renderbufferStorageMultisample(36161,o,a,t.width,t.height),i.bindFramebuffer(36160,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,c.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),D(c.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(u){i.bindTexture(34067,l.__webglTexture),I(34067,h,f);for(let e=0;e<6;e++)L(c.__webglFramebuffer[e],t,h,36064,34069+e);v(h,f)&&y(34067,h,t.width,t.height),i.unbindTexture()}else if(d){const e=t.texture;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=n.get(s);i.bindTexture(3553,a.__webglTexture),I(3553,s,f),L(c.__webglFramebuffer,t,s,36064+r,3553),v(s,f)&&y(3553,s,t.width,t.height)}i.unbindTexture()}else{let e=3553;if(m)if(o){e=h.isDataTexture3D?32879:35866}else console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.");i.bindTexture(e,l.__webglTexture),I(e,h,f),L(c.__webglFramebuffer,t,h,36064,e),v(h,f)&&y(e,h,t.width,t.height,t.depth),i.unbindTexture()}t.depthBuffer&&N(t)},this.updateRenderTargetMipmap=function(e){const t=_(e)||o,r=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let s=0,a=r.length;s<a;s++){const a=r[s];if(v(a,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,r=n.get(a).__webglTexture;i.bindTexture(t,r),y(t,a,e.width,e.height),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(o){const r=t.width,s=t.height;let a=16384;t.depthBuffer&&(a|=256),t.stencilBuffer&&(a|=1024);const o=n.get(t);i.bindFramebuffer(36008,o.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,o.__webglFramebuffer),e.blitFramebuffer(0,0,r,s,0,0,r,s,a,9728),i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,o.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===k&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),k=!0),e=e.texture),T(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===O&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),O=!0),e=e.texture),C(e,t)}}function th(e,t,i){const n=i.isWebGL2;return{convert:function(e){let i;if(e===ei)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120;if(1011===e)return 5122;if(e===ti)return 5123;if(1013===e)return 5124;if(e===ii)return 5125;if(e===ni)return 5126;if(e===ri)return n?5131:(i=t.get("OES_texture_half_float"),null!==i?i.HALF_FLOAT_OES:null);if(1021===e)return 6406;if(e===ai)return 6407;if(e===oi)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(e===hi)return 6402;if(e===ci)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032===e)return 36248;if(1033===e)return 36249;if(33776===e||33777===e||33778===e||33779===e){if(i=t.get("WEBGL_compressed_texture_s3tc"),null===i)return null;if(33776===e)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===e)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===e)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===e)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===e||35841===e||35842===e||35843===e){if(i=t.get("WEBGL_compressed_texture_pvrtc"),null===i)return null;if(35840===e)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===e)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===e)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===e)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e)return i=t.get("WEBGL_compressed_texture_etc1"),null!==i?i.COMPRESSED_RGB_ETC1_WEBGL:null;if((37492===e||37496===e)&&(i=t.get("WEBGL_compressed_texture_etc"),null!==i)){if(37492===e)return i.COMPRESSED_RGB8_ETC2;if(37496===e)return i.COMPRESSED_RGBA8_ETC2_EAC}return 37808===e||37809===e||37810===e||37811===e||37812===e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e?(i=t.get("WEBGL_compressed_texture_astc"),null!==i?e:null):36492===e?(i=t.get("EXT_texture_compression_bptc"),null!==i?e:null):e===si?n?34042:(i=t.get("WEBGL_depth_texture"),null!==i?i.UNSIGNED_INT_24_8_WEBGL:null):void 0}}}class ih extends hs{constructor(e=[]){super(),this.cameras=e}}ih.prototype.isArrayCamera=!0;class nh extends tr{constructor(){super(),this.type="Group"}}nh.prototype.isGroup=!0;const rh={type:"move"};class sh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new nh,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new nh,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ki,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ki),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new nh,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ki,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ki),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,s=null;const a=this._targetRay,o=this._grip,h=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==a&&(n=t.getPose(e.targetRaySpace,i),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(rh))),h&&e.hand){s=!0;for(const n of e.hand.values()){const e=t.getJointPose(n,i);if(void 0===h.joints[n.jointName]){const e=new nh;e.matrixAutoUpdate=!1,e.visible=!1,h.joints[n.jointName]=e,h.add(e)}const r=h.joints[n.jointName];null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.jointRadius=e.radius),r.visible=null!==e}const n=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],a=n.position.distanceTo(r.position),o=.02,c=.005;h.inputState.pinching&&a>o+c?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!h.inputState.pinching&&a<=o-c&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==s),this}}class ah extends Ti{constructor(e,t){super();const i=this,n=e.state;let r=null,s=1,a=null,o="local-floor",h=null,c=null,l=null,u=null,d=null,p=!1,m=null,f=null,g=null,_=null,v=null,y=null;const b=[],x=new Map,w=new hs;w.layers.enable(1),w.viewport=new Xi;const M=new hs;M.layers.enable(2),M.viewport=new Xi;const S=[w,M],T=new ih;T.layers.enable(1),T.layers.enable(2);let C=null,E=null;function A(e){const t=x.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function I(){x.forEach((function(e,t){e.disconnect(t)})),x.clear(),C=null,E=null,n.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),l&&t.deleteFramebuffer(l),m&&t.deleteFramebuffer(m),f&&t.deleteRenderbuffer(f),g&&t.deleteRenderbuffer(g),l=null,m=null,f=null,g=null,d=null,u=null,c=null,r=null,$.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function R(e){const t=r.inputSources;for(let e=0;e<b.length;e++)x.set(t[e],b[e]);for(let t=0;t<e.removed.length;t++){const i=e.removed[t],n=x.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),x.delete(i))}for(let t=0;t<e.added.length;t++){const i=e.added[t],n=x.get(i);n&&n.dispatchEvent({type:"connected",data:i})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return void 0===t&&(t=new sh,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return void 0===t&&(t=new sh,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return void 0===t&&(t=new sh,b[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){s=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return a},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(e){if(r=e,null!==r){r.addEventListener("select",A),r.addEventListener("selectstart",A),r.addEventListener("selectend",A),r.addEventListener("squeeze",A),r.addEventListener("squeezestart",A),r.addEventListener("squeezeend",A),r.addEventListener("end",I),r.addEventListener("inputsourceschange",R);const e=t.getContextAttributes();if(!0!==e.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers){const i={antialias:e.antialias,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,i),r.updateRenderState({baseLayer:d})}else if(t instanceof WebGLRenderingContext){const i={antialias:!0,alpha:e.alpha,depth:e.depth,stencil:e.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,i),r.updateRenderState({layers:[d]})}else{p=e.antialias;let i=null;e.depth&&(y=256,e.stencil&&(y|=1024),v=e.stencil?33306:36096,i=e.stencil?35056:33190);const a={colorFormat:e.alpha?32856:32849,depthFormat:i,scaleFactor:s};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(a),l=t.createFramebuffer(),r.updateRenderState({layers:[u]}),p&&(m=t.createFramebuffer(),f=t.createRenderbuffer(),t.bindRenderbuffer(36161,f),t.renderbufferStorageMultisample(36161,4,32856,u.textureWidth,u.textureHeight),n.bindFramebuffer(36160,m),t.framebufferRenderbuffer(36160,36064,36161,f),t.bindRenderbuffer(36161,null),null!==i&&(g=t.createRenderbuffer(),t.bindRenderbuffer(36161,g),t.renderbufferStorageMultisample(36161,4,i,u.textureWidth,u.textureHeight),t.framebufferRenderbuffer(36160,v,36161,g),t.bindRenderbuffer(36161,null)),n.bindFramebuffer(36160,null))}a=await r.requestReferenceSpace(o),$.setContext(r),$.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};const P=new Ki,L=new Ki;function D(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;T.near=M.near=w.near=e.near,T.far=M.far=w.far=e.far,C===T.near&&E===T.far||(r.updateRenderState({depthNear:T.near,depthFar:T.far}),C=T.near,E=T.far);const t=e.parent,i=T.cameras;D(T,t);for(let e=0;e<i.length;e++)D(i[e],t);T.matrixWorld.decompose(T.position,T.quaternion,T.scale),e.position.copy(T.position),e.quaternion.copy(T.quaternion),e.scale.copy(T.scale),e.matrix.copy(T.matrix),e.matrixWorld.copy(T.matrixWorld);const n=e.children;for(let e=0,t=n.length;e<t;e++)n[e].updateMatrixWorld(!0);2===i.length?function(e,t,i){P.setFromMatrixPosition(t.matrixWorld),L.setFromMatrixPosition(i.matrixWorld);const n=P.distanceTo(L),r=t.projectionMatrix.elements,s=i.projectionMatrix.elements,a=r[14]/(r[10]-1),o=r[14]/(r[10]+1),h=(r[9]+1)/r[5],c=(r[9]-1)/r[5],l=(r[8]-1)/r[0],u=(s[8]+1)/s[0],d=a*l,p=a*u,m=n/(-l+u),f=m*-l;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+m,_=o+m,v=d-f,y=p+(n-f),b=h*o/_*g,x=c*o/_*g;e.projectionMatrix.makePerspective(v,y,b,x,g,_)}(T,w,M):T.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return T},this.getFoveation=function(){return null!==u?u.fixedFoveation:null!==d?d.fixedFoveation:void 0},this.setFoveation=function(e){null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let N=null;const $=new bs;$.setAnimationLoop((function(e,i){if(h=i.getViewerPose(a),_=i,null!==h){const e=h.views;null!==d&&n.bindXRFramebuffer(d.framebuffer);let i=!1;e.length!==T.cameras.length&&(T.cameras.length=0,i=!0);for(let r=0;r<e.length;r++){const s=e[r];let a=null;if(null!==d)a=d.getViewport(s);else{const e=c.getViewSubImage(u,s);n.bindXRFramebuffer(l),void 0!==e.depthStencilTexture&&t.framebufferTexture2D(36160,v,3553,e.depthStencilTexture,0),t.framebufferTexture2D(36160,36064,3553,e.colorTexture,0),a=e.viewport}const o=S[r];o.matrix.fromArray(s.transform.matrix),o.projectionMatrix.fromArray(s.projectionMatrix),o.viewport.set(a.x,a.y,a.width,a.height),0===r&&T.matrix.copy(o.matrix),!0===i&&T.cameras.push(o)}p&&(n.bindXRFramebuffer(m),null!==y&&t.clear(y))}const s=r.inputSources;for(let e=0;e<b.length;e++){const t=b[e],n=s[e];t.update(n,i,a)}if(N&&N(e,i),p){const e=u.textureWidth,i=u.textureHeight;n.bindFramebuffer(36008,m),n.bindFramebuffer(36009,l),t.invalidateFramebuffer(36008,[v]),t.invalidateFramebuffer(36009,[v]),t.blitFramebuffer(0,0,e,i,0,0,e,i,16384,9728),t.invalidateFramebuffer(36008,[36064]),n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),n.bindFramebuffer(36160,m)}_=null})),this.setAnimationLoop=function(e){N=e},this.dispose=function(){}}}function oh(e){function t(t,i){t.opacity.value=i.opacity,i.color&&t.diffuse.value.copy(i.color),i.emissive&&t.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(t.map.value=i.map),i.alphaMap&&(t.alphaMap.value=i.alphaMap),i.specularMap&&(t.specularMap.value=i.specularMap),i.alphaTest>0&&(t.alphaTest.value=i.alphaTest);const n=e.get(i).envMap;if(n){t.envMap.value=n,t.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,t.reflectivity.value=i.reflectivity,t.ior.value=i.ior,t.refractionRatio.value=i.refractionRatio;const r=e.get(n).__maxMipLevel;void 0!==r&&(t.maxMipLevel.value=r)}let r,s;i.lightMap&&(t.lightMap.value=i.lightMap,t.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(t.aoMap.value=i.aoMap,t.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap?r=i.clearcoatRoughnessMap:i.specularIntensityMap?r=i.specularIntensityMap:i.specularColorMap?r=i.specularColorMap:i.transmissionMap?r=i.transmissionMap:i.thicknessMap?r=i.thicknessMap:i.sheenColorMap?r=i.sheenColorMap:i.sheenRoughnessMap&&(r=i.sheenRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix)),i.aoMap?s=i.aoMap:i.lightMap&&(s=i.lightMap),void 0!==s&&(s.isWebGLRenderTarget&&(s=s.texture),!0===s.matrixAutoUpdate&&s.updateMatrix(),t.uv2Transform.value.copy(s.matrix))}function i(t,i){t.roughness.value=i.roughness,t.metalness.value=i.metalness,i.roughnessMap&&(t.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(t.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(t.emissiveMap.value=i.emissiveMap),i.bumpMap&&(t.bumpMap.value=i.bumpMap,t.bumpScale.value=i.bumpScale,1===i.side&&(t.bumpScale.value*=-1)),i.normalMap&&(t.normalMap.value=i.normalMap,t.normalScale.value.copy(i.normalScale),1===i.side&&t.normalScale.value.negate()),i.displacementMap&&(t.displacementMap.value=i.displacementMap,t.displacementScale.value=i.displacementScale,t.displacementBias.value=i.displacementBias);e.get(i).envMap&&(t.envMapIntensity.value=i.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,n,r,s,a){n.isMeshBasicMaterial?t(e,n):n.isMeshLambertMaterial?(t(e,n),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(e,n)):n.isMeshToonMaterial?(t(e,n),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshPhongMaterial?(t(e,n),function(e,t){e.specular.value.copy(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,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshStandardMaterial?(t(e,n),n.isMeshPhysicalMaterial?function(e,t,n){i(e,t),e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate()));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap);t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,n,a):i(e,n)):n.isMeshMatcapMaterial?(t(e,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDepthMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isMeshDistanceMaterial?(t(e,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,n)):n.isMeshNormalMaterial?(t(e,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(e,n)):n.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,n),n.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,n)):n.isPointsMaterial?function(e,t,i,n){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*n,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let r;t.map?r=t.map:t.alphaMap&&(r=t.alphaMap);void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix))}(e,n,r,s):n.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let i;t.map?i=t.map:t.alphaMap&&(i=t.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,n):n.isShadowMaterial?(e.color.value.copy(n.color),e.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function hh(e={}){const t=void 0!==e.canvas?e.canvas:function(){const e=Ui("canvas");return e.style.display="block",e}(),i=void 0!==e.context?e.context:null,n=void 0!==e.alpha&&e.alpha,r=void 0===e.depth||e.depth,s=void 0===e.stencil||e.stencil,a=void 0!==e.antialias&&e.antialias,o=void 0===e.premultipliedAlpha||e.premultipliedAlpha,h=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",l=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let u=null,d=null;const p=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=_i,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const f=this;let g=!1,_=0,v=0,y=null,b=-1,x=null;const w=new Xi,M=new Xi;let S=null,T=t.width,C=t.height,E=1,A=null,I=null;const R=new Xi(0,0,T,C),P=new Xi(0,0,T,C);let L=!1;const D=[],N=new ys;let $=!1,k=!1,O=null;const z=new Rn,F=new Ki,B={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function U(){return null===y?E:1}let V,H,j,G,W,q,X,Z,Y,J,K,Q,ee,te,ie,ne,re,se,ae,oe,he,ce,le,ue=i;function de(e,i){for(let n=0;n<e.length;n++){const r=e[n],s=t.getContext(r,i);if(null!==s)return s}return null}try{const e={alpha:n,depth:r,stencil:s,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:l};if(t.addEventListener("webglcontextlost",fe,!1),t.addEventListener("webglcontextrestored",ge,!1),null===ue){const t=["webgl2","webgl","experimental-webgl"];if(!0===f.isWebGL1Renderer&&t.shift(),ue=de(t,e),null===ue)throw de(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===ue.getShaderPrecisionFormat&&(ue.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function pe(){V=new ra(ue),H=new Is(ue,V,e),V.init(H),ce=new th(ue,V,H),j=new Qo(ue,V,H),D[0]=1029,G=new oa(ue),W=new Fo,q=new eh(ue,V,j,W,H,ce,G),X=new Ps(f),Z=new na(f),Y=new xs(ue,H),le=new Es(ue,V,Y,H),J=new sa(ue,Y,G,le),K=new pa(ue,J,Y,G),ae=new da(ue,H,q),ne=new Rs(W),Q=new zo(f,X,Z,V,H,le,ne),ee=new oh(W),te=new Ho(W),ie=new Zo(V,H),se=new Cs(f,X,j,K,o),re=new Ko(f,K,H),oe=new As(ue,V,G,H),he=new aa(ue,V,G,H),G.programs=Q.programs,f.capabilities=H,f.extensions=V,f.properties=W,f.renderLists=te,f.shadowMap=re,f.state=j,f.info=G}pe();const me=new ah(f,ue);function fe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function ge(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;const e=G.autoReset,t=re.enabled,i=re.autoUpdate,n=re.needsUpdate,r=re.type;pe(),G.autoReset=e,re.enabled=t,re.autoUpdate=i,re.needsUpdate=n,re.type=r}function _e(e){const t=e.target;t.removeEventListener("dispose",_e),function(e){(function(e){const t=W.get(e).programs;void 0!==t&&t.forEach((function(e){Q.releaseProgram(e)}))})(e),W.remove(e)}(t)}this.xr=me,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){const e=V.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=V.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return E},this.setPixelRatio=function(e){void 0!==e&&(E=e,this.setSize(T,C,!1))},this.getSize=function(e){return e.set(T,C)},this.setSize=function(e,i,n){me.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(T=e,C=i,t.width=Math.floor(e*E),t.height=Math.floor(i*E),!1!==n&&(t.style.width=e+"px",t.style.height=i+"px"),this.setViewport(0,0,e,i))},this.getDrawingBufferSize=function(e){return e.set(T*E,C*E).floor()},this.setDrawingBufferSize=function(e,i,n){T=e,C=i,E=n,t.width=Math.floor(e*n),t.height=Math.floor(i*n),this.setViewport(0,0,e,i)},this.getCurrentViewport=function(e){return e.copy(w)},this.getViewport=function(e){return e.copy(R)},this.setViewport=function(e,t,i,n){e.isVector4?R.set(e.x,e.y,e.z,e.w):R.set(e,t,i,n),j.viewport(w.copy(R).multiplyScalar(E).floor())},this.getScissor=function(e){return e.copy(P)},this.setScissor=function(e,t,i,n){e.isVector4?P.set(e.x,e.y,e.z,e.w):P.set(e,t,i,n),j.scissor(M.copy(P).multiplyScalar(E).floor())},this.getScissorTest=function(){return L},this.setScissorTest=function(e){j.setScissorTest(L=e)},this.setOpaqueSort=function(e){A=e},this.setTransparentSort=function(e){I=e},this.getClearColor=function(e){return e.copy(se.getClearColor())},this.setClearColor=function(){se.setClearColor.apply(se,arguments)},this.getClearAlpha=function(){return se.getClearAlpha()},this.setClearAlpha=function(){se.setClearAlpha.apply(se,arguments)},this.clear=function(e,t,i){let n=0;(void 0===e||e)&&(n|=16384),(void 0===t||t)&&(n|=256),(void 0===i||i)&&(n|=1024),ue.clear(n)},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.dispose=function(){t.removeEventListener("webglcontextlost",fe,!1),t.removeEventListener("webglcontextrestored",ge,!1),te.dispose(),ie.dispose(),W.dispose(),X.dispose(),Z.dispose(),K.dispose(),le.dispose(),me.dispose(),me.removeEventListener("sessionstart",ye),me.removeEventListener("sessionend",be),O&&(O.dispose(),O=null),xe.stop()},this.renderBufferDirect=function(e,t,i,n,r,s){null===t&&(t=B);const a=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,i,n,r){!0!==t.isScene&&(t=B);q.resetTextureUnits();const s=t.fog,a=n.isMeshStandardMaterial?t.environment:null,o=null===y?f.outputEncoding:y.texture.encoding,h=(n.isMeshStandardMaterial?Z:X).get(n.envMap||a),c=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,l=!!n.normalMap&&!!i.attributes.tangent,u=!!i.morphAttributes.position,p=!!i.morphAttributes.normal,m=i.morphAttributes.position?i.morphAttributes.position.length:0,g=W.get(n),_=d.state.lights;if(!0===$&&(!0===k||e!==x)){const t=e===x&&n.id===b;ne.setState(n,e,t)}let v=!1;n.version===g.__version?g.needsLights&&g.lightsStateVersion!==_.state.version||g.outputEncoding!==o||r.isInstancedMesh&&!1===g.instancing?v=!0:r.isInstancedMesh||!0!==g.instancing?r.isSkinnedMesh&&!1===g.skinning?v=!0:r.isSkinnedMesh||!0!==g.skinning?g.envMap!==h||n.fog&&g.fog!==s?v=!0:void 0===g.numClippingPlanes||g.numClippingPlanes===ne.numPlanes&&g.numIntersection===ne.numIntersection?(g.vertexAlphas!==c||g.vertexTangents!==l||g.morphTargets!==u||g.morphNormals!==p||!0===H.isWebGL2&&g.morphTargetsCount!==m)&&(v=!0):v=!0:v=!0:v=!0:(v=!0,g.__version=n.version);let w=g.currentProgram;!0===v&&(w=Ce(n,t,r));let M=!1,S=!1,T=!1;const A=w.getUniforms(),I=g.uniforms;j.useProgram(w.program)&&(M=!0,S=!0,T=!0);n.id!==b&&(b=n.id,S=!0);if(M||x!==e){if(A.setValue(ue,"projectionMatrix",e.projectionMatrix),H.logarithmicDepthBuffer&&A.setValue(ue,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),x!==e&&(x=e,S=!0,T=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const t=A.map.cameraPosition;void 0!==t&&t.setValue(ue,F.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&A.setValue(ue,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&A.setValue(ue,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){A.setOptional(ue,r,"bindMatrix"),A.setOptional(ue,r,"bindMatrixInverse");const e=r.skeleton;e&&(H.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),A.setValue(ue,"boneTexture",e.boneTexture,q),A.setValue(ue,"boneTextureSize",e.boneTextureSize)):A.setOptional(ue,e,"boneMatrices"))}!i||void 0===i.morphAttributes.position&&void 0===i.morphAttributes.normal||ae.update(r,i,n,w);(S||g.receiveShadow!==r.receiveShadow)&&(g.receiveShadow=r.receiveShadow,A.setValue(ue,"receiveShadow",r.receiveShadow));S&&(A.setValue(ue,"toneMappingExposure",f.toneMappingExposure),g.needsLights&&(P=T,(R=I).ambientLightColor.needsUpdate=P,R.lightProbe.needsUpdate=P,R.directionalLights.needsUpdate=P,R.directionalLightShadows.needsUpdate=P,R.pointLights.needsUpdate=P,R.pointLightShadows.needsUpdate=P,R.spotLights.needsUpdate=P,R.spotLightShadows.needsUpdate=P,R.rectAreaLights.needsUpdate=P,R.hemisphereLights.needsUpdate=P),s&&n.fog&&ee.refreshFogUniforms(I,s),ee.refreshMaterialUniforms(I,n,E,C,O),_o.upload(ue,g.uniformsList,I,q));var R,P;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(_o.upload(ue,g.uniformsList,I,q),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&A.setValue(ue,"center",r.center);return A.setValue(ue,"modelViewMatrix",r.modelViewMatrix),A.setValue(ue,"normalMatrix",r.normalMatrix),A.setValue(ue,"modelMatrix",r.matrixWorld),w}(e,t,i,n,r);j.setMaterial(n,a);let h=i.index;const c=i.attributes.position;if(null===h){if(void 0===c||0===c.count)return}else if(0===h.count)return;let l,u=1;!0===n.wireframe&&(h=J.getWireframeAttribute(i),u=2),le.setup(r,n,o,i,h);let p=oe;null!==h&&(l=Y.get(h),p=he,p.setIndex(l));const m=null!==h?h.count:c.count,g=i.drawRange.start*u,_=i.drawRange.count*u,v=null!==s?s.start*u:0,w=null!==s?s.count*u:1/0,M=Math.max(g,v),S=Math.min(m,g+_,v+w)-1,T=Math.max(0,S-M+1);if(0!==T){if(r.isMesh)!0===n.wireframe?(j.setLineWidth(n.wireframeLinewidth*U()),p.setMode(1)):p.setMode(4);else if(r.isLine){let e=n.linewidth;void 0===e&&(e=1),j.setLineWidth(e*U()),r.isLineSegments?p.setMode(1):r.isLineLoop?p.setMode(2):p.setMode(3)}else r.isPoints?p.setMode(0):r.isSprite&&p.setMode(4);if(r.isInstancedMesh)p.renderInstances(M,T,r.count);else if(i.isInstancedBufferGeometry){const e=Math.min(i.instanceCount,i._maxInstanceCount);p.renderInstances(M,T,e)}else p.render(M,T)}},this.compile=function(e,t){d=ie.get(e),d.init(),m.push(d),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(d.pushLight(e),e.castShadow&&d.pushShadow(e))})),d.setupLights(f.physicallyCorrectLights),e.traverse((function(t){const i=t.material;if(i)if(Array.isArray(i))for(let n=0;n<i.length;n++){Ce(i[n],e,t)}else Ce(i,e,t)})),m.pop(),d=null};let ve=null;function ye(){xe.stop()}function be(){xe.start()}const xe=new bs;function we(e,t,i,n){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)i=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)d.pushLight(e),e.castShadow&&d.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||N.intersectsSprite(e)){n&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=K.update(e),r=e.material;r.visible&&u.push(e,t,r,i,F.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==G.render.frame&&(e.skeleton.update(),e.skeleton.frame=G.render.frame),!e.frustumCulled||N.intersectsObject(e))){n&&F.setFromMatrixPosition(e.matrixWorld).applyMatrix4(z);const t=K.update(e),r=e.material;if(Array.isArray(r)){const n=t.groups;for(let s=0,a=n.length;s<a;s++){const a=n[s],o=r[a.materialIndex];o&&o.visible&&u.push(e,t,o,i,F.z,a)}}else r.visible&&u.push(e,t,r,i,F.z,null)}const r=e.children;for(let e=0,s=r.length;e<s;e++)we(r[e],t,i,n)}function Me(e,t,i,n){const r=e.opaque,s=e.transmissive,o=e.transparent;d.setupLightsView(i),s.length>0&&function(e,t,i){if(null===O){const e=!0===a&&!0===H.isWebGL2;O=new(e?Yi:Zi)(1024,1024,{generateMipmaps:!0,type:null!==ce.convert(ri)?ri:ei,minFilter:Qt,magFilter:Jt,wrapS:Zt,wrapT:Zt})}const n=f.getRenderTarget();f.setRenderTarget(O),f.clear();const r=f.toneMapping;f.toneMapping=0,Se(e,t,i),f.toneMapping=r,q.updateMultisampleRenderTarget(O),q.updateRenderTargetMipmap(O),f.setRenderTarget(n)}(r,t,i),n&&j.viewport(w.copy(n)),r.length>0&&Se(r,t,i),s.length>0&&Se(s,t,i),o.length>0&&Se(o,t,i)}function Se(e,t,i){const n=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r<s;r++){const s=e[r],a=s.object,o=s.geometry,h=null===n?s.material:n,c=s.group;a.layers.test(i.layers)&&Te(a,t,i,o,h,c)}}function Te(e,t,i,n,r,s){e.onBeforeRender(f,t,i,n,r,s),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(f,t,i,n,e,s),!0===r.transparent&&2===r.side?(r.side=1,r.needsUpdate=!0,f.renderBufferDirect(i,t,n,r,e,s),r.side=0,r.needsUpdate=!0,f.renderBufferDirect(i,t,n,r,e,s),r.side=2):f.renderBufferDirect(i,t,n,r,e,s),e.onAfterRender(f,t,i,n,r,s)}function Ce(e,t,i){!0!==t.isScene&&(t=B);const n=W.get(e),r=d.state.lights,s=d.state.shadowsArray,a=r.state.version,o=Q.getParameters(e,r.state,s,t,i),h=Q.getProgramCacheKey(o);let c=n.programs;n.environment=e.isMeshStandardMaterial?t.environment:null,n.fog=t.fog,n.envMap=(e.isMeshStandardMaterial?Z:X).get(e.envMap||n.environment),void 0===c&&(e.addEventListener("dispose",_e),c=new Map,n.programs=c);let l=c.get(h);if(void 0!==l){if(n.currentProgram===l&&n.lightsStateVersion===a)return Ee(e,o),l}else o.uniforms=Q.getUniforms(e),e.onBuild(i,o,f),e.onBeforeCompile(o,f),l=Q.acquireProgram(o,h),c.set(h,l),n.uniforms=o.uniforms;const u=n.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(u.clippingPlanes=ne.uniform),Ee(e,o),n.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),n.lightsStateVersion=a,n.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotShadowMatrix.value=r.state.spotShadowMatrix,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=l.getUniforms(),m=_o.seqWithValue(p.seq,u);return n.currentProgram=l,n.uniformsList=m,l}function Ee(e,t){const i=W.get(e);i.outputEncoding=t.outputEncoding,i.instancing=t.instancing,i.skinning=t.skinning,i.morphTargets=t.morphTargets,i.morphNormals=t.morphNormals,i.morphTargetsCount=t.morphTargetsCount,i.numClippingPlanes=t.numClippingPlanes,i.numIntersection=t.numClipIntersection,i.vertexAlphas=t.vertexAlphas,i.vertexTangents=t.vertexTangents}xe.setAnimationLoop((function(e){ve&&ve(e)})),"undefined"!=typeof window&&xe.setContext(window),this.setAnimationLoop=function(e){ve=e,me.setAnimationLoop(e),null===e?xe.stop():xe.start()},me.addEventListener("sessionstart",ye),me.addEventListener("sessionend",be),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===g)return;!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===me.enabled&&!0===me.isPresenting&&(!0===me.cameraAutoUpdate&&me.updateCamera(t),t=me.getCamera()),!0===e.isScene&&e.onBeforeRender(f,e,t,y),d=ie.get(e,m.length),d.init(),m.push(d),z.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),N.setFromProjectionMatrix(z),k=this.localClippingEnabled,$=ne.init(this.clippingPlanes,k,t),u=te.get(e,p.length),u.init(),p.push(u),we(e,t,0,f.sortObjects),u.finish(),!0===f.sortObjects&&u.sort(A,I),!0===$&&ne.beginShadows();const i=d.state.shadowsArray;if(re.render(i,e,t),!0===$&&ne.endShadows(),!0===this.info.autoReset&&this.info.reset(),se.render(u,e),d.setupLights(f.physicallyCorrectLights),t.isArrayCamera){const i=t.cameras;for(let t=0,n=i.length;t<n;t++){const n=i[t];Me(u,e,n,n.viewport)}}else Me(u,e,t);null!==y&&(q.updateMultisampleRenderTarget(y),q.updateRenderTargetMipmap(y)),!0===e.isScene&&e.onAfterRender(f,e,t),j.buffers.depth.setTest(!0),j.buffers.depth.setMask(!0),j.buffers.color.setMask(!0),j.setPolygonOffset(!1),le.resetDefaultState(),b=-1,x=null,m.pop(),d=m.length>0?m[m.length-1]:null,p.pop(),u=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return y},this.setRenderTarget=function(e,t=0,i=0){y=e,_=t,v=i,e&&void 0===W.get(e).__webglFramebuffer&&q.setupRenderTarget(e);let n=null,r=!1,s=!1;if(e){const i=e.texture;(i.isDataTexture3D||i.isDataTexture2DArray)&&(s=!0);const a=W.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(n=a[t],r=!0):n=e.isWebGLMultisampleRenderTarget?W.get(e).__webglMultisampledFramebuffer:a,w.copy(e.viewport),M.copy(e.scissor),S=e.scissorTest}else w.copy(R).multiplyScalar(E).floor(),M.copy(P).multiplyScalar(E).floor(),S=L;if(j.bindFramebuffer(36160,n)&&H.drawBuffers){let t=!1;if(e)if(e.isWebGLMultipleRenderTargets){const i=e.texture;if(D.length!==i.length||36064!==D[0]){for(let e=0,t=i.length;e<t;e++)D[e]=36064+e;D.length=i.length,t=!0}}else 1===D.length&&36064===D[0]||(D[0]=36064,D.length=1,t=!0);else 1===D.length&&1029===D[0]||(D[0]=1029,D.length=1,t=!0);t&&(H.isWebGL2?ue.drawBuffers(D):V.get("WEBGL_draw_buffers").drawBuffersWEBGL(D))}if(j.viewport(w),j.scissor(M),j.setScissorTest(S),r){const n=W.get(e.texture);ue.framebufferTexture2D(36160,36064,34069+t,n.__webglTexture,i)}else if(s){const n=W.get(e.texture),r=t||0;ue.framebufferTextureLayer(36160,36064,n.__webglTexture,i||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,i,n,r,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=W.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){j.bindFramebuffer(36160,o);try{const a=e.texture,o=a.format,h=a.type;if(o!==oi&&ce.convert(o)!==ue.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=h===ri&&(V.has("EXT_color_buffer_half_float")||H.isWebGL2&&V.has("EXT_color_buffer_float"));if(!(h===ei||ce.convert(h)===ue.getParameter(35738)||h===ni&&(H.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ue.checkFramebufferStatus(36160)?t>=0&&t<=e.width-n&&i>=0&&i<=e.height-r&&ue.readPixels(t,i,n,r,ce.convert(o),ce.convert(h),s):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==y?W.get(y).__webglFramebuffer:null;j.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),s=Math.floor(t.image.height*n);let a=ce.convert(t.format);H.isWebGL2&&(6407===a&&(a=32849),6408===a&&(a=32856)),q.setTexture2D(t,0),ue.copyTexImage2D(3553,i,a,e.x,e.y,r,s,0),j.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n=0){const r=t.image.width,s=t.image.height,a=ce.convert(i.format),o=ce.convert(i.type);q.setTexture2D(i,0),ue.pixelStorei(37440,i.flipY),ue.pixelStorei(37441,i.premultiplyAlpha),ue.pixelStorei(3317,i.unpackAlignment),t.isDataTexture?ue.texSubImage2D(3553,n,e.x,e.y,r,s,a,o,t.image.data):t.isCompressedTexture?ue.compressedTexSubImage2D(3553,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):ue.texSubImage2D(3553,n,e.x,e.y,a,o,t.image),0===n&&i.generateMipmaps&&ue.generateMipmap(3553),j.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,n,r=0){if(f.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,h=ce.convert(n.format),c=ce.convert(n.type);let l;if(n.isDataTexture3D)q.setTexture3D(n,0),l=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");q.setTexture2DArray(n,0),l=35866}ue.pixelStorei(37440,n.flipY),ue.pixelStorei(37441,n.premultiplyAlpha),ue.pixelStorei(3317,n.unpackAlignment);const u=ue.getParameter(3314),d=ue.getParameter(32878),p=ue.getParameter(3316),m=ue.getParameter(3315),g=ue.getParameter(32877),_=i.isCompressedTexture?i.mipmaps[0]:i.image;ue.pixelStorei(3314,_.width),ue.pixelStorei(32878,_.height),ue.pixelStorei(3316,e.min.x),ue.pixelStorei(3315,e.min.y),ue.pixelStorei(32877,e.min.z),i.isDataTexture||i.isDataTexture3D?ue.texSubImage3D(l,r,t.x,t.y,t.z,s,a,o,h,c,_.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ue.compressedTexSubImage3D(l,r,t.x,t.y,t.z,s,a,o,h,_.data)):ue.texSubImage3D(l,r,t.x,t.y,t.z,s,a,o,h,c,_),ue.pixelStorei(3314,u),ue.pixelStorei(32878,d),ue.pixelStorei(3316,p),ue.pixelStorei(3315,m),ue.pixelStorei(32877,g),0===r&&n.generateMipmaps&&ue.generateMipmap(l),j.unbindTexture()},this.initTexture=function(e){q.setTexture2D(e,0),j.unbindTexture()},this.resetState=function(){_=0,v=0,y=null,j.reset(),le.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}hh.prototype.isWebGLRenderer=!0;(class extends hh{}).prototype.isWebGL1Renderer=!0;class ch extends tr{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}ch.prototype.isScene=!0;class lh{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=wi,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Pi()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=Pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}lh.prototype.isInterleavedBuffer=!0;const uh=new Ki;class dh{constructor(e,t,i,n=!1){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=!0===n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)uh.x=this.getX(t),uh.y=this.getY(t),uh.z=this.getZ(t),uh.applyMatrix4(e),this.setXYZ(t,uh.x,uh.y,uh.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)uh.x=this.getX(t),uh.y=this.getY(t),uh.z=this.getZ(t),uh.applyNormalMatrix(e),this.setXYZ(t,uh.x,uh.y,uh.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)uh.x=this.getX(t),uh.y=this.getY(t),uh.z=this.getZ(t),uh.transformDirection(e),this.setXYZ(t,uh.x,uh.y,uh.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return new Tr(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new dh(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}dh.prototype.isInterleavedBufferAttribute=!0;class ph extends mr{constructor(e){super(),this.type="SpriteMaterial",this.color=new xr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}let mh;ph.prototype.isSpriteMaterial=!0;const fh=new Ki,gh=new Ki,_h=new Ki,vh=new zi,yh=new zi,bh=new Rn,xh=new Ki,wh=new Ki,Mh=new Ki,Sh=new zi,Th=new zi,Ch=new zi;class Eh extends tr{constructor(e){if(super(),this.type="Sprite",void 0===mh){mh=new kr;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new lh(e,5);mh.setIndex([0,1,2,0,2,3]),mh.setAttribute("position",new dh(t,3,0,!1)),mh.setAttribute("uv",new dh(t,2,3,!1))}this.geometry=mh,this.material=void 0!==e?e:new ph,this.center=new zi(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),gh.setFromMatrixScale(this.matrixWorld),bh.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),_h.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&gh.multiplyScalar(-_h.z);const i=this.material.rotation;let n,r;0!==i&&(r=Math.cos(i),n=Math.sin(i));const s=this.center;Ah(xh.set(-.5,-.5,0),_h,s,gh,n,r),Ah(wh.set(.5,-.5,0),_h,s,gh,n,r),Ah(Mh.set(.5,.5,0),_h,s,gh,n,r),Sh.set(0,0),Th.set(1,0),Ch.set(1,1);let a=e.ray.intersectTriangle(xh,wh,Mh,!1,fh);if(null===a&&(Ah(wh.set(-.5,.5,0),_h,s,gh,n,r),Th.set(0,1),a=e.ray.intersectTriangle(xh,Mh,wh,!1,fh),null===a))return;const o=e.ray.origin.distanceTo(fh);o<e.near||o>e.far||t.push({distance:o,point:fh.clone(),uv:dr.getUV(fh,xh,wh,Mh,Sh,Th,Ch,new zi),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Ah(e,t,i,n,r,s){vh.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(yh.x=s*vh.x-r*vh.y,yh.y=r*vh.x+s*vh.y):yh.copy(vh),e.copy(t),e.x+=yh.x,e.y+=yh.y,e.applyMatrix4(bh)}Eh.prototype.isSprite=!0;const Ih=new Ki,Rh=new Xi,Ph=new Xi,Lh=new Ki,Dh=new Rn;class Nh extends es{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Rn,this.bindMatrixInverse=new Rn}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Xi,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const i=this.skeleton,n=this.geometry;Rh.fromBufferAttribute(n.attributes.skinIndex,e),Ph.fromBufferAttribute(n.attributes.skinWeight,e),Ih.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const n=Ph.getComponent(e);if(0!==n){const r=Rh.getComponent(e);Dh.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),t.addScaledVector(Lh.copy(Ih).applyMatrix4(Dh),n)}}return t.applyMatrix4(this.bindMatrixInverse)}}Nh.prototype.isSkinnedMesh=!0;(class extends tr{constructor(){super(),this.type="Bone"}}).prototype.isBone=!0;(class extends Wi{constructor(e=null,t=1,i=1,n,r,s,a,o,h=1003,c=1003,l,u){super(null,s,a,o,h,c,n,r,l,u),this.image={data:e,width:t,height:i},this.magFilter=h,this.minFilter=c,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}).prototype.isDataTexture=!0;class $h extends Tr{constructor(e,t,i,n=1){"number"==typeof i&&(n=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,i),this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}$h.prototype.isInstancedBufferAttribute=!0;const kh=new Rn,Oh=new Rn,zh=[],Fh=new es;(class extends es{constructor(e,t,i){super(e,t),this.instanceMatrix=new $h(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const i=this.matrixWorld,n=this.count;if(Fh.geometry=this.geometry,Fh.material=this.material,void 0!==Fh.material)for(let r=0;r<n;r++){this.getMatrixAt(r,kh),Oh.multiplyMatrices(i,kh),Fh.matrixWorld=Oh,Fh.raycast(e,zh);for(let e=0,i=zh.length;e<i;e++){const i=zh[e];i.instanceId=r,i.object=this,t.push(i)}zh.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new $h(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}).prototype.isInstancedMesh=!0;class Bh extends mr{constructor(e){super(),this.type="LineBasicMaterial",this.color=new xr(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}Bh.prototype.isLineBasicMaterial=!0;const Uh=new Ki,Vh=new Ki,Hh=new Rn,jh=new In,Gh=new xn;class Wh extends tr{constructor(e=new kr,t=new Bh){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[0];for(let e=1,n=t.count;e<n;e++)Uh.fromBufferAttribute(t,e-1),Vh.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=Uh.distanceTo(Vh);e.setAttribute("lineDistance",new Ar(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Gh.copy(i.boundingSphere),Gh.applyMatrix4(n),Gh.radius+=r,!1===e.ray.intersectsSphere(Gh))return;Hh.copy(n).invert(),jh.copy(e.ray).applyMatrix4(Hh);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,h=new Ki,c=new Ki,l=new Ki,u=new Ki,d=this.isLineSegments?2:1;if(i.isBufferGeometry){const n=i.index,r=i.attributes.position;if(null!==n){for(let i=Math.max(0,s.start),a=Math.min(n.count,s.start+s.count)-1;i<a;i+=d){const s=n.getX(i),a=n.getX(i+1);h.fromBufferAttribute(r,s),c.fromBufferAttribute(r,a);if(jh.distanceSqToSegment(h,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);const d=e.ray.origin.distanceTo(u);d<e.near||d>e.far||t.push({distance:d,point:l.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{for(let i=Math.max(0,s.start),n=Math.min(r.count,s.start+s.count)-1;i<n;i+=d){h.fromBufferAttribute(r,i),c.fromBufferAttribute(r,i+1);if(jh.distanceSqToSegment(h,c,u,l)>o)continue;u.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(u);n<e.near||n>e.far||t.push({distance:n,point:l.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Wh.prototype.isLine=!0;const qh=new Ki,Xh=new Ki;class Zh extends Wh{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,i=[];for(let e=0,n=t.count;e<n;e+=2)qh.fromBufferAttribute(t,e),Xh.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+qh.distanceTo(Xh);e.setAttribute("lineDistance",new Ar(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}Zh.prototype.isLineSegments=!0;(class extends Wh{constructor(e,t){super(e,t),this.type="LineLoop"}}).prototype.isLineLoop=!0;class Yh extends mr{constructor(e){super(),this.type="PointsMaterial",this.color=new xr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this}}Yh.prototype.isPointsMaterial=!0;const Jh=new Rn,Kh=new In,Qh=new xn,ec=new Ki;class tc extends tr{constructor(e=new kr,t=new Yh){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,s=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Qh.copy(i.boundingSphere),Qh.applyMatrix4(n),Qh.radius+=r,!1===e.ray.intersectsSphere(Qh))return;Jh.copy(n).invert(),Kh.copy(e.ray).applyMatrix4(Jh);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a;if(i.isBufferGeometry){const r=i.index,a=i.attributes.position;if(null!==r){for(let i=Math.max(0,s.start),h=Math.min(r.count,s.start+s.count);i<h;i++){const s=r.getX(i);ec.fromBufferAttribute(a,s),ic(ec,s,o,n,e,t,this)}}else{for(let i=Math.max(0,s.start),r=Math.min(a.count,s.start+s.count);i<r;i++)ec.fromBufferAttribute(a,i),ic(ec,i,o,n,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t<i;t++){const i=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=t}}}}else{const t=e.morphTargets;void 0!==t&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function ic(e,t,i,n,r,s,a){const o=Kh.distanceSqToPoint(e);if(o<i){const i=new Ki;Kh.closestPointToPoint(e,i),i.applyMatrix4(n);const h=r.ray.origin.distanceTo(i);if(h<r.near||h>r.far)return;s.push({distance:h,distanceToRay:Math.sqrt(o),point:i,index:t,face:null,object:a})}}tc.prototype.isPoints=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h){super(e,t,i,n,r,s,a,o,h),this.format=void 0!==a?a:ai,this.minFilter=void 0!==s?s:Kt,this.magFilter=void 0!==r?r:Kt,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}).prototype.isVideoTexture=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h,c,l,u){super(null,s,a,o,h,c,n,r,l,u),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}).prototype.isCompressedTexture=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h){super(e,t,i,n,r,s,a,o,h),this.needsUpdate=!0}}).prototype.isCanvasTexture=!0;(class extends Wi{constructor(e,t,i,n,r,s,a,o,h,c){if((c=void 0!==c?c:hi)!==hi&&c!==ci)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===hi&&(i=ti),void 0===i&&c===ci&&(i=si),super(null,n,r,s,a,o,c,i,h),this.image={width:e,height:t},this.magFilter=void 0!==a?a:Jt,this.minFilter=void 0!==o?o:Jt,this.flipY=!1,this.generateMipmaps=!1}}).prototype.isDepthTexture=!0;class nc extends kr{constructor(e=1,t=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);const r=[],s=[],a=[],o=[],h=new Ki,c=new zi;s.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let r=0,l=3;r<=t;r++,l+=3){const u=i+r/t*n;h.x=e*Math.cos(u),h.y=e*Math.sin(u),s.push(h.x,h.y,h.z),a.push(0,0,1),c.x=(s[l]/e+1)/2,c.y=(s[l+1]/e+1)/2,o.push(c.x,c.y)}for(let e=1;e<=t;e++)r.push(e,e+1,0);this.setIndex(r),this.setAttribute("position",new Ar(s,3)),this.setAttribute("normal",new Ar(a,3)),this.setAttribute("uv",new Ar(o,2))}static fromJSON(e){return new nc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}new Ki,new Ki,new Ki,new dr;class rc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let i,n=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),r+=i.distanceTo(n),t.push(r),n=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let n=0;const r=i.length;let s;s=t||e*i[r-1];let a,o=0,h=r-1;for(;o<=h;)if(n=Math.floor(o+(h-o)/2),a=i[n]-s,a<0)o=n+1;else{if(!(a>0)){h=n;break}h=n-1}if(n=h,i[n]===s)return n/(r-1);const c=i[n];return(n+(s-c)/(i[n+1]-c))/(r-1)}getTangent(e,t){const i=1e-4;let n=e-i,r=e+i;n<0&&(n=0),r>1&&(r=1);const s=this.getPoint(n),a=this.getPoint(r),o=t||(s.isVector2?new zi:new Ki);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new Ki,n=[],r=[],s=[],a=new Ki,o=new Rn;for(let t=0;t<=e;t++){const i=t/e;n[t]=this.getTangentAt(i,new Ki)}r[0]=new Ki,s[0]=new Ki;let h=Number.MAX_VALUE;const c=Math.abs(n[0].x),l=Math.abs(n[0].y),u=Math.abs(n[0].z);c<=h&&(h=c,i.set(1,0,0)),l<=h&&(h=l,i.set(0,1,0)),u<=h&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],a),s[0].crossVectors(n[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(n[t-1],n[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Li(n[t-1].dot(n[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(n[t],r[t])}if(!0===t){let t=Math.acos(Li(r[0].dot(r[e]),-1,1));t/=e,n[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let i=1;i<=e;i++)r[i].applyMatrix4(o.makeRotationAxis(n[i],t*i)),s[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class sc extends rc{constructor(e=0,t=0,i=1,n=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const i=t||new zi,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=s?0:n),!0!==this.aClockwise||s||(r===n?r=-n:r-=n);const a=this.aStartAngle+e*r;let o=this.aX+this.xRadius*Math.cos(a),h=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),i=o-this.aX,n=h-this.aY;o=i*e-n*t+this.aX,h=i*t+n*e+this.aY}return i.set(o,h)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}sc.prototype.isEllipseCurve=!0;class ac extends sc{constructor(e,t,i,n,r,s){super(e,t,i,i,n,r,s),this.type="ArcCurve"}}function oc(){let e=0,t=0,i=0,n=0;function r(r,s,a,o){e=r,t=a,i=-3*r+3*s-2*a-o,n=2*r-2*s+a+o}return{initCatmullRom:function(e,t,i,n,s){r(t,i,s*(i-e),s*(n-t))},initNonuniformCatmullRom:function(e,t,i,n,s,a,o){let h=(t-e)/s-(i-e)/(s+a)+(i-t)/a,c=(i-t)/a-(n-t)/(a+o)+(n-i)/o;h*=a,c*=a,r(t,i,h,c)},calc:function(r){const s=r*r;return e+t*r+i*s+n*(s*r)}}}ac.prototype.isArcCurve=!0;const hc=new Ki,cc=new oc,lc=new oc,uc=new oc;class dc extends rc{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new Ki){const i=t,n=this.points,r=n.length,s=(r-(this.closed?0:1))*e;let a,o,h=Math.floor(s),c=s-h;this.closed?h+=h>0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===c&&h===r-1&&(h=r-2,c=1),this.closed||h>0?a=n[(h-1)%r]:(hc.subVectors(n[0],n[1]).add(n[0]),a=hc);const l=n[h%r],u=n[(h+1)%r];if(this.closed||h+2<r?o=n[(h+2)%r]:(hc.subVectors(n[r-1],n[r-2]).add(n[r-1]),o=hc),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(l),e),i=Math.pow(l.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(o),e);i<1e-4&&(i=1),t<1e-4&&(t=i),n<1e-4&&(n=i),cc.initNonuniformCatmullRom(a.x,l.x,u.x,o.x,t,i,n),lc.initNonuniformCatmullRom(a.y,l.y,u.y,o.y,t,i,n),uc.initNonuniformCatmullRom(a.z,l.z,u.z,o.z,t,i,n)}else"catmullrom"===this.curveType&&(cc.initCatmullRom(a.x,l.x,u.x,o.x,this.tension),lc.initCatmullRom(a.y,l.y,u.y,o.y,this.tension),uc.initCatmullRom(a.z,l.z,u.z,o.z,this.tension));return i.set(cc.calc(c),lc.calc(c),uc.calc(c)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new Ki).fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function pc(e,t,i,n,r){const s=.5*(n-t),a=.5*(r-i),o=e*e;return(2*i-2*n+s+a)*(e*o)+(-3*i+3*n-2*s-a)*o+s*e+i}function mc(e,t,i,n){return function(e,t){const i=1-e;return i*i*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,i)+function(e,t){return e*e*t}(e,n)}function fc(e,t,i,n,r){return function(e,t){const i=1-e;return i*i*i*t}(e,t)+function(e,t){const i=1-e;return 3*i*i*e*t}(e,i)+function(e,t){return 3*(1-e)*e*e*t}(e,n)+function(e,t){return e*e*e*t}(e,r)}dc.prototype.isCatmullRomCurve3=!0;class gc extends rc{constructor(e=new zi,t=new zi,i=new zi,n=new zi){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new zi){const i=t,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(fc(e,n.x,r.x,s.x,a.x),fc(e,n.y,r.y,s.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}gc.prototype.isCubicBezierCurve=!0;class _c extends rc{constructor(e=new Ki,t=new Ki,i=new Ki,n=new Ki){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new Ki){const i=t,n=this.v0,r=this.v1,s=this.v2,a=this.v3;return i.set(fc(e,n.x,r.x,s.x,a.x),fc(e,n.y,r.y,s.y,a.y),fc(e,n.z,r.z,s.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}_c.prototype.isCubicBezierCurve3=!0;class vc extends rc{constructor(e=new zi,t=new zi){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new zi){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const i=t||new zi;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}vc.prototype.isLineCurve=!0;class yc extends rc{constructor(e=new zi,t=new zi,i=new zi){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new zi){const i=t,n=this.v0,r=this.v1,s=this.v2;return i.set(mc(e,n.x,r.x,s.x),mc(e,n.y,r.y,s.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}yc.prototype.isQuadraticBezierCurve=!0;class bc extends rc{constructor(e=new Ki,t=new Ki,i=new Ki){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Ki){const i=t,n=this.v0,r=this.v1,s=this.v2;return i.set(mc(e,n.x,r.x,s.x),mc(e,n.y,r.y,s.y),mc(e,n.z,r.z,s.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}bc.prototype.isQuadraticBezierCurve3=!0;class xc extends rc{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new zi){const i=t,n=this.points,r=(n.length-1)*e,s=Math.floor(r),a=r-s,o=n[0===s?s:s-1],h=n[s],c=n[s>n.length-2?n.length-1:s+1],l=n[s>n.length-3?n.length-1:s+2];return i.set(pc(a,o.x,h.x,c.x,l.x),pc(a,o.y,h.y,c.y,l.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const i=e.points[t];this.points.push((new zi).fromArray(i))}return this}}xc.prototype.isSplineCurve=!0;var wc=Object.freeze({__proto__:null,ArcCurve:ac,CatmullRomCurve3:dc,CubicBezierCurve:gc,CubicBezierCurve3:_c,EllipseCurve:sc,LineCurve:vc,LineCurve3:class extends rc{constructor(e=new Ki,t=new Ki){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new Ki){const i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},QuadraticBezierCurve:yc,QuadraticBezierCurve3:bc,SplineCurve:xc});class Mc extends rc{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new vc(t,e))}getPoint(e,t){const i=e*this.getLength(),n=this.getCurveLengths();let r=0;for(;r<n.length;){if(n[r]>=i){const e=n[r]-i,s=this.curves[r],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let n=0,r=this.curves;n<r.length;n++){const s=r[n],a=s&&s.isEllipseCurve?2*e:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?e*s.points.length:e,o=s.getPoints(a);for(let e=0;e<o.length;e++){const n=o[e];i&&i.equals(n)||(t.push(n),i=n)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const i=e.curves[t];this.curves.push((new wc[i.type]).fromJSON(i))}return this}}class Sc extends Mc{constructor(e){super(),this.type="Path",this.currentPoint=new zi,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new vc(this.currentPoint.clone(),new zi(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){const r=new yc(this.currentPoint.clone(),new zi(e,t),new zi(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,s){const a=new gc(this.currentPoint.clone(),new zi(e,t),new zi(i,n),new zi(r,s));return this.curves.push(a),this.currentPoint.set(r,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new xc(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,s){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,n,r,s),this}absarc(e,t,i,n,r,s){return this.absellipse(e,t,i,i,n,r,s),this}ellipse(e,t,i,n,r,s,a,o){const h=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+h,t+c,i,n,r,s,a,o),this}absellipse(e,t,i,n,r,s,a,o){const h=new sc(e,t,i,n,r,s,a,o);if(this.curves.length>0){const e=h.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(h);const c=h.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Tc extends Sc{constructor(e){super(e),this.uuid=Pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const i=e.holes[t];this.holes.push((new Sc).fromJSON(i))}return this}}const Cc=function(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let s=Ec(e,0,r,i,!0);const a=[];if(!s||s.next===s.prev)return a;let o,h,c,l,u,d,p;if(n&&(s=function(e,t,i,n){const r=[];let s,a,o,h,c;for(s=0,a=t.length;s<a;s++)o=t[s]*n,h=s<a-1?t[s+1]*n:e.length,c=Ec(e,o,h,n,!1),c===c.next&&(c.steiner=!0),r.push(zc(c));for(r.sort(Nc),s=0;s<r.length;s++)$c(r[s],i),i=Ac(i,i.next);return i}(e,t,s,i)),e.length>80*i){o=c=e[0],h=l=e[1];for(let t=i;t<r;t+=i)u=e[t],d=e[t+1],u<o&&(o=u),d<h&&(h=d),u>c&&(c=u),d>l&&(l=d);p=Math.max(c-o,l-h),p=0!==p?1/p:0}return Ic(s,a,i,o,h,p),a};function Ec(e,t,i,n,r){let s,a;if(r===function(e,t,i,n){let r=0;for(let s=t,a=i-n;s<i;s+=n)r+=(e[a]-e[s])*(e[s+1]+e[a+1]),a=s;return r}(e,t,i,n)>0)for(s=t;s<i;s+=n)a=Xc(s,e[s],e[s+1],a);else for(s=i-n;s>=t;s-=n)a=Xc(s,e[s],e[s+1],a);return a&&Vc(a,a.next)&&(Zc(a),a=a.next),a}function Ac(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Vc(n,n.next)&&0!==Uc(n.prev,n,n.next))n=n.next;else{if(Zc(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Ic(e,t,i,n,r,s,a){if(!e)return;!a&&s&&function(e,t,i,n){let r=e;do{null===r.z&&(r.z=Oc(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i,n,r,s,a,o,h,c=1;do{for(i=e,e=null,s=null,a=0;i;){for(a++,n=i,o=0,t=0;t<c&&(o++,n=n.nextZ,n);t++);for(h=c;o>0||h>0&&n;)0!==o&&(0===h||!n||i.z<=n.z)?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,h--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;i=n}s.nextZ=null,c*=2}while(a>1)}(r)}(e,n,r,s);let o,h,c=e;for(;e.prev!==e.next;)if(o=e.prev,h=e.next,s?Pc(e,n,r,s):Rc(e))t.push(o.i/i),t.push(e.i/i),t.push(h.i/i),Zc(e),e=h.next,c=h.next;else if((e=h)===c){a?1===a?Ic(e=Lc(Ac(e),t,i),t,i,n,r,s,2):2===a&&Dc(e,t,i,n,r,s):Ic(Ac(e),t,i,n,r,s,1);break}}function Rc(e){const t=e.prev,i=e,n=e.next;if(Uc(t,i,n)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Fc(t.x,t.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Uc(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Pc(e,t,i,n){const r=e.prev,s=e,a=e.next;if(Uc(r,s,a)>=0)return!1;const o=r.x<s.x?r.x<a.x?r.x:a.x:s.x<a.x?s.x:a.x,h=r.y<s.y?r.y<a.y?r.y:a.y:s.y<a.y?s.y:a.y,c=r.x>s.x?r.x>a.x?r.x:a.x:s.x>a.x?s.x:a.x,l=r.y>s.y?r.y>a.y?r.y:a.y:s.y>a.y?s.y:a.y,u=Oc(o,h,t,i,n),d=Oc(c,l,t,i,n);let p=e.prevZ,m=e.nextZ;for(;p&&p.z>=u&&m&&m.z<=d;){if(p!==e.prev&&p!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,p.x,p.y)&&Uc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,m!==e.prev&&m!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,m.x,m.y)&&Uc(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;p&&p.z>=u;){if(p!==e.prev&&p!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,p.x,p.y)&&Uc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;m&&m.z<=d;){if(m!==e.prev&&m!==e.next&&Fc(r.x,r.y,s.x,s.y,a.x,a.y,m.x,m.y)&&Uc(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Lc(e,t,i){let n=e;do{const r=n.prev,s=n.next.next;!Vc(r,s)&&Hc(r,n,n.next,s)&&Wc(r,s)&&Wc(s,r)&&(t.push(r.i/i),t.push(n.i/i),t.push(s.i/i),Zc(n),Zc(n.next),n=e=s),n=n.next}while(n!==e);return Ac(n)}function Dc(e,t,i,n,r,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Bc(a,e)){let o=qc(a,e);return a=Ac(a,a.next),o=Ac(o,o.next),Ic(a,t,i,n,r,s),void Ic(o,t,i,n,r,s)}e=e.next}a=a.next}while(a!==e)}function Nc(e,t){return e.x-t.x}function $c(e,t){if(t=function(e,t){let i=t;const n=e.x,r=e.y;let s,a=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>a){if(a=e,e===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x<i.next.x?i:i.next}}i=i.next}while(i!==t);if(!s)return null;if(n===a)return s;const o=s,h=s.x,c=s.y;let l,u=1/0;i=s;do{n>=i.x&&i.x>=h&&n!==i.x&&Fc(r<c?n:a,r,h,c,r<c?a:n,r,i.x,i.y)&&(l=Math.abs(r-i.y)/(n-i.x),Wc(i,e)&&(l<u||l===u&&(i.x>s.x||i.x===s.x&&kc(s,i)))&&(s=i,u=l)),i=i.next}while(i!==o);return s}(e,t)){const i=qc(t,e);Ac(t,t.next),Ac(i,i.next)}}function kc(e,t){return Uc(e.prev,e,t.prev)<0&&Uc(t.next,e,e.next)<0}function Oc(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zc(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Fc(e,t,i,n,r,s,a,o){return(r-a)*(t-o)-(e-a)*(s-o)>=0&&(e-a)*(n-o)-(i-a)*(t-o)>=0&&(i-a)*(s-o)-(r-a)*(n-o)>=0}function Bc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Hc(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Wc(e,t)&&Wc(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Uc(e.prev,e,t.prev)||Uc(e,t.prev,t))||Vc(e,t)&&Uc(e.prev,e,e.next)>0&&Uc(t.prev,t,t.next)>0)}function Uc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Vc(e,t){return e.x===t.x&&e.y===t.y}function Hc(e,t,i,n){const r=Gc(Uc(e,t,i)),s=Gc(Uc(e,t,n)),a=Gc(Uc(i,n,e)),o=Gc(Uc(i,n,t));return r!==s&&a!==o||(!(0!==r||!jc(e,i,t))||(!(0!==s||!jc(e,n,t))||(!(0!==a||!jc(i,e,n))||!(0!==o||!jc(i,t,n)))))}function jc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Gc(e){return e>0?1:e<0?-1:0}function Wc(e,t){return Uc(e.prev,e,e.next)<0?Uc(e,t,e.next)>=0&&Uc(e,e.prev,t)>=0:Uc(e,t,e.prev)<0||Uc(e,e.next,t)<0}function qc(e,t){const i=new Yc(e.i,e.x,e.y),n=new Yc(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Xc(e,t,i,n){const r=new Yc(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Zc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Yc(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Jc{static area(e){const t=e.length;let i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return.5*i}static isClockWise(e){return Jc.area(e)<0}static triangulateShape(e,t){const i=[],n=[],r=[];Kc(e),Qc(i,e);let s=e.length;t.forEach(Kc);for(let e=0;e<t.length;e++)n.push(s),s+=t[e].length,Qc(i,t[e]);const a=Cc(i,n);for(let e=0;e<a.length;e+=3)r.push(a.slice(e,e+3));return r}}function Kc(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Qc(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}class el extends kr{constructor(e=new Tc([new zi(.5,.5),new zi(-.5,.5),new zi(-.5,-.5),new zi(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,n=[],r=[];for(let t=0,i=e.length;t<i;t++){s(e[t])}function s(e){const s=[],a=void 0!==t.curveSegments?t.curveSegments:12,o=void 0!==t.steps?t.steps:1;let h=void 0!==t.depth?t.depth:1,c=void 0===t.bevelEnabled||t.bevelEnabled,l=void 0!==t.bevelThickness?t.bevelThickness:.2,u=void 0!==t.bevelSize?t.bevelSize:l-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const m=t.extrudePath,f=void 0!==t.UVGenerator?t.UVGenerator:tl;void 0!==t.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=t.amount);let g,_,v,y,b,x=!1;m&&(g=m.getSpacedPoints(o),x=!0,c=!1,_=m.computeFrenetFrames(o,!1),v=new Ki,y=new Ki,b=new Ki),c||(p=0,l=0,u=0,d=0);const w=e.extractPoints(a);let M=w.shape;const S=w.holes;if(!Jc.isClockWise(M)){M=M.reverse();for(let e=0,t=S.length;e<t;e++){const t=S[e];Jc.isClockWise(t)&&(S[e]=t.reverse())}}const T=Jc.triangulateShape(M,S),C=M;for(let e=0,t=S.length;e<t;e++){const t=S[e];M=M.concat(t)}function E(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(i).add(e)}const A=M.length,I=T.length;function R(e,t,i){let n,r,s;const a=e.x-t.x,o=e.y-t.y,h=i.x-e.x,c=i.y-e.y,l=a*a+o*o,u=a*c-o*h;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(l),d=Math.sqrt(h*h+c*c),p=t.x-o/u,m=t.y+a/u,f=((i.x-c/d-p)*c-(i.y+h/d-m)*h)/(a*c-o*h);n=p+a*f-e.x,r=m+o*f-e.y;const g=n*n+r*r;if(g<=2)return new zi(n,r);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?h>Number.EPSILON&&(e=!0):a<-Number.EPSILON?h<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(c)&&(e=!0),e?(n=-o,r=a,s=Math.sqrt(l)):(n=a,r=o,s=Math.sqrt(l/2))}return new zi(n/s,r/s)}const P=[];for(let e=0,t=C.length,i=t-1,n=e+1;e<t;e++,i++,n++)i===t&&(i=0),n===t&&(n=0),P[e]=R(C[e],C[i],C[n]);const L=[];let D,N=P.concat();for(let e=0,t=S.length;e<t;e++){const t=S[e];D=[];for(let e=0,i=t.length,n=i-1,r=e+1;e<i;e++,n++,r++)n===i&&(n=0),r===i&&(r=0),D[e]=R(t[e],t[n],t[r]);L.push(D),N=N.concat(D)}for(let e=0;e<p;e++){const t=e/p,i=l*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=C.length;e<t;e++){const t=E(C[e],P[e],n);O(t.x,t.y,-i)}for(let e=0,t=S.length;e<t;e++){const t=S[e];D=L[e];for(let e=0,r=t.length;e<r;e++){const r=E(t[e],D[e],n);O(r.x,r.y,-i)}}}const $=u+d;for(let e=0;e<A;e++){const t=c?E(M[e],N[e],$):M[e];x?(y.copy(_.normals[0]).multiplyScalar(t.x),v.copy(_.binormals[0]).multiplyScalar(t.y),b.copy(g[0]).add(y).add(v),O(b.x,b.y,b.z)):O(t.x,t.y,0)}for(let e=1;e<=o;e++)for(let t=0;t<A;t++){const i=c?E(M[t],N[t],$):M[t];x?(y.copy(_.normals[e]).multiplyScalar(i.x),v.copy(_.binormals[e]).multiplyScalar(i.y),b.copy(g[e]).add(y).add(v),O(b.x,b.y,b.z)):O(i.x,i.y,h/o*e)}for(let e=p-1;e>=0;e--){const t=e/p,i=l*Math.cos(t*Math.PI/2),n=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=C.length;e<t;e++){const t=E(C[e],P[e],n);O(t.x,t.y,h+i)}for(let e=0,t=S.length;e<t;e++){const t=S[e];D=L[e];for(let e=0,r=t.length;e<r;e++){const r=E(t[e],D[e],n);x?O(r.x,r.y+g[o-1].y,g[o-1].x+i):O(r.x,r.y,h+i)}}}function k(e,t){let i=e.length;for(;--i>=0;){const n=i;let r=i-1;r<0&&(r=e.length-1);for(let e=0,i=o+2*p;e<i;e++){const i=A*e,s=A*(e+1);F(t+n+i,t+r+i,t+r+s,t+n+s)}}}function O(e,t,i){s.push(e),s.push(t),s.push(i)}function z(e,t,r){B(e),B(t),B(r);const s=n.length/3,a=f.generateTopUV(i,n,s-3,s-2,s-1);U(a[0]),U(a[1]),U(a[2])}function F(e,t,r,s){B(e),B(t),B(s),B(t),B(r),B(s);const a=n.length/3,o=f.generateSideWallUV(i,n,a-6,a-3,a-2,a-1);U(o[0]),U(o[1]),U(o[3]),U(o[1]),U(o[2]),U(o[3])}function B(e){n.push(s[3*e+0]),n.push(s[3*e+1]),n.push(s[3*e+2])}function U(e){r.push(e.x),r.push(e.y)}!function(){const e=n.length/3;if(c){let e=0,t=A*e;for(let e=0;e<I;e++){const i=T[e];z(i[2]+t,i[1]+t,i[0]+t)}e=o+2*p,t=A*e;for(let e=0;e<I;e++){const i=T[e];z(i[0]+t,i[1]+t,i[2]+t)}}else{for(let e=0;e<I;e++){const t=T[e];z(t[2],t[1],t[0])}for(let e=0;e<I;e++){const t=T[e];z(t[0]+A*o,t[1]+A*o,t[2]+A*o)}}i.addGroup(e,n.length/3-e,0)}(),function(){const e=n.length/3;let t=0;k(C,t),t+=C.length;for(let e=0,i=S.length;e<i;e++){const i=S[e];k(i,t),t+=i.length}i.addGroup(e,n.length/3-e,1)}()}this.setAttribute("position",new Ar(n,3)),this.setAttribute("uv",new Ar(r,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return function(e,t,i){if(i.shapes=[],Array.isArray(e))for(let t=0,n=e.length;t<n;t++){const n=e[t];i.shapes.push(n.uuid)}else i.shapes.push(e.uuid);void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON());return i}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const r=t[e.shapes[n]];i.push(r)}const n=e.options.extrudePath;return void 0!==n&&(e.options.extrudePath=(new wc[n.type]).fromJSON(n)),new el(i,e.options)}}const tl={generateTopUV:function(e,t,i,n,r){const s=t[3*i],a=t[3*i+1],o=t[3*n],h=t[3*n+1],c=t[3*r],l=t[3*r+1];return[new zi(s,a),new zi(o,h),new zi(c,l)]},generateSideWallUV:function(e,t,i,n,r,s){const a=t[3*i],o=t[3*i+1],h=t[3*i+2],c=t[3*n],l=t[3*n+1],u=t[3*n+2],d=t[3*r],p=t[3*r+1],m=t[3*r+2],f=t[3*s],g=t[3*s+1],_=t[3*s+2];return Math.abs(o-l)<Math.abs(a-c)?[new zi(a,1-h),new zi(c,1-u),new zi(d,1-m),new zi(f,1-_)]:[new zi(o,1-h),new zi(l,1-u),new zi(p,1-m),new zi(g,1-_)]}};class il extends kr{constructor(e=new Tc([new zi(0,.5),new zi(-.5,-.5),new zi(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],n=[],r=[],s=[];let a=0,o=0;if(!1===Array.isArray(e))h(e);else for(let t=0;t<e.length;t++)h(e[t]),this.addGroup(a,o,t),a+=o,o=0;function h(e){const a=n.length/3,h=e.extractPoints(t);let c=h.shape;const l=h.holes;!1===Jc.isClockWise(c)&&(c=c.reverse());for(let e=0,t=l.length;e<t;e++){const t=l[e];!0===Jc.isClockWise(t)&&(l[e]=t.reverse())}const u=Jc.triangulateShape(c,l);for(let e=0,t=l.length;e<t;e++){const t=l[e];c=c.concat(t)}for(let e=0,t=c.length;e<t;e++){const t=c[e];n.push(t.x,t.y,0),r.push(0,0,1),s.push(t.x,t.y)}for(let e=0,t=u.length;e<t;e++){const t=u[e],n=t[0]+a,r=t[1]+a,s=t[2]+a;i.push(n,r,s),o+=3}}this.setIndex(i),this.setAttribute("position",new Ar(n,3)),this.setAttribute("normal",new Ar(r,3)),this.setAttribute("uv",new Ar(s,2))}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,n=e.length;i<n;i++){const n=e[i];t.shapes.push(n.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const i=[];for(let n=0,r=e.shapes.length;n<r;n++){const r=t[e.shapes[n]];i.push(r)}return new il(i,e.curveSegments)}}class nl extends kr{constructor(e=1,t=32,i=16,n=0,r=2*Math.PI,s=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:s,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const o=Math.min(s+a,Math.PI);let h=0;const c=[],l=new Ki,u=new Ki,d=[],p=[],m=[],f=[];for(let d=0;d<=i;d++){const g=[],_=d/i;let v=0;0==d&&0==s?v=.5/t:d==i&&o==Math.PI&&(v=-.5/t);for(let i=0;i<=t;i++){const o=i/t;l.x=-e*Math.cos(n+o*r)*Math.sin(s+_*a),l.y=e*Math.cos(s+_*a),l.z=e*Math.sin(n+o*r)*Math.sin(s+_*a),p.push(l.x,l.y,l.z),u.copy(l).normalize(),m.push(u.x,u.y,u.z),f.push(o+v,1-_),g.push(h++)}c.push(g)}for(let e=0;e<i;e++)for(let n=0;n<t;n++){const t=c[e][n+1],r=c[e][n],a=c[e+1][n],h=c[e+1][n+1];(0!==e||s>0)&&d.push(t,r,h),(e!==i-1||o<Math.PI)&&d.push(r,a,h)}this.setIndex(d),this.setAttribute("position",new Ar(p,3)),this.setAttribute("normal",new Ar(m,3)),this.setAttribute("uv",new Ar(f,2))}static fromJSON(e){return new nl(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}(class extends mr{constructor(e){super(),this.type="ShadowMaterial",this.color=new xr(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}).prototype.isShadowMaterial=!0;class rl extends mr{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new xr(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}rl.prototype.isMeshStandardMaterial=!0;(class extends rl{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new zi(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Li(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.sheenColor=new xr(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new xr(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new xr(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}).prototype.isMeshPhysicalMaterial=!0;(class extends mr{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new xr(16777215),this.specular=new xr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}).prototype.isMeshPhongMaterial=!0;(class extends mr{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new xr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}).prototype.isMeshToonMaterial=!0;(class extends mr{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}).prototype.isMeshNormalMaterial=!0;(class extends mr{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new xr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}).prototype.isMeshLambertMaterial=!0;(class extends mr{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new xr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new zi(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}).prototype.isMeshMatcapMaterial=!0;(class extends Bh{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}).prototype.isLineDashedMaterial=!0;const sl={arraySlice:function(e,t,i){return sl.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){const t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort((function(t,i){return e[t]-e[i]})),i},sortedArray:function(e,t,i){const n=e.length,r=new e.constructor(n);for(let s=0,a=0;a!==n;++s){const n=i[s]*t;for(let i=0;i!==t;++i)r[a++]=e[n+i]}return r},flattenJSON:function(e,t,i,n){let r=1,s=e[0];for(;void 0!==s&&void 0===s[n];)s=e[r++];if(void 0===s)return;let a=s[n];if(void 0!==a)if(Array.isArray(a))do{a=s[n],void 0!==a&&(t.push(s.time),i.push.apply(i,a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[n],void 0!==a&&(t.push(s.time),a.toArray(i,i.length)),s=e[r++]}while(void 0!==s);else do{a=s[n],void 0!==a&&(t.push(s.time),i.push(a)),s=e[r++]}while(void 0!==s)},subclip:function(e,t,i,n,r=30){const s=e.clone();s.name=t;const a=[];for(let e=0;e<s.tracks.length;++e){const t=s.tracks[e],o=t.getValueSize(),h=[],c=[];for(let e=0;e<t.times.length;++e){const s=t.times[e]*r;if(!(s<i||s>=n)){h.push(t.times[e]);for(let i=0;i<o;++i)c.push(t.values[e*o+i])}}0!==h.length&&(t.times=sl.convertArray(h,t.times.constructor),t.values=sl.convertArray(c,t.values.constructor),a.push(t))}s.tracks=a;let o=1/0;for(let e=0;e<s.tracks.length;++e)o>s.tracks[e].times[0]&&(o=s.tracks[e].times[0]);for(let e=0;e<s.tracks.length;++e)s.tracks[e].shift(-1*o);return s.resetDuration(),s},makeClipAdditive:function(e,t=0,i=e,n=30){n<=0&&(n=30);const r=i.tracks.length,s=t/n;for(let t=0;t<r;++t){const n=i.tracks[t],r=n.ValueTypeName;if("bool"===r||"string"===r)continue;const a=e.tracks.find((function(e){return e.name===n.name&&e.ValueTypeName===r}));if(void 0===a)continue;let o=0;const h=n.getValueSize();n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=h/3);let c=0;const l=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=l/3);const u=n.times.length-1;let d;if(s<=n.times[0]){const e=o,t=h-o;d=sl.arraySlice(n.values,e,t)}else if(s>=n.times[u]){const e=u*h+o,t=e+h-o;d=sl.arraySlice(n.values,e,t)}else{const e=n.createInterpolant(),t=o,i=h-o;e.evaluate(s),d=sl.arraySlice(e.resultBuffer,t,i)}if("quaternion"===r){(new Ji).fromArray(d).normalize().conjugate().toArray(d)}const p=a.times.length;for(let e=0;e<p;++e){const t=e*l+c;if("quaternion"===r)Ji.multiplyQuaternionsFlat(a.values,t,d,0,a.values,t);else{const e=l-2*c;for(let i=0;i<e;++i)a.values[t+i]-=d[i]}}}return e.blendMode=2501,e}};class al{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let s;i:{n:if(!(e<n)){for(let s=i+2;;){if(void 0===n){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,r)}if(i===s)break;if(r=n,n=t[++i],e<n)break t}s=t.length;break i}if(e>=r)break e;{const a=t[1];e<a&&(i=2,r=a);for(let s=i-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(i===s)break;if(n=r,r=t[--i-1],e>=r)break t}s=i,i=0}}for(;i<s;){const n=i+s>>>1;e<t[n]?s=n:i=n+1}if(n=t[i],r=t[i-1],void 0===r)return this._cachedIndex=0,this.beforeStart_(0,e,n);if(void 0===n)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,r,e)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let e=0;e!==n;++e)t[e]=i[r+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}al.prototype.beforeStart_=al.prototype.copySampleValue_,al.prototype.afterEnd_=al.prototype.copySampleValue_;class ol extends al{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:pi,endingEnd:pi}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,s=e+1,a=n[r],o=n[s];if(void 0===a)switch(this.getSettings_().endingStart){case mi:r=e,a=2*t-i;break;case fi:r=n.length-2,a=t+n[r]-n[r+1];break;default:r=e,a=i}if(void 0===o)switch(this.getSettings_().endingEnd){case mi:s=e,o=2*i-t;break;case fi:s=1,o=i+n[1]-n[0];break;default:s=e-1,o=t}const h=.5*(i-t),c=this.valueSize;this._weightPrev=h/(t-a),this._weightNext=h/(o-i),this._offsetPrev=r*c,this._offsetNext=s*c}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,h=o-a,c=this._offsetPrev,l=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-t)/(n-t),m=p*p,f=m*p,g=-u*f+2*u*m-u*p,_=(1+u)*f+(-1.5-2*u)*m+(-.5+u)*p+1,v=(-1-d)*f+(1.5+d)*m+.5*p,y=d*f-d*m;for(let e=0;e!==a;++e)r[e]=g*s[c+e]+_*s[h+e]+v*s[o+e]+y*s[l+e];return r}}class hl extends al{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,h=o-a,c=(i-t)/(n-t),l=1-c;for(let e=0;e!==a;++e)r[e]=s[h+e]*l+s[o+e]*c;return r}}class cl extends al{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class ll{constructor(e,t,i,n){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=sl.convertArray(t,this.TimeBufferType),this.values=sl.convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:sl.convertArray(e.times,Array),values:sl.convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(i.interpolation=t)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new cl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new hl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ol(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case li:t=this.InterpolantFactoryMethodDiscrete;break;case ui:t=this.InterpolantFactoryMethodLinear;break;case di:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return li;case this.InterpolantFactoryMethodLinear:return ui;case this.InterpolantFactoryMethodSmooth:return di}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,s=n-1;for(;r!==n&&i[r]<e;)++r;for(;-1!==s&&i[s]>t;)--s;if(++s,0!==r||s!==n){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=sl.arraySlice(i,r,s),this.values=sl.arraySlice(this.values,r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const n=i[t];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,n),e=!1;break}if(null!==s&&s>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,n,s),e=!1;break}s=n}if(void 0!==n&&sl.isTypedArray(n))for(let t=0,i=n.length;t!==i;++t){const i=n[t];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,i),e=!1;break}}return e}optimize(){const e=sl.arraySlice(this.times),t=sl.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===di,r=e.length-1;let s=1;for(let a=1;a<r;++a){let r=!1;const o=e[a];if(o!==e[a+1]&&(1!==a||o!==e[0]))if(n)r=!0;else{const e=a*i,n=e-i,s=e+i;for(let a=0;a!==i;++a){const i=t[e+a];if(i!==t[n+a]||i!==t[s+a]){r=!0;break}}}if(r){if(a!==s){e[s]=e[a];const n=a*i,r=s*i;for(let e=0;e!==i;++e)t[r+e]=t[n+e]}++s}}if(r>0){e[s]=e[r];for(let e=r*i,n=s*i,a=0;a!==i;++a)t[n+a]=t[e+a];++s}return s!==e.length?(this.times=sl.arraySlice(e,0,s),this.values=sl.arraySlice(t,0,s*i)):(this.times=e,this.values=t),this}clone(){const e=sl.arraySlice(this.times,0),t=sl.arraySlice(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}ll.prototype.TimeBufferType=Float32Array,ll.prototype.ValueBufferType=Float32Array,ll.prototype.DefaultInterpolation=ui;class ul extends ll{}ul.prototype.ValueTypeName="bool",ul.prototype.ValueBufferType=Array,ul.prototype.DefaultInterpolation=li,ul.prototype.InterpolantFactoryMethodLinear=void 0,ul.prototype.InterpolantFactoryMethodSmooth=void 0;class dl extends ll{}dl.prototype.ValueTypeName="color";class pl extends ll{}pl.prototype.ValueTypeName="number";class ml extends al{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(i-t)/(n-t);let h=e*a;for(let e=h+a;h!==e;h+=4)Ji.slerpFlat(r,0,s,h-a,s,h,o);return r}}class fl extends ll{InterpolantFactoryMethodLinear(e){return new ml(this.times,this.values,this.getValueSize(),e)}}fl.prototype.ValueTypeName="quaternion",fl.prototype.DefaultInterpolation=ui,fl.prototype.InterpolantFactoryMethodSmooth=void 0;class gl extends ll{}gl.prototype.ValueTypeName="string",gl.prototype.ValueBufferType=Array,gl.prototype.DefaultInterpolation=li,gl.prototype.InterpolantFactoryMethodLinear=void 0,gl.prototype.InterpolantFactoryMethodSmooth=void 0;class _l extends ll{}_l.prototype.ValueTypeName="vector";class vl{constructor(e,t=-1,i,n=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Pi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,r=i.length;e!==r;++e)t.push(yl(i[e]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,n=i.length;e!==n;++e)t.push(ll.toJSON(i[e]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,s=[];for(let e=0;e<r;e++){let a=[],o=[];a.push((e+r-1)%r,e,(e+1)%r),o.push(0,1,0);const h=sl.getKeyframeOrder(a);a=sl.sortedArray(a,1,h),o=sl.sortedArray(o,1,h),n||0!==a[0]||(a.push(r),o.push(o[0])),s.push(new pl(".morphTargetInfluences["+t[e].name+"]",a,o).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const t=e;i=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,i=e.length;t<i;t++){const i=e[t],s=i.name.match(r);if(s&&s.length>1){const e=s[1];let t=n[e];t||(n[e]=t=[]),t.push(i)}}const s=[];for(const e in n)s.push(this.CreateFromMorphTargetSequence(e,n[e],t,i));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(e,t,i,n,r){if(0!==i.length){const s=[],a=[];sl.flattenJSON(i,s,a,n),0!==s.length&&r.push(new e(t,s,a))}},n=[],r=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const h=e.hierarchy||[];for(let e=0;e<h.length;e++){const r=h[e].keys;if(r&&0!==r.length)if(r[0].morphTargets){const e={};let t;for(t=0;t<r.length;t++)if(r[t].morphTargets)for(let i=0;i<r[t].morphTargets.length;i++)e[r[t].morphTargets[i]]=-1;for(const i in e){const e=[],s=[];for(let n=0;n!==r[t].morphTargets.length;++n){const n=r[t];e.push(n.time),s.push(n.morphTarget===i?1:0)}n.push(new pl(".morphTargetInfluence["+i+"]",e,s))}o=e.length*(s||1)}else{const s=".bones["+t[e].name+"]";i(_l,s+".position",r,"pos",n),i(fl,s+".quaternion",r,"rot",n),i(_l,s+".scale",r,"scl",n)}}if(0===n.length)return null;return new this(r,o,n,a)}resetDuration(){let e=0;for(let t=0,i=this.tracks.length;t!==i;++t){const i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function yl(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return pl;case"vector":case"vector2":case"vector3":case"vector4":return _l;case"color":return dl;case"quaternion":return fl;case"bool":case"boolean":return ul;case"string":return gl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],i=[];sl.flattenJSON(e.keys,t,i,"value"),e.times=t,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const bl={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};const xl=new class{constructor(e,t,i){const n=this;let r,s=!1,a=0,o=0;const h=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){o++,!1===s&&void 0!==n.onStart&&n.onStart(e,a,o),s=!0},this.itemEnd=function(e){a++,void 0!==n.onProgress&&n.onProgress(e,a,o),a===o&&(s=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(e){void 0!==n.onError&&n.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return h.push(e,t),this},this.removeHandler=function(e){const t=h.indexOf(e);return-1!==t&&h.splice(t,2),this},this.getHandler=function(e){for(let t=0,i=h.length;t<i;t+=2){const i=h[t],n=h[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return n}return null}}};class wl{constructor(e){this.manager=void 0!==e?e:xl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise((function(n,r){i.load(e,n,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const Ml={};class Sl extends wl{constructor(e){super(e)}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=bl.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Ml[e])return void Ml[e].push({onLoad:t,onProgress:i,onError:n});Ml[e]=[],Ml[e].push({onLoad:t,onProgress:i,onError:n});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});fetch(s).then((t=>{if(200===t.status||0===t.status){0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");const i=Ml[e],n=t.body.getReader(),r=t.headers.get("Content-Length"),s=r?parseInt(r):0,a=0!==s;let o=0;return new ReadableStream({start(e){!function t(){n.read().then((({done:n,value:r})=>{if(n)e.close();else{o+=r.byteLength;const n=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=i.length;e<t;e++){const t=i[e];t.onProgress&&t.onProgress(n)}e.enqueue(r),t()}}))}()}})}throw Error(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`)})).then((e=>{const t=new Response(e);switch(this.responseType){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((e=>(new DOMParser).parseFromString(e,this.mimeType)));case"json":return t.json();default:return t.text()}})).then((t=>{bl.add(e,t);const i=Ml[e];delete Ml[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onLoad&&n.onLoad(t)}this.manager.itemEnd(e)})).catch((t=>{const i=Ml[e];delete Ml[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onError&&n.onError(t)}this.manager.itemError(e),this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Tl extends wl{constructor(e){super(e)}load(e,t,i,n){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=bl.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a=Ui("img");function o(){c(),bl.add(e,this),t&&t(this),r.manager.itemEnd(e)}function h(t){c(),n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",h,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",h,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Cl extends wl{constructor(e){super(e)}load(e,t,i,n){const r=new us,s=new Tl(this.manager);s.setCrossOrigin(this.crossOrigin),s.setPath(this.path);let a=0;function o(i){s.load(e[i],(function(e){r.images[i]=e,a++,6===a&&(r.needsUpdate=!0,t&&t(r))}),void 0,n)}for(let t=0;t<e.length;++t)o(t);return r}}class El extends wl{constructor(e){super(e)}load(e,t,i,n){const r=new Wi,s=new Tl(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),i,n),r}}class Al extends tr{constructor(e,t=1){super(),this.type="Light",this.color=new xr(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(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}}Al.prototype.isLight=!0;(class extends Al{constructor(e,t,i){super(e,i),this.type="HemisphereLight",this.position.copy(tr.DefaultUp),this.updateMatrix(),this.groundColor=new xr(t)}copy(e){return Al.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}).prototype.isHemisphereLight=!0;const Il=new Rn,Rl=new Ki,Pl=new Ki;class Ll{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new zi(512,512),this.map=null,this.mapPass=null,this.matrix=new Rn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ys,this._frameExtents=new zi(1,1),this._viewportCount=1,this._viewports=[new Xi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;Rl.setFromMatrixPosition(e.matrixWorld),t.position.copy(Rl),Pl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Pl),t.updateMatrixWorld(),Il.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Il),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),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}}class Dl extends Ll{constructor(){super(new hs(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,i=2*Ai*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;i===t.fov&&n===t.aspect&&r===t.far||(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}Dl.prototype.isSpotLightShadow=!0;(class extends Al{constructor(e,t,i=0,n=Math.PI/3,r=0,s=1){super(e,t),this.type="SpotLight",this.position.copy(tr.DefaultUp),this.updateMatrix(),this.target=new tr,this.distance=i,this.angle=n,this.penumbra=r,this.decay=s,this.shadow=new Dl}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(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}}).prototype.isSpotLight=!0;const Nl=new Rn,$l=new Ki,kl=new Ki;class Ol extends Ll{constructor(){super(new hs(90,1,.5,500)),this._frameExtents=new zi(4,2),this._viewportCount=6,this._viewports=[new Xi(2,1,1,1),new Xi(0,1,1,1),new Xi(3,1,1,1),new Xi(1,1,1,1),new Xi(3,0,1,1),new Xi(1,0,1,1)],this._cubeDirections=[new Ki(1,0,0),new Ki(-1,0,0),new Ki(0,0,1),new Ki(0,0,-1),new Ki(0,1,0),new Ki(0,-1,0)],this._cubeUps=[new Ki(0,1,0),new Ki(0,1,0),new Ki(0,1,0),new Ki(0,1,0),new Ki(0,0,1),new Ki(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),$l.setFromMatrixPosition(e.matrixWorld),i.position.copy($l),kl.copy(i.position),kl.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(kl),i.updateMatrixWorld(),n.makeTranslation(-$l.x,-$l.y,-$l.z),Nl.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Nl)}}Ol.prototype.isPointLightShadow=!0;(class extends Al{constructor(e,t,i=0,n=1){super(e,t),this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new Ol}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}).prototype.isPointLight=!0;class zl extends Ll{constructor(){super(new Ls(-5,5,5,-5,.5,500))}}zl.prototype.isDirectionalLightShadow=!0;(class extends Al{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(tr.DefaultUp),this.updateMatrix(),this.target=new tr,this.shadow=new zl}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}).prototype.isDirectionalLight=!0;(class extends Al{constructor(e,t){super(e,t),this.type="AmbientLight"}}).prototype.isAmbientLight=!0;(class extends Al{constructor(e,t,i=10,n=10){super(e,t),this.type="RectAreaLight",this.width=i,this.height=n}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}).prototype.isRectAreaLight=!0;class Fl{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Ki)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,n=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*n),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*i),t.addScaledVector(s[4],i*n*1.092548),t.addScaledVector(s[5],n*r*1.092548),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],i*r*1.092548),t.addScaledVector(s[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*n),t.addScaledVector(s[2],1.023328*r),t.addScaledVector(s[3],1.023328*i),t.addScaledVector(s[4],.858086*i*n),t.addScaledVector(s[5],.858086*n*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],.858086*i*r),t.addScaledVector(s[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+3*n);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+3*n);return e}static getBasisAt(e,t){const i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}Fl.prototype.isSphericalHarmonics3=!0;class Bl extends Al{constructor(e=new Fl,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}Bl.prototype.isLightProbe=!0;(class extends kr{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}).prototype.isInstancedBufferGeometry=!0;let Ul;(class extends wl{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=bl.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){bl.add(e,i),t&&t(i),r.manager.itemEnd(e)})).catch((function(t){n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}).prototype.isImageBitmapLoader=!0;const Vl=function(){return void 0===Ul&&(Ul=new(window.AudioContext||window.webkitAudioContext)),Ul};class Hl extends wl{constructor(e){super(e)}load(e,t,i,n){const r=this,s=new Sl(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(i){try{const e=i.slice(0);Vl().decodeAudioData(e,(function(e){t(e)}))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}}(class extends Bl{constructor(e,t,i=1){super(void 0,i);const n=(new xr).set(e),r=(new xr).set(t),s=new Ki(n.r,n.g,n.b),a=new Ki(r.r,r.g,r.b),o=Math.sqrt(Math.PI),h=o*Math.sqrt(.75);this.sh.coefficients[0].copy(s).add(a).multiplyScalar(o),this.sh.coefficients[1].copy(s).sub(a).multiplyScalar(h)}}).prototype.isHemisphereLightProbe=!0;(class extends Bl{constructor(e,t=1){super(void 0,t);const i=(new xr).set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}}).prototype.isAmbientLightProbe=!0;class jl{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Gl(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Gl();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Gl(){return("undefined"==typeof performance?Date:performance).now()}class Wl{constructor(e,t,i){let n,r,s;switch(this.binding=e,this.valueSize=i,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let s=this.cumulativeWeight;if(0===s){for(let e=0;e!==n;++e)i[r+e]=i[e];s=t}else{s+=t;const e=t/s;this._mixBufferRegion(i,r,0,e,n)}this.cumulativeWeight=s}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,s=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const e=t*this._origIndex;this._mixBufferRegion(i,n,e,1-r,t)}s>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(i[e]!==i[e+t]){a.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let e=i,r=n;e!==r;++e)t[e]=t[n+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)e[t+n]=e[i+n]}_slerp(e,t,i,n){Ji.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const s=this._workIndex*r;Ji.multiplyQuaternionsFlat(e,s,e,t,e,i),Ji.slerpFlat(e,t,e,t,e,s,n)}_lerp(e,t,i,n,r){const s=1-n;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*s+e[i+a]*n}}_lerpAdditive(e,t,i,n,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[i+s]*n}}}const ql="\\[\\]\\.:\\/",Xl=new RegExp("[\\[\\]\\.:\\/]","g"),Zl="[^\\[\\]\\.:\\/]",Yl="[^"+ql.replace("\\.","")+"]",Jl=/((?:WC+[\/:])*)/.source.replace("WC",Zl),Kl=/(WCOD+)?/.source.replace("WCOD",Yl),Ql=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Zl),eu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Zl),tu=new RegExp("^"+Jl+Kl+Ql+eu+"$"),iu=["material","materials","bones"];class nu{constructor(e,t,i){this.path=t,this.parsedPath=i||nu.parseTrackName(t),this.node=nu.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new nu.Composite(e,t,i):new nu(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Xl,"")}static parseTrackName(e){const t=tu.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const e=i.nodeName.substring(n+1);-1!==iu.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){const i=function(e){for(let n=0;n<e.length;n++){const r=e[n];if(r.name===t||r.uuid===t)return r;const s=i(r.children);if(s)return s}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=nu.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: 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("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===n){n=t;break}break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==n){if(void 0===e[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[n]}}const s=e[n];if(void 0===s){const i=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}o=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(o=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(o=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=n;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}nu.Composite=class{constructor(e,t,i){const n=i||nu.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},nu.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},nu.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},nu.prototype.GetterByBindingType=[nu.prototype._getValue_direct,nu.prototype._getValue_array,nu.prototype._getValue_arrayElement,nu.prototype._getValue_toArray],nu.prototype.SetterByBindingTypeAndVersioning=[[nu.prototype._setValue_direct,nu.prototype._setValue_direct_setNeedsUpdate,nu.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[nu.prototype._setValue_array,nu.prototype._setValue_array_setNeedsUpdate,nu.prototype._setValue_array_setMatrixWorldNeedsUpdate],[nu.prototype._setValue_arrayElement,nu.prototype._setValue_arrayElement_setNeedsUpdate,nu.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[nu.prototype._setValue_fromArray,nu.prototype._setValue_fromArray_setNeedsUpdate,nu.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ru{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,s=r.length,a=new Array(s),o={endingStart:pi,endingEnd:pi};for(let e=0;e!==s;++e){const t=r[e].createInterpolant(null);a[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const i=this._clip.duration,n=e._clip.duration,r=n/i,s=i/n;e.warp(1,r,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=n._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,h=a.sampleValues;return o[0]=r,o[1]=r+i,h[0]=e/s,h[1]=t/s,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const n=(e-r)*i;if(n<0||0===i)return;this._startTime=null,t=i*n}t*=this._updateTimeScale(e);const s=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case 2501:for(let i=0,n=e.length;i!==n;++i)e[i].evaluate(s),t[i].accumulateAdditive(a);break;case gi:default:for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(s),t[i].accumulate(n,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const s=2202===i;if(0===e)return-1===r?n:s&&1==(1&r)?t-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),n>=t||n<0){const i=Math.floor(n/t);n-=t*i,r+=Math.abs(i);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(s&&1==(1&r))return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=mi,n.endingEnd=mi):(n.endingStart=e?this.zeroSlopeAtStart?mi:pi:fi,n.endingEnd=t?this.zeroSlopeAtEnd?mi:pi:fi)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=i,this}}(class extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,s=e._propertyBindings,a=e._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let c=h[o];void 0===c&&(c={},h[o]=c);for(let e=0;e!==r;++e){const r=n[e],h=r.name;let l=c[h];if(void 0!==l)s[e]=l;else{if(l=s[e],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,h));continue}const n=t&&t._propertyBindings[e].binding.parsedPath;l=new Wl(nu.create(i,h,n),r.ValueTypeName,r.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,h),s[e]=l}a[e].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,t)}const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,r=this._actionsByClip;let s=r[t];if(void 0===s)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=s;else{const t=s.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=n.length,n.push(e),s.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,s=this._actionsByClip,a=s[r],o=a.knownActions,h=o[o.length-1],c=e._byClipCacheIndex;h._byClipCacheIndex=c,o[c]=h,o.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===o.length&&delete s[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let s=n[t];void 0===s&&(s={},n[t]=s),s[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,s=this._bindingsByRootAndName,a=s[n],o=t[t.length-1],h=e._cacheIndex;o._cacheIndex=h,t[h]=o,t.pop(),delete a[r],0===Object.keys(a).length&&delete s[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return void 0===i&&(i=new hl(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let s="string"==typeof e?vl.findByName(n,e):e;const a=null!==s?s.uuid:e,o=this._actionsByClip[a];let h=null;if(void 0===i&&(i=null!==s?s.blendMode:gi),void 0!==o){const e=o.actionByRoot[r];if(void 0!==e&&e.blendMode===i)return e;h=o.knownActions[0],null===s&&(s=h._clip)}if(null===s)return null;const c=new ru(this,s,t,i);return this._bindAction(c,h),this._addInactiveAction(c,a,r),c}existingAction(e,t){const i=t||this._root,n=i.uuid,r="string"==typeof e?vl.findByName(i,e):e,s=r?r.uuid:e,a=this._actionsByClip[s];return void 0!==a&&a.actionByRoot[n]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let a=0;a!==i;++a){t[a]._update(n,e,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)a[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const e=r.knownActions;for(let i=0,n=e.length;i!==n;++i){const n=e[i];this._deactivateAction(n);const r=n._cacheIndex,s=t[t.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,s._cacheIndex=r,t[r]=s,t.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const e in i){const n=i[e].actionByRoot[t];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[t];if(void 0!==n)for(const e in n){const t=n[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}).prototype._controlInterpolantsResultBuffer=new Float32Array(1);(class extends lh{constructor(e,t,i=1){super(e,t),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}).prototype.isInstancedInterleavedBuffer=!0;class su{constructor(e,t,i=0,n=1/0){this.ray=new In(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new Un,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return ou(e,this,i,t),i.sort(au),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)ou(e[n],this,i,t);return i.sort(au),i}}function au(e,t){return e.distance-t.distance}function ou(e,t,i,n){if(e.layers.test(t.layers)&&e.raycast(t,i),!0===n){const n=e.children;for(let e=0,r=n.length;e<r;e++)ou(n[e],t,i,!0)}}const hu=new Ki,cu=new Rn,lu=new Rn;function uu(e){const t=[];e&&e.isBone&&t.push(e);for(let i=0;i<e.children.length;i++)t.push.apply(t,uu(e.children[i]));return t}const du=new Float32Array(1);new Int32Array(du.buffer),rc.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(rc.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Sc.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},class extends Zh{constructor(e=10,t=10,i=4473924,n=8947848){i=new xr(i),n=new xr(n);const r=t/2,s=e/t,a=e/2,o=[],h=[];for(let e=0,c=0,l=-a;e<=t;e++,l+=s){o.push(-a,0,l,a,0,l),o.push(l,0,-a,l,0,a);const t=e===r?i:n;t.toArray(h,c),c+=3,t.toArray(h,c),c+=3,t.toArray(h,c),c+=3,t.toArray(h,c),c+=3}const c=new kr;c.setAttribute("position",new Ar(o,3)),c.setAttribute("color",new Ar(h,3));super(c,new Bh({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},class extends Zh{constructor(e){const t=uu(e),i=new kr,n=[],r=[],s=new xr(0,0,1),a=new xr(0,1,0);for(let e=0;e<t.length;e++){const i=t[e];i.parent&&i.parent.isBone&&(n.push(0,0,0),n.push(0,0,0),r.push(s.r,s.g,s.b),r.push(a.r,a.g,a.b))}i.setAttribute("position",new Ar(n,3)),i.setAttribute("color",new Ar(r,3));super(i,new Bh({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,n=i.getAttribute("position");lu.copy(this.root.matrixWorld).invert();for(let e=0,i=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(cu.multiplyMatrices(lu,r.matrixWorld),hu.setFromMatrixPosition(cu),n.setXYZ(i,hu.x,hu.y,hu.z),cu.multiplyMatrices(lu,r.parent.matrixWorld),hu.setFromMatrixPosition(cu),n.setXYZ(i+1,hu.x,hu.y,hu.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},wl.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),class{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}.extractUrlBase(e)},wl.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},tn.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},tn.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},tn.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},tn.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},tn.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},xn.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},ys.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Fi.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Fi.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},Fi.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},Fi.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},Fi.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},Fi.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Rn.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},Rn.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Rn.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Ki).setFromMatrixColumn(this,3)},Rn.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},Rn.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},Rn.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},Rn.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},Rn.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},Rn.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},Rn.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},Rn.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},Rn.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},Rn.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Rn.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},Rn.prototype.makeFrustum=function(e,t,i,n,r,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,n,i,r,s)},Rn.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},gs.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},Ji.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},Ji.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},In.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},In.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},In.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},dr.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},dr.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},dr.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},dr.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},dr.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},dr.barycoordFromPoint=function(e,t,i,n,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),dr.getBarycoord(e,t,i,n,r)},dr.normal=function(e,t,i,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),dr.getNormal(e,t,i,n)},Tc.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},Tc.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new el(this,e)},Tc.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new il(this,e)},zi.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},zi.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},zi.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Ki.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},Ki.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},Ki.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},Ki.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},Ki.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},Ki.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},Ki.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},Ki.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Ki.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Xi.prototype.fromAttribute=function(e,t,i){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,i)},Xi.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},tr.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},tr.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},tr.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},tr.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},tr.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(tr.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),es.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(es.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),Nh.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},hs.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Al.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(Tr.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Mi},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Mi)}}}),Tr.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Mi:wi),this},Tr.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},Tr.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},kr.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},kr.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new Tr(arguments[1],arguments[2])))},kr.prototype.addDrawCall=function(e,t,i){void 0!==i&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},kr.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},kr.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},kr.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},kr.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(kr.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),lh.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Mi:wi),this},lh.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},el.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},el.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},el.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},ch.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Object.defineProperties(mr.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new xr}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}}),Object.defineProperties(as.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),hh.prototype.clearTarget=function(e,t,i,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,i,n)},hh.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},hh.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},hh.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},hh.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},hh.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},hh.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},hh.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},hh.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},hh.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},hh.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},hh.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},hh.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},hh.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},hh.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},hh.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},hh.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},hh.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},hh.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},hh.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},hh.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},hh.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},hh.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},hh.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},hh.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(hh.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?vi:_i}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(Ko.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Zi.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),class extends tr{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new Hl).load(e,(function(e){t.setBuffer(e)})),this},ls.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},ls.prototype.clear=function(e,t,i,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,i,n)},ji.crossOrigin=void 0,ji.loadTexture=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new El;r.setCrossOrigin(this.crossOrigin);const s=r.load(e,i,void 0,n);return t&&(s.mapping=t),s},ji.loadTextureCube=function(e,t,i,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new Cl;r.setCrossOrigin(this.crossOrigin);const s=r.load(e,i,void 0,n);return t&&(s.mapping=t),s},ji.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ji.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"134"}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="134");const pu=Math.PI/180,mu=180/Math.PI,fu=6378137,gu=6356752.31424518;function _u(e,t,i,n,r,s){const a=xu(e,t,i);return yu(a[0],a[1],a[2],n,r,s)}function vu(e,t,i,n,r,s){const a=bu(e,t,i,n,r,s);return wu(a[0],a[1],a[2])}function yu(e,t,i,n,r,s){const a=xu(n,r,s),o=[e-a[0],t-a[1],i-a[2]];n*=pu,r*=pu;const h=Math.cos(n),c=Math.sin(n),l=Math.cos(r),u=Math.sin(r);return[-c*o[0]+h*o[1],-u*h*o[0]-u*c*o[1]+l*o[2],l*h*o[0]+l*c*o[1]+u*o[2]]}function bu(e,t,i,n,r,s){const a=xu(n,r,s);n*=pu,r*=pu;const o=Math.cos(n),h=Math.sin(n),c=Math.cos(r),l=Math.sin(r);return[-h*e-l*o*t+c*o*i+a[0],o*e-l*h*t+c*h*i+a[1],c*t+l*i+a[2]]}function xu(e,t,i){const n=fu,r=gu;e*=pu,t*=pu;const s=Math.cos(e),a=Math.sin(e),o=Math.cos(t),h=Math.sin(t),c=n*n,l=r*r,u=1/Math.sqrt(c*o*o+l*h*h),d=(c*u+i)*o;return[d*s,d*a,(l*u+i)*h]}function wu(e,t,i){const n=fu,r=gu,s=n*n,a=r*r,o=s-a,h=Math.sqrt(o/s),c=Math.sqrt(o/a),l=Math.sqrt(e*e+t*t),u=Math.atan2(i*n,l*r),d=Math.sin(u),p=Math.cos(u),m=Math.atan2(t,e),f=Math.atan2(i+c*c*r*d*d*d,l-h*h*n*p*p*p),g=Math.sin(f),_=Math.cos(f),v=n/Math.sqrt(1-h*h*g*g);return[m*mu,f*mu,l/_-v]}class Mu{boundingBoxCorners(e,t){const i=vu(-t,-t,0,e.lng,e.lat,0),n=vu(t,t,0,e.lng,e.lat,0);return[{lat:i[1],lng:i[0]},{lat:n[1],lng:n[0]}]}rotationFromCompass(e,t){let i=0,n=0,r=0;switch(t){case 1:i=Math.PI/2;break;case 3:i=-Math.PI/2,r=Math.PI;break;case 6:n=-Math.PI/2,r=-Math.PI/2;break;case 8:n=Math.PI/2,r=Math.PI/2}const s=(new Rn).makeRotationZ(r),a=new Bn(i,n,e*Math.PI/180,"XYZ"),o=(new Rn).makeRotationFromEuler(a),h=(new Xi).setAxisAngleFromRotationMatrix(o.multiply(s));return h.multiplyScalar(h.w).toArray().slice(0,3)}}class Su{constructor(e){if(!e)throw new Error(`Incorrect core image data ${e}`);this._cache=null,this._core=e,this._spatial=null}get assetsCached(){return null!=this._core&&null!=this._spatial&&null!=this._cache&&null!=this._cache.image&&null!=this._cache.mesh}get cameraParameters(){return this._spatial.camera_parameters}get cameraType(){return this._spatial.camera_type}get capturedAt(){return this._spatial.captured_at}get clusterId(){return this._spatial.cluster?this._spatial.cluster.id:null}get clusterUrl(){return this._spatial.cluster?this._spatial.cluster.url:null}get compassAngle(){return null!=this._spatial.computed_compass_angle?this._spatial.computed_compass_angle:this._spatial.compass_angle}get complete(){return null!=this._spatial}get computedAltitude(){return this._spatial.computed_altitude}get computedCompassAngle(){return this._spatial.computed_compass_angle}get computedLngLat(){return this._core.computed_geometry}get creatorId(){return this._spatial.creator.id}get creatorUsername(){return this._spatial.creator.username}get exifOrientation(){return this._spatial.exif_orientation}get height(){return this._spatial.height}get image(){return this._cache.image}get image$(){return this._cache.image$}get id(){return this._core.id}get lngLat(){return null!=this._core.computed_geometry?this._core.computed_geometry:this._core.geometry}get merged(){return null!=this._spatial&&null!=this._spatial.merge_id}get mergeId(){return this._spatial.merge_id}get mesh(){return this._cache.mesh}get originalAltitude(){return this._spatial.altitude}get originalCompassAngle(){return this._spatial.compass_angle}get originalLngLat(){return this._core.geometry}get ownerId(){return this._spatial.owner?this._spatial.owner.id:null}get private(){return this._spatial.private}get qualityScore(){return this._spatial.quality_score}get rotation(){return this._spatial.computed_rotation}get scale(){return this._spatial.atomic_scale}get sequenceId(){return this._core.sequence?this._core.sequence.id:null}get sequenceEdges(){return this._cache.sequenceEdges}get sequenceEdges$(){return this._cache.sequenceEdges$}get spatialEdges(){return this._cache.spatialEdges}get spatialEdges$(){return this._cache.spatialEdges$}get width(){return this._spatial.width}cacheAssets$(){return this._cache.cacheAssets$(this._spatial,this.merged).pipe(De((()=>this)))}cacheImage$(){return this._cache.cacheImage$(this._spatial).pipe(De((()=>this)))}cacheSequenceEdges(e){this._cache.cacheSequenceEdges(e)}cacheSpatialEdges(e){this._cache.cacheSpatialEdges(e)}dispose(){null!=this._cache&&(this._cache.dispose(),this._cache=null),this._core=null,this._spatial=null}initializeCache(e){if(null!=this._cache)throw new Error(`Image cache already initialized (${this.id}).`);this._cache=e}makeComplete(e){if(null==e)throw new Error("Fill can not be null.");this._spatial=e}resetSequenceEdges(){this._cache.resetSequenceEdges()}resetSpatialEdges(){this._cache.resetSpatialEdges()}uncache(){null!=this._cache&&(this._cache.dispose(),this._cache=null)}}class Tu{constructor(e){this._disposed=!1,this._provider=e,this._image=null,this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$=new j,this._image$=this._imageChanged$.pipe(Ot(null),Rt(1),U()),this._iamgeSubscription=this._image$.subscribe(),this._sequenceEdgesChanged$=new j,this._sequenceEdges$=this._sequenceEdgesChanged$.pipe(Ot(this._sequenceEdges),Rt(1),U()),this._sequenceEdgesSubscription=this._sequenceEdges$.subscribe((()=>{})),this._spatialEdgesChanged$=new j,this._spatialEdges$=this._spatialEdgesChanged$.pipe(Ot(this._spatialEdges),Rt(1),U()),this._spatialEdgesSubscription=this._spatialEdges$.subscribe((()=>{})),this._cachingAssets$=null}get image(){return this._image}get image$(){return this._image$}get mesh(){return this._mesh}get sequenceEdges(){return this._sequenceEdges}get sequenceEdges$(){return this._sequenceEdges$}get spatialEdges(){return this._spatialEdges}get spatialEdges$(){return this._spatialEdges$}cacheAssets$(e,t){return null!=this._cachingAssets$||(this._cachingAssets$=Ve(this._cacheImage$(e),this._cacheMesh$(e,t)).pipe(De((([e,t])=>(this._image=e,this._mesh=t,this))),Mt((()=>{this._cachingAssets$=null})),Rt(1),U()),this._cachingAssets$.pipe(St((e=>!!e._image))).subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{}))),this._cachingAssets$}cacheImage$(e){if(null!=this._image)return Ce(this);const t=this._cacheImage$(e).pipe(St((e=>!!e)),Ut((e=>{this._disposeImage(),this._image=e})),De((()=>this)),Rt(1),U());return t.subscribe((()=>{this._imageChanged$.next(this._image)}),(()=>{})),t}cacheSequenceEdges(e){this._sequenceEdges={cached:!0,edges:e},this._sequenceEdgesChanged$.next(this._sequenceEdges)}cacheSpatialEdges(e){this._spatialEdges={cached:!0,edges:e},this._spatialEdgesChanged$.next(this._spatialEdges)}dispose(){this._iamgeSubscription.unsubscribe(),this._sequenceEdgesSubscription.unsubscribe(),this._spatialEdgesSubscription.unsubscribe(),this._disposeImage(),this._mesh=null,this._sequenceEdges={cached:!1,edges:[]},this._spatialEdges={cached:!1,edges:[]},this._imageChanged$.next(null),this._sequenceEdgesChanged$.next(this._sequenceEdges),this._spatialEdgesChanged$.next(this._spatialEdges),this._disposed=!0,null!=this._imageAborter&&(this._imageAborter(),this._imageAborter=null),null!=this._meshAborter&&(this._meshAborter(),this._meshAborter=null)}resetSequenceEdges(){this._sequenceEdges={cached:!1,edges:[]},this._sequenceEdgesChanged$.next(this._sequenceEdges)}resetSpatialEdges(){this._spatialEdges={cached:!1,edges:[]},this._spatialEdgesChanged$.next(this._spatialEdges)}_cacheImage$(e){return k.create((t=>{const i=new Promise(((e,t)=>{this._imageAborter=t})),n=e.thumb.url;if(n)this._provider.getImageBuffer(n,i).then((e=>{this._imageAborter=null;const i=new Image;i.crossOrigin="Anonymous",i.onload=()=>{if(this._disposed){window.URL.revokeObjectURL(i.src);const e=`Image load was aborted (${n})`;t.error(new Error(e))}else t.next(i),t.complete()},i.onerror=()=>{this._imageAborter=null,t.error(new Error(`Failed to load image (${n})`))};const r=new Blob([e]);i.src=window.URL.createObjectURL(r)}),(e=>{this._imageAborter=null,t.error(e)}));else{const i=e.thumb.id,r=`Incorrect thumb URL for ${e.id} (${i}, ${n})`;t.error(new Error(r))}}))}_cacheMesh$(e,t){return k.create((i=>{if(!t)return i.next(this._createEmptyMesh()),void i.complete();const n=e.mesh.url;if(!n){const t=e.mesh.id,r=`Incorrect mesh URL for ${e.id} (${t}, ${n})`;return console.warn(r),i.next(this._createEmptyMesh()),void i.complete()}const r=new Promise(((e,t)=>{this._meshAborter=t}));this._provider.getMesh(n,r).then((e=>{this._meshAborter=null,this._disposed||(i.next(e),i.complete())}),(e=>{this._meshAborter=null,console.error(e),i.next(this._createEmptyMesh()),i.complete()}))}))}_createEmptyMesh(){return{faces:[],vertices:[]}}_disposeImage(){null!=this._image&&window.URL.revokeObjectURL(this._image.src),this._image=null}}class Cu{constructor(e){this._id=e.id,this._imageIds=e.image_ids}get id(){return this._id}get imageIds(){return this._imageIds}dispose(){this._id=null,this._imageIds=null}findNext(e){let t=this._imageIds.indexOf(e);return t+1>=this._imageIds.length||-1===t?null:this._imageIds[t+1]}findPrev(e){let t=this._imageIds.indexOf(e);return 0===t||-1===t?null:this._imageIds[t-1]}}class Eu{constructor(){this.sphericalPreferredDistance=2,this.sphericalMotion=2,this.sphericalSequencePenalty=1,this.sphericalMergeCCPenalty=4,this.stepPreferredDistance=4,this.stepMotion=3,this.stepRotation=4,this.stepSequencePenalty=2,this.stepMergeCCPenalty=6,this.similarDistance=2,this.similarRotation=3,this.turnDistance=4,this.turnMotion=2,this.turnSequencePenalty=1,this.turnMergeCCPenalty=4}}var Au;e.NavigationDirection=void 0,(Au=e.NavigationDirection||(e.NavigationDirection={}))[Au.Next=0]="Next",Au[Au.Prev=1]="Prev",Au[Au.StepLeft=2]="StepLeft",Au[Au.StepRight=3]="StepRight",Au[Au.StepForward=4]="StepForward",Au[Au.StepBackward=5]="StepBackward",Au[Au.TurnLeft=6]="TurnLeft",Au[Au.TurnRight=7]="TurnRight",Au[Au.TurnU=8]="TurnU",Au[Au.Spherical=9]="Spherical",Au[Au.Similar=10]="Similar";class Iu{constructor(){this.steps={},this.turns={},this.spherical={},this.steps[e.NavigationDirection.StepForward]={direction:e.NavigationDirection.StepForward,motionChange:0,useFallback:!0},this.steps[e.NavigationDirection.StepBackward]={direction:e.NavigationDirection.StepBackward,motionChange:Math.PI,useFallback:!0},this.steps[e.NavigationDirection.StepLeft]={direction:e.NavigationDirection.StepLeft,motionChange:Math.PI/2,useFallback:!1},this.steps[e.NavigationDirection.StepRight]={direction:e.NavigationDirection.StepRight,motionChange:-Math.PI/2,useFallback:!1},this.turns[e.NavigationDirection.TurnLeft]={direction:e.NavigationDirection.TurnLeft,directionChange:Math.PI/2,motionChange:Math.PI/4},this.turns[e.NavigationDirection.TurnRight]={direction:e.NavigationDirection.TurnRight,directionChange:-Math.PI/2,motionChange:-Math.PI/4},this.turns[e.NavigationDirection.TurnU]={direction:e.NavigationDirection.TurnU,directionChange:Math.PI,motionChange:null},this.spherical[e.NavigationDirection.StepForward]={direction:e.NavigationDirection.StepForward,directionChange:0,next:e.NavigationDirection.StepLeft,prev:e.NavigationDirection.StepRight},this.spherical[e.NavigationDirection.StepBackward]={direction:e.NavigationDirection.StepBackward,directionChange:Math.PI,next:e.NavigationDirection.StepRight,prev:e.NavigationDirection.StepLeft},this.spherical[e.NavigationDirection.StepLeft]={direction:e.NavigationDirection.StepLeft,directionChange:Math.PI/2,next:e.NavigationDirection.StepBackward,prev:e.NavigationDirection.StepForward},this.spherical[e.NavigationDirection.StepRight]={direction:e.NavigationDirection.StepRight,directionChange:-Math.PI/2,next:e.NavigationDirection.StepForward,prev:e.NavigationDirection.StepBackward}}}class Ru{constructor(){this.sphericalMinDistance=.1,this.sphericalMaxDistance=20,this.sphericalPreferredDistance=5,this.sphericalMaxItems=4,this.sphericalMaxStepTurnChange=Math.PI/8,this.rotationMaxDistance=this.turnMaxRigDistance,this.rotationMaxDirectionChange=Math.PI/6,this.rotationMaxVerticalDirectionChange=Math.PI/8,this.similarMaxDirectionChange=Math.PI/8,this.similarMaxDistance=12,this.similarMinTimeDifference=432e5,this.stepMaxDistance=20,this.stepMaxDirectionChange=Math.PI/6,this.stepMaxDrift=Math.PI/6,this.stepPreferredDistance=4,this.turnMaxDistance=15,this.turnMaxDirectionChange=2*Math.PI/9,this.turnMaxRigDistance=.65,this.turnMinRigDirectionChange=Math.PI/6}get maxDistance(){return Math.max(this.sphericalMaxDistance,this.similarMaxDistance,this.stepMaxDistance,this.turnMaxDistance)}}class Pu extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Pu.prototype),this.name="MapillaryError"}}class Lu extends Pu{constructor(e){super(null!=e?e:"The argument is not valid."),Object.setPrototypeOf(this,Lu.prototype),this.name="ArgumentMapillaryError"}}class Du{constructor(){this._epsilon=1e-9}azimuthalToBearing(e){return-e+Math.PI/2}degToRad(e){return Math.PI*e/180}radToDeg(e){return 180*e/Math.PI}rotationMatrix(e){let t=new Ki(e[0],e[1],e[2]),i=t.length();return i>0&&t.normalize(),(new Rn).makeRotationAxis(t,i)}rotate(e,t){let i=new Ki(e[0],e[1],e[2]),n=this.rotationMatrix(t);return i.applyMatrix4(n),i}opticalCenter(e,t){let i=[-e[0],-e[1],-e[2]],n=[-t[0],-t[1],-t[2]];return this.rotate(n,i)}viewingDirection(e){let t=[-e[0],-e[1],-e[2]];return this.rotate([0,0,1],t)}wrap(e,t,i){if(i<t)throw new Error("Invalid arguments: max must be larger than min.");let n=i-t;for(;e>i||e<t;)e>i?e-=n:e<t&&(e+=n);return e}wrapAngle(e){return this.wrap(e,-Math.PI,Math.PI)}clamp(e,t,i){return e<t?t:e>i?i:e}angleBetweenVector2(e,t,i,n){let r=Math.atan2(n,i)-Math.atan2(t,e);return this.wrapAngle(r)}angleDifference(e,t){let i=t-e;return this.wrapAngle(i)}relativeRotationAngle(e,t){let i=this.rotationMatrix([-e[0],-e[1],-e[2]]),n=this.rotationMatrix(t),r=i.multiply(n).elements,s=r[0]+r[5]+r[10];return Math.acos(Math.max(Math.min((s-1)/2,1),-1))}angleToPlane(e,t){let i=(new Ki).fromArray(e),n=i.length();if(n<this._epsilon)return 0;let r=i.dot((new Ki).fromArray(t));return Math.asin(r/n)}azimuthal(e,t){const i=(new Ki).fromArray(e),n=(new Ki).fromArray(t),r=i.clone().dot(n),s=i.clone().sub(n.clone().multiplyScalar(r));return Math.atan2(s.y,s.x)}distanceFromLngLat(e,t,i,n){let r=this.degToRad(n-t),s=this.degToRad(i-e),a=Math.sin(r/2)*Math.sin(r/2)+Math.cos(this.degToRad(t))*Math.cos(this.degToRad(n))*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}}const Nu=new Du;function $u(e){return"spherical"===e}function ku(e){return"fisheye"===e}function Ou(e,t,i){const n=_u(e.lng,e.lat,e.alt,i.lng,i.lat,i.alt),r=Nu.rotate(n,t);return[-r.x,-r.y,-r.z]}function zu(e,t,i,n,r){const s=[];for(let e=0;e<t.length;++e){const r=t[e],a=i[e];for(let e=0;e<=n;++e)s.push([r[0]+a[0]*e/n,r[1]+a[1]*e/n])}const a=new os;a.up.copy(e.upVector()),a.position.copy((new Ki).fromArray(e.unprojectSfM([0,0],0))),a.lookAt((new Ki).fromArray(e.unprojectSfM([0,0],10))),a.updateMatrix(),a.updateMatrixWorld(!0);return s.map((t=>{const i=e.unprojectBasic(t,1e4),n=r.worldToCamera(i,a);return[Math.abs(n[0]/n[2]),Math.abs(n[1]/n[2])]}))}class Fu{constructor(e,t,i){this._spatial=new Du,this._settings=null!=e?e:new Ru,this._directions=null!=t?t:new Iu,this._coefficients=null!=i?i:new Eu}getPotentialEdges(e,t,i){if(!e.complete)throw new Lu("Image has to be full.");if(!e.merged)return[];let n=this._spatial.viewingDirection(e.rotation),r=this._spatial.angleToPlane(n.toArray(),[0,0,1]),s=[];for(let a of t){if(!a.merged||a.id===e.id)continue;let t=_u(a.lngLat.lng,a.lngLat.lat,a.computedAltitude,e.lngLat.lng,e.lngLat.lat,e.computedAltitude),o=new Ki(t[0],t[1],t[2]),h=o.length();if(h>this._settings.maxDistance&&i.indexOf(a.id)<0)continue;let c=this._spatial.angleBetweenVector2(n.x,n.y,o.x,o.y),l=this._spatial.angleToPlane(o.toArray(),[0,0,1]),u=this._spatial.viewingDirection(a.rotation),d=this._spatial.angleBetweenVector2(n.x,n.y,u.x,u.y),p=this._spatial.angleToPlane(u.toArray(),[0,0,1])-r,m=this._spatial.relativeRotationAngle(e.rotation,a.rotation),f=this._spatial.angleBetweenVector2(1,0,o.x,o.y),g=null!=a.sequenceId&&null!=e.sequenceId&&a.sequenceId===e.sequenceId,_=a.mergeId===e.mergeId,v=a.creatorId===e.creatorId,y={capturedAt:a.capturedAt,directionChange:d,distance:h,spherical:$u(a.cameraType),id:a.id,motionChange:c,rotation:m,sameMergeCC:_,sameSequence:g,sameUser:v,sequenceId:a.sequenceId,verticalDirectionChange:p,verticalMotion:l,worldMotionAzimuth:f};s.push(y)}return s}computeSequenceEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");if(t.sequenceId!==i.id)throw new Lu("Image and sequence does not correspond.");let n=[],r=i.findNext(t.id);null!=r&&n.push({data:{direction:e.NavigationDirection.Next,worldMotionAzimuth:Number.NaN},source:t.id,target:r});let s=i.findPrev(t.id);return null!=s&&n.push({data:{direction:e.NavigationDirection.Prev,worldMotionAzimuth:Number.NaN},source:t.id,target:s}),n}computeSimilarEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");let n=$u(t.cameraType),r={};for(let e of i)if(null!=e.sequenceId&&!e.sameSequence){if(n){if(!e.spherical)continue}else if(!e.spherical&&Math.abs(e.directionChange)>this._settings.similarMaxDirectionChange)continue;e.distance>this._settings.similarMaxDistance||e.sameUser&&Math.abs(e.capturedAt-t.capturedAt)<this._settings.similarMinTimeDifference||(null==r[e.sequenceId]&&(r[e.sequenceId]=[]),r[e.sequenceId].push(e))}let s=[],a=$u(t.cameraType)?e=>e.distance:e=>this._coefficients.similarDistance*e.distance+this._coefficients.similarRotation*e.rotation;for(let e in r){if(!r.hasOwnProperty(e))continue;let t=Number.MAX_VALUE,i=null;for(let n of r[e]){let e=a(n);e<t&&(t=e,i=n)}null!=i&&s.push(i)}return s.map((i=>({data:{direction:e.NavigationDirection.Similar,worldMotionAzimuth:i.worldMotionAzimuth},source:t.id,target:i.id})))}computeStepEdges(e,t,i,n){if(!e.complete)throw new Lu("Image has to be full.");let r=[];if($u(e.cameraType))return r;for(let s in this._directions.steps){if(!this._directions.steps.hasOwnProperty(s))continue;let a=this._directions.steps[s],o=Number.MAX_VALUE,h=null,c=null;for(let e of t){if(e.spherical)continue;if(Math.abs(e.directionChange)>this._settings.stepMaxDirectionChange)continue;let t=this._spatial.angleDifference(a.motionChange,e.motionChange),r=this._spatial.angleDifference(e.directionChange,t),s=Math.max(Math.abs(t),Math.abs(r));if(Math.abs(s)>this._settings.stepMaxDrift)continue;let l=e.id;if(!a.useFallback||l!==i&&l!==n||(c=e),e.distance>this._settings.stepMaxDistance)continue;t=Math.sqrt(t*t+e.verticalMotion*e.verticalMotion);let u=this._coefficients.stepPreferredDistance*Math.abs(e.distance-this._settings.stepPreferredDistance)/this._settings.stepMaxDistance+this._coefficients.stepMotion*t/this._settings.stepMaxDrift+this._coefficients.stepRotation*e.rotation/this._settings.stepMaxDirectionChange+this._coefficients.stepSequencePenalty*(e.sameSequence?0:1)+this._coefficients.stepMergeCCPenalty*(e.sameMergeCC?0:1);u<o&&(o=u,h=e)}h=null==h?c:h,null!=h&&r.push({data:{direction:a.direction,worldMotionAzimuth:h.worldMotionAzimuth},source:e.id,target:h.id})}return r}computeTurnEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");let n=[];if($u(t.cameraType))return n;for(let r in this._directions.turns){if(!this._directions.turns.hasOwnProperty(r))continue;let s=this._directions.turns[r],a=Number.MAX_VALUE,o=null;for(let t of i){if(t.spherical)continue;if(t.distance>this._settings.turnMaxDistance)continue;let i,n=s.direction!==e.NavigationDirection.TurnU&&t.distance<this._settings.turnMaxRigDistance&&Math.abs(t.directionChange)>this._settings.turnMinRigDirectionChange,r=this._spatial.angleDifference(s.directionChange,t.directionChange);if(n&&t.directionChange*s.directionChange>0&&Math.abs(t.directionChange)<Math.abs(s.directionChange))i=-Math.PI/2+Math.abs(t.directionChange);else{if(Math.abs(r)>this._settings.turnMaxDirectionChange)continue;let e=s.motionChange?this._spatial.angleDifference(s.motionChange,t.motionChange):0;e=Math.sqrt(e*e+t.verticalMotion*t.verticalMotion),i=this._coefficients.turnDistance*t.distance/this._settings.turnMaxDistance+this._coefficients.turnMotion*e/Math.PI+this._coefficients.turnSequencePenalty*(t.sameSequence?0:1)+this._coefficients.turnMergeCCPenalty*(t.sameMergeCC?0:1)}i<a&&(a=i,o=t)}null!=o&&n.push({data:{direction:s.direction,worldMotionAzimuth:o.worldMotionAzimuth},source:t.id,target:o.id})}return n}computePerspectiveToSphericalEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");if($u(t.cameraType))return[];let n=Number.MAX_VALUE,r=null;for(let e of i){if(!e.spherical)continue;let t=this._coefficients.sphericalPreferredDistance*Math.abs(e.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(e.motionChange)/Math.PI+this._coefficients.sphericalMergeCCPenalty*(e.sameMergeCC?0:1);t<n&&(n=t,r=e)}return null==r?[]:[{data:{direction:e.NavigationDirection.Spherical,worldMotionAzimuth:r.worldMotionAzimuth},source:t.id,target:r.id}]}computeSphericalEdges(t,i){if(!t.complete)throw new Lu("Image has to be full.");if(!$u(t.cameraType))return[];let n=[],r=[],s=[];for(let e of i)if(!(e.distance>this._settings.sphericalMaxDistance))if(e.spherical){if(e.distance<this._settings.sphericalMinDistance)continue;r.push(e)}else for(let t in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(t))continue;let i=this._directions.spherical[t],n=this._spatial.angleDifference(e.directionChange,e.motionChange),r=this._spatial.angleDifference(i.directionChange,n);if(!(Math.abs(r)>this._settings.sphericalMaxStepTurnChange)){s.push([i.direction,e]);break}}let a=Math.PI/this._settings.sphericalMaxItems,o=[],h=[];for(let i=0;i<this._settings.sphericalMaxItems;i++){let s=i/this._settings.sphericalMaxItems*2*Math.PI,c=Number.MAX_VALUE,l=null;for(let e of r){let t=this._spatial.angleDifference(s,e.motionChange);if(Math.abs(t)>a)continue;let i=Number.MAX_VALUE;for(let t of o){let n=Math.abs(this._spatial.angleDifference(t,e.motionChange));n<i&&(i=n)}if(i<=a)continue;let n=this._coefficients.sphericalPreferredDistance*Math.abs(e.distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(t)/a+this._coefficients.sphericalSequencePenalty*(e.sameSequence?0:1)+this._coefficients.sphericalMergeCCPenalty*(e.sameMergeCC?0:1);n<c&&(c=n,l=e)}null!=l?(o.push(l.motionChange),n.push({data:{direction:e.NavigationDirection.Spherical,worldMotionAzimuth:l.worldMotionAzimuth},source:t.id,target:l.id})):h.push(s)}let c={};c[e.NavigationDirection.Spherical]=o,c[e.NavigationDirection.StepForward]=[],c[e.NavigationDirection.StepLeft]=[],c[e.NavigationDirection.StepBackward]=[],c[e.NavigationDirection.StepRight]=[];for(let i of h){let r=[];for(let o in this._directions.spherical){if(!this._directions.spherical.hasOwnProperty(o))continue;let h=this._directions.spherical[o],l=c[e.NavigationDirection.Spherical].concat(c[h.direction]).concat(c[h.prev]).concat(c[h.next]),u=Number.MAX_VALUE,d=null;for(let e of s){if(e[0]!==h.direction)continue;let t=this._spatial.angleDifference(i,e[1].motionChange);if(Math.abs(t)>a)continue;let n=Number.MAX_VALUE;for(let t of l){let i=Math.abs(this._spatial.angleDifference(t,e[1].motionChange));i<n&&(n=i)}if(n<=a)continue;let r=this._coefficients.sphericalPreferredDistance*Math.abs(e[1].distance-this._settings.sphericalPreferredDistance)/this._settings.sphericalMaxDistance+this._coefficients.sphericalMotion*Math.abs(t)/a+this._coefficients.sphericalMergeCCPenalty*(e[1].sameMergeCC?0:1);r<u&&(u=r,d=e)}null!=d&&(r.push(d),n.push({data:{direction:d[0],worldMotionAzimuth:d[1].worldMotionAzimuth},source:t.id,target:d[1].id}))}for(let e of r)c[e[0]].push(e[1].motionChange)}return n}}class Bu extends Pu{constructor(e){super(e),Object.setPrototypeOf(this,Bu.prototype),this.name="GraphMapillaryError"}}class Uu{constructor(e,t,i,n,r,s){this._api=e,this._cachedNodes={},this._cachedNodeTiles={},this._cachedSequenceNodes={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequenceNodes$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._changed$=new j,this._filterCreator=null!=r?r:new Ht,this._filter=this._filterCreator.createFilter(void 0),this._filterSubject$=new j,this._filter$=Ze(Ce(this._filter),this._filterSubject$).pipe(Rt(1),U()),this._filterSubscription=this._filter$.subscribe((()=>{})),this._defaultAlt=2,this._edgeCalculator=null!=n?n:new Fu,this._graphCalculator=null!=i?i:new Mu,this._configuration=null!=s?s:{maxSequences:50,maxUnusedImages:100,maxUnusedPreStoredImages:30,maxUnusedTiles:20},this._nodes={},this._nodeIndex=null!=t?t:new Uu._spatialIndex(16),this._nodeIndexTiles={},this._nodeToTile={},this._preStored={},this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._tileThreshold=20}static register(e){Uu._spatialIndex=e}get api(){return this._api}get changed$(){return this._changed$}get filter$(){return this._filter$}cacheBoundingBox$(e,t){const i=this._api.data.geometry.bboxToCellIds(e,t).filter((e=>!(e in this._cachedTiles))).map((e=>e in this._cachingTiles$?this._cachingTiles$[e]:this._cacheTile$(e)));return 0===i.length&&i.push(Ce(this)),ge(i).pipe(qe(),Ct(),We((()=>{const i=this._nodeIndex.search({maxX:t.lng,maxY:t.lat,minX:e.lng,minY:e.lat}).map((e=>e.node)),n=[],r=[];for(const e of i)e.complete?n.push(e):r.push(e.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return it(Ce(n),ge(s.map((e=>this._api.getSpatialImages$(e).pipe(De((e=>{const t=[];for(const i of e){if(!this.hasNode(i.node_id))continue;const e=this.getNode(i.node_id);e.complete||this._makeFull(e,i.node),t.push(e)}return t})))))).pipe(qe()))})),ut(((e,t)=>e.concat(t))))}cacheCell$(e){return(e in this._cachedTiles?Ce(this):e in this._cachingTiles$?this._cachingTiles$[e]:this._cacheTile$(e)).pipe(We((()=>{const t=this._cachedTiles[e];t.accessed=(new Date).getTime();const i=t.nodes,n=[],r=[];for(const e of i)e.complete?n.push(e):r.push(e.id);const s=[];for(;r.length>0;)s.push(r.splice(0,200));return it(Ce(n),ge(s.map((e=>this._api.getSpatialImages$(e).pipe(De((e=>{const t=[];for(const i of e){if(!i.node){console.warn(`Image is empty (${i.node})`);continue}const e=i.node_id;if(!this.hasNode(e))continue;const n=this.getNode(e);n.complete||this._makeFull(n,i.node),t.push(n)}return t})))))).pipe(qe()))})),ut(((e,t)=>e.concat(t))))}cacheFill$(e){if(e in this._cachingFull$)throw new Bu(`Cannot fill node while caching full (${e}).`);if(!this.hasNode(e))throw new Bu(`Cannot fill node that does not exist in graph (${e}).`);if(e in this._cachingFill$)return this._cachingFill$[e];const t=this.getNode(e);if(t.complete)throw new Bu(`Cannot fill node that is already full (${e}).`);return this._cachingFill$[e]=this._api.getSpatialImages$([e]).pipe(Ut((e=>{for(const i of e)i.node||console.warn(`Image is empty ${i.node_id}`),t.complete||this._makeFull(t,i.node),delete this._cachingFill$[i.node_id]})),De((()=>this)),Mt((()=>{e in this._cachingFill$&&delete this._cachingFill$[e],this._changed$.next(this)})),It(),U()),this._cachingFill$[e]}cacheFull$(e){if(e in this._cachingFull$)return this._cachingFull$[e];if(this.hasNode(e))throw new Bu(`Cannot cache full node that already exist in graph (${e}).`);return this._cachingFull$[e]=this._api.getImages$([e]).pipe(Ut((t=>{for(const i of t){if(!i.node)throw new Bu(`Image does not exist (${e}, ${i.node}).`);const t=i.node_id;if(this.hasNode(t)){const t=this.getNode(e);t.complete||this._makeFull(t,i.node)}else{if(null==i.node.sequence.id)throw new Bu(`Image has no sequence key (${e}).`);const n=new Su(i.node);this._makeFull(n,i.node);const r=this._api.data.geometry.lngLatToCellId(n.originalLngLat);this._preStore(r,n),this._setNode(n),delete this._cachingFull$[t]}}})),De((()=>this)),Mt((()=>{e in this._cachingFull$&&delete this._cachingFull$[e],this._changed$.next(this)})),It(),U()),this._cachingFull$[e]}cacheNodeSequence$(e){if(!this.hasNode(e))throw new Bu(`Cannot cache sequence edges of node that does not exist in graph (${e}).`);let t=this.getNode(e);if(t.sequenceId in this._sequences)throw new Bu(`Sequence already cached (${e}), (${t.sequenceId}).`);return this._cacheSequence$(t.sequenceId)}cacheSequence$(e){if(e in this._sequences)throw new Bu(`Sequence already cached (${e})`);return this._cacheSequence$(e)}cacheSequenceEdges(e){let t=this.getNode(e);if(!(t.sequenceId in this._sequences))throw new Bu(`Sequence is not cached (${e}), (${t.sequenceId})`);let i=this._sequences[t.sequenceId].sequence,n=this._edgeCalculator.computeSequenceEdges(t,i);t.cacheSequenceEdges(n)}cacheSequenceNodes$(e,t){if(!this.hasSequence(e))throw new Bu(`Cannot cache sequence nodes of sequence that does not exist in graph (${e}).`);if(this.hasSequenceNodes(e))throw new Bu(`Sequence nodes already cached (${e}).`);const i=this.getSequence(e);if(i.id in this._cachingSequenceNodes$)return this._cachingSequenceNodes$[i.id];const n=[],r=i.imageIds.slice();if(t&&r.length>50){const e=r.indexOf(t),i=Math.max(0,Math.min(e-25,r.length-50));n.push(r.splice(i,50))}for(;r.length>0;)n.push(r.splice(0,200));let s=n.length;const a=ge(n).pipe(We((e=>this._api.getImages$(e).pipe(Ut((e=>{for(const t of e){if(!t.node){console.warn(`Image empty (${t.node_id})`);continue}const e=t.node_id;if(this.hasNode(e)){const i=this.getNode(e);i.complete||this._makeFull(i,t.node)}else{null==t.node.sequence.id&&console.warn(`Sequence missing, discarding node (${t.node_id})`);const e=new Su(t.node);this._makeFull(e,t.node);const i=this._api.data.geometry.lngLatToCellId(e.originalLngLat);this._preStore(i,e),this._setNode(e)}}s--})),De((()=>this)))),6),Ct(),Mt((()=>{delete this._cachingSequenceNodes$[i.id],0===s&&(this._cachedSequenceNodes[i.id]=!0)})),It(),U());return this._cachingSequenceNodes$[i.id]=a,a}cacheSpatialArea$(e){if(!this.hasNode(e))throw new Bu(`Cannot cache spatial area of node that does not exist in graph (${e}).`);if(e in this._cachedSpatialEdges)throw new Bu(`Image already spatially cached (${e}).`);if(!(e in this._requiredSpatialArea))throw new Bu(`Spatial area not determined (${e}).`);let t=this._requiredSpatialArea[e];if(0===Object.keys(t.cacheNodes).length)throw new Bu(`Spatial nodes already cached (${e}).`);if(e in this._cachingSpatialArea$)return this._cachingSpatialArea$[e];let i=[];for(;t.cacheKeys.length>0;)i.push(t.cacheKeys.splice(0,200));let n=i.length,r=[];for(let s of i){let i=this._api.getSpatialImages$(s).pipe(Ut((i=>{for(const e of i){if(!e.node){console.warn(`Image is empty (${e.node_id})`);continue}const i=e.node_id,n=t.cacheNodes[i];n.complete?delete t.cacheNodes[i]:(this._makeFull(n,e.node),delete t.cacheNodes[i])}0==--n&&delete this._cachingSpatialArea$[e]})),De((()=>this)),ct((i=>{for(let e of s)e in t.all&&delete t.all[e],e in t.cacheNodes&&delete t.cacheNodes[e];throw 0==--n&&delete this._cachingSpatialArea$[e],i})),Mt((()=>{0===Object.keys(t.cacheNodes).length&&this._changed$.next(this)})),It(),U());r.push(i)}return this._cachingSpatialArea$[e]=r,r}cacheSpatialEdges(e){if(e in this._cachedSpatialEdges)throw new Bu(`Spatial edges already cached (${e}).`);let t=this.getNode(e),i=this._sequences[t.sequenceId].sequence,n=[],r=i.findPrev(t.id);null!=r&&n.push(r);let s=i.findNext(t.id);null!=s&&n.push(s);let a=this._requiredSpatialArea[e].all,o=[],h=this._filter;for(let e in a){if(!a.hasOwnProperty(e))continue;let t=a[e];h(t)&&o.push(t)}let c=this._edgeCalculator.getPotentialEdges(t,o,n),l=this._edgeCalculator.computeStepEdges(t,c,r,s);l=l.concat(this._edgeCalculator.computeTurnEdges(t,c)),l=l.concat(this._edgeCalculator.computeSphericalEdges(t,c)),l=l.concat(this._edgeCalculator.computePerspectiveToSphericalEdges(t,c)),l=l.concat(this._edgeCalculator.computeSimilarEdges(t,c)),t.cacheSpatialEdges(l),this._cachedSpatialEdges[e]=t,delete this._requiredSpatialArea[e],delete this._cachedNodeTiles[e]}cacheTiles$(e){if(e in this._cachedNodeTiles)throw new Bu(`Tiles already cached (${e}).`);if(e in this._cachedSpatialEdges)throw new Bu(`Spatial edges already cached so tiles considered cached (${e}).`);if(!(e in this._requiredNodeTiles))throw new Bu(`Tiles have not been determined (${e}).`);let t=this._requiredNodeTiles[e];if(0===t.cache.length&&0===t.caching.length)throw new Bu(`Tiles already cached (${e}).`);if(!this.hasNode(e))throw new Bu(`Cannot cache tiles of node that does not exist in graph (${e}).`);let i=t.cache.slice();t.caching=this._requiredNodeTiles[e].caching.concat(i),t.cache=[];let n=[];for(let i of t.caching){const r=i in this._cachingTiles$?this._cachingTiles$[i]:this._cacheTile$(i);n.push(r.pipe(Ut((n=>{let r=t.caching.indexOf(i);r>-1&&t.caching.splice(r,1),0===t.caching.length&&0===t.cache.length&&(delete this._requiredNodeTiles[e],this._cachedNodeTiles[e]=!0)})),ct((n=>{let r=t.caching.indexOf(i);throw r>-1&&t.caching.splice(r,1),0===t.caching.length&&0===t.cache.length&&(delete this._requiredNodeTiles[e],this._cachedNodeTiles[e]=!0),n})),Mt((()=>{this._changed$.next(this)})),It(),U()))}return n}initializeCache(e){if(e in this._cachedNodes)throw new Bu(`Image already in cache (${e}).`);const t=this.getNode(e),i=this._api.data;t.initializeCache(new Tu(i));const n=(new Date).getTime();this._cachedNodes[e]={accessed:n,node:t},this._updateCachedTileAccess(e,n)}isCachingFill(e){return e in this._cachingFill$}isCachingFull(e){return e in this._cachingFull$}isCachingNodeSequence(e){return this.getNode(e).sequenceId in this._cachingSequences$}isCachingSequence(e){return e in this._cachingSequences$}isCachingSequenceNodes(e){return e in this._cachingSequenceNodes$}isCachingTiles(e){return e in this._requiredNodeTiles&&0===this._requiredNodeTiles[e].cache.length&&this._requiredNodeTiles[e].caching.length>0}hasInitializedCache(e){return e in this._cachedNodes}hasNode(e){let t=(new Date).getTime();return this._updateCachedNodeAccess(e,t),this._updateCachedTileAccess(e,t),e in this._nodes}hasNodeSequence(e){let t=this.getNode(e).sequenceId,i=t in this._sequences;return i&&(this._sequences[t].accessed=(new Date).getTime()),i}hasSequence(e){let t=e in this._sequences;return t&&(this._sequences[e].accessed=(new Date).getTime()),t}hasSequenceNodes(e){return e in this._cachedSequenceNodes}hasSpatialArea(e){if(!this.hasNode(e))throw new Bu(`Spatial area nodes cannot be determined if node not in graph (${e}).`);if(e in this._cachedSpatialEdges)return!0;if(e in this._requiredSpatialArea)return 0===Object.keys(this._requiredSpatialArea[e].cacheNodes).length;let t=this.getNode(e),i=this._graphCalculator.boundingBoxCorners(t.lngLat,this._tileThreshold),n=this._nodeIndex.search({maxX:i[1].lng,maxY:i[1].lat,minX:i[0].lng,minY:i[0].lat}),r={all:{},cacheKeys:[],cacheNodes:{}};for(let e of n)r.all[e.node.id]=e.node,e.node.complete||(r.cacheKeys.push(e.node.id),r.cacheNodes[e.node.id]=e.node);return this._requiredSpatialArea[e]=r,0===r.cacheKeys.length}hasTiles(e){if(e in this._cachedNodeTiles)return!0;if(e in this._cachedSpatialEdges)return!0;if(!this.hasNode(e))throw new Bu(`Image does not exist in graph (${e}).`);let t={cache:[],caching:[]};if(e in this._requiredNodeTiles)t=this._requiredNodeTiles[e];else{const i=this.getNode(e),[n,r]=this._graphCalculator.boundingBoxCorners(i.lngLat,this._tileThreshold);t.cache=this._api.data.geometry.bboxToCellIds(n,r).filter((e=>!(e in this._cachedTiles))),t.cache.length>0&&(this._requiredNodeTiles[e]=t)}return 0===t.cache.length&&0===t.caching.length}getNode(e){let t=(new Date).getTime();return this._updateCachedNodeAccess(e,t),this._updateCachedTileAccess(e,t),this._nodes[e]}getSequence(e){let t=this._sequences[e];return t.accessed=(new Date).getTime(),t.sequence}resetSpatialEdges(){let e=Object.keys(this._cachedSpatialEdges);for(let t of e){this._cachedSpatialEdges[t].resetSpatialEdges(),delete this._cachedSpatialEdges[t]}}reset(e){const t=[];for(const i of e){if(!this.hasNode(i))throw new Error(`Image does not exist ${i}`);const e=this.getNode(i);e.resetSequenceEdges(),e.resetSpatialEdges(),t.push(e)}for(let t of Object.keys(this._cachedNodes))-1===e.indexOf(t)&&(this._cachedNodes[t].node.dispose(),delete this._cachedNodes[t]);this._cachedNodeTiles={},this._cachedSpatialEdges={},this._cachedTiles={},this._cachingFill$={},this._cachingFull$={},this._cachingSequences$={},this._cachingSpatialArea$={},this._cachingTiles$={},this._nodes={},this._nodeToTile={},this._preStored={};for(const e of t){this._nodes[e.id]=e;const t=this._api.data.geometry.lngLatToCellId(e.originalLngLat);this._preStore(t,e)}this._requiredNodeTiles={},this._requiredSpatialArea={},this._sequences={},this._nodeIndexTiles={},this._nodeIndex.clear()}setFilter(e){this._filter=this._filterCreator.createFilter(e),this._filterSubject$.next(this._filter)}uncache(e,t,i){const n={};this._addNewKeys(n,this._cachingFull$),this._addNewKeys(n,this._cachingFill$),this._addNewKeys(n,this._cachingSpatialArea$),this._addNewKeys(n,this._requiredNodeTiles),this._addNewKeys(n,this._requiredSpatialArea);for(const t of e)t in n||(n[t]=!0);const r=this._tileThreshold,s=this._graphCalculator,a=this._api.data.geometry,o=new Set(t);for(let e in n){if(!n.hasOwnProperty(e))continue;const t=this._nodes[e],[i,h]=s.boundingBoxCorners(t.lngLat,r),c=a.bboxToCellIds(i,h);for(const e of c)o.has(e)||o.add(e)}const h=[];for(let e in this._cachedTiles)this._cachedTiles.hasOwnProperty(e)&&!o.has(e)&&h.push([e,this._cachedTiles[e]]);const c=h.sort(((e,t)=>t[1].accessed-e[1].accessed)).slice(this._configuration.maxUnusedTiles).map((e=>e[0]));for(let e of c)this._uncacheTile(e,i);const l=[],u=[];for(let e in this._preStored){if(!this._preStored.hasOwnProperty(e)||e in this._cachingTiles$)continue;const t=this._preStored[e];for(let r in t)t.hasOwnProperty(r)&&!(r in n)&&t[r].sequenceId!==i&&(r in this._cachedNodes?l.push([this._cachedNodes[r],e]):u.push([r,e]))}const d=l.sort((([e],[t])=>t.accessed-e.accessed)).slice(this._configuration.maxUnusedPreStoredImages).map((([e,t])=>[e.node.id,t]));this._uncachePreStored(u),this._uncachePreStored(d);const p=[];for(let e in this._cachedNodes)this._cachedNodes.hasOwnProperty(e)&&!(e in n)&&p.push(this._cachedNodes[e]);const m=p.sort(((e,t)=>t.accessed-e.accessed)).slice(this._configuration.maxUnusedImages);for(const e of m){e.node.uncache();const t=e.node.id;delete this._cachedNodes[t],t in this._cachedNodeTiles&&delete this._cachedNodeTiles[t],t in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[t]}const f=[];for(let e in this._sequences)this._sequences.hasOwnProperty(e)&&!(e in this._cachingSequences$)&&e!==i&&f.push(this._sequences[e]);const g=f.sort(((e,t)=>t.accessed-e.accessed)).slice(this._configuration.maxSequences);for(const e of g){const t=e.sequence.id;delete this._sequences[t],t in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[t],e.sequence.dispose()}}updateCells$(e){const t=this._cachedTiles,i=this._cachingTiles$;return ge(e).pipe(We((e=>e in t?this._updateCell$(e):e in i?i[e].pipe(ct((()=>Ce(this))),We((()=>this._updateCell$(e)))):ie())))}unsubscribe(){this._filterSubscription.unsubscribe()}_addNewKeys(e,t){for(let i in t)t.hasOwnProperty(i)&&this.hasNode(i)&&(i in e||(e[i]=!0))}_cacheSequence$(e){return e in this._cachingSequences$||(this._cachingSequences$[e]=this._api.getSequence$(e).pipe(Ut((t=>{t?(t.id in this._sequences||(this._sequences[t.id]={accessed:(new Date).getTime(),sequence:new Cu(t)}),delete this._cachingSequences$[e]):console.warn(`Sequence does not exist (${e})`)})),De((()=>this)),Mt((()=>{e in this._cachingSequences$&&delete this._cachingSequences$[e],this._changed$.next(this)})),It(),U())),this._cachingSequences$[e]}_cacheTile$(e){return this._cachingTiles$[e]=this._api.getCoreImages$(e).pipe(Ut((t=>{if(e in this._cachedTiles)return;const i=t.images;this._nodeIndexTiles[e]=[],this._cachedTiles[e]={accessed:(new Date).getTime(),nodes:[]};const n=this._cachedTiles[e].nodes,r=this._removeFromPreStore(e);for(const t of i){if(!t)break;if(null==t.sequence.id){console.warn(`Sequence missing, discarding node (${t.id})`);continue}if(null!=r&&t.id in r){const i=r[t.id];delete r[t.id],n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[e].push(s),this._nodeToTile[i.id]=e;continue}const i=new Su(t);n.push(i);const s={lat:i.lngLat.lat,lng:i.lngLat.lng,node:i};this._nodeIndex.insert(s),this._nodeIndexTiles[e].push(s),this._nodeToTile[i.id]=e,this._setNode(i)}delete this._cachingTiles$[e]})),De((()=>this)),ct((t=>{throw delete this._cachingTiles$[e],t})),It(),U()),this._cachingTiles$[e]}_makeFull(e,t){null==t.computed_altitude&&(t.computed_altitude=this._defaultAlt),null==t.computed_rotation&&(t.computed_rotation=this._graphCalculator.rotationFromCompass(t.compass_angle,t.exif_orientation)),e.makeComplete(t)}_preStore(e,t){e in this._preStored||(this._preStored[e]={}),this._preStored[e][t.id]=t}_removeFromPreStore(e){let t=null;return e in this._preStored&&(t=this._preStored[e],delete this._preStored[e]),t}_setNode(e){let t=e.id;if(this.hasNode(t))throw new Bu(`Image already exist (${t}).`);this._nodes[t]=e}_uncacheTile(e,t){for(let i of this._cachedTiles[e].nodes){let n=i.id;delete this._nodeToTile[n],n in this._cachedNodes&&delete this._cachedNodes[n],n in this._cachedNodeTiles&&delete this._cachedNodeTiles[n],n in this._cachedSpatialEdges&&delete this._cachedSpatialEdges[n],i.sequenceId===t?(this._preStore(e,i),i.uncache()):(delete this._nodes[n],i.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[i.sequenceId],i.dispose())}for(let t of this._nodeIndexTiles[e])this._nodeIndex.remove(t);delete this._nodeIndexTiles[e],delete this._cachedTiles[e]}_uncachePreStored(e){let t={};for(let[i,n]of e){i in this._nodes&&delete this._nodes[i],i in this._cachedNodes&&delete this._cachedNodes[i];let e=this._preStored[n][i];e.sequenceId in this._cachedSequenceNodes&&delete this._cachedSequenceNodes[e.sequenceId],delete this._preStored[n][i],e.dispose(),t[n]=!0}for(let e in t)t.hasOwnProperty(e)&&0===Object.keys(this._preStored[e]).length&&delete this._preStored[e]}_updateCachedTileAccess(e,t){e in this._nodeToTile&&(this._cachedTiles[this._nodeToTile[e]].accessed=t)}_updateCachedNodeAccess(e,t){e in this._cachedNodes&&(this._cachedNodes[e].accessed=t)}_updateCell$(e){return this._api.getCoreImages$(e).pipe(We((t=>{if(!(e in this._cachedTiles))return ie();const i=this._nodeIndex,n=this._nodeIndexTiles[e],r=this._nodeToTile,s=this._cachedTiles[e];s.accessed=(new Date).getTime();const a=s.nodes,o=t.images;for(const t of o){if(null==t)break;if(this.hasNode(t.id))continue;if(null==t.sequence.id){console.warn(`Sequence missing, discarding node (${t.id})`);continue}const s=new Su(t);a.push(s);const o={lat:s.lngLat.lat,lng:s.lngLat.lng,node:s};i.insert(o),n.push(o),r[s.id]=e,this._setNode(s)}return Ce(e)})),ct((e=>(console.error(e),ie()))))}}class Vu{constructor(){this._hash={},this._index=new Vu._spatialIndex(16),this._indexChanged$=new j,this._updated$=new j}static register(e){Vu._spatialIndex=e}get changed$(){return this._indexChanged$}get updated$(){return this._updated$}add(e){const t=[],i=this._hash,n=this._index;for(const r of e){const e=r.id;e in i&&(n.remove(i[e]),t.push(r));const s={lat:r.lngLat.lat,lng:r.lngLat.lng,marker:r};i[e]=s,n.insert(s)}t.length>0&&this._updated$.next(t),e.length>t.length&&this._indexChanged$.next(this)}has(e){return e in this._hash}get(e){return this.has(e)?this._hash[e].marker:void 0}getAll(){return this._index.all().map((e=>e.marker))}remove(e){const t=this._hash,i=this._index;let n=!1;for(const r of e){if(!(r in t))continue;const e=t[r];i.remove(e),delete t[r],n=!0}n&&this._indexChanged$.next(this)}removeAll(){this._hash={},this._index.clear(),this._indexChanged$.next(this)}search([e,t]){return this._index.search({maxX:t.lng,maxY:t.lat,minX:e.lng,minY:e.lat}).map((e=>e.marker))}update(e){const t=this._hash,i=this._index,n=e.id;if(!(n in t))return;i.remove(t[n]);const r={lat:e.lngLat.lat,lng:e.lngLat.lng,marker:e};t[n]=r,i.insert(r)}}function Hu(e,t,i,n,r){ju(e,t,i||0,n||e.length-1,r||Wu)}function ju(e,t,i,n,r){for(;n>i;){if(n-i>600){var s=n-i+1,a=t-i+1,o=Math.log(s),h=.5*Math.exp(2*o/3),c=.5*Math.sqrt(o*h*(s-h)/s)*(a-s/2<0?-1:1);ju(e,t,Math.max(i,Math.floor(t-a*h/s+c)),Math.min(n,Math.floor(t+(s-a)*h/s+c)),r)}var l=e[t],u=i,d=n;for(Gu(e,i,t),r(e[n],l)>0&&Gu(e,i,n);u<d;){for(Gu(e,u,d),u++,d--;r(e[u],l)<0;)u++;for(;r(e[d],l)>0;)d--}0===r(e[i],l)?Gu(e,i,d):Gu(e,++d,n),d<=t&&(i=d+1),t<=d&&(n=d-1)}}function Gu(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function Wu(e,t){return e<t?-1:e>t?1:0}function qu(e,t,i){if(!i)return t.indexOf(e);for(let n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function Xu(e,t){Zu(e,0,e.children.length,t,e)}function Zu(e,t,i,n,r){r||(r=rd(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=t;s<i;s++){const t=e.children[s];Yu(r,e.leaf?n(t):t)}return r}function Yu(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Ju(e,t){return e.minX-t.minX}function Ku(e,t){return e.minY-t.minY}function Qu(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function ed(e){return e.maxX-e.minX+(e.maxY-e.minY)}function td(e,t){const i=Math.max(e.minX,t.minX),n=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),s=Math.min(e.maxY,t.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function id(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function nd(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function rd(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function sd(e,t,i,n,r){const s=[t,i];for(;s.length;){if((i=s.pop())-(t=s.pop())<=n)continue;const a=t+Math.ceil((i-t)/n/2)*n;Hu(e,a,t,i,r),s.push(t,a,a,i)}}class ad extends class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!nd(e,t))return i;const n=this.toBBox,r=[];for(;t;){for(let s=0;s<t.children.length;s++){const a=t.children[s],o=t.leaf?n(a):a;nd(e,o)&&(t.leaf?i.push(a):id(e,o)?this._all(a,i):r.push(a))}t=r.pop()}return i}collides(e){let t=this.data;if(!nd(e,t))return!1;const i=[];for(;t;){for(let n=0;n<t.children.length;n++){const r=t.children[n],s=t.leaf?this.toBBox(r):r;if(nd(e,s)){if(t.leaf||id(e,s))return!0;i.push(r)}}t=i.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=rd([]),this}remove(e,t){if(!e)return this;let i=this.data;const n=this.toBBox(e),r=[],s=[];let a,o,h;for(;i||r.length;){if(i||(i=r.pop(),o=r[r.length-1],a=s.pop(),h=!0),i.leaf){const n=qu(e,i.children,t);if(-1!==n)return i.children.splice(n,1),r.push(i),this._condense(r),this}h||i.leaf||!id(i,n)?o?(a++,i=o.children[a],h=!1):i=null:(r.push(i),s.push(a),a=0,o=i,i=i.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,n){const r=i-t+1;let s,a=this._maxEntries;if(r<=a)return s=rd(e.slice(t,i+1)),Xu(s,this.toBBox),s;n||(n=Math.ceil(Math.log(r)/Math.log(a)),a=Math.ceil(r/Math.pow(a,n-1))),s=rd([]),s.leaf=!1,s.height=n;const o=Math.ceil(r/a),h=o*Math.ceil(Math.sqrt(a));sd(e,t,i,h,this.compareMinX);for(let r=t;r<=i;r+=h){const t=Math.min(r+h-1,i);sd(e,r,t,o,this.compareMinY);for(let i=r;i<=t;i+=o){const r=Math.min(i+o-1,t);s.children.push(this._build(e,i,r,n-1))}}return Xu(s,this.toBBox),s}_chooseSubtree(e,t,i,n){for(;n.push(t),!t.leaf&&n.length-1!==i;){let i,n=1/0,a=1/0;for(let o=0;o<t.children.length;o++){const h=t.children[o],c=Qu(h),l=(r=e,s=h,(Math.max(s.maxX,r.maxX)-Math.min(s.minX,r.minX))*(Math.max(s.maxY,r.maxY)-Math.min(s.minY,r.minY))-c);l<a?(a=l,n=c<n?c:n,i=h):l===a&&c<n&&(n=c,i=h)}t=i||t.children[0]}var r,s;return t}_insert(e,t,i){const n=i?e:this.toBBox(e),r=[],s=this._chooseSubtree(n,this.data,t,r);for(s.children.push(e),Yu(s,n);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)}_split(e,t){const i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const s=this._chooseSplitIndex(i,r,n),a=rd(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Xu(i,this.toBBox),Xu(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=rd([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Xu(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let n,r=1/0,s=1/0;for(let a=t;a<=i-t;a++){const t=Zu(e,0,a,this.toBBox),o=Zu(e,a,i,this.toBBox),h=td(t,o),c=Qu(t)+Qu(o);h<r?(r=h,n=a,s=c<s?c:s):h===r&&c<s&&(s=c,n=a)}return n||i-t}_chooseSplitAxis(e,t,i){const n=e.leaf?this.compareMinX:Ju,r=e.leaf?this.compareMinY:Ku;this._allDistMargin(e,t,i,n)<this._allDistMargin(e,t,i,r)&&e.children.sort(n)}_allDistMargin(e,t,i,n){e.children.sort(n);const r=this.toBBox,s=Zu(e,0,t,r),a=Zu(e,i-t,i,r);let o=ed(s)+ed(a);for(let n=t;n<i-t;n++){const t=e.children[n];Yu(s,e.leaf?r(t):t),o+=ed(s)}for(let n=i-t-1;n>=t;n--){const t=e.children[n];Yu(a,e.leaf?r(t):t),o+=ed(a)}return o}_adjustParentBBoxes(e,t,i){for(let n=i;n>=0;n--)Yu(t[n],e)}_condense(e){for(let t,i=e.length-1;i>=0;i--)0===e[i].children.length?i>0?(t=e[i-1].children,t.splice(t.indexOf(e[i]),1)):this.clear():Xu(e[i],this.toBBox)}}{compareMinX(e,t){return e.lng-t.lng}compareMinY(e,t){return e.lat-t.lat}toBBox(e){return{minX:e.lng,minY:e.lat,maxX:e.lng,maxY:e.lat}}}class od{constructor(e,t){this._components={};for(const i in od.registeredComponents){if(!od.registeredComponents.hasOwnProperty(i))continue;const n=od.registeredComponents[i];this._components[i]={active:!1,component:new n(i,e,t)}}this._coverComponent=new od.registeredCoverComponent("cover",e,t),this._coverComponent.activate(),this._coverActivated=!0}static register(e){void 0===od.registeredComponents[e.componentName]&&(od.registeredComponents[e.componentName]=e)}static registerCover(e){od.registeredCoverComponent=e}get coverActivated(){return this._coverActivated}activateCover(){if(!this._coverActivated){this._coverActivated=!0;for(const e in this._components){if(!this._components.hasOwnProperty(e))continue;const t=this._components[e];t.active&&t.component.deactivate()}}}deactivateCover(){if(this._coverActivated){this._coverActivated=!1;for(const e in this._components){if(!this._components.hasOwnProperty(e))continue;const t=this._components[e];t.active&&t.component.activate()}}}activate(e){this._checkName(e),this._components[e].active=!0,this._coverActivated||this.get(e).activate()}configure(e,t){this._checkName(e),this.get(e).configure(t)}deactivate(e){this._checkName(e),this._components[e].active=!1,this._coverActivated||this.get(e).deactivate()}get(e){return this._components[e].component}getCover(){return this._coverComponent}remove(){this._coverComponent.deactivate();for(const e in this._components)this._components.hasOwnProperty(e)&&this._components[e].component.deactivate()}_checkName(e){if(!(e in this._components))throw new Lu(`Component does not exist: ${e}`)}}od.registeredComponents={};var hd="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function cd(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(i){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})})),t}var ld=Array.isArray,ud=Object.prototype.toString,dd=ld||function(e){return"[object Array]"===ud.call(e)};md.NONE=0,md.VTEXT=1,md.VNODE=2,md.WIDGET=3,md.PROPS=4,md.ORDER=5,md.INSERT=6,md.REMOVE=7,md.THUNK=8;var pd=md;function md(e,t,i){this.type=Number(e),this.vNode=t,this.patch=i}md.prototype.version="2",md.prototype.type="VirtualPatch";var fd=function(e){return e&&"VirtualNode"===e.type&&"2"===e.version};var gd=function(e){return e&&"VirtualText"===e.type&&"2"===e.version};var _d=function(e){return e&&"Widget"===e.type};var vd=function(e){return e&&"Thunk"===e.type};var yd=fd,bd=gd,xd=_d,wd=vd,Md=function(e,t){var i=e,n=t;wd(t)&&(n=Sd(t,e));wd(e)&&(i=Sd(e,null));return{a:i,b:n}};function Sd(e,t){var i=e.vnode;if(i||(i=e.vnode=e.render(t)),!(yd(i)||bd(i)||xd(i)))throw new Error("thunk did not return a valid node");return i}var Td=function(e){return"object"==typeof e&&null!==e},Cd=function(e){return e&&("function"==typeof e.hook&&!e.hasOwnProperty("hook")||"function"==typeof e.unhook&&!e.hasOwnProperty("unhook"))};var Ed=Td,Ad=Cd;function Id(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}var Rd=dd,Pd=pd,Ld=fd,Dd=gd,Nd=_d,$d=vd,kd=Md,Od=function e(t,i){var n;for(var r in t){r in i||((n=n||{})[r]=void 0);var s=t[r],a=i[r];if(s!==a)if(Ed(s)&&Ed(a))if(Id(a)!==Id(s))(n=n||{})[r]=a;else if(Ad(a))(n=n||{})[r]=a;else{var o=e(s,a);o&&((n=n||{})[r]=o)}else(n=n||{})[r]=a}for(var h in i)h in t||((n=n||{})[h]=i[h]);return n};function zd(e,t){var i={a:e};return Fd(e,t,i,0),i}function Fd(e,t,i,n){if(e!==t){var r=i[n],s=!1;if($d(e)||$d(t))Vd(e,t,i,n);else if(null==t)Nd(e)||(Bd(e,i,n),r=i[n]),r=Wd(r,new Pd(Pd.REMOVE,e,t));else if(Ld(t))if(Ld(e))if(e.tagName===t.tagName&&e.namespace===t.namespace&&e.key===t.key){var a=Od(e.properties,t.properties);a&&(r=Wd(r,new Pd(Pd.PROPS,e,a))),r=function(e,t,i,n,r){for(var s=e.children,a=function(e,t){var i=Gd(t),n=i.keys,r=i.free;if(r.length===t.length)return{children:t,moves:null};var s=Gd(e),a=s.keys;if(s.free.length===e.length)return{children:t,moves:null};for(var o=[],h=0,c=r.length,l=0,u=0;u<e.length;u++){var d,p=e[u];p.key?n.hasOwnProperty(p.key)?(d=n[p.key],o.push(t[d])):(d=u-l++,o.push(null)):h<c?(d=r[h++],o.push(t[d])):(d=u-l++,o.push(null))}for(var m=h>=r.length?t.length:r[h],f=0;f<t.length;f++){var g=t[f];g.key?a.hasOwnProperty(g.key)||o.push(g):f>=m&&o.push(g)}for(var _,v=o.slice(),y=0,b=[],x=[],w=0;w<t.length;){var M=t[w];for(_=v[y];null===_&&v.length;)b.push(jd(v,y,null)),_=v[y];_&&_.key===M.key?(y++,w++):M.key?(_&&_.key&&n[_.key]!==w+1?(b.push(jd(v,y,_.key)),(_=v[y])&&_.key===M.key?y++:x.push({key:M.key,to:w})):x.push({key:M.key,to:w}),w++):_&&_.key&&b.push(jd(v,y,_.key))}for(;y<v.length;)_=v[y],b.push(jd(v,y,_&&_.key));if(b.length===l&&!x.length)return{children:o,moves:null};return{children:o,moves:{removes:b,inserts:x}}}(s,t.children),o=a.children,h=s.length,c=o.length,l=h>c?h:c,u=0;u<l;u++){var d=s[u],p=o[u];r+=1,d?Fd(d,p,i,r):p&&(n=Wd(n,new Pd(Pd.INSERT,null,p))),Ld(d)&&d.count&&(r+=d.count)}a.moves&&(n=Wd(n,new Pd(Pd.ORDER,e,a.moves)));return n}(e,t,i,r,n)}else r=Wd(r,new Pd(Pd.VNODE,e,t)),s=!0;else r=Wd(r,new Pd(Pd.VNODE,e,t)),s=!0;else Dd(t)?Dd(e)?e.text!==t.text&&(r=Wd(r,new Pd(Pd.VTEXT,e,t))):(r=Wd(r,new Pd(Pd.VTEXT,e,t)),s=!0):Nd(t)&&(Nd(e)||(s=!0),r=Wd(r,new Pd(Pd.WIDGET,e,t)));r&&(i[n]=r),s&&Bd(e,i,n)}}function Bd(e,t,i){Hd(e,t,i),Ud(e,t,i)}function Ud(e,t,i){if(Nd(e))"function"==typeof e.destroy&&(t[i]=Wd(t[i],new Pd(Pd.REMOVE,e,null)));else if(Ld(e)&&(e.hasWidgets||e.hasThunks))for(var n=e.children,r=n.length,s=0;s<r;s++){var a=n[s];Ud(a,t,i+=1),Ld(a)&&a.count&&(i+=a.count)}else $d(e)&&Vd(e,null,t,i)}function Vd(e,t,i,n){var r=kd(e,t),s=zd(r.a,r.b);(function(e){for(var t in e)if("a"!==t)return!0;return!1})(s)&&(i[n]=new Pd(Pd.THUNK,null,s))}function Hd(e,t,i){if(Ld(e)){if(e.hooks&&(t[i]=Wd(t[i],new Pd(Pd.PROPS,e,function(e){var t={};for(var i in e)t[i]=void 0;return t}(e.hooks)))),e.descendantHooks||e.hasThunks)for(var n=e.children,r=n.length,s=0;s<r;s++){var a=n[s];Hd(a,t,i+=1),Ld(a)&&a.count&&(i+=a.count)}}else $d(e)&&Vd(e,null,t,i)}function jd(e,t,i){return e.splice(t,1),{from:t,key:i}}function Gd(e){for(var t={},i=[],n=e.length,r=0;r<n;r++){var s=e[r];s.key?t[s.key]=r:i.push(r)}return{keys:t,free:i}}function Wd(e,t){return e?(Rd(e)?e.push(t):e=[e,t],e):t}var qd=zd,Xd=Array.prototype.slice,Zd=function(e,t){"length"in e||(e=[e]);e=Xd.call(e);for(;e.length;){var i=e.shift(),n=t(i);if(n)return n;i.childNodes&&i.childNodes.length&&(e=Xd.call(i.childNodes).concat(e))}};var Yd=Jd;function Jd(e,t){if(!(this instanceof Jd))return new Jd(e,t);this.data=e,this.nodeValue=e,this.length=e.length,this.ownerDocument=t||null}Jd.prototype.nodeType=8,Jd.prototype.nodeName="#comment",Jd.prototype.toString=function(){return"[object Comment]"};var Kd=Qd;function Qd(e,t){if(!(this instanceof Qd))return new Qd(e);this.data=e||"",this.length=this.data.length,this.ownerDocument=t||null}Qd.prototype.type="DOMTextNode",Qd.prototype.nodeType=3,Qd.prototype.nodeName="#text",Qd.prototype.toString=function(){return this.data},Qd.prototype.replaceData=function(e,t,i){var n=this.data,r=n.substring(0,e),s=n.substring(e+t,n.length);this.data=r+i+s,this.length=this.data.length};var ep=function(e){var t=this,i=e.type;e.target||(e.target=t);t.listeners||(t.listeners={});var n=t.listeners[i];if(n)return n.forEach((function(i){e.currentTarget=t,"function"==typeof i?i(e):i.handleEvent(e)}));t.parentNode&&t.parentNode.dispatchEvent(e)};var tp=function(e,t){var i=this;i.listeners||(i.listeners={});i.listeners[e]||(i.listeners[e]=[]);-1===i.listeners[e].indexOf(t)&&i.listeners[e].push(t)};var ip=function(e,t){var i=this;if(!i.listeners)return;if(!i.listeners[e])return;var n=i.listeners[e],r=n.indexOf(t);-1!==r&&n.splice(r,1)};var np=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function rp(e){switch(e.nodeType){case 3:return op(e.data);case 8:return"\x3c!--"+e.data+"--\x3e";default:return function(e){var t=[],i=e.tagName;"http://www.w3.org/1999/xhtml"===e.namespaceURI&&(i=i.toLowerCase());t.push("<"+i+function(e){var t=[];for(var i in e)sp(e,i)&&t.push({name:i,value:e[i]});for(var n in e._attributes)for(var r in e._attributes[n]){var s=e._attributes[n][r],a=(s.prefix?s.prefix+":":"")+r;t.push({name:a,value:s.value})}e.className&&t.push({name:"class",value:e.className});return t.length?ap(t):""}(e)+function(e){var t=e.dataset,i=[];for(var n in t)i.push({name:"data-"+n,value:t[n]});return i.length?ap(i):""}(e)),np.indexOf(i)>-1?t.push(" />"):(t.push(">"),e.childNodes.length?t.push.apply(t,e.childNodes.map(rp)):e.textContent||e.innerText?t.push(op(e.textContent||e.innerText)):e.innerHTML&&t.push(e.innerHTML),t.push("</"+i+">"));return t.join("")}(e)}}function sp(e,t){var i=typeof e[t];return"style"===t&&Object.keys(e.style).length>0||e.hasOwnProperty(t)&&("string"===i||"boolean"===i||"number"===i)&&"nodeName"!==t&&"className"!==t&&"tagName"!==t&&"textContent"!==t&&"innerText"!==t&&"namespaceURI"!==t&&"innerHTML"!==t}function ap(e){var t=[];return e.forEach((function(e){var i=e.name,n=e.value;"style"===i&&(n=function(e){if("string"==typeof e)return e;var t="";return Object.keys(e).forEach((function(i){var n=e[i];i=i.replace(/[A-Z]/g,(function(e){return"-"+e.toLowerCase()})),t+=i+":"+n+";"})),t}(n)),t.push(i+'="'+(op(n).replace(/"/g,""")+'"'))})),t.length?" "+t.join(" "):""}function op(e){var t="";return"string"==typeof e?t=e:e&&(t=e.toString()),t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var hp=Zd,cp=ep,lp=tp,up=ip,dp=rp,pp="http://www.w3.org/1999/xhtml",mp=fp;function fp(e,t,i){if(!(this instanceof fp))return new fp(e);var n=void 0===i?pp:i||null;this.tagName=n===pp?String(e).toUpperCase():e,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=t||null,this.namespaceURI=n,this._attributes={},"INPUT"===this.tagName&&(this.type="text")}fp.prototype.type="DOMElement",fp.prototype.nodeType=1,fp.prototype.appendChild=function(e){return e.parentNode&&e.parentNode.removeChild(e),this.childNodes.push(e),e.parentNode=this,e},fp.prototype.replaceChild=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=this.childNodes.indexOf(t);return t.parentNode=null,this.childNodes[i]=e,e.parentNode=this,t},fp.prototype.removeChild=function(e){var t=this.childNodes.indexOf(e);return this.childNodes.splice(t,1),e.parentNode=null,e},fp.prototype.insertBefore=function(e,t){e.parentNode&&e.parentNode.removeChild(e);var i=null==t?-1:this.childNodes.indexOf(t);return i>-1?this.childNodes.splice(i,0,e):this.childNodes.push(e),e.parentNode=this,e},fp.prototype.setAttributeNS=function(e,t,i){var n=null,r=t,s=t.indexOf(":");(s>-1&&(n=t.substr(0,s),r=t.substr(s+1)),"INPUT"===this.tagName&&"type"===t)?this.type=i:(this._attributes[e]||(this._attributes[e]={}))[r]={value:i,prefix:n}},fp.prototype.getAttributeNS=function(e,t){var i=this._attributes[e],n=i&&i[t]&&i[t].value;return"INPUT"===this.tagName&&"type"===t?this.type:"string"!=typeof n?null:n},fp.prototype.removeAttributeNS=function(e,t){var i=this._attributes[e];i&&delete i[t]},fp.prototype.hasAttributeNS=function(e,t){var i=this._attributes[e];return!!i&&t in i},fp.prototype.setAttribute=function(e,t){return this.setAttributeNS(null,e,t)},fp.prototype.getAttribute=function(e){return this.getAttributeNS(null,e)},fp.prototype.removeAttribute=function(e){return this.removeAttributeNS(null,e)},fp.prototype.hasAttribute=function(e){return this.hasAttributeNS(null,e)},fp.prototype.removeEventListener=up,fp.prototype.addEventListener=lp,fp.prototype.dispatchEvent=cp,fp.prototype.focus=function(){},fp.prototype.toString=function(){return dp(this)},fp.prototype.getElementsByClassName=function(e){var t=e.split(" "),i=[];return hp(this,(function(e){if(1===e.nodeType){var n=(e.className||"").split(" ");t.every((function(e){return-1!==n.indexOf(e)}))&&i.push(e)}})),i},fp.prototype.getElementsByTagName=function(e){e=e.toLowerCase();var t=[];return hp(this.childNodes,(function(i){1!==i.nodeType||"*"!==e&&i.tagName.toLowerCase()!==e||t.push(i)})),t},fp.prototype.contains=function(e){return hp(this,(function(t){return e===t}))||!1};var gp=mp,_p=vp;function vp(e){if(!(this instanceof vp))return new vp;this.childNodes=[],this.parentNode=null,this.ownerDocument=e||null}vp.prototype.type="DocumentFragment",vp.prototype.nodeType=11,vp.prototype.nodeName="#document-fragment",vp.prototype.appendChild=gp.prototype.appendChild,vp.prototype.replaceChild=gp.prototype.replaceChild,vp.prototype.removeChild=gp.prototype.removeChild,vp.prototype.toString=function(){return this.childNodes.map((function(e){return String(e)})).join("")};var yp=bp;function bp(e){}bp.prototype.initEvent=function(e,t,i){this.type=e,this.bubbles=t,this.cancelable=i},bp.prototype.preventDefault=function(){};var xp=Zd,wp=Yd,Mp=Kd,Sp=mp,Tp=_p,Cp=yp,Ep=ep,Ap=tp,Ip=ip,Rp=Pp;function Pp(){if(!(this instanceof Pp))return new Pp;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var Lp=Pp.prototype;Lp.createTextNode=function(e){return new Mp(e,this)},Lp.createElementNS=function(e,t){var i=null===e?null:String(e);return new Sp(t,this,i)},Lp.createElement=function(e){return new Sp(e,this)},Lp.createDocumentFragment=function(){return new Tp(this)},Lp.createEvent=function(e){return new Cp(e)},Lp.createComment=function(e){return new wp(e,this)},Lp.getElementById=function(e){return e=String(e),xp(this.childNodes,(function(t){if(String(t.id)===e)return t}))||null},Lp.getElementsByClassName=Sp.prototype.getElementsByClassName,Lp.getElementsByTagName=Sp.prototype.getElementsByTagName,Lp.contains=Sp.prototype.contains,Lp.removeEventListener=Ip,Lp.addEventListener=Ap,Lp.dispatchEvent=Ep;var Dp,Np=new Rp,$p=void 0!==hd?hd:"undefined"!=typeof window?window:{},kp=Np;"undefined"!=typeof document?Dp=document:(Dp=$p["__GLOBAL_DOCUMENT_CACHE@4"])||(Dp=$p["__GLOBAL_DOCUMENT_CACHE@4"]=kp);var Op=Td,zp=Cd,Fp=function(e,t,i){for(var n in t){var r=t[n];void 0===r?Bp(e,n,r,i):zp(r)?(Bp(e,n,r,i),r.hook&&r.hook(e,n,i?i[n]:void 0)):Op(r)?Up(e,t,i,n,r):e[n]=r}};function Bp(e,t,i,n){if(n){var r=n[t];if(zp(r))r.unhook&&r.unhook(e,t,i);else if("attributes"===t)for(var s in r)e.removeAttribute(s);else if("style"===t)for(var a in r)e.style[a]="";else e[t]="string"==typeof r?"":null}}function Up(e,t,i,n,r){var s=i?i[n]:void 0;if("attributes"!==n)if(s&&Op(s)&&Vp(s)!==Vp(r))e[n]=r;else{Op(e[n])||(e[n]={});var a="style"===n?"":void 0;for(var o in r){var h=r[o];e[n][o]=void 0===h?a:h}}else for(var c in r){var l=r[c];void 0===l?e.removeAttribute(c):e.setAttribute(c,l)}}function Vp(e){return Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__?e.__proto__:e.constructor?e.constructor.prototype:void 0}var Hp=Dp,jp=Fp,Gp=fd,Wp=gd,qp=_d,Xp=Md,Zp=function e(t,i){var n=i&&i.document||Hp,r=i?i.warn:null;if(t=Xp(t).a,qp(t))return t.init();if(Wp(t))return n.createTextNode(t.text);if(!Gp(t))return r&&r("Item is not a valid virtual dom node",t),null;var s=null===t.namespace?n.createElement(t.tagName):n.createElementNS(t.namespace,t.tagName),a=t.properties;jp(s,a);for(var o=t.children,h=0;h<o.length;h++){var c=e(o[h],i);c&&s.appendChild(c)}return s};var Yp={};function Jp(e,t,i,n,r){if(n=n||{},e){Kp(i,r,r)&&(n[r]=e);var s=t.children;if(s)for(var a=e.childNodes,o=0;o<t.children.length;o++){r+=1;var h=s[o]||Yp,c=r+(h.count||0);Kp(i,r,c)&&Jp(a[o],h,i,n,r),r=c}}return n}function Kp(e,t,i){if(0===e.length)return!1;for(var n,r,s=0,a=e.length-1;s<=a;){if(r=e[n=(a+s)/2>>0],s===a)return r>=t&&r<=i;if(r<t)s=n+1;else{if(!(r>i))return!0;a=n-1}}return!1}function Qp(e,t){return e>t?1:-1}var em=_d;var tm=Fp,im=_d,nm=pd,rm=function(e,t){if(em(e)&&em(t))return"name"in e&&"name"in t?e.id===t.id:e.init===t.init;return!1};function sm(e,t){"function"==typeof t.destroy&&im(t)&&t.destroy(e)}var am=Dp,om=dd,hm=Zp,cm=function(e,t,i,n){return i&&0!==i.length?(i.sort(Qp),Jp(e,t,i,n,0)):{}},lm=function(e,t,i){var n=e.type,r=e.vNode,s=e.patch;switch(n){case nm.REMOVE:return function(e,t){var i=e.parentNode;i&&i.removeChild(e);return sm(e,t),null}(t,r);case nm.INSERT:return function(e,t,i){var n=i.render(t,i);e&&e.appendChild(n);return e}(t,s,i);case nm.VTEXT:return function(e,t,i,n){var r;if(3===e.nodeType)e.replaceData(0,e.length,i.text),r=e;else{var s=e.parentNode;r=n.render(i,n),s&&r!==e&&s.replaceChild(r,e)}return r}(t,0,s,i);case nm.WIDGET:return function(e,t,i,n){var r,s=rm(t,i);r=s?i.update(t,e)||e:n.render(i,n);var a=e.parentNode;a&&r!==e&&a.replaceChild(r,e);s||sm(e,t);return r}(t,r,s,i);case nm.VNODE:return function(e,t,i,n){var r=e.parentNode,s=n.render(i,n);r&&s!==e&&r.replaceChild(s,e);return s}(t,0,s,i);case nm.ORDER:return function(e,t){for(var i,n,r,s=e.childNodes,a={},o=0;o<t.removes.length;o++)i=s[(n=t.removes[o]).from],n.key&&(a[n.key]=i),e.removeChild(i);for(var h=s.length,c=0;c<t.inserts.length;c++)i=a[(r=t.inserts[c]).key],e.insertBefore(i,r.to>=h++?null:s[r.to])}(t,s),t;case nm.PROPS:return tm(t,s,r.properties),t;case nm.THUNK:return function(e,t){e&&t&&e!==t&&e.parentNode&&e.parentNode.replaceChild(t,e);return t}(t,i.patch(t,s,i));default:return t}};function um(e,t,i){var n=function(e){var t=[];for(var i in e)"a"!==i&&t.push(Number(i));return t}(t);if(0===n.length)return e;var r=cm(e,t.a,n),s=e.ownerDocument;i.document||s===am||(i.document=s);for(var a=0;a<n.length;a++){var o=n[a];e=dm(e,r[o],t[o],i)}return e}function dm(e,t,i,n){if(!t)return e;var r;if(om(i))for(var s=0;s<i.length;s++)r=lm(i[s],t,n),t===e&&(e=r);else r=lm(i,t,n),t===e&&(e=r);return e}var pm=function e(t,i,n){return(n=n||{}).patch=n.patch&&n.patch!==e?n.patch:um,n.render=n.render||hm,n.patch(t,i,n)},mm=fd,fm=_d,gm=vd,_m=Cd,vm=xm,ym={},bm=[];function xm(e,t,i,n,r){this.tagName=e,this.properties=t||ym,this.children=i||bm,this.key=null!=n?String(n):void 0,this.namespace="string"==typeof r?r:null;var s,a=i&&i.length||0,o=0,h=!1,c=!1,l=!1;for(var u in t)if(t.hasOwnProperty(u)){var d=t[u];_m(d)&&d.unhook&&(s||(s={}),s[u]=d)}for(var p=0;p<a;p++){var m=i[p];mm(m)?(o+=m.count||0,!h&&m.hasWidgets&&(h=!0),!c&&m.hasThunks&&(c=!0),l||!m.hooks&&!m.descendantHooks||(l=!0)):!h&&fm(m)?"function"==typeof m.destroy&&(h=!0):!c&&gm(m)&&(c=!0)}this.count=a+o,this.hasWidgets=h,this.hasThunks=c,this.hooks=s,this.descendantHooks=l}xm.prototype.version="2",xm.prototype.type="VirtualNode";var wm=Mm;function Mm(e){this.text=String(e)}Mm.prototype.version="2",Mm.prototype.type="VirtualText";