soonspacejs 2.3.3 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- var t="soonspacejs",e="2.3.3",n=!1;
1
+ var t="soonspacejs",e="2.3.4",n=!1;
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2010-2021 Three.js Authors
@@ -31,7 +31,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
31
31
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32
32
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33
33
  PERFORMANCE OF THIS SOFTWARE.
34
- ***************************************************************************** */var Cu=function(t,e){return(Cu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var Lu=function(){return(Lu=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function Ru(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Iu(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,s=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function Fu(t){return this instanceof Fu?(this.v=t,this):new Fu(t)}var Du=Object.freeze({__proto__:null,__extends:function(t,e){function n(){this.constructor=t}Cu(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},get __assign(){return Lu},__rest:function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n},__decorate:function(t,e,n,r){var i,s=arguments.length,a=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var o=t.length-1;o>=0;o--)(i=t[o])&&(a=(s<3?i(a):s>3?i(e,n,a):i(e,n))||a);return s>3&&a&&Object.defineProperty(e,n,a),a},__param:function(t,e){return function(n,r){e(n,r,t)}},__metadata:function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter:function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{l(r.next(t))}catch(t){s(t)}}function o(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))},__generator:function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}},__createBinding:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]},__exportStar:function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||(e[n]=t[n])},__values:Ru,__read:Iu,__spread:function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Iu(arguments[e]));return t},__spreadArrays:function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var s=arguments[e],a=0,o=s.length;a<o;a++,i++)r[i]=s[a];return r},__await:Fu,__asyncGenerator:function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(t,e||[]),s=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(t){i[t]&&(r[t]=function(e){return new Promise((function(n,r){s.push([t,e,n,r])>1||o(t,e)}))})}function o(t,e){try{(n=i[t](e)).value instanceof Fu?Promise.resolve(n.value.v).then(l,c):h(s[0][2],n)}catch(t){h(s[0][3],t)}var n}function l(t){o("next",t)}function c(t){o("throw",t)}function h(t,e){t(e),s.shift(),s.length&&o(s[0][0],s[0][1])}},__asyncDelegator:function(t){var e,n;return e={},r("next"),r("throw",(function(t){throw t})),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,i){e[r]=t[r]?function(e){return(n=!n)?{value:Fu(t[r](e)),done:"return"===r}:i?i(e):e}:i}},__asyncValues:function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=Ru(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,i){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,i,(e=t[n](e)).done,e.value)}))}}},__makeTemplateObject:function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t},__importStar:function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e},__importDefault:function(t){return t&&t.__esModule?t:{default:t}},__classPrivateFieldGet:function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},__classPrivateFieldSet:function(t,e,n){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,n),n}}),Nu=function(){function t(e,n){if(void 0===n&&(n=null),this.nonEmpty=!1,e||n){if(!e)throw new Error("Parameter head cannot be null.");this.head=e,this.tail=n||t.NIL,this.nonEmpty=!0}else{if(t.NIL)throw new Error("Parameters head and tail are null. Use the NIL element instead.");this.nonEmpty=!1}}return Object.defineProperty(t.prototype,"length",{get:function(){if(!this.nonEmpty)return 0;if(this.tail===t.NIL)return 1;for(var e=0,n=this;n.nonEmpty;)++e,n=n.tail;return e},enumerable:!0,configurable:!0}),t.prototype.prepend=function(e){return new t(e,this)},t.prototype.append=function(e){if(!e)return this;if(!this.nonEmpty)return new t(e);if(this.tail===t.NIL)return new t(e).prepend(this.head);for(var n=new t(this.head),r=n,i=this.tail;i.nonEmpty;)r=r.tail=new t(i.head),i=i.tail;return r.tail=new t(e),n},t.prototype.insertWithPriority=function(e){if(!this.nonEmpty)return new t(e);var n=e.priority;if(n>this.head.priority)return this.prepend(e);for(var r=new t(this.head),i=r,s=this.tail;s.nonEmpty;){if(n>s.head.priority)return i.tail=s.prepend(e),r;i=i.tail=new t(s.head),s=s.tail}return i.tail=new t(e),r},t.prototype.filterNot=function(e){if(!this.nonEmpty||null==e)return this;if(e===this.head.listener)return this.tail;for(var n=new t(this.head),r=n,i=this.tail;i.nonEmpty;){if(i.head.listener===e)return r.tail=i.tail,n;r=r.tail=new t(i.head),i=i.tail}return this},t.prototype.contains=function(t){if(!this.nonEmpty)return!1;for(var e=this;e.nonEmpty;){if(e.head.listener===t)return!0;e=e.tail}return!1},t.prototype.find=function(t){if(!this.nonEmpty)return null;for(var e=this;e.nonEmpty;){if(e.head.listener===t)return e.head;e=e.tail}return null},t.prototype.toString=function(){for(var t="",e=this;e.nonEmpty;)t+=e.head+" -> ",e=e.tail;return"[List "+(t+="NIL")+"]"},t.NIL=new t(null,null),t}(),Ou=Object.defineProperty({SlotList:Nu},"__esModule",{value:!0}),Uu=function(){function t(t,e,n,r){void 0===n&&(n=!1),void 0===r&&(r=0),this._enabled=!0,this._once=!1,this._priority=0,this._listener=t,this._once=n,this._signal=e,this._priority=r,this.verifyListener(t)}return t.prototype.execute0=function(){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,this._params):this._listener())},t.prototype.execute1=function(t){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,[t].concat(this._params)):this._listener(t))},t.prototype.execute=function(t){if(this._enabled){this._once&&this.remove(),this._params&&this._params.length&&(t=t.concat(this._params));var e=t.length;0===e?this._listener():1===e?this._listener(t[0]):2===e?this._listener(t[0],t[1]):3===e?this._listener(t[0],t[1],t[2]):this._listener.apply(null,t)}},Object.defineProperty(t.prototype,"listener",{get:function(){return this._listener},set:function(t){if(null==t)throw new Error("Given listener is null.\nDid you want to set enabled to false instead?");this.verifyListener(t),this._listener=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"once",{get:function(){return this._once},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return this._priority},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return"[Slot listener: "+this._listener+", once: "+this._once+", priority: "+this._priority+", enabled: "+this._enabled+"]"},Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this._enabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"params",{get:function(){return this._params},set:function(t){this._params=t},enumerable:!0,configurable:!0}),t.prototype.remove=function(){this._signal.remove(this._listener)},t.prototype.verifyListener=function(t){if(null==t)throw new Error("Given listener is null.");if(null==this._signal)throw new Error("Internal signal reference has not been set yet.")},t}(),Bu=Object.defineProperty({Slot:Uu},"__esModule",{value:!0}),zu=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.slots=Ou.SlotList.NIL,this.valueClasses=1===t.length&&t[0]instanceof Array?t[0]:t}return Object.defineProperty(t.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(t){this._valueClasses=t?t.slice():[];for(var e=this._valueClasses.length;e--;)if(!(this._valueClasses[e]instanceof Object))throw new Error("Invalid valueClasses argument: item at index "+e+" should be a Class but was:<"+this._valueClasses[e]+">."+this._valueClasses[e])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numListeners",{get:function(){return this.slots.length},enumerable:!0,configurable:!0}),t.prototype.addOnce=function(t){return this.registerListener(t,!0)},t.prototype.remove=function(t){var e=this.slots.find(t);return e?(this.slots=this.slots.filterNot(t),e):null},t.prototype.removeAll=function(){this.slots=Ou.SlotList.NIL},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this._valueClasses.length,r=t.length;if(r<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+r+".");for(var i=0;i<n;i++)if(!(null===t[i]||t[i]instanceof this._valueClasses[i]||t[i].constructor===this._valueClasses[i]))throw new Error("Value object <"+t[i]+"> is not an instance of <"+this._valueClasses[i]+">.");var s=this.slots;if(s.nonEmpty)for(;s.nonEmpty;)s.head.execute(t),s=s.tail},t.prototype.registerListener=function(t,e){if(void 0===e&&(e=!1),this.registrationPossible(t,e)){var n=new Bu.Slot(t,this,e);return this.slots=this.slots.prepend(n),n}return this.slots.find(t)},t.prototype.registrationPossible=function(t,e){if(!this.slots.nonEmpty)return!0;var n=this.slots.find(t);if(!n)return!0;if(n.once!==e)throw new Error("You cannot addOnce() then add() the same listener without removing the relationship first.");return!1},t}(),ku=Object.defineProperty({OnceSignal:zu},"__esModule",{value:!0}),Hu="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Gu(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}function ju(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.')}var Vu=Gu(Du),Wu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Vu.__extends(e,t),e.prototype.add=function(t){return this.registerListener(t)},e}(ku.OnceSignal),Xu=Object.defineProperty({Signal:Wu},"__esModule",{value:!0}),Yu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Vu.__extends(e,t),e.prototype.addWithPriority=function(t,e){return void 0===e&&(e=0),this.registerListenerWithPriority(t,!1,e)},e.prototype.addOnceWithPriority=function(t,e){return void 0===e&&(e=0),this.registerListenerWithPriority(t,!0,e)},e.prototype.registerListener=function(t,e){return void 0===e&&(e=!1),this.registerListenerWithPriority(t,e)},e.prototype.registerListenerWithPriority=function(t,e,n){if(void 0===n&&(n=0),this.registrationPossible(t,e)){var r=new Bu.Slot(t,this,e,n);return this.slots=this.slots.insertWithPriority(r),r}return this.slots.find(t)},e}(Xu.Signal),qu=Object.defineProperty({PrioritySignal:Yu},"__esModule",{value:!0}),Qu=function(t){function e(e){void 0===e&&(e=null);for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this;return n=1===n.length&&n[0]instanceof Array?n[0]:n,(i=t.call(this,n)||this)._target=e,i}return Vu.__extends(e,t),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(t){t!==this._target&&(this.removeAll(),this._target=t)},enumerable:!0,configurable:!0}),e.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this._valueClasses.length,r=t.length;if(r<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+r+".");for(var i=0;i<n;i++)if(null!==t[i]&&t[i].constructor!==this._valueClasses[i])throw new Error("Value object <"+t[i]+"> is not an instance of <"+this._valueClasses[i]+">.");var s=t[0];s&&(s.target&&(s=s.clone(),t[0]=s),s.target=this.target,s.currentTarget=this.target,s.signal=this);for(var a=this.slots;a.nonEmpty;)a.head.execute(t),a=a.tail;if(s&&s.bubbles)for(var o=this.target;o&&o.hasOwnProperty("parent")&&(null===(o=o.parent).onEventBubbled||(s.currentTarget=o,o.onEventBubbled(s))););},e}(qu.PrioritySignal),Zu=Object.defineProperty({DeluxeSignal:Qu},"__esModule",{value:!0}),Ju=function(){function t(t){void 0===t&&(t=!1),this._bubbles=t}return Object.defineProperty(t.prototype,"signal",{get:function(){return this._signal},set:function(t){this._signal=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(t){this._target=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentTarget",{get:function(){return this._currentTarget},set:function(t){this._currentTarget=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bubbles",{get:function(){return this._bubbles},set:function(t){this._bubbles=t},enumerable:!0,configurable:!0}),t.prototype.clone=function(){return new t(this._bubbles)},t}(),Ku=Object.defineProperty({GenericEvent:Ju},"__esModule",{value:!0}),$u=Symbol("IOnceSignal"),td=Object.defineProperty({IOnceSignal:$u},"__esModule",{value:!0}),ed=Symbol("IPrioritySignal"),nd=Object.defineProperty({IPrioritySignal:ed},"__esModule",{value:!0}),rd=Symbol("ISignal"),id=Object.defineProperty({ISignal:rd},"__esModule",{value:!0}),sd=Symbol("ISlot"),ad=Object.defineProperty({ISlot:sd},"__esModule",{value:!0}),od=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.valueClasses=1===t.length&&t[0]instanceof Array?t[0]:t}return Object.defineProperty(t.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(t){this._valueClasses=t?t.slice():[];for(var e=this._valueClasses.length;e--;)if("function"!=typeof this._valueClasses[e])throw new Error("Invalid valueClasses argument: item at index "+e+" should be a Class but was:<"+this._valueClasses[e]+"'>."+this._valueClasses[e])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numListeners",{get:function(){return this.slot?1:0},enumerable:!0,configurable:!0}),t.prototype.add=function(t){return this.registerListener(t)},t.prototype.addOnce=function(t){return this.registerListener(t,!0)},t.prototype.remove=function(t){if(this.slot&&this.slot.listener===t){var e=this.slot;return this.slot=null,e}return null},t.prototype.removeAll=function(){this.slot&&this.slot.remove()},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this._valueClasses.length,r=t.length;if(r<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+r+".");for(var i=0;i<n;i++)if(!(null===t[i]||t[i]instanceof this._valueClasses[i]||t[i].constructor===this._valueClasses[i]))throw new Error("Value object <"+t[i]+"> is not an instance of <"+this._valueClasses[i]+">.");this.slot&&this.slot.execute(t)},t.prototype.registerListener=function(t,e){if(void 0===e&&(e=!1),this.slot)throw new Error("You cannot add or addOnce with a listener already added, remove the current listener first.");return this.slot=new Bu.Slot(t,this,e)},t}(),ld=Object.defineProperty({MonoSignal:od},"__esModule",{value:!0}),cd=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Vu.__extends(e,t),e.prototype.addOnce=function(e){var n=t.prototype.addOnce.call(this,e);return this.isDispatched&&(n.execute(this.valueObjects),n.remove()),n},e.prototype.dispatch=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.isDispatched)throw new Error("You cannot dispatch() a Promise more than once");this.isDispatched=!0,this.valueObjects=e,t.prototype.dispatch.apply(this,e)},e}(ku.OnceSignal),hd=Object.defineProperty({Promise:cd},"__esModule",{value:!0});Zu.DeluxeSignal,Ku.GenericEvent,td.IOnceSignal,nd.IPrioritySignal,id.ISignal,ad.ISlot,ld.MonoSignal,ku.OnceSignal,qu.PrioritySignal,hd.Promise;var ud=Xu.Signal;Bu.Slot,Ou.SlotList;const dd=new es;dd.name="Scene";class pd{constructor(t){this.signals=t,this.scene=dd.clone(),this.scene.castShadow=!0,this.scene.receiveShadow=!0,this.selectedObjects={edge:[],stroke:[],opacity:[],highlight:[],emissive:[]},this.intersectsList={meshOfModelList:[],poiIconList:[],otherObjList:[],getAll:function(){return[...this.meshOfModelList,...this.poiIconList,...this.otherObjList]}}}addObject(t,e){e?e.add(t):this.scene.add(t),this._triggerObjectAdded(t),this.signals.objectAdded.dispatch(t)}removeObject(t){var e;function n(t){var e;t instanceof No&&((e=t.map)&&e.isTexture&&e.dispose()),t.dispose()}t.traverse((t=>{if("Mesh"===t.type){const e=t;e.geometry.dispose(),Ph(e.material)?e.material.forEach((t=>n(t))):e.material instanceof No&&n(e.material)}t instanceof Eu&&t.element.remove();const{meshOfModelList:e,poiIconList:r,otherObjList:i}=this.intersectsList,s=e.findIndex((e=>e.uuid===t.uuid)),a=r.findIndex((e=>e.uuid===t.uuid)),o=i.findIndex((e=>e.uuid===t.uuid));s>-1&&this.intersectsList.meshOfModelList.splice(s,1),a>-1&&this.intersectsList.poiIconList.splice(a,1),o>-1&&this.intersectsList.otherObjList.splice(o,1)})),null===(e=t.parent)||void 0===e||e.remove(t),this.signals.objectRemoved.dispatch()}openSceneFog(t={}){const{color:e=13426943,near:n=500,far:r=5e4}=t;this.scene.fog=new ts(e,n,r),this.signals.sceneChanged.dispatch()}closeSceneFog(){this.scene.fog=null,this.signals.sceneChanged.dispatch()}edgeShow(t,e){const n=[],r=t=>{-1===this.selectedObjects.edge.findIndex((e=>e.uuid===t.uuid))&&n.push(t)};return Ph(t)?t.forEach((t=>r(t))):Ch(t)&&r(t),this.selectedObjects.edge=[...this.selectedObjects.edge,...n],this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge,options:e}),Promise.resolve()}unEdgeShow(t){t||(t=[...this.selectedObjects.edge]);const e=t=>{const e=this.selectedObjects.edge.findIndex((e=>e.uuid===t.uuid));return-1===e||(this.selectedObjects.edge.splice(e,1),this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge})),Promise.resolve()};return Ph(t)?Promise.all(t.map((t=>e(t)))):Ch(t)?e(t):Promise.resolve()}strokeShow(t,e={}){const{isOpacityShow:n=!0,color:r=4647927,opacity:i=.2,edgeColor:s=61183,edgeOpacity:a=1}=e,o=t=>{if(-1!==this.selectedObjects.stroke.findIndex((e=>e.sid===t.sid)))return Promise.resolve();if(t.userData.strokeGroup)return Promise.resolve();const e=new ru({id:t.sid});return t.traverse((t=>{if(t instanceof ke&&t.geometry){const n=new ya(t.geometry.clone(),89),r=new Zs(n,new Hs({color:s,transparent:!0,opacity:a}));gh(r,t),e.add(r)}})),t.userData.strokeGroup=e,this.addObject(e),this.selectedObjects.stroke.push(t),Promise.resolve()};return n&&this.opacityShow(t,{color:r,opacity:i}),Ph(t)?Promise.all(t.map((t=>o(t)))):Ch(t)?o(t):Promise.resolve()}unStrokeShow(t){t||(t=[...this.selectedObjects.stroke]);const e=t=>{if(!t.userData.strokeGroup)return Promise.resolve();this.removeObject(t.userData.strokeGroup),Reflect.deleteProperty(t.userData,"strokeGroup");const e=this.selectedObjects.stroke.findIndex((e=>e.sid===t.sid));return-1===e||(this.selectedObjects.stroke.splice(e,1),this.signals.geometryChanged.dispatch(),this.unOpacityShow(t)),Promise.resolve()};return Ph(t)?Promise.all(t.map((t=>e(t)))):Ch(t)?e(t):Promise.resolve()}opacityShow(t,e={}){const{color:n="#fff",opacity:r=.8}=e;function i(t){if(t.userData.material)return t;const e=t.clone();return(t=Reflect.construct(t.constructor,[{transparent:!0,color:n,opacity:r}])).userData.material=e,t}const s=t=>(-1!==this.selectedObjects.opacity.findIndex((e=>e.uuid===t.uuid))||(t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach(((e,n)=>{t.material[n]=i(e)})):t.material instanceof Yt&&(t.material=i(t.material)))})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(t)),Promise.resolve());return Ph(t)?Promise.all(t.map((t=>s(t)))):Ch(t)?s(t):Promise.resolve()}unOpacityShow(t){function e(t){if(!t.userData.material)return t;const e=t.userData.material.clone();return t.userData={},e}t||(t=[...this.selectedObjects.opacity]);const n=t=>new Promise((n=>{const r=this.selectedObjects.opacity.findIndex((e=>e.uuid===t.uuid));-1===r&&n(),this.selectedObjects.opacity.splice(r,1),t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach(((n,r)=>{t.material[r]=e(n)})):t.material instanceof Yt&&(t.material=e(t.material)))})),this.signals.materialChanged.dispatch(),n()}));return Ph(t)?Promise.all(t.map((t=>n(t)))):Ch(t)?n(t):Promise.resolve()}highlightShow(t,e={}){const{color:n="red",opacity:r=1}=e;function i(t){if(t instanceof No||t instanceof Fo){if(t.userData.color&&t.userData.opacity)return;t.userData={color:t.color.clone(),opacity:t.opacity,transparent:t.transparent},t.color=new te(n),t.opacity=r,t.transparent=!0}}const s=t=>(-1!==this.selectedObjects.highlight.findIndex((e=>e.uuid===t.uuid))||(t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>i(t))):t.material instanceof Yt&&i(t.material))})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(t)),Promise.resolve());return Ph(t)?Promise.all(t.map((t=>s(t)))):Ch(t)?s(t):Promise.resolve()}unHighlightShow(t){function e(t){if(t instanceof No||t instanceof Fo){if(!t.userData.color&&!t.userData.opacity)return;t.color=t.userData.color,t.opacity=t.userData.opacity,t.transparent=t.userData.transparent,t.userData={}}}t||(t=[...this.selectedObjects.highlight]);const n=t=>new Promise((n=>{const r=this.selectedObjects.highlight.findIndex((e=>e.uuid===t.uuid));-1===r&&n(),this.selectedObjects.highlight.splice(r,1),t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>e(t))):t.material instanceof Yt&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Ph(t)?Promise.all(t.map((t=>n(t)))):Ch(t)?n(t):Promise.resolve()}emissiveShow(t,e={}){const{color:n="red",opacity:r=.3,maxOpacity:i=1,minOpacity:s=0,duration:a=1e3}=e;function o(t){if(t instanceof No||t instanceof Fo){if(t.userData.emissive&&t.userData.opacity)return;t.userData={emissive:t.emissive.clone(),opacity:t.emissiveIntensity,animation:null},t.emissive.set(n),t.emissiveIntensity=r,$h({emissiveIntensity:i},{emissiveIntensity:s},{duration:a,repeat:!0},(e=>t.emissiveIntensity=e.emissiveIntensity),(e=>t.userData.animation=e))}}const l=t=>(-1!==this.selectedObjects.emissive.findIndex((e=>e.uuid===t.uuid))||(t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>o(t))):t.material instanceof Yt&&o(t.material))})),this.selectedObjects.emissive.push(t),this.signals.materialChanged.dispatch()),Promise.resolve());return Ph(t)?Promise.all(t.map((t=>l(t)))):Ch(t)?l(t):Promise.resolve()}unEmissiveShow(t){function e(t){var e;if(t instanceof No||t instanceof Fo){if(!t.userData.emissive&&!t.userData.opacity)return;t.emissive=t.userData.emissive.clone(),t.emissiveIntensity=t.userData.opacity,null===(e=t.userData.animation)||void 0===e||e.stop(),t.userData={}}}t||(t=[...this.selectedObjects.emissive]);const n=t=>new Promise((n=>{const r=this.selectedObjects.emissive.findIndex((e=>e.uuid===t.uuid));-1===r&&n(),this.selectedObjects.emissive.splice(r,1),t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>e(t))):t.material instanceof Yt&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Ph(t)?Promise.all(t.map((t=>n(t)))):Ch(t)?n(t):Promise.resolve()}_triggerObjectAdded(t){if(t instanceof eu)if("Sbm"===t.stype||"Model"===t.stype)t.traverse((t=>{if(t instanceof ke){-1===this.intersectsList.meshOfModelList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.meshOfModelList.push(t)}}));else if("Poi"===t.stype){-1===this.intersectsList.poiIconList.findIndex((e=>e.uuid===t.icon.uuid))&&this.intersectsList.meshOfModelList.push(t.icon)}else if("BaseMesh"===t.stype){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}else"Group"===t.stype?t.children.forEach((t=>this._triggerObjectAdded(t))):"Object3D"===t.type&&t.traverse((t=>{if(t instanceof ke){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}));else if(t instanceof tu){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}}class fd{constructor(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}const md=new yn(-1,1,1,-1,0,1),gd=new we;gd.setAttribute("position",new pe([-1,3,0,-1,-1,0,3,-1,0],3)),gd.setAttribute("uv",new pe([0,2,0,0,2,0],2));class vd{constructor(t){this._mesh=new ke(gd,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,md)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}const yd={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},tDiffuse:{value:null},tNormal:{value:null},size:{value:new g(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new ct},cameraInverseProjectionMatrix:{value:new ct},scale:{value:1},intensity:{value:.1},bias:{value:.5},minResolution:{value:0},kernelRadius:{value:100},randomSeed:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include <common>\n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform sampler2D tDepth;\n\n\t\t#if NORMAL_TEXTURE == 1\n\t\tuniform sampler2D tNormal;\n\t\t#endif\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include <packing>\n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\t#if NORMAL_TEXTURE == 1\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t\t#else\n\t\t\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},xd={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new g(512,512)},sampleUvOffsets:{value:[new g(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include <common>\n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},_d={createSampleWeights:function(t,e){const n=[];for(let r=0;r<=t;r++)n.push(bd(r,e));return n},createSampleOffsets:function(t,e){const n=[];for(let r=0;r<=t;r++)n.push(e.clone().multiplyScalar(r));return n},configure:function(t,e,n,r){t.defines.KERNEL_RADIUS=e,t.uniforms.sampleUvOffsets.value=_d.createSampleOffsets(e,r),t.uniforms.sampleWeights.value=_d.createSampleWeights(e,n),t.needsUpdate=!0}};function bd(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}var wd={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\t\t}"};const Md={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include <packing>\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );\n\t\t\tgl_FragColor = vec4( vec3( depth ), opacity );\n\n\t\t}"};class Sd extends fd{constructor(t,e,n=!1,r=!1,i=new g(256,256)){let s;super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=r,this.originalClearColor=new te,this._oldClearColor=new te,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new g(i.x,i.y),this.saoRenderTarget=new P(this.resolution.x,this.resolution.y,{minFilter:1006,magFilter:1006,format:1023}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new P(this.resolution.x,this.resolution.y,{minFilter:1003,magFilter:1003,format:1023}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(s=new qi,s.type=1012,this.beautyRenderTarget.depthTexture=s,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Bi,this.depthMaterial.depthPacking=3201,this.depthMaterial.blending=0,this.normalMaterial=new Uo,this.normalMaterial.blending=0,void 0===yd&&console.error("THREE.SAOPass relies on SAOShader"),this.saoMaterial=new Xe({defines:Object.assign({},yd.defines),fragmentShader:yd.fragmentShader,vertexShader:yd.vertexShader,uniforms:We.clone(yd.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?s:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=0,void 0===xd&&console.error("THREE.SAOPass relies on DepthLimitedBlurShader"),this.vBlurMaterial=new Xe({uniforms:We.clone(xd.uniforms),defines:Object.assign({},xd.defines),vertexShader:xd.vertexShader,fragmentShader:xd.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?s:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=0,this.hBlurMaterial=new Xe({uniforms:We.clone(xd.uniforms),defines:Object.assign({},xd.defines),vertexShader:xd.vertexShader,fragmentShader:xd.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?s:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=0,void 0===wd&&console.error("THREE.SAOPass relies on CopyShader"),this.materialCopy=new Xe({uniforms:We.clone(wd.uniforms),vertexShader:wd.vertexShader,fragmentShader:wd.fragmentShader,blending:0}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=5,this.materialCopy.blendSrc=208,this.materialCopy.blendDst=200,this.materialCopy.blendEquation=100,this.materialCopy.blendSrcAlpha=206,this.materialCopy.blendDstAlpha=200,this.materialCopy.blendEquationAlpha=100,void 0===Md&&console.error("THREE.SAOPass relies on UnpackDepthRGBAShader"),this.depthCopy=new Xe({uniforms:We.clone(Md.uniforms),vertexShader:Md.vertexShader,fragmentShader:Md.fragmentShader,blending:0}),this.fsQuad=new vd(null)}render(t,e,n){if(this.renderToScreen&&(this.materialCopy.blending=0,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(t,this.materialCopy,null)),1===this.params.output)return;t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const r=t.autoClear;t.autoClear=!1,t.setRenderTarget(this.depthRenderTarget),t.clear(),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;const i=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=i,this.hBlurMaterial.uniforms.depthCutoff.value=i,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(_d.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new g(0,1)),_d.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new g(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),t.setClearColor(0),t.setRenderTarget(this.beautyRenderTarget),t.clear(),t.render(this.scene,this.camera),this.supportsDepthTextureExtension||this.renderOverride(t,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(t,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(t,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(t,this.hBlurMaterial,this.saoRenderTarget,16777215,1));let s=this.materialCopy;3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,s=this.depthCopy):4===this.params.output?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?s.blending=5:s.blending=0,this.renderPass(t,s,this.renderToScreen?null:n),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=r}renderPass(t,e,n,r,i){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=r&&(t.setClearColor(r),t.setClearAlpha(i||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,r,i){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,r=e.clearColor||r,i=e.clearAlpha||i,null!=r&&(t.setClearColor(r),t.setClearAlpha(i||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}setSize(t,e){this.beautyRenderTarget.setSize(t,e),this.saoRenderTarget.setSize(t,e),this.blurIntermediateRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.depthRenderTarget.setSize(t,e),this.saoMaterial.uniforms.size.value.set(t,e),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(t,e),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(t,e),this.hBlurMaterial.needsUpdate=!0}}Sd.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};class Td extends fd{constructor(t,e,n,r,i){super(),this.scene=t,this.camera=e,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new te}render(t,e,n){const r=t.autoClear;let i,s;t.autoClear=!1,void 0!==this.overrideMaterial&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(t.getClearColor(this._oldClearColor),i=t.getClearAlpha(),t.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:n),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor&&t.setClearColor(this._oldClearColor,i),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=s),t.autoClear=r}}class Ad extends fd{constructor(t,e){super(),this.textureID=void 0!==e?e:"tDiffuse",t instanceof Xe?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=We.clone(t.uniforms),this.material=new Xe({defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new vd(this.material)}render(t,e,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}}class Ed extends fd{constructor(t,e,n,r){super(),this.renderScene=e,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new te(1,1,1),this.hiddenEdgeColor=new te(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this.resolution=void 0!==t?new g(t.x,t.y):new g(256,256);const i={minFilter:1006,magFilter:1006,format:1023},s=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.maskBufferMaterial=new ee({color:16777215}),this.maskBufferMaterial.side=2,this.renderTargetMaskBuffer=new P(this.resolution.x,this.resolution.y,i),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Bi,this.depthMaterial.side=2,this.depthMaterial.depthPacking=3201,this.depthMaterial.blending=0,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(t,e){var n=e.isPerspectiveCamera?"perspective":"orthographic";return t.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new P(this.resolution.x,this.resolution.y,i),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new P(s,a,i),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new P(s,a,i),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new P(Math.round(s/2),Math.round(a/2),i),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new P(s,a,i),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new P(Math.round(s/2),Math.round(a/2),i),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;this.separableBlurMaterial1=this.getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(s,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(s/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial(),void 0===wd&&console.error("THREE.OutlinePass relies on CopyShader");const o=wd;this.copyUniforms=We.clone(o.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Xe({uniforms:this.copyUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new te,this.oldClearAlpha=1,this.fsQuad=new vd(null),this.tempPulseColor1=new te,this.tempPulseColor2=new te,this.textureMatrix=new ct}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()}setSize(t,e){this.renderTargetMaskBuffer.setSize(t,e),this.renderTargetDepthBuffer.setSize(t,e);let n=Math.round(t/this.downSampleRatio),r=Math.round(e/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,r),this.renderTargetBlurBuffer1.setSize(n,r),this.renderTargetEdgeBuffer1.setSize(n,r),this.separableBlurMaterial1.uniforms.texSize.value.set(n,r),n=Math.round(n/2),r=Math.round(r/2),this.renderTargetBlurBuffer2.setSize(n,r),this.renderTargetEdgeBuffer2.setSize(n,r),this.separableBlurMaterial2.uniforms.texSize.value.set(n,r)}changeVisibilityOfSelectedObjects(t){const e=this._visibilityCache;function n(n){n.isMesh&&(!0===t?n.visible=e.get(n):(e.set(n,n.visible),n.visible=t))}for(let t=0;t<this.selectedObjects.length;t++){this.selectedObjects[t].traverse(n)}}changeVisibilityOfNonSelectedObjects(t){const e=this._visibilityCache,n=[];function r(t){t.isMesh&&n.push(t)}for(let t=0;t<this.selectedObjects.length;t++){this.selectedObjects[t].traverse(r)}this.renderScene.traverse((function(r){if(r.isMesh||r.isSprite){let i=!1;for(let t=0;t<n.length;t++){if(n[t].id===r.id){i=!0;break}}if(!1===i){const n=r.visible;!1!==t&&!0!==e.get(r)||(r.visible=t),e.set(r,n)}}else(r.isPoints||r.isLine)&&(!0===t?r.visible=e.get(r):(e.set(r,r.visible),r.visible=t))}))}updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(t,e,n,r,i){if(this.selectedObjects.length>0){t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const e=t.autoClear;t.autoClear=!1,i&&t.state.buffers.stencil.setTest(!1),t.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);const r=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,t.setRenderTarget(this.renderTargetDepthBuffer),t.clear(),t.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,t.setRenderTarget(this.renderTargetMaskBuffer),t.clear(),t.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=r,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,t.setRenderTarget(this.renderTargetMaskDownSampleBuffer),t.clear(),this.fsQuad.render(t),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const t=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(t),this.tempPulseColor2.multiplyScalar(t)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,t.setRenderTarget(this.renderTargetEdgeBuffer1),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Ed.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,t.setRenderTarget(this.renderTargetBlurBuffer1),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Ed.BlurDirectionY,t.setRenderTarget(this.renderTargetEdgeBuffer1),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Ed.BlurDirectionX,t.setRenderTarget(this.renderTargetBlurBuffer2),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Ed.BlurDirectionY,t.setRenderTarget(this.renderTargetEdgeBuffer2),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,i&&t.state.buffers.stencil.setTest(!0),t.setRenderTarget(n),this.fsQuad.render(t),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=e}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,t.setRenderTarget(null),this.fsQuad.render(t))}getPrepareMaskMaterial(){return new Xe({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new g(.5,.5)},textureMatrix:{value:null}},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\t\t\t\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}getEdgeDetectionMaterial(){return new Xe({uniforms:{maskTexture:{value:null},texSize:{value:new g(.5,.5)},visibleEdgeColor:{value:new I(1,1,1)},hiddenEdgeColor:{value:new I(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}getSeperableBlurMaterial(t){return new Xe({defines:{MAX_RADIUS:t},uniforms:{colorTexture:{value:null},texSize:{value:new g(.5,.5)},direction:{value:new g(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}getOverlayMaterial(){return new Xe({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n\t\t\t\t}",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}Ed.BlurDirectionX=new g(1,0),Ed.BlurDirectionY=new g(0,1);class Pd extends fd{constructor(t,e,n,r){super(),this.scene=t,this.camera=e,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==r?r:0,this._oldClearColor=new te,void 0===wd&&console.error("THREE.SSAARenderPass relies on CopyShader");const i=wd;this.copyUniforms=We.clone(i.uniforms),this.copyMaterial=new Xe({uniforms:this.copyUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.fsQuad=new vd(this.copyMaterial)}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)}setSize(t,e){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(t,e)}render(t,e,n){this.sampleRenderTarget||(this.sampleRenderTarget=new P(n.width,n.height,{minFilter:1006,magFilter:1006,format:1023}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");const r=Cd[Math.max(0,Math.min(this.sampleLevel,5))],i=t.autoClear;t.autoClear=!1,t.getClearColor(this._oldClearColor);const s=t.getClearAlpha(),a=1/r.length;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture;const o={fullWidth:n.width,fullHeight:n.height,offsetX:0,offsetY:0,width:n.width,height:n.height},l=Object.assign({},this.camera.view);l.enabled&&Object.assign(o,l);for(let n=0;n<r.length;n++){const i=r[n];this.camera.setViewOffset&&this.camera.setViewOffset(o.fullWidth,o.fullHeight,o.offsetX+.0625*i[0],o.offsetY+.0625*i[1],o.width,o.height);let s=a;if(this.unbiased){s+=.03125*((n+.5)/r.length-.5)}this.copyUniforms.opacity.value=s,t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(this.renderToScreen?null:e),0===n&&(t.setClearColor(0,0),t.clear()),this.fsQuad.render(t)}this.camera.setViewOffset&&l.enabled?this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX,l.offsetY,l.width,l.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),t.autoClear=i,t.setClearColor(this._oldClearColor,s)}}const Cd=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],Ld={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new te(0)},defaultOpacity:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec3 defaultColor;\n\t\tuniform float defaultOpacity;\n\t\tuniform float luminosityThreshold;\n\t\tuniform float smoothWidth;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\n\t\t\tvec3 luma = vec3( 0.299, 0.587, 0.114 );\n\n\t\t\tfloat v = dot( texel.xyz, luma );\n\n\t\t\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n\t\t\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n\t\t\tgl_FragColor = mix( outputColor, texel, alpha );\n\n\t\t}"};class Rd extends fd{constructor(t,e,n,r){super(),this.strength=void 0!==e?e:1,this.radius=n,this.threshold=r,this.resolution=void 0!==t?new g(t.x,t.y):new g(256,256),this.clearColor=new te(0,0,0);const i={minFilter:1006,magFilter:1006,format:1023};this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let s=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new P(s,a,i),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let t=0;t<this.nMips;t++){const e=new P(s,a,i);e.texture.name="UnrealBloomPass.h"+t,e.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e);const n=new P(s,a,i);n.texture.name="UnrealBloomPass.v"+t,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),s=Math.round(s/2),a=Math.round(a/2)}void 0===Ld&&console.error("THREE.UnrealBloomPass relies on LuminosityHighPassShader");const o=Ld;this.highPassUniforms=We.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new Xe({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,defines:{}}),this.separableBlurMaterials=[];const l=[3,5,7,9,11];s=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let t=0;t<this.nMips;t++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(l[t])),this.separableBlurMaterials[t].uniforms.texSize.value=new g(s,a),s=Math.round(s/2),a=Math.round(a/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=e,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new I(1,1,1),new I(1,1,1),new I(1,1,1),new I(1,1,1),new I(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,void 0===wd&&console.error("THREE.UnrealBloomPass relies on CopyShader");const c=wd;this.copyUniforms=We.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Xe({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new te,this.oldClearAlpha=1,this.basic=new ee,this.fsQuad=new vd(null)}dispose(){for(let t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(let t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose()}setSize(t,e){let n=Math.round(t/2),r=Math.round(e/2);this.renderTargetBright.setSize(n,r);for(let t=0;t<this.nMips;t++)this.renderTargetsHorizontal[t].setSize(n,r),this.renderTargetsVertical[t].setSize(n,r),this.separableBlurMaterials[t].uniforms.texSize.value=new g(n,r),n=Math.round(n/2),r=Math.round(r/2)}render(t,e,n,r,i){t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const s=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),i&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,t.setRenderTarget(null),t.clear(),this.fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this.fsQuad.render(t);let a=this.renderTargetBright;for(let e=0;e<this.nMips;e++)this.fsQuad.material=this.separableBlurMaterials[e],this.separableBlurMaterials[e].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[e].uniforms.direction.value=Rd.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[e]),t.clear(),this.fsQuad.render(t),this.separableBlurMaterials[e].uniforms.colorTexture.value=this.renderTargetsHorizontal[e].texture,this.separableBlurMaterials[e].uniforms.direction.value=Rd.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[e]),t.clear(),this.fsQuad.render(t),a=this.renderTargetsVertical[e];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,i&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(n),this.fsQuad.render(t)),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=s}getSeperableBlurMaterial(t){return new Xe({defines:{KERNEL_RADIUS:t,SIGMA:t},uniforms:{colorTexture:{value:null},texSize:{value:new g(.5,.5)},direction:{value:new g(.5,.5)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat fSigma = float(SIGMA);\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(t){return new Xe({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform sampler2D dirtTexture;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}}Rd.BlurDirectionX=new g(1,0),Rd.BlurDirectionY=new g(0,1);class Id extends fd{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,n){const r=t.getContext(),i=t.state;let s,a;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0),this.inverse?(s=0,a=1):(s=1,a=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,s,4294967295),i.buffers.stencil.setClear(a),i.buffers.stencil.setLocked(!0),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}}class Fd extends fd{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class Dd{constructor(t,e){if(this.renderer=t,void 0===e){const n={minFilter:1006,magFilter:1006,format:1023},r=t.getSize(new g);this._pixelRatio=t.getPixelRatio(),this._width=r.width,this._height=r.height,(e=new P(this._width*this._pixelRatio,this._height*this._pixelRatio,n)).texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===wd&&console.error("THREE.EffectComposer relies on CopyShader"),void 0===Ad&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Ad(wd),this.clock=new ql}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){void 0===t&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let n=!1;for(let e=0,r=this.passes.length;e<r;e++){const r=this.passes[e];if(!1!==r.enabled){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(e),r.render(this.renderer,this.writeBuffer,this.readBuffer,t,n),r.needsSwap){if(n){const e=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(e.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),n.setFunc(e.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==Id&&(r instanceof Id?n=!0:r instanceof Fd&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new g);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let t=0;t<this.passes.length;t++)this.passes[t].setSize(n,r)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}}new yn(-1,1,1,-1,0,1);const Nd=new we;Nd.setAttribute("position",new pe([-1,3,0,-1,-1,0,3,-1,0],3)),Nd.setAttribute("uv",new pe([0,2,0,0,2,0],2));const Od={uniforms:{tDiffuse:{value:null},resolution:{value:new g(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:'\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\t#define FXAA_PC 1\n\t\t#define FXAA_GLSL_100 1\n\t\t#define FXAA_QUALITY_PRESET 12\n\n\t\t#define FXAA_GREEN_AS_LUMA 1\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_PC_CONSOLE\n\t\t\t\t//\n\t\t\t\t// The console algorithm for PC is included\n\t\t\t\t// for developers targeting really low spec machines.\n\t\t\t\t// Likely better to just run FXAA_PC, and use a really low preset.\n\t\t\t\t//\n\t\t\t\t#define FXAA_PC_CONSOLE 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_GLSL_120\n\t\t\t\t#define FXAA_GLSL_120 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_GLSL_130\n\t\t\t\t#define FXAA_GLSL_130 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_HLSL_3\n\t\t\t\t#define FXAA_HLSL_3 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_HLSL_4\n\t\t\t\t#define FXAA_HLSL_4 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_HLSL_5\n\t\t\t\t#define FXAA_HLSL_5 0\n\t\t#endif\n\t\t/*==========================================================================*/\n\t\t#ifndef FXAA_GREEN_AS_LUMA\n\t\t\t\t//\n\t\t\t\t// For those using non-linear color,\n\t\t\t\t// and either not able to get luma in alpha, or not wanting to,\n\t\t\t\t// this enables FXAA to run using green as a proxy for luma.\n\t\t\t\t// So with this enabled, no need to pack luma in alpha.\n\t\t\t\t//\n\t\t\t\t// This will turn off AA on anything which lacks some amount of green.\n\t\t\t\t// Pure red and blue or combination of only R and B, will get no AA.\n\t\t\t\t//\n\t\t\t\t// Might want to lower the settings for both,\n\t\t\t\t//\t\tfxaaConsoleEdgeThresholdMin\n\t\t\t\t//\t\tfxaaQualityEdgeThresholdMin\n\t\t\t\t// In order to insure AA does not get turned off on colors\n\t\t\t\t// which contain a minor amount of green.\n\t\t\t\t//\n\t\t\t\t// 1 = On.\n\t\t\t\t// 0 = Off.\n\t\t\t\t//\n\t\t\t\t#define FXAA_GREEN_AS_LUMA 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_EARLY_EXIT\n\t\t\t\t//\n\t\t\t\t// Controls algorithm\'s early exit path.\n\t\t\t\t// On PS3 turning this ON adds 2 cycles to the shader.\n\t\t\t\t// On 360 turning this OFF adds 10ths of a millisecond to the shader.\n\t\t\t\t// Turning this off on console will result in a more blurry image.\n\t\t\t\t// So this defaults to on.\n\t\t\t\t//\n\t\t\t\t// 1 = On.\n\t\t\t\t// 0 = Off.\n\t\t\t\t//\n\t\t\t\t#define FXAA_EARLY_EXIT 1\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_DISCARD\n\t\t\t\t//\n\t\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t\t//\n\t\t\t\t// 1 = Use discard on pixels which don\'t need AA.\n\t\t\t\t//\t\t For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t\t// 0 = Return unchanged color on pixels which don\'t need AA.\n\t\t\t\t//\n\t\t\t\t#define FXAA_DISCARD 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_FAST_PIXEL_OFFSET\n\t\t\t\t//\n\t\t\t\t// Used for GLSL 120 only.\n\t\t\t\t//\n\t\t\t\t// 1 = GL API supports fast pixel offsets\n\t\t\t\t// 0 = do not use fast pixel offsets\n\t\t\t\t//\n\t\t\t\t#ifdef GL_EXT_gpu_shader4\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_NV_gpu_shader5\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_ARB_gpu_shader5\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 1\n\t\t\t\t#endif\n\t\t\t\t#ifndef FXAA_FAST_PIXEL_OFFSET\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 0\n\t\t\t\t#endif\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_GATHER4_ALPHA\n\t\t\t\t//\n\t\t\t\t// 1 = API supports gather4 on alpha channel.\n\t\t\t\t// 0 = API does not support gather4 on alpha channel.\n\t\t\t\t//\n\t\t\t\t#if (FXAA_HLSL_5 == 1)\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_ARB_gpu_shader5\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_NV_gpu_shader5\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 1\n\t\t\t\t#endif\n\t\t\t\t#ifndef FXAA_GATHER4_ALPHA\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 0\n\t\t\t\t#endif\n\t\t#endif\n\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFXAA QUALITY - TUNING KNOBS\n\t\t------------------------------------------------------------------------------\n\t\tNOTE the other tuning knobs are now in the shader function inputs!\n\t\t============================================================================*/\n\t\t#ifndef FXAA_QUALITY_PRESET\n\t\t\t\t//\n\t\t\t\t// Choose the quality preset.\n\t\t\t\t// This needs to be compiled into the shader as it effects code.\n\t\t\t\t// Best option to include multiple presets is to\n\t\t\t\t// in each shader define the preset, then include this file.\n\t\t\t\t//\n\t\t\t\t// OPTIONS\n\t\t\t\t// -----------------------------------------------------------------------\n\t\t\t\t// 10 to 15 - default medium dither (10=fastest, 15=highest quality)\n\t\t\t\t// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)\n\t\t\t\t// 39\t\t\t - no dither, very expensive\n\t\t\t\t//\n\t\t\t\t// NOTES\n\t\t\t\t// -----------------------------------------------------------------------\n\t\t\t\t// 12 = slightly faster then FXAA 3.9 and higher edge quality (default)\n\t\t\t\t// 13 = about same speed as FXAA 3.9 and better than 12\n\t\t\t\t// 23 = closest to FXAA 3.9 visually and performance wise\n\t\t\t\t//\t_ = the lowest digit is directly related to performance\n\t\t\t\t// _\t= the highest digit is directly related to style\n\t\t\t\t//\n\t\t\t\t#define FXAA_QUALITY_PRESET 12\n\t\t#endif\n\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - PRESETS\n\n\t\t============================================================================*/\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - MEDIUM DITHER PRESETS\n\t\t============================================================================*/\n\t\t#if (FXAA_QUALITY_PRESET == 10)\n\t\t\t\t#define FXAA_QUALITY_PS 3\n\t\t\t\t#define FXAA_QUALITY_P0 1.5\n\t\t\t\t#define FXAA_QUALITY_P1 3.0\n\t\t\t\t#define FXAA_QUALITY_P2 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 11)\n\t\t\t\t#define FXAA_QUALITY_PS 4\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 3.0\n\t\t\t\t#define FXAA_QUALITY_P3 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 12)\n\t\t\t\t#define FXAA_QUALITY_PS 5\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 4.0\n\t\t\t\t#define FXAA_QUALITY_P4 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 13)\n\t\t\t\t#define FXAA_QUALITY_PS 6\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 4.0\n\t\t\t\t#define FXAA_QUALITY_P5 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 14)\n\t\t\t\t#define FXAA_QUALITY_PS 7\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 4.0\n\t\t\t\t#define FXAA_QUALITY_P6 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 15)\n\t\t\t\t#define FXAA_QUALITY_PS 8\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 4.0\n\t\t\t\t#define FXAA_QUALITY_P7 12.0\n\t\t#endif\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - LOW DITHER PRESETS\n\t\t============================================================================*/\n\t\t#if (FXAA_QUALITY_PRESET == 20)\n\t\t\t\t#define FXAA_QUALITY_PS 3\n\t\t\t\t#define FXAA_QUALITY_P0 1.5\n\t\t\t\t#define FXAA_QUALITY_P1 2.0\n\t\t\t\t#define FXAA_QUALITY_P2 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 21)\n\t\t\t\t#define FXAA_QUALITY_PS 4\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 22)\n\t\t\t\t#define FXAA_QUALITY_PS 5\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 23)\n\t\t\t\t#define FXAA_QUALITY_PS 6\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 24)\n\t\t\t\t#define FXAA_QUALITY_PS 7\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 3.0\n\t\t\t\t#define FXAA_QUALITY_P6 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 25)\n\t\t\t\t#define FXAA_QUALITY_PS 8\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 4.0\n\t\t\t\t#define FXAA_QUALITY_P7 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 26)\n\t\t\t\t#define FXAA_QUALITY_PS 9\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 4.0\n\t\t\t\t#define FXAA_QUALITY_P8 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 27)\n\t\t\t\t#define FXAA_QUALITY_PS 10\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 4.0\n\t\t\t\t#define FXAA_QUALITY_P9 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 28)\n\t\t\t\t#define FXAA_QUALITY_PS 11\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 2.0\n\t\t\t\t#define FXAA_QUALITY_P9 4.0\n\t\t\t\t#define FXAA_QUALITY_P10 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 29)\n\t\t\t\t#define FXAA_QUALITY_PS 12\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 2.0\n\t\t\t\t#define FXAA_QUALITY_P9 2.0\n\t\t\t\t#define FXAA_QUALITY_P10 4.0\n\t\t\t\t#define FXAA_QUALITY_P11 8.0\n\t\t#endif\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - EXTREME QUALITY\n\t\t============================================================================*/\n\t\t#if (FXAA_QUALITY_PRESET == 39)\n\t\t\t\t#define FXAA_QUALITY_PS 12\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.0\n\t\t\t\t#define FXAA_QUALITY_P2 1.0\n\t\t\t\t#define FXAA_QUALITY_P3 1.0\n\t\t\t\t#define FXAA_QUALITY_P4 1.0\n\t\t\t\t#define FXAA_QUALITY_P5 1.5\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 2.0\n\t\t\t\t#define FXAA_QUALITY_P9 2.0\n\t\t\t\t#define FXAA_QUALITY_P10 4.0\n\t\t\t\t#define FXAA_QUALITY_P11 8.0\n\t\t#endif\n\n\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAPI PORTING\n\n\t\t============================================================================*/\n\t\t#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)\n\t\t\t\t#define FxaaBool bool\n\t\t\t\t#define FxaaDiscard discard\n\t\t\t\t#define FxaaFloat float\n\t\t\t\t#define FxaaFloat2 vec2\n\t\t\t\t#define FxaaFloat3 vec3\n\t\t\t\t#define FxaaFloat4 vec4\n\t\t\t\t#define FxaaHalf float\n\t\t\t\t#define FxaaHalf2 vec2\n\t\t\t\t#define FxaaHalf3 vec3\n\t\t\t\t#define FxaaHalf4 vec4\n\t\t\t\t#define FxaaInt2 ivec2\n\t\t\t\t#define FxaaSat(x) clamp(x, 0.0, 1.0)\n\t\t\t\t#define FxaaTex sampler2D\n\t\t#else\n\t\t\t\t#define FxaaBool bool\n\t\t\t\t#define FxaaDiscard clip(-1)\n\t\t\t\t#define FxaaFloat float\n\t\t\t\t#define FxaaFloat2 float2\n\t\t\t\t#define FxaaFloat3 float3\n\t\t\t\t#define FxaaFloat4 float4\n\t\t\t\t#define FxaaHalf half\n\t\t\t\t#define FxaaHalf2 half2\n\t\t\t\t#define FxaaHalf3 half3\n\t\t\t\t#define FxaaHalf4 half4\n\t\t\t\t#define FxaaSat(x) saturate(x)\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_GLSL_100 == 1)\n\t\t\t#define FxaaTexTop(t, p) texture2D(t, p, 0.0)\n\t\t\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_GLSL_120 == 1)\n\t\t\t\t// Requires,\n\t\t\t\t//\t#version 120\n\t\t\t\t// And at least,\n\t\t\t\t//\t#extension GL_EXT_gpu_shader4 : enable\n\t\t\t\t//\t(or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)\n\t\t\t\t#define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n\t\t\t\t#if (FXAA_FAST_PIXEL_OFFSET == 1)\n\t\t\t\t\t\t#define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n\t\t\t\t#else\n\t\t\t\t\t\t#define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n\t\t\t\t#endif\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 1)\n\t\t\t\t\t\t// use #extension GL_ARB_gpu_shader5 : enable\n\t\t\t\t\t\t#define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n\t\t\t\t\t\t#define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n\t\t\t\t\t\t#define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n\t\t\t\t\t\t#define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n\t\t\t\t#endif\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_GLSL_130 == 1)\n\t\t\t\t// Requires "#version 130" or better\n\t\t\t\t#define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n\t\t\t\t#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 1)\n\t\t\t\t\t\t// use #extension GL_ARB_gpu_shader5 : enable\n\t\t\t\t\t\t#define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n\t\t\t\t\t\t#define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n\t\t\t\t\t\t#define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n\t\t\t\t\t\t#define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n\t\t\t\t#endif\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_HLSL_3 == 1)\n\t\t\t\t#define FxaaInt2 float2\n\t\t\t\t#define FxaaTex sampler2D\n\t\t\t\t#define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))\n\t\t\t\t#define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_HLSL_4 == 1)\n\t\t\t\t#define FxaaInt2 int2\n\t\t\t\tstruct FxaaTex { SamplerState smpl; Texture2D tex; };\n\t\t\t\t#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n\t\t\t\t#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_HLSL_5 == 1)\n\t\t\t\t#define FxaaInt2 int2\n\t\t\t\tstruct FxaaTex { SamplerState smpl; Texture2D tex; };\n\t\t\t\t#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n\t\t\t\t#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n\t\t\t\t#define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)\n\t\t\t\t#define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)\n\t\t\t\t#define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)\n\t\t\t\t#define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)\n\t\t#endif\n\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t GREEN AS LUMA OPTION SUPPORT FUNCTION\n\t\t============================================================================*/\n\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\tFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n\t\t#else\n\t\t\t\tFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n\t\t#endif\n\n\n\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FXAA3 QUALITY - PC\n\n\t\t============================================================================*/\n\t\t#if (FXAA_PC == 1)\n\t\t/*--------------------------------------------------------------------------*/\n\t\tFxaaFloat4 FxaaPixelShader(\n\t\t\t\t//\n\t\t\t\t// Use noperspective interpolation here (turn off perspective interpolation).\n\t\t\t\t// {xy} = center of pixel\n\t\t\t\tFxaaFloat2 pos,\n\t\t\t\t//\n\t\t\t\t// Used only for FXAA Console, and not used on the 360 version.\n\t\t\t\t// Use noperspective interpolation here (turn off perspective interpolation).\n\t\t\t\t// {xy_} = upper left of pixel\n\t\t\t\t// {_zw} = lower right of pixel\n\t\t\t\tFxaaFloat4 fxaaConsolePosPos,\n\t\t\t\t//\n\t\t\t\t// Input color texture.\n\t\t\t\t// {rgb_} = color in linear or perceptual color space\n\t\t\t\t// if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t//\t\t {__a} = luma in perceptual color space (not linear)\n\t\t\t\tFxaaTex tex,\n\t\t\t\t//\n\t\t\t\t// Only used on the optimized 360 version of FXAA Console.\n\t\t\t\t// For everything but 360, just use the same input here as for "tex".\n\t\t\t\t// For 360, same texture, just alias with a 2nd sampler.\n\t\t\t\t// This sampler needs to have an exponent bias of -1.\n\t\t\t\tFxaaTex fxaaConsole360TexExpBiasNegOne,\n\t\t\t\t//\n\t\t\t\t// Only used on the optimized 360 version of FXAA Console.\n\t\t\t\t// For everything but 360, just use the same input here as for "tex".\n\t\t\t\t// For 360, same texture, just alias with a 3nd sampler.\n\t\t\t\t// This sampler needs to have an exponent bias of -2.\n\t\t\t\tFxaaTex fxaaConsole360TexExpBiasNegTwo,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// {x_} = 1.0/screenWidthInPixels\n\t\t\t\t// {_y} = 1.0/screenHeightInPixels\n\t\t\t\tFxaaFloat2 fxaaQualityRcpFrame,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// This effects sub-pixel AA quality and inversely sharpness.\n\t\t\t\t//\t Where N ranges between,\n\t\t\t\t//\t\t N = 0.50 (default)\n\t\t\t\t//\t\t N = 0.33 (sharper)\n\t\t\t\t// {x__} = -N/screenWidthInPixels\n\t\t\t\t// {_y_} = -N/screenHeightInPixels\n\t\t\t\t// {_z_} =\tN/screenWidthInPixels\n\t\t\t\t// {__w} =\tN/screenHeightInPixels\n\t\t\t\tFxaaFloat4 fxaaConsoleRcpFrameOpt,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// Not used on 360, but used on PS3 and PC.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// {x__} = -2.0/screenWidthInPixels\n\t\t\t\t// {_y_} = -2.0/screenHeightInPixels\n\t\t\t\t// {_z_} =\t2.0/screenWidthInPixels\n\t\t\t\t// {__w} =\t2.0/screenHeightInPixels\n\t\t\t\tFxaaFloat4 fxaaConsoleRcpFrameOpt2,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// Only used on 360 in place of fxaaConsoleRcpFrameOpt2.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// {x__} =\t8.0/screenWidthInPixels\n\t\t\t\t// {_y_} =\t8.0/screenHeightInPixels\n\t\t\t\t// {_z_} = -4.0/screenWidthInPixels\n\t\t\t\t// {__w} = -4.0/screenHeightInPixels\n\t\t\t\tFxaaFloat4 fxaaConsole360RcpFrameOpt2,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This used to be the FXAA_QUALITY_SUBPIX define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// Choose the amount of sub-pixel aliasing removal.\n\t\t\t\t// This can effect sharpness.\n\t\t\t\t//\t 1.00 - upper limit (softer)\n\t\t\t\t//\t 0.75 - default amount of filtering\n\t\t\t\t//\t 0.50 - lower limit (sharper, less sub-pixel aliasing removal)\n\t\t\t\t//\t 0.25 - almost off\n\t\t\t\t//\t 0.00 - completely off\n\t\t\t\tFxaaFloat fxaaQualitySubpix,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// The minimum amount of local contrast required to apply algorithm.\n\t\t\t\t//\t 0.333 - too little (faster)\n\t\t\t\t//\t 0.250 - low quality\n\t\t\t\t//\t 0.166 - default\n\t\t\t\t//\t 0.125 - high quality\n\t\t\t\t//\t 0.063 - overkill (slower)\n\t\t\t\tFxaaFloat fxaaQualityEdgeThreshold,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// Trims the algorithm from processing darks.\n\t\t\t\t//\t 0.0833 - upper limit (default, the start of visible unfiltered edges)\n\t\t\t\t//\t 0.0625 - high quality (faster)\n\t\t\t\t//\t 0.0312 - visible limit (slower)\n\t\t\t\t// Special notes when using FXAA_GREEN_AS_LUMA,\n\t\t\t\t//\t Likely want to set this to zero.\n\t\t\t\t//\t As colors that are mostly not-green\n\t\t\t\t//\t will appear very dark in the green channel!\n\t\t\t\t//\t Tune by looking at mostly non-green content,\n\t\t\t\t//\t then start at zero and increase until aliasing is a problem.\n\t\t\t\tFxaaFloat fxaaQualityEdgeThresholdMin,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// This does not effect PS3, as this needs to be compiled in.\n\t\t\t\t//\t Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.\n\t\t\t\t//\t Due to the PS3 being ALU bound,\n\t\t\t\t//\t there are only three safe values here: 2 and 4 and 8.\n\t\t\t\t//\t These options use the shaders ability to a free *|/ by 2|4|8.\n\t\t\t\t// For all other platforms can be a non-power of two.\n\t\t\t\t//\t 8.0 is sharper (default!!!)\n\t\t\t\t//\t 4.0 is softer\n\t\t\t\t//\t 2.0 is really soft (good only for vector graphics inputs)\n\t\t\t\tFxaaFloat fxaaConsoleEdgeSharpness,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// This does not effect PS3, as this needs to be compiled in.\n\t\t\t\t//\t Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.\n\t\t\t\t//\t Due to the PS3 being ALU bound,\n\t\t\t\t//\t there are only two safe values here: 1/4 and 1/8.\n\t\t\t\t//\t These options use the shaders ability to a free *|/ by 2|4|8.\n\t\t\t\t// The console setting has a different mapping than the quality setting.\n\t\t\t\t// Other platforms can use other values.\n\t\t\t\t//\t 0.125 leaves less aliasing, but is softer (default!!!)\n\t\t\t\t//\t 0.25 leaves more aliasing, and is sharper\n\t\t\t\tFxaaFloat fxaaConsoleEdgeThreshold,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// Trims the algorithm from processing darks.\n\t\t\t\t// The console setting has a different mapping than the quality setting.\n\t\t\t\t// This only applies when FXAA_EARLY_EXIT is 1.\n\t\t\t\t// This does not apply to PS3,\n\t\t\t\t// PS3 was simplified to avoid more shader instructions.\n\t\t\t\t//\t 0.06 - faster but more aliasing in darks\n\t\t\t\t//\t 0.05 - default\n\t\t\t\t//\t 0.04 - slower and less aliasing in darks\n\t\t\t\t// Special notes when using FXAA_GREEN_AS_LUMA,\n\t\t\t\t//\t Likely want to set this to zero.\n\t\t\t\t//\t As colors that are mostly not-green\n\t\t\t\t//\t will appear very dark in the green channel!\n\t\t\t\t//\t Tune by looking at mostly non-green content,\n\t\t\t\t//\t then start at zero and increase until aliasing is a problem.\n\t\t\t\tFxaaFloat fxaaConsoleEdgeThresholdMin,\n\t\t\t\t//\n\t\t\t\t// Extra constants for 360 FXAA Console only.\n\t\t\t\t// Use zeros or anything else for other platforms.\n\t\t\t\t// These must be in physical constant registers and NOT immediates.\n\t\t\t\t// Immediates will result in compiler un-optimizing.\n\t\t\t\t// {xyzw} = float4(1.0, -1.0, 0.25, -0.25)\n\t\t\t\tFxaaFloat4 fxaaConsole360ConstDir\n\t\t) {\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat2 posM;\n\t\t\t\tposM.x = pos.x;\n\t\t\t\tposM.y = pos.y;\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 1)\n\t\t\t\t\t\t#if (FXAA_DISCARD == 0)\n\t\t\t\t\t\t\t\tFxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n\t\t\t\t\t\t\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t\t\t\t\t\t\t#define lumaM rgbyM.w\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\t#define lumaM rgbyM.y\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\t\t\t\t#define lumaM luma4A.w\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#define lumaE luma4A.z\n\t\t\t\t\t\t#define lumaS luma4A.x\n\t\t\t\t\t\t#define lumaSE luma4A.y\n\t\t\t\t\t\t#define lumaNW luma4B.w\n\t\t\t\t\t\t#define lumaN luma4B.z\n\t\t\t\t\t\t#define lumaW luma4B.x\n\t\t\t\t#else\n\t\t\t\t\t\tFxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n\t\t\t\t\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t\t\t\t\t#define lumaM rgbyM.w\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t#define lumaM rgbyM.y\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#if (FXAA_GLSL_100 == 1)\n\t\t\t\t\t\t\tFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat maxSM = max(lumaS, lumaM);\n\t\t\t\tFxaaFloat minSM = min(lumaS, lumaM);\n\t\t\t\tFxaaFloat maxESM = max(lumaE, maxSM);\n\t\t\t\tFxaaFloat minESM = min(lumaE, minSM);\n\t\t\t\tFxaaFloat maxWN = max(lumaN, lumaW);\n\t\t\t\tFxaaFloat minWN = min(lumaN, lumaW);\n\t\t\t\tFxaaFloat rangeMax = max(maxWN, maxESM);\n\t\t\t\tFxaaFloat rangeMin = min(minWN, minESM);\n\t\t\t\tFxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n\t\t\t\tFxaaFloat range = rangeMax - rangeMin;\n\t\t\t\tFxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n\t\t\t\tFxaaBool earlyExit = range < rangeMaxClamped;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(earlyExit)\n\t\t\t\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\t\t\t\tFxaaDiscard;\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\treturn rgbyM;\n\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 0)\n\t\t\t\t\t\t#if (FXAA_GLSL_100 == 1)\n\t\t\t\t\t\t\tFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#endif\n\t\t\t\t#else\n\t\t\t\t\t\tFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\tFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat lumaNS = lumaN + lumaS;\n\t\t\t\tFxaaFloat lumaWE = lumaW + lumaE;\n\t\t\t\tFxaaFloat subpixRcpRange = 1.0/range;\n\t\t\t\tFxaaFloat subpixNSWE = lumaNS + lumaWE;\n\t\t\t\tFxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n\t\t\t\tFxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat lumaNESE = lumaNE + lumaSE;\n\t\t\t\tFxaaFloat lumaNWNE = lumaNW + lumaNE;\n\t\t\t\tFxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n\t\t\t\tFxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat lumaNWSW = lumaNW + lumaSW;\n\t\t\t\tFxaaFloat lumaSWSE = lumaSW + lumaSE;\n\t\t\t\tFxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n\t\t\t\tFxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n\t\t\t\tFxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n\t\t\t\tFxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n\t\t\t\tFxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n\t\t\t\tFxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n\t\t\t\tFxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n\t\t\t\tFxaaBool horzSpan = edgeHorz >= edgeVert;\n\t\t\t\tFxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(!horzSpan) lumaN = lumaW;\n\t\t\t\tif(!horzSpan) lumaS = lumaE;\n\t\t\t\tif(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n\t\t\t\tFxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat gradientN = lumaN - lumaM;\n\t\t\t\tFxaaFloat gradientS = lumaS - lumaM;\n\t\t\t\tFxaaFloat lumaNN = lumaN + lumaM;\n\t\t\t\tFxaaFloat lumaSS = lumaS + lumaM;\n\t\t\t\tFxaaBool pairN = abs(gradientN) >= abs(gradientS);\n\t\t\t\tFxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n\t\t\t\tif(pairN) lengthSign = -lengthSign;\n\t\t\t\tFxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat2 posB;\n\t\t\t\tposB.x = posM.x;\n\t\t\t\tposB.y = posM.y;\n\t\t\t\tFxaaFloat2 offNP;\n\t\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\t\t\t\tif(!horzSpan) posB.x += lengthSign * 0.5;\n\t\t\t\tif( horzSpan) posB.y += lengthSign * 0.5;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat2 posN;\n\t\t\t\tposN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n\t\t\t\tposN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n\t\t\t\tFxaaFloat2 posP;\n\t\t\t\tposP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n\t\t\t\tposP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n\t\t\t\tFxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n\t\t\t\tFxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));\n\t\t\t\tFxaaFloat subpixE = subpixC * subpixC;\n\t\t\t\tFxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(!pairN) lumaNN = lumaSS;\n\t\t\t\tFxaaFloat gradientScaled = gradient * 1.0/4.0;\n\t\t\t\tFxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n\t\t\t\tFxaaFloat subpixF = subpixD * subpixE;\n\t\t\t\tFxaaBool lumaMLTZero = lumaMM < 0.0;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tlumaEndN -= lumaNN * 0.5;\n\t\t\t\tlumaEndP -= lumaNN * 0.5;\n\t\t\t\tFxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\tFxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n\t\t\t\tFxaaBool doneNP = (!doneN) || (!doneP);\n\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(doneNP) {\n\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 3)\n\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 4)\n\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 5)\n\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 6)\n\t\t\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t#if (FXAA_QUALITY_PS > 8)\n\t\t\t\tif(doneNP) {\n\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 9)\n\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 10)\n\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 11)\n\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 12)\n\t\t\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t}\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat dstN = posM.x - posN.x;\n\t\t\t\tFxaaFloat dstP = posP.x - posM.x;\n\t\t\t\tif(!horzSpan) dstN = posM.y - posN.y;\n\t\t\t\tif(!horzSpan) dstP = posP.y - posM.y;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n\t\t\t\tFxaaFloat spanLength = (dstP + dstN);\n\t\t\t\tFxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n\t\t\t\tFxaaFloat spanLengthRcp = 1.0/spanLength;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaBool directionN = dstN < dstP;\n\t\t\t\tFxaaFloat dst = min(dstN, dstP);\n\t\t\t\tFxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n\t\t\t\tFxaaFloat subpixG = subpixF * subpixF;\n\t\t\t\tFxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n\t\t\t\tFxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n\t\t\t\tFxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n\t\t\t\tif(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n\t\t\t\tif( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n\t\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\t\treturn FxaaTexTop(tex, posM);\n\t\t\t\t#else\n\t\t\t\t\t\treturn FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n\t\t\t\t#endif\n\t\t}\n\t\t/*==========================================================================*/\n\t\t#endif\n\n\t\tvoid main() {\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\tvUv,\n\t\t\t\tvec4(0.0),\n\t\t\t\ttDiffuse,\n\t\t\t\ttDiffuse,\n\t\t\t\ttDiffuse,\n\t\t\t\tresolution,\n\t\t\t\tvec4(0.0),\n\t\t\t\tvec4(0.0),\n\t\t\t\tvec4(0.0),\n\t\t\t\t0.75,\n\t\t\t\t0.166,\n\t\t\t\t0.0833,\n\t\t\t\t0.0,\n\t\t\t\t0.0,\n\t\t\t\t0.0,\n\t\t\t\tvec4(0.0)\n\t\t\t);\n\n\t\t\t// TODO avoid querying texture twice for same texel\n\t\t\tgl_FragColor.a = texture2D(tDiffuse, vUv).a;\n\t\t}'},Ud={uniforms:{tDiffuse:{type:"t",value:null},time:{type:"f",value:-1}},vertexShader:"\nvarying vec2 vUv;\nvarying vec3 iPosition;\nvoid main(){\n vUv = uv;\n iPosition = position;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\nuniform float time;\nuniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvarying vec3 iPosition;\nvoid main(){\n\tvec4 texel = texture2D(tDiffuse, vUv);\n\tfloat x = iPosition.x;\n\tfloat lighty = -x*2.0 + time;\n\tfloat alpha = abs(iPosition.y - lighty);\n\tif(alpha < 0.1){\n float a = 1.0 - alpha / 0.1;\n float enda = smoothstep(0.0,1.0,a) + 0.3;\n gl_FragColor = texel * enda+vec4(1.0,0,0,0);\n\t}else{\n gl_FragColor = texel * 0.3;\n\t}\n} \n"};class Bd{constructor(t,e){this.scene=t,this.options=e,this.internalOptions={enableRenderCss2D:!1,enableRenderCss2DHalf:!1,enableRenderCss3D:!1},this.effectComposer=null,this.container=this._initContainer(),this.renderer=this._initRenderer(),this.rendererCSS2D=this._initRenderCSS2D(),this.rendererCSS3D=this._initRenderCSS3D(),this.rendererCSS2DHalf=this._initRenderCSS2DHalf(),this.interactiveContainer=this._initInteractiveContainer()}initEffectComposer(t){return this.effectComposer=new Dd(this.renderer),this.effectComposer.addPass(new Td(this.scene,t)),this.effectComposer}initAllPass(t){const e={ssaaPass:this._initSsaaPass(t),outlinePass:this._initOutlinePass(t)};for(let t in e)this.addPass(e[t]);return e}addPass(t){this.effectComposer&&this.effectComposer.addPass(t)}setInternalState(t,e){this.internalOptions[t]=e}getWidth(){return this.renderer.domElement.width}getHeight(){return this.renderer.domElement.height}getMouseRelativeConRatio(t){let e=this.container.getBoundingClientRect();return[(t.offsetX-e.left)/e.width,(t.offsetY-e.top)/e.height]}getMousePoint(t){let e=new g(0,0);return e.fromArray(this.getMouseRelativeConRatio(t)),e}_initContainer(){const t=document.createElement("div");return t.style.position="relative",t.style.width="100%",t.style.height="100%",t}_initRenderer(){const{background:t={},logarithmicDepthBuffer:e}=this.options,{color:n,alpha:r}=t,i=new Ji({antialias:!0,alpha:r,logarithmicDepthBuffer:e,preserveDrawingBuffer:!0}),s=r?0:1;i.setClearColor(n||0,s),i.setPixelRatio(window.devicePixelRatio),i.autoClear=!1,i.outputEncoding=3e3,i.localClippingEnabled=!0,i.sortObjects=!0,i.shadowMap.type=2,i.shadowMap.enabled=!0;const{offsetWidth:a,offsetHeight:o}=this.container;return i.domElement.style.width=a.toString(),i.domElement.style.height=o.toString(),this.container.appendChild(i.domElement),i}_initRenderCSS2D(){const t=new fu;return t.domElement.id="ssp_view_2DPoi",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.width="100%",t.domElement.style.height="100%",t.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(t.domElement),t}_initRenderCSS3D(){const t=new wu;return t.domElement.id="ssp_view_3DPoi",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.width="100%",t.domElement.style.height="100%",t.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(t.domElement),t}_initRenderCSS2DHalf(){const t=new Au(this.rendererCSS3D.domElement,this.rendererCSS3D.cameraElement);return t.setSize(this.container.offsetWidth,this.container.offsetHeight),t}_initInteractiveContainer(){return this.rendererCSS3D.domElement}_initFxaaPass(){const t=new Ad(Od),e=this.renderer.getPixelRatio();return t.material.uniforms.resolution.value.x=1/(this.container.offsetWidth*e),t.material.uniforms.resolution.value.y=1/(this.container.offsetHeight*e),t}_initSsaaPass(t){let e=new Pd(this.scene,t,0,0);return e.unbiased=!0,e.sampleLevel=1,e}_initOutlinePass(t){return new Ed(new g(window.innerWidth,window.innerHeight),this.scene,t)}_initSweepingLightShaderPass(){return new Ad(Ud)}_initUnrealBloomPass(){return new Rd(new g(this.getWidth(),this.getHeight()),0,.4,.85)}_initSAOPass(t){const e=new Sd(this.scene,t,!1,!0);return e.params.saoScale=368900,e}}const zd=new ct,kd=(t,e)=>{const n=zd.clone(),r=zd.clone(),i=zd.clone();n.makeRotationY(t),r.makeRotationX(e);const s=new xt;return i.multiplyMatrices(n,r),s.setFromRotationMatrix(i),s},Hd=kd(-Math.PI/2,-Math.PI/4),Gd=kd(Math.PI/2,-Math.PI/4),jd=kd(-Math.PI/4,-Math.PI/4),Vd=kd(Math.PI/4,-Math.PI/4),Wd=kd(1.25*Math.PI,-Math.PI/4),Xd=kd(.75*Math.PI,-Math.PI/4),Yd={LEFT:new xt(0,-Math.PI/2,0),RIGHT:new xt(0,Math.PI/2,0),FRONT:new xt(0,0,0),BACK:new xt(0,Math.PI,0),TOP:new xt(-Math.PI/2,0,0),BOTTOM:new xt(Math.PI/2,0,0),FRONTTOP:new xt(-Math.PI/4,0,0),BACKTOP:new xt(Math.PI/4,Math.PI,0),LEFTTOP:new xt(Hd.x,Hd.y,Hd.z),RIGHTTOP:new xt(Gd.x,Gd.y,Gd.z),LEFTFRONTTOP:new xt(jd.x,jd.y,jd.z),RIGHTFRONTTOP:new xt(Vd.x,Vd.y,Vd.z),LEFTBACKTOP:new xt(Wd.x,Wd.y,Wd.z),RIGHTBACKTOP:new xt(Xd.x,Xd.y,Xd.z)},qd=t=>Sh(t)?t:t.includes("%")?.01*Number(t.split("%")[0]):isNaN(+t)?0:Number(t),Qd=new qe(50,1,.1,5e5);Qd.name="Camera",Qd.position.set(500,1e3,500),Qd.lookAt(new I);class Zd{constructor(t){this.viewport=t,this.mainCamera=Qd.clone(),this.currentCamera=this.mainCamera,this.cameras={}}createCamera(t){const e=Qd.clone();return this.cameras[t]=e,e}removeCamera(t){return"fullFreeCamera"!==t&&(delete this.cameras[t],!0)}setCurrentCamera(t){this.currentCamera=this.viewport.camera=t,this.viewport.signals.cameraObjectChange.dispatch()}getMainCamera(){return this.mainCamera}getCameraViewpoint(){return{position:this.currentCamera.position.clone(),rotation:{x:this.currentCamera.rotation.x,y:this.currentCamera.rotation.y,z:this.currentCamera.rotation.z}}}setCameraViewpoint(t){const{position:e,rotation:n}=t;this.currentCamera.position.set(e.x,e.y,e.z),this.currentCamera.rotation.set(n.x,n.y,n.z),this.viewport.signals.cameraChange.dispatch(this.currentCamera.position.clone())}rotateTo(t,e){return $h(this.currentCamera.rotation,t,e)}moveTo(t,e){return $h(this.currentCamera.position,t,e,(t=>this.viewport.signals.cameraChange.dispatch(t)))}flyTo(t,e="frontTop",n){const r=this.viewport.controls.enableAutoRotate;this.viewport.controls.enableAutoRotate=!1;const i=new xt;if(wh(e)){const t=e.toLocaleUpperCase();"CURRENT"===t?i.copy(this.currentCamera.rotation):Yd[t]&&i.copy(Yd[t])}else e instanceof xt?i.copy(e):Ch(e)&&i.set(e.x,e.y,e.z);return i.copy(dh(this.currentCamera.rotation,i.clone())),Promise.all([this.moveTo(t,n),this.rotateTo(i,n)]).then((()=>(this.viewport.controls.enableAutoRotate=r,Promise.resolve())))}flyToBoundingBox(t,e="frontTop",n){if(wh(e)){if("CURRENT"===e.toLocaleUpperCase())return this.flyTo(this.getMovePosByBBox(t),e,n);{const r=Yd[e.toLocaleUpperCase()],i=this.getObjectLabelPos(t,r);return this.flyTo(i,e,n)}}{const r=ch(e),i=this.getObjectLabelPos(t,r);return this.flyTo(i,r,n)}}flyToObj(t,e="frontTop",n={}){if(t instanceof vp||t instanceof Eu){const{padding:r=50}=n,i=qd(r);return this.flyToBoundingBox(t.getBoundingBox(i),e,n)}{const{padding:r="30%"}=n,i=hh(t),s=i.getSize(new I);let a=0;if(wh(r)){const t=Math.max(s.x,s.y,s.z);a=qd(r)*t}else a=r;let o=a,l=a;if(a<0){const t=Math.min(s.x,s.z),e=s.y-1;o=Math.abs(a)>t?-t:a,l=Math.abs(o)>e?-e:o}return 0!==r&&(i.max.add(new I(o/2,l/2,o/2)),i.min.sub(new I(o/2,l/2,o/2))),this.flyToBoundingBox(i,e,n)}}surroundOnTarget(t,e={}){const{speed:n=1,angle:r=360,onStart:i}=e,s=lh(t),a=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),o=Math.abs(r);return $h({angle:0},{angle:Math.PI/180*o},{duration:o/360*5e3/n},(t=>{const e=r>0?t.angle:2*Math.PI-t.angle;this.currentCamera.position.x=Math.sin(e)*a+s.x,this.currentCamera.position.z=Math.cos(e)*a+s.z,this.currentCamera.lookAt(s)}),i)}surroundOnObject(t,e={}){const n=new N(new I,new I).setFromObject(t).getCenter(new I);return this.surroundOnTarget(n,e)}getMovePosByBBox(t){const e=this.currentCamera.position,n=t.getCenter(new I);(new I).subVectors(n,e).normalize();let r=new tt;r=t.getBoundingSphere(r);let i=this.currentCamera.fov/2*Math.PI/180,s=Math.sin(i),a=r.radius/s,o=new I;this.currentCamera.getWorldDirection(o);let l=o.clone();return l.multiplyScalar(-a),n.clone().add(l)}getObjectLabelPos(t,e="frontTop",n={}){t instanceof eu&&(t=new N(new I,new I).setFromObject(t));const{extendScale:r=1.6,mode:i="scene"}=n;if("scene"===i){const n=t.getCenter(new I),i=t.max.clone().sub(t.min),s=Math.max(i.x,i.y,i.z);let a=n.clone();const o=t=>{const e=(r-.5)*Math.abs(s),n=Math.max(e,this.viewport.camera.near);a.add(t.multiplyScalar(n))};let l;return l=wh(e)?Yd[e.toLocaleUpperCase()]:ch(e),o(new I(0,0,1).applyEuler(l)),a}return"screen"===i?t.getCenter(new I):new I}}const Jd=navigator.userAgent.toLowerCase().includes("mac");var Kd;!function(t){t[t.NONE=-1]="NONE",t[t.ROTATE=0]="ROTATE",t[t.ZOOM=1]="ZOOM",t[t.PAN=2]="PAN"}(Kd||(Kd={}));const $d=new I,tp=new g,ep=new g,np=[new I,new I,new I],rp=[new I,new I,new I];class ip{constructor(t,e){this.viewport=t,this.camera=e,this.domElement=t.interactiveContainer,this.enabled=!0,this.enabledMousePointInteractive=!0,this.enableZoom=!0,this.zoomSpeed=1,this.zoomMinDistance=50,this.zoomMaxDistance=1e5,this.zoomMinStepDistance=20,this.zoomMaxStepDistance=2e4,this.enableRotate=!0,this.enableRotateX=!0,this.enableRotateY=!0,this.rotateSpeed=1,this.rotateTiltRange={max:Math.PI,min:0},this.enableAutoRotate=!1,this.autoRotateSpeed=1,this.autoRotateClockwise=!0,this.enableOutOfScene=!0,this.unOffsetOfScene=0,this.enablePan=!0,this.enablePanX=!0,this.enablePanY=!0,this.enablePanAxisX=!0,this.enablePanAxisY=!0,this.enablePanAxisZ=!0,this.panSpeed=2,this.interactivePosition=null,this.state=Kd.NONE,this.init()}setOptions(t){for(let e in t)this[e]=t[e]}init(){const t=t=>{if(t.preventDefault(),!1===this.enabled)return;const e=this.domElement.getBoundingClientRect(),n=t.pageX-e.left,r=t.pageY-e.top;tp.set(n,r);const i=tp.x-ep.x,s=tp.y-ep.y;this.state===Kd.ROTATE?this.rotate(new I(.00375*-i,.00375*-s,0)):this.state===Kd.PAN&&this.pan(new I(-i,s,0)),ep.set(n,r)},e=n=>{n.preventDefault(),this.domElement.removeEventListener("mousemove",t,!1),window.removeEventListener("mouseup",e,!0),this.state=Kd.NONE},n=t=>{if(t.preventDefault(),!1!==this.enabled){switch(t.touches.length){case 1:np[0].set(t.touches[0].pageX,t.touches[0].pageY,0),np[1].set(t.touches[0].pageX,t.touches[0].pageY,0);var e=np[0].clone().sub(function(t,e){var n=e[0];for(var r in e)n.distanceTo(t)>e[r].distanceTo(t)&&(n=e[r]);return n}(np[0],rp));e.x=-e.x;const r=e.multiplyScalar(.9);this.pan(r);break;case 2:np[0].set(t.touches[0].pageX,t.touches[0].pageY,0),np[1].set(t.touches[1].pageX,t.touches[1].pageY,0);const i=rp[0].distanceTo(rp[1])-np[0].distanceTo(np[1]);this.zoom_touch(new I(0,0,i*this.zoomSpeed/25)),this.rotate(n(np,rp,"x"));break;case 3:case 4:case 5:np[0].set(t.touches[0].pageX,t.touches[0].pageY,0),np[1].set(t.touches[2].pageX,t.touches[2].pageY,0),this.rotate(n(np,rp,"y"))}rp[0].copy(np[0]),rp[1].copy(np[1])}function n(t,e,n="y"){const r=new g(t[1].x-t[0].x,t[1].y-t[0].y),i=new g(e[1].x-e[0].x,e[1].y-e[0].y),s=r.angle(),a=i.angle();r.normalize(),i.normalize();const o=e[0].y-t[0].y;return"y"===n?new I(0,.005*o,0):"x"===n?new I(s-a,0,0):new I}},r=t=>{t.preventDefault(),this.state=Kd.NONE,this.domElement.removeEventListener("touchmove",n,!1),this.domElement.removeEventListener("touchend",r,!1)};this.domElement.addEventListener("mousedown",(n=>{if(n.preventDefault(),!1===this.enabled)return;0===n.button?this.state=Kd.ROTATE:1===n.button?this.state=Kd.ZOOM:2===n.button&&(this.state=Kd.PAN);const r=this.domElement.getBoundingClientRect(),i=n.pageX-r.left,s=n.pageY-r.top;ep.set(i,s),this.state!==Kd.ROTATE&&this.state!==Kd.PAN||(this.interactivePosition=this.getInteractivePosition(n),this.domElement.addEventListener("mousemove",t,!1),window.addEventListener("mouseup",e,!0))}),!1),this.domElement.addEventListener("wheel",(t=>{if(t.preventDefault(),!this.enabled)return;let e=0;e=Jd&&t.shiftKey?120*-t.deltaX:120*-t.deltaY,this.zoom_on_point(new I(0,0,e),t)}),!1),this.domElement.addEventListener("touchstart",(t=>{if(t.preventDefault(),!1===this.enabled)return;const e=t.touches;switch(e.length){case 1:np[0].set(e[0].pageX,e[0].pageY,0),np[1].set(e[0].pageX,e[0].pageY,0);break;case 2:np[0].set(e[0].pageX,e[0].pageY,0),np[1].set(e[1].pageX,e[1].pageY,0);break;case 3:case 4:case 5:np[0].set(e[0].pageX,e[0].pageY,0),np[1].set(e[2].pageX,e[2].pageY,0)}rp[0].copy(np[0]),rp[1].copy(np[1]),this.interactivePosition=this.getInteractivePosition({offsetX:(np[0].x+np[1].x)/2,offsetY:(np[0].y+np[1].y)/2}),this.domElement.addEventListener("touchmove",n,!1),this.domElement.addEventListener("touchend",r,!1)}),!1)}getInteractivePosition(t){var e;if(this.enabledMousePointInteractive){const n=this.viewport.getIntersects(t);return n.length?null===(e=n[0].point)||void 0===e?void 0:e.clone():null}return null}intersectsBox(t){const e=this.getSceneBbox();let n=new I;e.getSize(n);let r=Math.max(n.x,n.y,n.z);0!=this.unOffsetOfScene&&(r=this.unOffsetOfScene);const i=e.clone();i.min.addScalar(r/2),i.max.addScalar(-r/2);let s=(new qe).copy(this.camera);return s.position.add(t),s.updateMatrixWorld(),s.updateProjectionMatrix(),(new sn).setFromProjectionMatrix((new ct).multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse)).intersectsBox(e)}caculateContainPoint(t,e){let n=(new I).copy(t).applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);return!(Math.abs(n.x)>1||Math.abs(n.y)>1||Math.abs(n.z)>1)}panLeft(t){const e=new I,n=this.camera.matrix.elements;this.enablePanAxisX&&e.setX(n[0]),this.enablePanAxisY&&e.setY(n[1]),this.enablePanAxisZ&&e.setZ(n[2]),e.multiplyScalar(t);let r=!0;this.enableOutOfScene||(r=this.intersectsBox(e)),r&&this.camera.position.add(e)}panUp(t){const e=new I,n=this.camera.matrix.elements;this.enablePanAxisX&&e.setX(n[4]),this.enablePanAxisY&&e.setY(n[5]),this.enablePanAxisZ&&e.setZ(n[6]),e.multiplyScalar(t);let r=!0;this.enableOutOfScene||(r=this.intersectsBox(e)),r&&this.camera.position.add(e)}pan(t){if(!this.enablePan)return;this.enablePanX||t.setX(0),this.enablePanY||t.setY(0);const e=this.interactivePosition||this.getSceneBbox().getCenter(new I);let n=this.camera.position.clone().sub(e).length();n*=Math.tan(this.camera.fov/2*Math.PI/180),n<50&&(n=50*this.panSpeed),this.panLeft(this.panSpeed*t.x*n/this.domElement.offsetHeight),this.panUp(this.panSpeed*t.y*n/this.domElement.offsetHeight),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}zoom_on_point(t,e){if(!this.enableZoom)return;this.interactivePosition=this.getInteractivePosition(e);let n=t.z>0?6:-6;const r=new I(0,0,0);let i;if(this.interactivePosition){i=this.interactivePosition.distanceTo(this.camera.position);const t=this.domElement.getBoundingClientRect();r.set(e.offsetX/t.width*2-1,-e.offsetY/t.height*2+1,.1)}else i=this.camera.position.y,r.set(0,0,.1);let s=!1;i>this.zoomMaxDistance&&n<0?(s=!0,i=this.zoomMaxDistance,n*=2):i<this.zoomMinDistance&&n>0&&(s=!0,i=this.zoomMinDistance,n*=2),r.unproject(this.camera),r.sub(this.camera.position);let a=i/n*this.zoomSpeed;if(s){if(!e.shiftKey)return;a>0?a>this.zoomMaxStepDistance?a=this.zoomMaxStepDistance:a<this.zoomMinStepDistance&&(a=this.zoomMinStepDistance):a<0&&(a<-this.zoomMaxStepDistance?a=-this.zoomMaxStepDistance:a>-this.zoomMinStepDistance&&(a=-this.zoomMinStepDistance))}const o=this.camera.position.clone().addVectors(this.camera.position,r.setLength(a));this.camera.position.copy(o),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}zoom_touch(t){if(!this.enableZoom)return;let e=t.z;const n=new I(0,0,0);let r;if(this.interactivePosition){const t=this.domElement.getBoundingClientRect(),e={offsetX:(rp[0].x+rp[1].x)/2,offsetY:(rp[0].y+rp[1].y)/2};r=this.interactivePosition.distanceTo(this.camera.position),n.set(e.offsetX/t.width*2-1,-e.offsetY/t.height*2+1,.1)}else r=this.camera.position.y,n.set(0,0,.1);if(r>this.zoomMaxDistance&&e>0?(r=this.zoomMaxDistance,e=0):r<this.zoomMinDistance&&e<0&&(r=this.zoomMinDistance,e=0),0===e)return;n.unproject(this.camera),n.sub(this.camera.position);let i=r*-e*this.zoomSpeed*.1;i>0?i>this.zoomMaxStepDistance?i=this.zoomMaxStepDistance:i<this.zoomMinStepDistance&&(i=this.zoomMinStepDistance):i<0&&(i<-this.zoomMaxStepDistance?i=-this.zoomMaxStepDistance:i>-this.zoomMinStepDistance&&(i=-this.zoomMinStepDistance));const s=this.camera.position.clone().addVectors(this.camera.position,n.setLength(i));this.camera.position.copy(s),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}rotate(t){if(!this.enableRotate)return;t.x*=this.rotateSpeed,t.y*=this.rotateSpeed;const e=new I(0,0,-1);e.applyQuaternion(this.camera.quaternion);const n=e.angleTo(new I(0,1,0));(n-t.y>this.rotateTiltRange.max&&t.y<0||n-t.y<this.rotateTiltRange.min&&t.y>0)&&(t.y=0);const r=this.interactivePosition||this.getSceneBbox().getCenter(new I);$d.copy(this.camera.position).sub(r);const i=new ct;let s=new I(1,0,0);this.enableRotateX&&i.makeRotationAxis(new I(0,1,0),t.x);const a=new ct;this.enableRotateY&&(s.applyEuler(this.camera.rotation),a.makeRotationAxis(s,t.y),i.multiply(a)),$d.applyMatrix4(i),e.applyMatrix4(i),this.camera.position.copy(r).add($d),this.camera.lookAt(e.add(this.camera.position)),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}autoRotate(){const t=this.autoRotateClockwise?.01:-.01;this.rotate(new I(t*this.autoRotateSpeed,0,0))}update(){this.enableAutoRotate&&this.autoRotate()}getSceneBbox(){const t=this.viewport._getManagerScene("sbm"),e=this.viewport._getManagerScene("model"),n=new N;return t&&n.setFromObject(t),e&&n.union((new N).setFromObject(e)),n}}class sp{constructor(t,e){const n=document.createElement("div");function r(t,e=!0){const n=document.createElement("span");return e&&(n.style.marginLeft="6px"),n.innerHTML=t,n}function i(){return document.createElement("br")}n.style.position="absolute",n.style.left="12px",n.style.bottom="12px",n.style.fontSize="12px",n.style.color="#fff",this.container=n,this.state={objects:0,vertices:0,triangles:0,frametime:0,lodFrametime:0};const s=r("0"),a=r("0"),o=r("0"),l=r("0"),c=r("0");this.container.appendChild(r("objects",!1)),this.container.appendChild(s),this.container.appendChild(i()),this.container.appendChild(r("triangles",!1)),this.container.appendChild(a),this.container.appendChild(i()),this.container.appendChild(r("vertices",!1)),this.container.appendChild(o),this.container.appendChild(i()),this.container.appendChild(r("frametime",!1)),this.container.appendChild(l),this.container.appendChild(i()),this.container.appendChild(r("lodFrametime",!1)),this.container.appendChild(c);const h=()=>{this.state.objects=0,this.state.vertices=0,this.state.triangles=0;for(let e=0;e<t.children.length;e++){t.children[e].traverseVisible((t=>{var e,n,r,i;if("SceneManager"!==t.stype&&this.state.objects++,t.isMesh){let s=t.geometry;s.isGeometry?(this.state.vertices+=(null===(e=s.vertices)||void 0===e?void 0:e.length)||0,this.state.triangles+=(null===(n=s.faces)||void 0===n?void 0:n.length)||0):s.isBufferGeometry&&(this.state.vertices+=(null===(r=s.attributes.position)||void 0===r?void 0:r.count)||0,null!==s.index?this.state.triangles+=s.index.count/3:this.state.triangles+=(null===(i=s.attributes.position)||void 0===i?void 0:i.count)/3||0)}}))}s.innerHTML=String(this.state.objects),o.innerHTML=String(this.state.vertices),a.innerHTML=String(this.state.triangles)};e.objectAdded.add(h),e.objectRemoved.add(h),e.geometryChanged.add(h);e.sceneRendered.add((t=>{this.state.frametime=t,l.innerHTML=Number(t).toFixed(2)+" ms"}));e.loadRendered.add((t=>{this.state.lodFrametime=t,c.innerHTML=Number(t).toFixed(2)+" ms"}))}}const ap={needRender:!1};let op=0,lp=0;const cp=new ql;class hp{constructor(t){this.options=t,this.state={useFreq:1,animationTotal:0},this.signals={windowResize:new ud,cameraObjectChange:new ud,sceneChanged:new ud,backgroundChanged:new ud,beforeRender:new ud,afterRender:new ud,sceneRendered:new ud,loadRendered:new ud,tweenUpdate:new ud,hover:new ud,click:new ud,dblClick:new ud,rightClick:new ud,mouseDown:new ud,mouseMove:new ud,mouseUp:new ud,mouseWheel:new ud,keyDown:new ud,keyUp:new ud,modelHover:new ud,modelUnHover:new ud,modelClick:new ud,modelDblClick:new ud,modelRightClick:new ud,poiHover:new ud,poiUnHover:new ud,poiClick:new ud,poiDblClick:new ud,poiRightClick:new ud,selectPosition:new ud,sceneClick:new ud,objectAdded:new ud,objectRemoved:new ud,objectChanged:new ud,geometryChanged:new ud,materialAdded:new ud,materialChanged:new ud,materialRemoved:new ud,cameraChange:new ud,outlineChange:new ud,modelAnimation:new ud,getSceneInfo:new ud},this.scener=new pd(this.signals),this.scene=this.scener.scene,this.rendererManager=new Bd(this.scene,t),this.container=this.rendererManager.container,this.interactiveContainer=this.rendererManager.interactiveContainer,this.renderer=this.rendererManager.renderer,this.rendererCSS3D=this.rendererManager.rendererCSS3D,this.rendererCSS2D=this.rendererManager.rendererCSS2D,this.rendererCSS2DHalf=this.rendererManager.rendererCSS2DHalf,this.info=new sp(this.scene,this.signals),this.cameraManager=new Zd(this),this.camera=this.cameraManager.currentCamera,this.controls=new ip(this,this.camera),this.effectComposer=this.rendererManager.initEffectComposer(this.camera),this.pass=this.rendererManager.initAllPass(this.camera),this.mixer=new yc(this.scene),this.postUpdate=new Map,this.postRender=new Map,this.selectModel=null,this.selectPoi=null,this._loop=0,this.initInfo(),this._signalsEventListenr(),this._containerAddEventListener(this.container),this.animate(0)}initInfo(){if(this.options.showInfo){const{container:t}=this.info;t.style.zIndex="1",this.container.appendChild(t)}}setSphereSkyBackground(t){(new dl).load(t,(t=>{t.mapping=303,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setSkyBackground(t,e){yh(t,e).then((t=>{this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setBackgroundColor(t){this.renderer.setClearColor(t),this.scene.background=new te(t),this.signals.backgroundChanged.dispatch()}setBackgroundImage(t){(new dl).load(t,(t=>{t.wrapS=1002,t.wrapT=1002,t.encoding=3e3,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}playModelAnimation(t,e){let n;if(e instanceof el?n=e:Sh(e)?n=t.animations[e]:Lh(e)&&(n=t.animations.find(e)),!n)return;const r=this.mixer.clipAction(n,t);return r.play(),this.state.animationTotal++,r}stopModelAnimation(t,e){let n;e instanceof el?n=e:Sh(e)?n=t.animations[e]:Lh(e)&&(n=t.animations.find(e)),n&&(this.mixer.uncacheAction(n,t),this.state.animationTotal--)}render(t){return Pu(this,void 0,void 0,(function*(){return ap.needRender=!0,yield null==t?void 0:t(),new Promise((t=>{const e=()=>{ap.needRender=!1,this.signals.afterRender.remove(e),t()};this.signals.afterRender.add(e),this.trigerRender()}))}))}trigerRender(t=1){this.state.useFreq+=t,this.state.useFreq>50&&(this.state.useFreq=10)}autoRender(t){this.state.useFreq<=0&&!ap.needRender||(this.state.useFreq>0&&this.state.useFreq--,ap.needRender&&(ap.needRender=!1),op=performance.now(),this.renderer.clear(),this.signals.beforeRender.dispatch(),this.renderer.render(this.scene,this.camera),this.rendererCSS2D&&this.rendererManager.internalOptions.enableRenderCss2D&&this.rendererCSS2D.render(this.scene,this.camera),this.rendererCSS2DHalf&&this.rendererManager.internalOptions.enableRenderCss2DHalf&&this.rendererCSS2DHalf.render(this.scene,this.camera),this.rendererCSS3D&&this.rendererManager.internalOptions.enableRenderCss3D&&this.rendererCSS3D.render(this.scene,this.camera),this.postRender.forEach((e=>e(t))),this.signals.afterRender.dispatch(),lp=performance.now(),this.signals.sceneRendered.dispatch(lp-op))}animate(t){this._loop=requestAnimationFrame((t=>{this.animate(t)}));const e=cp.getDelta();this.controls.update(),this.state.animationTotal>0&&(this.mixer.update(e),this.signals.modelAnimation.dispatch()),Jh.update()&&this.signals.tweenUpdate.dispatch(),this.postUpdate.forEach((e=>e(t))),this.autoRender(t),this.signals.getSceneInfo.dispatch(this.info.state)}getOffsetByPosition(t){const e=new I(t.x,t.y,t.z).project(this.camera),n=this.renderer.domElement.getBoundingClientRect();return{left:Math.round(n.left+n.width/2*(e.x+1)),top:Math.round(n.top+n.height/2*(1-e.y))}}getPositionByOffset(t,e=.1){const n=new I(0,0,0),r=new I(0,0,0),i=this.renderer.domElement.getBoundingClientRect();r.set(t.offsetX/i.width*2-1,-t.offsetY/i.height*2+1,e),r.unproject(this.camera),r.sub(this.camera.position).normalize();const s=r.distanceTo(this.camera.position);return n.copy(this.camera.position).add(r.multiplyScalar(s)),n}getIntersects(t,e=this.scener.intersectsList.getAll()){let n={offsetX:0,offsetY:0};if(t instanceof MouseEvent)n={offsetX:t.offsetX,offsetY:t.offsetY};else if(t instanceof TouchEvent){const{changedTouches:e}=t,r=this.renderer.domElement.getBoundingClientRect();n={offsetX:e[0].pageX-r.left,offsetY:e[0].pageY-r.top}}else n=t;const r=new g;r.set(n.offsetX/this.container.offsetWidth*2-1,-n.offsetY/this.container.offsetHeight*2+1);const i=new wc;return i.setFromCamera(r,this.camera),Ph(e)?i.intersectObjects(e,!0):i.intersectObject(e,!0)}rayClash(t=this.camera.position,e=new I(0,-1,0),n=this.scener.intersectsList.meshOfModelList){const r=new wc;return r.set(t,e),Ph(n)?r.intersectObjects(n,!0):r.intersectObject(n,!0)}setHoverEnabled(t){this.options.hoverEnabled=t}clearSignals(){for(let t in this.signals)this.signals[t].removeAll()}dispose(){return new Promise((t=>{cancelAnimationFrame(this._loop),setTimeout((()=>{Jh.removeAll(),this.clearSignals(),this.scene.remove(),this.renderer.forceContextLoss(),this.renderer.dispose(),this.container.remove(),t()}),100)}))}_signalsEventListenr(){const t=()=>{this.camera.aspect=this.container.offsetWidth/this.container.offsetHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.rendererCSS3D&&this.rendererCSS3D.setSize(this.container.offsetWidth,this.container.offsetHeight),this.rendererCSS2D&&this.rendererCSS2D.setSize(this.container.offsetWidth,this.container.offsetHeight),this.rendererCSS2DHalf&&this.rendererCSS2DHalf.setSize(this.container.offsetWidth,this.container.offsetHeight),this.effectComposer&&this.effectComposer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.trigerRender()};setTimeout((()=>t()),5e3),this.signals.windowResize.add(t),this.signals.cameraObjectChange.add(t),this.signals.sceneChanged.add((()=>this.trigerRender())),this.signals.backgroundChanged.add((()=>this.trigerRender())),this.signals.objectAdded.add((()=>this.trigerRender())),this.signals.objectRemoved.add((()=>this.trigerRender())),this.signals.objectChanged.add((()=>this.trigerRender())),this.signals.materialAdded.add((()=>this.trigerRender())),this.signals.materialRemoved.add((()=>this.trigerRender())),this.signals.materialChanged.add((()=>this.trigerRender())),this.signals.geometryChanged.add((()=>this.trigerRender())),this.signals.cameraChange.add((()=>this.trigerRender())),this.signals.tweenUpdate.add((()=>this.trigerRender())),this.signals.modelAnimation.add((()=>this.trigerRender())),this.signals.outlineChange.add((t=>{const{objects:e,options:n}=t,{color:r,hideColor:i,edgeThickness:s,edgeStrength:a,pulsePeriod:o}=Object.assign(Object.assign({},{color:"#fff",hideColor:"#999",edgeThickness:3,edgeStrength:10,pulsePeriod:0}),n);this.pass.outlinePass.selectedObjects=e,this.pass.outlinePass.visibleEdgeColor.set(r),this.pass.outlinePass.hiddenEdgeColor.set(i),this.pass.outlinePass.edgeThickness=s,this.pass.outlinePass.edgeStrength=a,this.pass.outlinePass.pulsePeriod=o,this.trigerRender()}))}_containerAddEventListener(t){const e=[0,0];let n=null;const r=i=>{this.signals.mouseUp.dispatch(i);const s=i.offsetX-(null==n?void 0:n.offsetX),a=i.offsetY-(null==n?void 0:n.offsetY);if(Math.abs(s)>2||Math.abs(a)>2)return e[0]=0,void(e[1]=0);setTimeout((()=>{0!==e[0]&&0===e[1]&&(0===i.button?(this.signals.click.dispatch(i),this._triggerSceneEventInAllObject("click",i)):2===i.button&&(this.signals.rightClick.dispatch(i),this._triggerSceneEventInAllObject("rightClick",i))),e[0]=0,e[1]=0}),300),t.removeEventListener("mouseup",r,!1)};let i=!1,s=null;const a=[0,0],o=e=>{s&&clearTimeout(s),i||(setTimeout((()=>{0!==a[0]&&0===a[1]?(this.signals.click.dispatch(e),this._triggerSceneEventInAllObject("click",e)):0!==a[0]&&0!==a[1]&&a[1]-a[0]<=300&&(this.signals.dblClick.dispatch(e),this._triggerSceneEventInAllObject("dblClick",e)),a[0]=0,a[1]=0}),300),t.removeEventListener("touchend",o,!1))};t.addEventListener("mousedown",(i=>{n=i,this.signals.mouseDown.dispatch(i),0===e[0]?e[0]=performance.now():0===e[1]&&(e[1]=performance.now()),t.addEventListener("mouseup",r,!1)}),!1),t.addEventListener("mousemove",(t=>{this.signals.mouseMove.dispatch(t),this.options.hoverEnabled&&this._triggerSceneEventInAllObject("hover",t)}),!1),t.addEventListener("dblclick",(t=>{this.signals.dblClick.dispatch(t),this._triggerSceneEventInAllObject("dblClick",t)}),!1),t.addEventListener("wheel",(t=>{this.signals.mouseWheel.dispatch(t)}),!1),t.addEventListener("touchstart",(e=>{0===a[0]?a[0]=performance.now():0===a[1]&&(a[1]=performance.now()),s=setTimeout((()=>{i=!0,a[0]=0,a[1]=0,this.signals.rightClick.dispatch(e),this._triggerSceneEventInAllObject("rightClick",e)}),800),t.addEventListener("touchend",o,!1)}),!1),t.addEventListener("contextmenu",(t=>t.preventDefault()),!1),document.addEventListener("keydown",(t=>{this.signals.keyDown.dispatch(t)}),!1),document.addEventListener("keyup",(t=>{this.signals.keyUp.dispatch(t)}),!1)}_triggerSceneEventInAllObject(t,e){const n=this.getIntersects(e,this.scener.intersectsList.getAll());if(0===n.length)return this.selectModel&&this.signals.modelHover.numListeners>0&&this.signals.modelUnHover.dispatch(this.selectModel),this.selectPoi&&this.signals.poiHover.numListeners>0&&this.signals.poiUnHover.dispatch(this.selectPoi),this.selectModel=null,this.selectPoi=null,void this.signals.sceneClick.dispatch({type:t,event:e});"click"===t&&n.length>0&&this.signals.selectPosition.dispatch(n[0].point);const r={object:null,type:null},i=[],s=[];function a(t){return t.parent?"Sbm"===t.parent.stype||"Model"===t.parent.stype?t.parent:a(t.parent):void 0}function o(t){return!!t.visible&&(!t.parent||o(t.parent))}n.forEach((t=>{if(t.object.parent instanceof vp){const e=t.object.parent;if(o(e)){r.object||(r.type="Poi",r.object=t.object);-1===i.findIndex((t=>t.poi.uuid===e.uuid))&&i.push({poi:e,sourceData:t})}}else if(t.object instanceof Dt){const e=a(t.object);if(e&&o(e)){r.object||(r.type="Model",r.object=t.object);-1===s.findIndex((t=>t.model.uuid===e.uuid))&&s.push({model:e,sourceData:t})}}}));const l=t.slice(0,1).toUpperCase()+t.slice(1),c=t=>{var e;const{model:n}=t[0];if(n)if("Hover"===l)(null===(e=this.selectModel)||void 0===e?void 0:e.uuid)!==n.uuid&&(this.signals.modelHover.dispatch({target:n,currentTarget:r.object,intersects:t}),this.selectModel=n);else{let e=null;"Click"===l?e=n.onClick:"RightClick"===l?e=n.onRightClick:"DblClick"===l&&(e=n.onDblClick),e?e(n):n.isEventPropagation=!0,n.isEventPropagation&&(this.signals[`model${l}`].dispatch({target:n,currentTarget:r.object,intersects:t}),n.isEventPropagation=!1)}},h=t=>{var e;const{poi:n}=t[0];if(n)if("Hover"===l)(null===(e=this.selectPoi)||void 0===e?void 0:e.uuid)!==n.uuid&&(this.signals.poiHover.dispatch(n),this.selectPoi=n);else{let t=null;"Click"===l?t=n.onClick:"RightClick"===l?t=n.onRightClick:"DblClick"===l&&(t=n.onDblClick),t?t(n):n.isEventPropagation=!0,n.isEventPropagation&&(this.signals[`poi${l}`].dispatch(n),n.isEventPropagation=!1)}};"Model"===r.type?c(s):"Poi"===r.type&&h(i)}_getManagerScene(t){return this.scene.children.find((e=>e.name===`${t.toLocaleLowerCase()}Manager`))}}const up={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class dp extends eu{constructor(t){super(t,"Sbm"),this.isEventPropagation=!1;const{onLoad:e,onClick:n,onDblClick:r,onRightClick:i}=Object.assign(Object.assign({},up),t);this.onLoad=(null==e?void 0:e.bind(this))||null,this.onClick=(null==n?void 0:n.bind(this))||null,this.onDblClick=(null==r?void 0:r.bind(this))||null,this.onRightClick=(null==i?void 0:i.bind(this))||null}getBoundingBox(){return new N(new I,new I).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){yh(t,e).then((t=>{this.traverse((e=>{if(e instanceof ke&&e.material instanceof No){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,ap.needRender=!0}}))}))}sClone(t){return new dp({id:`${this.sid}_clone`,url:""}).sCopy(this,t)}}const pp={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class fp extends eu{constructor(t){super(t,"Model");const{format:e,onLoad:n,onClick:r,onDblClick:i,onRightClick:s}=Object.assign(Object.assign({},pp),t);this.formatType=e,this.isEventPropagation=!1,this.onLoad=(null==n?void 0:n.bind(this))||null,this.onClick=(null==r?void 0:r.bind(this))||null,this.onDblClick=(null==i?void 0:i.bind(this))||null,this.onRightClick=(null==s?void 0:s.bind(this))||null}getBoundingBox(){return new N(new I,new I).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){yh(t,e).then((t=>{this.traverse((e=>{if(e instanceof ke&&e.material instanceof No){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,ap.needRender=!0}}))}))}sClone(t){return new fp({id:`${this.sid}_clone`,url:"",format:this.formatType}).sCopy(this,t)}}const mp={position:{x:0,y:0,z:0},scale:{x:16,y:16,z:1},stype:"Icon"};class gp extends xs{constructor(t,e){super(t);const{position:n,scale:r,stype:i}=Object.assign(Object.assign({},mp),e);this.stype=i,this.position.set(n.x,n.y,n.z),this.scale.set(r.x,r.y,r.z),this.renderOrder=1}}class vp extends eu{constructor(t,e){super(e,"Poi"),this.isEventPropagation=!1;const{name:n,nameScale:r={x:16,y:16,z:1},onClick:i,onDblClick:s,onRightClick:a}=e;this.onClick=(null==i?void 0:i.bind(this))||null,this.onDblClick=(null==s?void 0:s.bind(this))||null,this.onRightClick=(null==a?void 0:a.bind(this))||null,this.icon=this._createIcon(t),this.text=null,this.name&&this._createText({position:{x:0,y:10,z:0},name:n,scale:r}),this.renderOrder=11}getBoundingBox(t=50){t=t<=0?50:t;let e=new I,n=new I,r=new I(t,t,t);return e.copy(this.position),n.copy(this.position),e.sub(r),n.add(r),new N(e,n)}eventPropagation(){this.isEventPropagation=!0}sClone(t){return new vp(this.icon.material,{id:`${this.sid}_clone`,url:"",name:this.name}).sCopy(this,t)}_createIcon(t){const e=new gp(t);return this.add(e),e}_createText(t){const e=this._createCanvasText(t.name||""),n=new T(e);n.flipY=!0,n.version+=1;const r=new ss({map:n,depthTest:!0});this.text=new gp(r,t),this.add(this.text)}_createCanvasText(t,e){const n=256,r=document.createElement("canvas");r.width=n,r.height=n;const i=r.getContext("2d"),{fontFamily:s,fontSize:a,color:o,textAlign:l,textBaseline:c}=Object.assign(Object.assign({},{fontFamily:"Microsoft YaHei",fontSize:32,color:"#fff",textAlign:"center",textBaseline:"bottom"}),e);return i&&(i.save(),i.font=a+"px "+s,i.textAlign=l,i.textBaseline=c,i.shadowColor="black",i.strokeStyle="black",i.lineWidth=3,i.fillStyle=o,i.strokeText(t,128,128),i.fillText(t,128,128),i.restore()),r}}class yp extends tu{constructor(t,e="Point"){const{radius:n=10,color:r=255,opacity:i=1}=t;super(function(t){return new So(t,32,32)}(n),function(t,e){return new ee({color:t,opacity:e,transparent:!0})}(r,i),t,e)}setOptions(t){const{color:e,opacity:n,radius:r,position:i}=t,s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&(this.geometry=new So(r,32,32)),i&&this.position.copy(lh(i)),s.version++,ap.needRender=!0}}class xp extends yp{constructor(t){super(t,"Node"),this.graphs=t.graphs}}class _p extends tu{constructor(t){const{radius:e=50,color:n=65280,opacity:r=1}=t;super(function(t){return new ca(t,64)}(e),function(t,e){return new ee({color:t,opacity:e,transparent:!0,side:2})}(n,r),t,"Circle"),this.rotation.set(Math.PI/2,0,0)}setOptions(t){const{color:e,opacity:n,radius:r,position:i}=t,s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&(this.geometry=new ca(r,64)),i&&this.position.copy(lh(i)),s.version++,ap.needRender=!0}}class bp extends tu{constructor(t){const{start:e,end:n,imgUrl:r,width:i=20,color:s=65280,opacity:a=1,animation:o=!1,passable:l=0,restrict:c=0}=t,h=lh(e),u=lh(n),d=h.distanceTo(u);super(function(t,e,n,r=new I(0,1,0)){const i=n/2,s=new I,a=new I;s.subVectors(e,t),s.normalize(),a.crossVectors(s,r);const o=new I(a.x*i,a.y*i,a.z*i),l=new I(-a.x*i,-a.y*i,-a.z*i),c=new I;c.addVectors(t,o);const h=new I;h.addVectors(t,l);const u=new I;u.addVectors(e,l);const d=new I;d.addVectors(e,o);const p=new we;return p.setAttribute("position",new pe([c.x,c.y,c.z,h.x,h.y,h.z,u.x,u.y,u.z,u.x,u.y,u.z,d.x,d.y,d.z,c.x,c.y,c.z],3)),p.setAttribute("uv",new pe([0,0,1,0,1,1,1,1,0,1,0,0],2)),p}(h,u,i),function(t,e,n,r,i,s){const a=new ee({color:n,side:2,transparent:!0,opacity:r});let o;return i&&(o=(new dl).load(i,(n=>{o.repeat.set(1,t/(e*(n.image.height/n.image.width))*.63*(n.image.height/n.image.height)),a.color.set(16777215)})),o.wrapS=1e3,o.wrapT=1e3,o.flipY=!0,o.matrixAutoUpdate=!0,Mh(s)&&s?$h(o.offset,{y:-1,x:0},{repeat:!0,duration:500}):Ch(s)&&$h(o.offset,{y:-1,x:0},Object.assign(Object.assign({},s),{repeat:!0})),a.map=o),a}(d,i,s,a,r,o),t,"Link"),this.passable=l,this.restrict=c}}class wp extends eu{constructor(t){super(t,"Topology");const{type:e="line"}=t;this.type=e,this.nodes=[],this.links=[],this.info=t,this.create()}create(){const{nodes:t,renderLink:e=!0,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255,nodeRadius:a=n/2,imgUrl:o,animation:l=!1}=this.info,c=[];for(let h of t){const t=this.createNode(Object.assign(Object.assign({},h),{radius:a,color:s}));if(!1===i&&t.hide(),this.nodes.push(t),!o&&e){const t=Ph(r)?r[h.graphs[0].passable]?r[h.graphs[0].passable]:r[0]:r;this.createCircle({id:`${h.id}_circle`,name:`${h.name||h.id}_circle`,position:h.position,radius:n/2,color:t})}if(e)for(let t=0;t<h.graphs.length;t++){const{linkInfo:e,targetNodeId:i,passable:s,restrict:a}=h.graphs[t],{id:u,name:d}=e,p=this.info.nodes.find((t=>t.id===i));if(!c.includes(u)&&p){c.push(u);const t=Ph(r)?r[s]?r[s]:r[0]:r,e=this.createLink({id:u,name:d,start:h.position,end:p.position,width:n,color:t,imgUrl:o,animation:l,passable:s,restrict:a});this.links.push(e)}}}}createNode(t){const e=new xp(Object.assign({},t));return this.add(e),e}createCircle(t){const e=new _p(Object.assign(Object.assign({},t),{rotation:{x:Math.PI/2,y:0,z:0}}));return this.add(e),e}createLink(t){const e=new bp(Object.assign({},t));return this.add(e),e}resetNodes(t){const{linkWidth:e=20,linkColor:n=65280,nodeColor:r=255,imgUrl:i,animation:s=!1}=this.info,a=[...this.info.nodes];this.info.nodes=[...t];const o=[];for(let e=0;e<a.length;e++){const n=t.find((t=>t.id===a[e].id));(!n||lh(n.position).distanceTo(lh(a[e].position))>1)&&o.push(a[e])}for(let t=0;t<o.length;t++){const e=this.nodes.findIndex((e=>o[t].id===e.sid));this.remove(this.nodes[e]),this.nodes.splice(e,1)}const l=[];for(let e=0;e<t.length;e++){const n=a.find((n=>n.id===t[e].id));(!n||lh(n.position).distanceTo(lh(t[e].position))>1)&&l.push(t[e])}for(let t=0;t<l.length;t++){const n=this.createNode(Object.assign(Object.assign({},l[t]),{radius:e/2,color:r}));this.nodes.push(n)}const c=[];for(let t=0;t<a.length;t++)for(let e=0;e<a[t].graphs.length;e++)c.push(Object.assign(Object.assign({},a[t].graphs[e]),{sourceNodeId:a[t].id.toString()}));const h=[];for(let e=0;e<t.length;e++)for(let n=0;n<t[e].graphs.length;n++)h.push(Object.assign(Object.assign({},t[e].graphs[n]),{sourceNodeId:t[e].id.toString()}));const u=[];for(let e=0;e<c.length;e++){const n=h.find((t=>t.linkInfo.id===c[e].linkInfo.id));if(n){const r=a.find((t=>t.id===n.targetNodeId)),i=t.find((t=>t.id===n.targetNodeId));r&&i&&lh(r.position).distanceTo(lh(i.position))>1&&u.push(c[e])}else u.push(c[e])}for(let t=0;t<u.length;t++){const e=this.links.findIndex((e=>u[t].linkInfo.id===e.sid));this.remove(this.links[e]),this.links.splice(e,1)}const d=[];for(let e=0;e<h.length;e++){const n=c.find((t=>t.linkInfo.id===h[e].linkInfo.id));if(n){const r=a.find((t=>t.id===n.targetNodeId)),i=t.find((t=>t.id===n.targetNodeId));r&&i&&lh(r.position).distanceTo(lh(i.position))>1&&d.push(h[e])}else d.push(h[e])}for(let r=0;r<d.length;r++){const{linkInfo:a,targetNodeId:o,sourceNodeId:l,passable:c,restrict:h}=d[r],{id:u,name:p}=a,f=t.find((t=>t.id===l)),m=t.find((t=>t.id===o));if(f&&m){const t=Ph(n)?n[c]?n[c]:n[0]:n,r=this.createLink({id:u,name:p,start:f.position,end:m.position,width:e,color:t,imgUrl:i,animation:s,passable:c,restrict:h});this.links.push(r)}}}}function Mp(t,e,n=new I(0,1,0)){const r=e/2,i=new we;let s=[],a=[];if(t.length<2)return i;for(let e=0;e<t.length-1;e++){const i=lh(t[e]),o=lh(t[e+1]),l=new I,c=new I;l.subVectors(o,i),l.normalize(),c.crossVectors(l,n);const h=new I(c.x*r,c.y*r,c.z*r),u=new I(-c.x*r,-c.y*r,-c.z*r),d=new I;d.addVectors(i,h);const p=new I;p.addVectors(i,u);const f=new I;f.addVectors(o,u);const m=new I;m.addVectors(o,h),s=[...s,d.x,d.y,d.z,p.x,p.y,p.z,f.x,f.y,f.z,f.x,f.y,f.z,m.x,m.y,m.z,d.x,d.y,d.z],a=[...a,0,0,1,0,1,1,1,1,0,1,0,0]}return i.setAttribute("position",new pe(s,3)),i.setAttribute("uv",new pe(a,2)),i}class Sp extends tu{constructor(t,e="Line"){const{points:n,width:r=20,color:i=65280,opacity:s=1}=t;super(Mp(n,r),function(t,e){return new ee({color:t,side:2,transparent:!0,opacity:e})}(i,s),t,e),this.params=t,this.points=n,this.frustumCulled=!1}setOptions(t){const{color:e,opacity:n,points:r,width:i}=t;this.points=r;const s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&i?this.geometry=Mp(r,i):r?this.geometry=Mp(r,this.params.width||20):i&&(this.geometry=Mp(this.points,i)),s.version++,ap.needRender=!0}}function Tp(t){const e=[];for(let n=0;n<t.length;n++)e.push(new g(t[n].x,t[n].z));return e.length>2?new Mo(new Ha(e)):new we}class Ap extends tu{constructor(t,e="Polygon"){const{yHeight:n,points:r,color:i=16776960,opacity:s=1}=t;super(Tp(r),function(t,e){return new ee({color:t,opacity:e,transparent:!0,side:2})}(i,s),t,e),this.points=r,this.position.set(0,n,0),this.rotation.set(Math.PI/2,0,0)}setOptions(t){const{color:e,opacity:n,yHeight:r,points:i}=t,s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&this.position.set(0,r,0),i&&(this.geometry=Tp(i)),s.version++,ap.needRender=!0}}class Ep extends eu{constructor(t){super(t,"Canvas3D"),this.create(t)}create(t){const{points:e=[],lines:n=[],polygons:r=[],circles:i=[]}=t;for(let t=0;t<e.length;t++)this.createPoint(e[t]);for(let t=0;t<n.length;t++)this.createLine(n[t]);for(let t=0;t<r.length;t++)this.createPolygon(r[t]);for(let t=0;t<i.length;t++)this.createCircle(i[t])}createPoint(t){const e=new yp(t);return this.add(e),ap.needRender=!0,e}getPoint(t){return this.getChildForType("Point",t)}removePoint(t){const e=this.getPoint(t);e&&this.remove(e),ap.needRender=!0}createLine(t){const e=new Sp(t);return this.add(e),ap.needRender=!0,e}getLine(t){return this.getChildForType("Line",t)}removeLine(t){const e=this.getLine(t);e&&this.remove(e),ap.needRender=!0}createPolygon(t){const e=new Ap(t);return this.add(e),ap.needRender=!0,e}getPolygon(t){return this.getChildForType("Polygon",t)}removePolygon(t){const e=this.getPolygon(t);e&&this.remove(e),ap.needRender=!0}createCircle(t){const e=new _p(t);return this.add(e),ap.needRender=!0,e}getCircle(t){return this.getChildForType("Circle",t)}removeCircle(t){const e=this.getCircle(t);e&&this.remove(e),ap.needRender=!0}getChildForType(t,e){for(let n=0;n<this.children.length;n++)if(this.children[n].stype===t&&this.children[n].sid===e)return this.children[n];return null}}class Pp extends tu{constructor(t,e,n){super(t,e,n,"Ground")}}var Cp=Object.freeze({__proto__:null,BaseObject3D:eu,BaseMesh:tu,SceneManage:nu,Group:ru,PluginObject:iu,PoiNode:Eu,Sbm:dp,Model:fp,Poi:vp,Icon:gp,Topology:wp,Point:yp,Line:Sp,Polygon:Ap,Circle:_p,Node:xp,Link:bp,Canvas3D:Ep,Ground:Pp});class Lp{constructor(t,e){this.type=t,this.scene=new nu({id:`${t.toLocaleLowerCase()}Manager`}),this.viewport=e,this.viewport.scener.addObject(this.scene)}update(){if(0===this.scene.children.length)return;const t=(t,e)=>{t.visible!==e&&(t instanceof Eu&&t._setElementDisplay(e),t.visible=e,t.matrixAutoUpdate=e,t.autoUpdate=!0)},e=e=>{const{level:n,handleHide:r,autoUpdate:i}=e,{max:s=null,min:a=null}=n;if(i)e.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!r&&(s||a)){const n=this.viewport.camera.position.distanceTo(e.position);t(e,!(s&&n>s)&&!(a&&n<a))}};this.scene.traverse((t=>{(t instanceof eu||t instanceof tu)&&e(t)}))}getById(t,e=this.type){return this._getChildByTypeAndProp(e,"sid",t)[0]||null}getByName(t,e=this.type){return this._getChildByTypeAndProp(e,"name",t)}getByUserDataProperty(t,e){const n=[];return this.scene.traverse((r=>{r instanceof eu&&Ch(r)&&r.stype===this.type&&(Lh(t)&&t(r.userData)||wh(t)&&r.userData[t]===e)&&n.push(r)})),n}removeById(t){const e=this.getById(t);return!!e&&(this.viewport.scener.removeObject(e),!0)}createGroup(t){const e=new ru(t);return this.viewport.scener.addObject(e,this.scene),e}getGroupById(t){return this._getChildByTypeAndProp("Group","sid",t)[0]||null}getGroupByName(t){return this._getChildByTypeAndProp("Group","name",t)}getAllGroup(){const t=[];return this.scene.traverse((e=>{e instanceof ru&&Ch(e)&&"Group"===e.stype&&t.push(e)})),t}removeGroupById(t){const e=this.getGroupById(t);return!!e&&(this.viewport.scener.removeObject(e),!0)}clear(){if(0===this.scene.children.length)return;for(let t=this.scene.children.length-1;t>=0;t--)this.viewport.scener.removeObject(this.scene.children[t])}getAll(){const t=[];return this.scene.traverse((e=>{((e instanceof eu||e instanceof tu)&&Ch(e)&&e.stype===this.type||Ch(e)&&e.userData.stype===this.type)&&t.push(e)})),t}hideAll(){this.getAll().forEach((t=>{t.hide?t.hide():t.visible=!1})),this.viewport.signals.objectChanged.dispatch()}showAll(){this.getAll().forEach((t=>{t.show?t.show():t.visible=!0})),this.viewport.signals.objectChanged.dispatch()}_getChildByTypeAndProp(t,e,n){const r=[];return e&&n?(this.scene.traverse((i=>{((i instanceof eu||i instanceof tu)&&Ch(i)&&i.stype===t&&i[e]===n||Ch(i)&&i.userData.stype===t&&i.userData[e]===n)&&r.push(i)})),r):r}}class Rp extends Lp{constructor(t){super("Light",t)}createAmbientLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1}=t,s=new Pl(r,i);return s.name=n||"",s.userData.sid=e,s.userData.stype="Light",this.viewport.scener.addObject(s,this.scene),s}setAmbientLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1}=t,s=this.getById(e);return!!s&&(s.name=n||"",s.color=new te(r),s.intensity=i,this.viewport.signals.objectChanged.dispatch(),!0)}createDirectionalLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1,position:s={x:1e3,y:1e3,z:1e3},target:a={x:-1e3,y:-1e3,z:-1e3},openShadow:o=!1}=t,l=new El(r,i);if(l.name=n||"",l.position.set(s.x,s.y,s.z),l.userData.sid=e,l.userData.stype="Light",l.castShadow=o,l.receiveShadow=!0,l.target.position.set(a.x,a.y,a.z),l.target.castShadow=o,l.target.receiveShadow=!0,l.target.updateMatrixWorld(),o){const t=l.position.distanceTo(l.target.position);l.shadow.camera.left=-t,l.shadow.camera.right=t,l.shadow.camera.top=t,l.shadow.camera.bottom=-t,l.shadow.camera.far=t,l.shadow.camera.updateProjectionMatrix()}return this.viewport.scener.addObject(l,this.scene),l}setDirectionalLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1,position:s={x:1e3,y:1e3,z:1e3},target:a={x:-1e3,y:-1e3,z:-1e3},openShadow:o=!1}=t,l=this.getById(e);if(!l)return!1;if(l.name=n||"",l.color=new te(r),l.intensity=i,l.position.set(s.x,s.y,s.z),l.castShadow=o,l.target.position.set(a.x,a.y,a.z),l.target.castShadow=o,l.target.updateMatrixWorld(),o){const t=l.position.distanceTo(l.target.position);l.shadow.camera.left=-t,l.shadow.camera.right=t,l.shadow.camera.top=t,l.shadow.camera.bottom=-t,l.shadow.camera.far=t,l.shadow.camera.updateProjectionMatrix()}return this.viewport.signals.objectChanged.dispatch(),!0}createHemisphereLight(t){const{id:e,name:n,skyColor:r=16777215,groundColor:i=14540253,intensity:s=1,position:a={x:0,y:0,z:0}}=t,o=new fl(r,i,s);return o.name=n||"",o.position.set(a.x,a.y,a.z),o.userData.sid=e,o.userData.stype="Light",o.castShadow=!0,o.receiveShadow=!0,this.viewport.scener.addObject(o,this.scene),o}setHemisphereLight(t){const{id:e,name:n,skyColor:r=16777215,groundColor:i=14540253,intensity:s=1,position:a={x:0,y:0,z:0}}=t,o=this.getById(e);return!!o&&(o.name=n||"",o.color=new te(r),o.groundColor=new te(i),o.intensity=s,o.position.set(a.x,a.y,a.z),this.viewport.signals.objectChanged.dispatch(),!0)}createSpotLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,angle:s=45,position:a={x:0,y:500,z:0},target:o={x:0,y:0,z:0},openShadow:l=!1}=t,c=lh(a).distanceTo(lh(o)),h=new _l(r,i,c,Math.PI/360*s,0,0);if(h.name=n||"",h.position.set(a.x,a.y,a.z),h.userData.sid=e,h.userData.stype="Light",h.castShadow=l,h.receiveShadow=!0,h.target.position.set(o.x,o.y,o.z),h.target.castShadow=l,h.target.receiveShadow=!0,h.target.updateMatrixWorld(),l){const t=h.position.distanceTo(h.target.position);h.shadow.focus=.6,h.shadow.camera.far=t,h.shadow.camera.updateProjectionMatrix()}return this.viewport.scener.addObject(h,this.scene),h}setSpotLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,angle:s=45,position:a={x:0,y:500,z:0},target:o={x:0,y:0,z:0},openShadow:l=!1}=t,c=this.getById(e);if(!c)return!1;const h=lh(a).distanceTo(lh(o));if(c.name=n||"",c.color=new te(r),c.intensity=i,c.distance=h,c.angle=Math.PI/360*s,c.position.set(a.x,a.y,a.z),c.castShadow=l,c.target.position.set(o.x,o.y,o.z),c.target.castShadow=l,c.target.updateMatrixWorld(),l){const t=c.position.distanceTo(c.target.position);c.shadow.focus=.6,c.shadow.camera.far=t,c.shadow.camera.updateProjectionMatrix()}return this.viewport.signals.objectChanged.dispatch(),!0}createPointLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,distance:s=5e3,position:a={x:0,y:500,z:0}}=t,o=new Tl(r,i,s);return o.name=n||"",o.userData.sid=e,o.userData.stype="Light",o.castShadow=!0,o.receiveShadow=!0,o.position.set(a.x,a.y,a.z),this.viewport.scener.addObject(o,this.scene),o}setPointLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,distance:s=5e3,position:a={x:0,y:500,z:0}}=t,o=this.getById(e);return!!o&&(o.name=n||"",o.color=new te(r),o.intensity=i,o.distance=s,o.position.set(a.x,a.y,a.z),this.viewport.signals.objectChanged.dispatch(),!0)}}
34
+ ***************************************************************************** */var Cu=function(t,e){return(Cu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var Lu=function(){return(Lu=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function Ru(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Iu(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,s=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}function Fu(t){return this instanceof Fu?(this.v=t,this):new Fu(t)}var Du=Object.freeze({__proto__:null,__extends:function(t,e){function n(){this.constructor=t}Cu(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},get __assign(){return Lu},__rest:function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n},__decorate:function(t,e,n,r){var i,s=arguments.length,a=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var o=t.length-1;o>=0;o--)(i=t[o])&&(a=(s<3?i(a):s>3?i(e,n,a):i(e,n))||a);return s>3&&a&&Object.defineProperty(e,n,a),a},__param:function(t,e){return function(n,r){e(n,r,t)}},__metadata:function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter:function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{l(r.next(t))}catch(t){s(t)}}function o(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))},__generator:function(t,e){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,o])}}},__createBinding:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]},__exportStar:function(t,e){for(var n in t)"default"===n||e.hasOwnProperty(n)||(e[n]=t[n])},__values:Ru,__read:Iu,__spread:function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Iu(arguments[e]));return t},__spreadArrays:function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var s=arguments[e],a=0,o=s.length;a<o;a++,i++)r[i]=s[a];return r},__await:Fu,__asyncGenerator:function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(t,e||[]),s=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(t){i[t]&&(r[t]=function(e){return new Promise((function(n,r){s.push([t,e,n,r])>1||o(t,e)}))})}function o(t,e){try{(n=i[t](e)).value instanceof Fu?Promise.resolve(n.value.v).then(l,c):h(s[0][2],n)}catch(t){h(s[0][3],t)}var n}function l(t){o("next",t)}function c(t){o("throw",t)}function h(t,e){t(e),s.shift(),s.length&&o(s[0][0],s[0][1])}},__asyncDelegator:function(t){var e,n;return e={},r("next"),r("throw",(function(t){throw t})),r("return"),e[Symbol.iterator]=function(){return this},e;function r(r,i){e[r]=t[r]?function(e){return(n=!n)?{value:Fu(t[r](e)),done:"return"===r}:i?i(e):e}:i}},__asyncValues:function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=Ru(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,i){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,i,(e=t[n](e)).done,e.value)}))}}},__makeTemplateObject:function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t},__importStar:function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e},__importDefault:function(t){return t&&t.__esModule?t:{default:t}},__classPrivateFieldGet:function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},__classPrivateFieldSet:function(t,e,n){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,n),n}}),Nu=function(){function t(e,n){if(void 0===n&&(n=null),this.nonEmpty=!1,e||n){if(!e)throw new Error("Parameter head cannot be null.");this.head=e,this.tail=n||t.NIL,this.nonEmpty=!0}else{if(t.NIL)throw new Error("Parameters head and tail are null. Use the NIL element instead.");this.nonEmpty=!1}}return Object.defineProperty(t.prototype,"length",{get:function(){if(!this.nonEmpty)return 0;if(this.tail===t.NIL)return 1;for(var e=0,n=this;n.nonEmpty;)++e,n=n.tail;return e},enumerable:!0,configurable:!0}),t.prototype.prepend=function(e){return new t(e,this)},t.prototype.append=function(e){if(!e)return this;if(!this.nonEmpty)return new t(e);if(this.tail===t.NIL)return new t(e).prepend(this.head);for(var n=new t(this.head),r=n,i=this.tail;i.nonEmpty;)r=r.tail=new t(i.head),i=i.tail;return r.tail=new t(e),n},t.prototype.insertWithPriority=function(e){if(!this.nonEmpty)return new t(e);var n=e.priority;if(n>this.head.priority)return this.prepend(e);for(var r=new t(this.head),i=r,s=this.tail;s.nonEmpty;){if(n>s.head.priority)return i.tail=s.prepend(e),r;i=i.tail=new t(s.head),s=s.tail}return i.tail=new t(e),r},t.prototype.filterNot=function(e){if(!this.nonEmpty||null==e)return this;if(e===this.head.listener)return this.tail;for(var n=new t(this.head),r=n,i=this.tail;i.nonEmpty;){if(i.head.listener===e)return r.tail=i.tail,n;r=r.tail=new t(i.head),i=i.tail}return this},t.prototype.contains=function(t){if(!this.nonEmpty)return!1;for(var e=this;e.nonEmpty;){if(e.head.listener===t)return!0;e=e.tail}return!1},t.prototype.find=function(t){if(!this.nonEmpty)return null;for(var e=this;e.nonEmpty;){if(e.head.listener===t)return e.head;e=e.tail}return null},t.prototype.toString=function(){for(var t="",e=this;e.nonEmpty;)t+=e.head+" -> ",e=e.tail;return"[List "+(t+="NIL")+"]"},t.NIL=new t(null,null),t}(),Ou=Object.defineProperty({SlotList:Nu},"__esModule",{value:!0}),Uu=function(){function t(t,e,n,r){void 0===n&&(n=!1),void 0===r&&(r=0),this._enabled=!0,this._once=!1,this._priority=0,this._listener=t,this._once=n,this._signal=e,this._priority=r,this.verifyListener(t)}return t.prototype.execute0=function(){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,this._params):this._listener())},t.prototype.execute1=function(t){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,[t].concat(this._params)):this._listener(t))},t.prototype.execute=function(t){if(this._enabled){this._once&&this.remove(),this._params&&this._params.length&&(t=t.concat(this._params));var e=t.length;0===e?this._listener():1===e?this._listener(t[0]):2===e?this._listener(t[0],t[1]):3===e?this._listener(t[0],t[1],t[2]):this._listener.apply(null,t)}},Object.defineProperty(t.prototype,"listener",{get:function(){return this._listener},set:function(t){if(null==t)throw new Error("Given listener is null.\nDid you want to set enabled to false instead?");this.verifyListener(t),this._listener=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"once",{get:function(){return this._once},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return this._priority},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return"[Slot listener: "+this._listener+", once: "+this._once+", priority: "+this._priority+", enabled: "+this._enabled+"]"},Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this._enabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"params",{get:function(){return this._params},set:function(t){this._params=t},enumerable:!0,configurable:!0}),t.prototype.remove=function(){this._signal.remove(this._listener)},t.prototype.verifyListener=function(t){if(null==t)throw new Error("Given listener is null.");if(null==this._signal)throw new Error("Internal signal reference has not been set yet.")},t}(),Bu=Object.defineProperty({Slot:Uu},"__esModule",{value:!0}),zu=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.slots=Ou.SlotList.NIL,this.valueClasses=1===t.length&&t[0]instanceof Array?t[0]:t}return Object.defineProperty(t.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(t){this._valueClasses=t?t.slice():[];for(var e=this._valueClasses.length;e--;)if(!(this._valueClasses[e]instanceof Object))throw new Error("Invalid valueClasses argument: item at index "+e+" should be a Class but was:<"+this._valueClasses[e]+">."+this._valueClasses[e])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numListeners",{get:function(){return this.slots.length},enumerable:!0,configurable:!0}),t.prototype.addOnce=function(t){return this.registerListener(t,!0)},t.prototype.remove=function(t){var e=this.slots.find(t);return e?(this.slots=this.slots.filterNot(t),e):null},t.prototype.removeAll=function(){this.slots=Ou.SlotList.NIL},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this._valueClasses.length,r=t.length;if(r<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+r+".");for(var i=0;i<n;i++)if(!(null===t[i]||t[i]instanceof this._valueClasses[i]||t[i].constructor===this._valueClasses[i]))throw new Error("Value object <"+t[i]+"> is not an instance of <"+this._valueClasses[i]+">.");var s=this.slots;if(s.nonEmpty)for(;s.nonEmpty;)s.head.execute(t),s=s.tail},t.prototype.registerListener=function(t,e){if(void 0===e&&(e=!1),this.registrationPossible(t,e)){var n=new Bu.Slot(t,this,e);return this.slots=this.slots.prepend(n),n}return this.slots.find(t)},t.prototype.registrationPossible=function(t,e){if(!this.slots.nonEmpty)return!0;var n=this.slots.find(t);if(!n)return!0;if(n.once!==e)throw new Error("You cannot addOnce() then add() the same listener without removing the relationship first.");return!1},t}(),ku=Object.defineProperty({OnceSignal:zu},"__esModule",{value:!0}),Hu="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Gu(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}function ju(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.')}var Vu=Gu(Du),Wu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Vu.__extends(e,t),e.prototype.add=function(t){return this.registerListener(t)},e}(ku.OnceSignal),Xu=Object.defineProperty({Signal:Wu},"__esModule",{value:!0}),Yu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Vu.__extends(e,t),e.prototype.addWithPriority=function(t,e){return void 0===e&&(e=0),this.registerListenerWithPriority(t,!1,e)},e.prototype.addOnceWithPriority=function(t,e){return void 0===e&&(e=0),this.registerListenerWithPriority(t,!0,e)},e.prototype.registerListener=function(t,e){return void 0===e&&(e=!1),this.registerListenerWithPriority(t,e)},e.prototype.registerListenerWithPriority=function(t,e,n){if(void 0===n&&(n=0),this.registrationPossible(t,e)){var r=new Bu.Slot(t,this,e,n);return this.slots=this.slots.insertWithPriority(r),r}return this.slots.find(t)},e}(Xu.Signal),qu=Object.defineProperty({PrioritySignal:Yu},"__esModule",{value:!0}),Qu=function(t){function e(e){void 0===e&&(e=null);for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this;return n=1===n.length&&n[0]instanceof Array?n[0]:n,(i=t.call(this,n)||this)._target=e,i}return Vu.__extends(e,t),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(t){t!==this._target&&(this.removeAll(),this._target=t)},enumerable:!0,configurable:!0}),e.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this._valueClasses.length,r=t.length;if(r<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+r+".");for(var i=0;i<n;i++)if(null!==t[i]&&t[i].constructor!==this._valueClasses[i])throw new Error("Value object <"+t[i]+"> is not an instance of <"+this._valueClasses[i]+">.");var s=t[0];s&&(s.target&&(s=s.clone(),t[0]=s),s.target=this.target,s.currentTarget=this.target,s.signal=this);for(var a=this.slots;a.nonEmpty;)a.head.execute(t),a=a.tail;if(s&&s.bubbles)for(var o=this.target;o&&o.hasOwnProperty("parent")&&(null===(o=o.parent).onEventBubbled||(s.currentTarget=o,o.onEventBubbled(s))););},e}(qu.PrioritySignal),Zu=Object.defineProperty({DeluxeSignal:Qu},"__esModule",{value:!0}),Ju=function(){function t(t){void 0===t&&(t=!1),this._bubbles=t}return Object.defineProperty(t.prototype,"signal",{get:function(){return this._signal},set:function(t){this._signal=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(t){this._target=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentTarget",{get:function(){return this._currentTarget},set:function(t){this._currentTarget=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bubbles",{get:function(){return this._bubbles},set:function(t){this._bubbles=t},enumerable:!0,configurable:!0}),t.prototype.clone=function(){return new t(this._bubbles)},t}(),Ku=Object.defineProperty({GenericEvent:Ju},"__esModule",{value:!0}),$u=Symbol("IOnceSignal"),td=Object.defineProperty({IOnceSignal:$u},"__esModule",{value:!0}),ed=Symbol("IPrioritySignal"),nd=Object.defineProperty({IPrioritySignal:ed},"__esModule",{value:!0}),rd=Symbol("ISignal"),id=Object.defineProperty({ISignal:rd},"__esModule",{value:!0}),sd=Symbol("ISlot"),ad=Object.defineProperty({ISlot:sd},"__esModule",{value:!0}),od=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.valueClasses=1===t.length&&t[0]instanceof Array?t[0]:t}return Object.defineProperty(t.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(t){this._valueClasses=t?t.slice():[];for(var e=this._valueClasses.length;e--;)if("function"!=typeof this._valueClasses[e])throw new Error("Invalid valueClasses argument: item at index "+e+" should be a Class but was:<"+this._valueClasses[e]+"'>."+this._valueClasses[e])},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numListeners",{get:function(){return this.slot?1:0},enumerable:!0,configurable:!0}),t.prototype.add=function(t){return this.registerListener(t)},t.prototype.addOnce=function(t){return this.registerListener(t,!0)},t.prototype.remove=function(t){if(this.slot&&this.slot.listener===t){var e=this.slot;return this.slot=null,e}return null},t.prototype.removeAll=function(){this.slot&&this.slot.remove()},t.prototype.dispatch=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this._valueClasses.length,r=t.length;if(r<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+r+".");for(var i=0;i<n;i++)if(!(null===t[i]||t[i]instanceof this._valueClasses[i]||t[i].constructor===this._valueClasses[i]))throw new Error("Value object <"+t[i]+"> is not an instance of <"+this._valueClasses[i]+">.");this.slot&&this.slot.execute(t)},t.prototype.registerListener=function(t,e){if(void 0===e&&(e=!1),this.slot)throw new Error("You cannot add or addOnce with a listener already added, remove the current listener first.");return this.slot=new Bu.Slot(t,this,e)},t}(),ld=Object.defineProperty({MonoSignal:od},"__esModule",{value:!0}),cd=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Vu.__extends(e,t),e.prototype.addOnce=function(e){var n=t.prototype.addOnce.call(this,e);return this.isDispatched&&(n.execute(this.valueObjects),n.remove()),n},e.prototype.dispatch=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(this.isDispatched)throw new Error("You cannot dispatch() a Promise more than once");this.isDispatched=!0,this.valueObjects=e,t.prototype.dispatch.apply(this,e)},e}(ku.OnceSignal),hd=Object.defineProperty({Promise:cd},"__esModule",{value:!0});Zu.DeluxeSignal,Ku.GenericEvent,td.IOnceSignal,nd.IPrioritySignal,id.ISignal,ad.ISlot,ld.MonoSignal,ku.OnceSignal,qu.PrioritySignal,hd.Promise;var ud=Xu.Signal;Bu.Slot,Ou.SlotList;const dd=new es;dd.name="Scene";class pd{constructor(t){this.signals=t,this.scene=dd.clone(),this.scene.castShadow=!0,this.scene.receiveShadow=!0,this.selectedObjects={edge:[],stroke:[],opacity:[],highlight:[],emissive:[]},this.intersectsList={meshOfModelList:[],poiIconList:[],otherObjList:[],getAll:function(){return[...this.meshOfModelList,...this.poiIconList,...this.otherObjList]}}}addObject(t,e){e?e.add(t):this.scene.add(t),this._triggerObjectAdded(t),this.signals.objectAdded.dispatch(t)}removeObject(t){var e;function n(t){var e;t instanceof No&&((e=t.map)&&e.isTexture&&e.dispose()),t.dispose()}t.traverse((t=>{if("Mesh"===t.type){const e=t;e.geometry.dispose(),Ph(e.material)?e.material.forEach((t=>n(t))):e.material instanceof No&&n(e.material)}t instanceof Eu&&t.element.remove();const{meshOfModelList:e,poiIconList:r,otherObjList:i}=this.intersectsList,s=e.findIndex((e=>e.uuid===t.uuid)),a=r.findIndex((e=>e.uuid===t.uuid)),o=i.findIndex((e=>e.uuid===t.uuid));s>-1&&this.intersectsList.meshOfModelList.splice(s,1),a>-1&&this.intersectsList.poiIconList.splice(a,1),o>-1&&this.intersectsList.otherObjList.splice(o,1)})),null===(e=t.parent)||void 0===e||e.remove(t),this.signals.objectRemoved.dispatch()}openSceneFog(t={}){const{color:e=13426943,near:n=500,far:r=5e4}=t;this.scene.fog=new ts(e,n,r),this.signals.sceneChanged.dispatch()}closeSceneFog(){this.scene.fog=null,this.signals.sceneChanged.dispatch()}edgeShow(t,e){const n=[],r=t=>{-1===this.selectedObjects.edge.findIndex((e=>e.uuid===t.uuid))&&n.push(t)};return Ph(t)?t.forEach((t=>r(t))):Ch(t)&&r(t),this.selectedObjects.edge=[...this.selectedObjects.edge,...n],this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge,options:e}),Promise.resolve()}unEdgeShow(t){t||(t=[...this.selectedObjects.edge]);const e=t=>{const e=this.selectedObjects.edge.findIndex((e=>e.uuid===t.uuid));return-1===e||(this.selectedObjects.edge.splice(e,1),this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge})),Promise.resolve()};return Ph(t)?Promise.all(t.map((t=>e(t)))):Ch(t)?e(t):Promise.resolve()}strokeShow(t,e={}){const{isOpacityShow:n=!0,color:r=4647927,opacity:i=.2,edgeColor:s=61183,edgeOpacity:a=1}=e,o=t=>{if(-1!==this.selectedObjects.stroke.findIndex((e=>e.sid===t.sid)))return Promise.resolve();if(t.userData.strokeGroup)return Promise.resolve();const e=new ru({id:t.sid});return t.traverse((t=>{if(t instanceof ke&&t.geometry){const n=new ya(t.geometry.clone(),89),r=new Zs(n,new Hs({color:s,transparent:!0,opacity:a}));gh(r,t),e.add(r)}})),t.userData.strokeGroup=e,this.addObject(e),this.selectedObjects.stroke.push(t),Promise.resolve()};return n&&this.opacityShow(t,{color:r,opacity:i}),Ph(t)?Promise.all(t.map((t=>o(t)))):Ch(t)?o(t):Promise.resolve()}unStrokeShow(t){t||(t=[...this.selectedObjects.stroke]);const e=t=>{if(!t.userData.strokeGroup)return Promise.resolve();this.removeObject(t.userData.strokeGroup),Reflect.deleteProperty(t.userData,"strokeGroup");const e=this.selectedObjects.stroke.findIndex((e=>e.sid===t.sid));return-1===e||(this.selectedObjects.stroke.splice(e,1),this.signals.geometryChanged.dispatch(),this.unOpacityShow(t)),Promise.resolve()};return Ph(t)?Promise.all(t.map((t=>e(t)))):Ch(t)?e(t):Promise.resolve()}opacityShow(t,e={}){const{color:n="#fff",opacity:r=.8}=e;function i(t){if(t.userData.material)return t;const e=t.clone();return(t=Reflect.construct(t.constructor,[{transparent:!0,color:n,opacity:r}])).userData.material=e,t}const s=t=>(-1!==this.selectedObjects.opacity.findIndex((e=>e.uuid===t.uuid))||(t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach(((e,n)=>{t.material[n]=i(e)})):t.material instanceof Yt&&(t.material=i(t.material)))})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(t)),Promise.resolve());return Ph(t)?Promise.all(t.map((t=>s(t)))):Ch(t)?s(t):Promise.resolve()}unOpacityShow(t){function e(t){if(!t.userData.material)return t;const e=t.userData.material.clone();return t.userData={},e}t||(t=[...this.selectedObjects.opacity]);const n=t=>new Promise((n=>{const r=this.selectedObjects.opacity.findIndex((e=>e.uuid===t.uuid));-1===r&&n(),this.selectedObjects.opacity.splice(r,1),t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach(((n,r)=>{t.material[r]=e(n)})):t.material instanceof Yt&&(t.material=e(t.material)))})),this.signals.materialChanged.dispatch(),n()}));return Ph(t)?Promise.all(t.map((t=>n(t)))):Ch(t)?n(t):Promise.resolve()}highlightShow(t,e={}){const{color:n="red",opacity:r=1}=e;function i(t){if(t instanceof No||t instanceof Fo){if(t.userData.color&&t.userData.opacity)return;t.userData={color:t.color.clone(),opacity:t.opacity,transparent:t.transparent},t.color=new te(n),t.opacity=r,t.transparent=!0}}const s=t=>(-1!==this.selectedObjects.highlight.findIndex((e=>e.uuid===t.uuid))||(t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>i(t))):t.material instanceof Yt&&i(t.material))})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(t)),Promise.resolve());return Ph(t)?Promise.all(t.map((t=>s(t)))):Ch(t)?s(t):Promise.resolve()}unHighlightShow(t){function e(t){if(t instanceof No||t instanceof Fo){if(!t.userData.color&&!t.userData.opacity)return;t.color=t.userData.color,t.opacity=t.userData.opacity,t.transparent=t.userData.transparent,t.userData={}}}t||(t=[...this.selectedObjects.highlight]);const n=t=>new Promise((n=>{const r=this.selectedObjects.highlight.findIndex((e=>e.uuid===t.uuid));-1===r&&n(),this.selectedObjects.highlight.splice(r,1),t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>e(t))):t.material instanceof Yt&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Ph(t)?Promise.all(t.map((t=>n(t)))):Ch(t)?n(t):Promise.resolve()}emissiveShow(t,e={}){const{color:n="red",opacity:r=.3,maxOpacity:i=1,minOpacity:s=0,duration:a=1e3}=e;function o(t){if(t instanceof No||t instanceof Fo){if(t.userData.emissive&&t.userData.opacity)return;t.userData={emissive:t.emissive.clone(),opacity:t.emissiveIntensity,animation:null},t.emissive.set(n),t.emissiveIntensity=r,$h({emissiveIntensity:i},{emissiveIntensity:s},{duration:a,repeat:!0},(e=>t.emissiveIntensity=e.emissiveIntensity),(e=>t.userData.animation=e))}}const l=t=>(-1!==this.selectedObjects.emissive.findIndex((e=>e.uuid===t.uuid))||(t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>o(t))):t.material instanceof Yt&&o(t.material))})),this.selectedObjects.emissive.push(t),this.signals.materialChanged.dispatch()),Promise.resolve());return Ph(t)?Promise.all(t.map((t=>l(t)))):Ch(t)?l(t):Promise.resolve()}unEmissiveShow(t){function e(t){var e;if(t instanceof No||t instanceof Fo){if(!t.userData.emissive&&!t.userData.opacity)return;t.emissive=t.userData.emissive.clone(),t.emissiveIntensity=t.userData.opacity,null===(e=t.userData.animation)||void 0===e||e.stop(),t.userData={}}}t||(t=[...this.selectedObjects.emissive]);const n=t=>new Promise((n=>{const r=this.selectedObjects.emissive.findIndex((e=>e.uuid===t.uuid));-1===r&&n(),this.selectedObjects.emissive.splice(r,1),t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material.forEach((t=>e(t))):t.material instanceof Yt&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Ph(t)?Promise.all(t.map((t=>n(t)))):Ch(t)?n(t):Promise.resolve()}_triggerObjectAdded(t){if(t instanceof eu)if("Sbm"===t.stype||"Model"===t.stype)t.traverse((t=>{if(t instanceof ke){-1===this.intersectsList.meshOfModelList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.meshOfModelList.push(t)}}));else if("Poi"===t.stype){-1===this.intersectsList.poiIconList.findIndex((e=>e.uuid===t.icon.uuid))&&this.intersectsList.meshOfModelList.push(t.icon)}else if("BaseMesh"===t.stype){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}else"Group"===t.stype?t.children.forEach((t=>this._triggerObjectAdded(t))):"Object3D"===t.type&&t.traverse((t=>{if(t instanceof ke){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}));else if(t instanceof tu){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}}class fd{constructor(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}const md=new yn(-1,1,1,-1,0,1),gd=new we;gd.setAttribute("position",new pe([-1,3,0,-1,-1,0,3,-1,0],3)),gd.setAttribute("uv",new pe([0,2,0,0,2,0],2));class vd{constructor(t){this._mesh=new ke(gd,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,md)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}const yd={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},tDiffuse:{value:null},tNormal:{value:null},size:{value:new g(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new ct},cameraInverseProjectionMatrix:{value:new ct},scale:{value:1},intensity:{value:.1},bias:{value:.5},minResolution:{value:0},kernelRadius:{value:100},randomSeed:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include <common>\n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform sampler2D tDepth;\n\n\t\t#if NORMAL_TEXTURE == 1\n\t\tuniform sampler2D tNormal;\n\t\t#endif\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include <packing>\n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\t#if NORMAL_TEXTURE == 1\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t\t#else\n\t\t\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},xd={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new g(512,512)},sampleUvOffsets:{value:[new g(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include <common>\n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include <common>\n\t\t#include <packing>\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},_d={createSampleWeights:function(t,e){const n=[];for(let r=0;r<=t;r++)n.push(bd(r,e));return n},createSampleOffsets:function(t,e){const n=[];for(let r=0;r<=t;r++)n.push(e.clone().multiplyScalar(r));return n},configure:function(t,e,n,r){t.defines.KERNEL_RADIUS=e,t.uniforms.sampleUvOffsets.value=_d.createSampleOffsets(e,r),t.uniforms.sampleWeights.value=_d.createSampleWeights(e,n),t.needsUpdate=!0}};function bd(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}var wd={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\t\t}"};const Md={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include <packing>\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );\n\t\t\tgl_FragColor = vec4( vec3( depth ), opacity );\n\n\t\t}"};class Sd extends fd{constructor(t,e,n=!1,r=!1,i=new g(256,256)){let s;super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=r,this.originalClearColor=new te,this._oldClearColor=new te,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new g(i.x,i.y),this.saoRenderTarget=new P(this.resolution.x,this.resolution.y,{minFilter:1006,magFilter:1006,format:1023}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new P(this.resolution.x,this.resolution.y,{minFilter:1003,magFilter:1003,format:1023}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(s=new qi,s.type=1012,this.beautyRenderTarget.depthTexture=s,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Bi,this.depthMaterial.depthPacking=3201,this.depthMaterial.blending=0,this.normalMaterial=new Uo,this.normalMaterial.blending=0,void 0===yd&&console.error("THREE.SAOPass relies on SAOShader"),this.saoMaterial=new Xe({defines:Object.assign({},yd.defines),fragmentShader:yd.fragmentShader,vertexShader:yd.vertexShader,uniforms:We.clone(yd.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?s:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=0,void 0===xd&&console.error("THREE.SAOPass relies on DepthLimitedBlurShader"),this.vBlurMaterial=new Xe({uniforms:We.clone(xd.uniforms),defines:Object.assign({},xd.defines),vertexShader:xd.vertexShader,fragmentShader:xd.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?s:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=0,this.hBlurMaterial=new Xe({uniforms:We.clone(xd.uniforms),defines:Object.assign({},xd.defines),vertexShader:xd.vertexShader,fragmentShader:xd.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?s:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=0,void 0===wd&&console.error("THREE.SAOPass relies on CopyShader"),this.materialCopy=new Xe({uniforms:We.clone(wd.uniforms),vertexShader:wd.vertexShader,fragmentShader:wd.fragmentShader,blending:0}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=5,this.materialCopy.blendSrc=208,this.materialCopy.blendDst=200,this.materialCopy.blendEquation=100,this.materialCopy.blendSrcAlpha=206,this.materialCopy.blendDstAlpha=200,this.materialCopy.blendEquationAlpha=100,void 0===Md&&console.error("THREE.SAOPass relies on UnpackDepthRGBAShader"),this.depthCopy=new Xe({uniforms:We.clone(Md.uniforms),vertexShader:Md.vertexShader,fragmentShader:Md.fragmentShader,blending:0}),this.fsQuad=new vd(null)}render(t,e,n){if(this.renderToScreen&&(this.materialCopy.blending=0,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(t,this.materialCopy,null)),1===this.params.output)return;t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const r=t.autoClear;t.autoClear=!1,t.setRenderTarget(this.depthRenderTarget),t.clear(),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;const i=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=i,this.hBlurMaterial.uniforms.depthCutoff.value=i,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(_d.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new g(0,1)),_d.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new g(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),t.setClearColor(0),t.setRenderTarget(this.beautyRenderTarget),t.clear(),t.render(this.scene,this.camera),this.supportsDepthTextureExtension||this.renderOverride(t,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(t,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(t,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(t,this.hBlurMaterial,this.saoRenderTarget,16777215,1));let s=this.materialCopy;3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,s=this.depthCopy):4===this.params.output?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?s.blending=5:s.blending=0,this.renderPass(t,s,this.renderToScreen?null:n),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=r}renderPass(t,e,n,r,i){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,null!=r&&(t.setClearColor(r),t.setClearAlpha(i||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}renderOverride(t,e,n,r,i){t.getClearColor(this.originalClearColor);const s=t.getClearAlpha(),a=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,r=e.clearColor||r,i=e.clearAlpha||i,null!=r&&(t.setClearColor(r),t.setClearAlpha(i||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=a,t.setClearColor(this.originalClearColor),t.setClearAlpha(s)}setSize(t,e){this.beautyRenderTarget.setSize(t,e),this.saoRenderTarget.setSize(t,e),this.blurIntermediateRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.depthRenderTarget.setSize(t,e),this.saoMaterial.uniforms.size.value.set(t,e),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(t,e),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(t,e),this.hBlurMaterial.needsUpdate=!0}}Sd.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};class Td extends fd{constructor(t,e,n,r,i){super(),this.scene=t,this.camera=e,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new te}render(t,e,n){const r=t.autoClear;let i,s;t.autoClear=!1,void 0!==this.overrideMaterial&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(t.getClearColor(this._oldClearColor),i=t.getClearAlpha(),t.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:n),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor&&t.setClearColor(this._oldClearColor,i),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=s),t.autoClear=r}}class Ad extends fd{constructor(t,e){super(),this.textureID=void 0!==e?e:"tDiffuse",t instanceof Xe?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=We.clone(t.uniforms),this.material=new Xe({defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new vd(this.material)}render(t,e,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}}class Ed extends fd{constructor(t,e,n,r){super(),this.renderScene=e,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new te(1,1,1),this.hiddenEdgeColor=new te(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this.resolution=void 0!==t?new g(t.x,t.y):new g(256,256);const i={minFilter:1006,magFilter:1006,format:1023},s=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.maskBufferMaterial=new ee({color:16777215}),this.maskBufferMaterial.side=2,this.renderTargetMaskBuffer=new P(this.resolution.x,this.resolution.y,i),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Bi,this.depthMaterial.side=2,this.depthMaterial.depthPacking=3201,this.depthMaterial.blending=0,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(t,e){var n=e.isPerspectiveCamera?"perspective":"orthographic";return t.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new P(this.resolution.x,this.resolution.y,i),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new P(s,a,i),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new P(s,a,i),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new P(Math.round(s/2),Math.round(a/2),i),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new P(s,a,i),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new P(Math.round(s/2),Math.round(a/2),i),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;this.separableBlurMaterial1=this.getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(s,a),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(s/2),Math.round(a/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial(),void 0===wd&&console.error("THREE.OutlinePass relies on CopyShader");const o=wd;this.copyUniforms=We.clone(o.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Xe({uniforms:this.copyUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new te,this.oldClearAlpha=1,this.fsQuad=new vd(null),this.tempPulseColor1=new te,this.tempPulseColor2=new te,this.textureMatrix=new ct}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()}setSize(t,e){this.renderTargetMaskBuffer.setSize(t,e),this.renderTargetDepthBuffer.setSize(t,e);let n=Math.round(t/this.downSampleRatio),r=Math.round(e/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,r),this.renderTargetBlurBuffer1.setSize(n,r),this.renderTargetEdgeBuffer1.setSize(n,r),this.separableBlurMaterial1.uniforms.texSize.value.set(n,r),n=Math.round(n/2),r=Math.round(r/2),this.renderTargetBlurBuffer2.setSize(n,r),this.renderTargetEdgeBuffer2.setSize(n,r),this.separableBlurMaterial2.uniforms.texSize.value.set(n,r)}changeVisibilityOfSelectedObjects(t){const e=this._visibilityCache;function n(n){n.isMesh&&(!0===t?n.visible=e.get(n):(e.set(n,n.visible),n.visible=t))}for(let t=0;t<this.selectedObjects.length;t++){this.selectedObjects[t].traverse(n)}}changeVisibilityOfNonSelectedObjects(t){const e=this._visibilityCache,n=[];function r(t){t.isMesh&&n.push(t)}for(let t=0;t<this.selectedObjects.length;t++){this.selectedObjects[t].traverse(r)}this.renderScene.traverse((function(r){if(r.isMesh||r.isSprite){let i=!1;for(let t=0;t<n.length;t++){if(n[t].id===r.id){i=!0;break}}if(!1===i){const n=r.visible;!1!==t&&!0!==e.get(r)||(r.visible=t),e.set(r,n)}}else(r.isPoints||r.isLine)&&(!0===t?r.visible=e.get(r):(e.set(r,r.visible),r.visible=t))}))}updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(t,e,n,r,i){if(this.selectedObjects.length>0){t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const e=t.autoClear;t.autoClear=!1,i&&t.state.buffers.stencil.setTest(!1),t.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);const r=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,t.setRenderTarget(this.renderTargetDepthBuffer),t.clear(),t.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,t.setRenderTarget(this.renderTargetMaskBuffer),t.clear(),t.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=r,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,t.setRenderTarget(this.renderTargetMaskDownSampleBuffer),t.clear(),this.fsQuad.render(t),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const t=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(t),this.tempPulseColor2.multiplyScalar(t)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,t.setRenderTarget(this.renderTargetEdgeBuffer1),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Ed.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,t.setRenderTarget(this.renderTargetBlurBuffer1),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Ed.BlurDirectionY,t.setRenderTarget(this.renderTargetEdgeBuffer1),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Ed.BlurDirectionX,t.setRenderTarget(this.renderTargetBlurBuffer2),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Ed.BlurDirectionY,t.setRenderTarget(this.renderTargetEdgeBuffer2),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,i&&t.state.buffers.stencil.setTest(!0),t.setRenderTarget(n),this.fsQuad.render(t),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=e}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,t.setRenderTarget(null),this.fsQuad.render(t))}getPrepareMaskMaterial(){return new Xe({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new g(.5,.5)},textureMatrix:{value:null}},vertexShader:"#include <morphtarget_pars_vertex>\n\t\t\t\t#include <skinning_pars_vertex>\n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include <skinbase_vertex>\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <morphtarget_vertex>\n\t\t\t\t\t#include <skinning_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t\tvPosition = mvPosition;\n\t\t\t\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include <packing>\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}getEdgeDetectionMaterial(){return new Xe({uniforms:{maskTexture:{value:null},texSize:{value:new g(.5,.5)},visibleEdgeColor:{value:new I(1,1,1)},hiddenEdgeColor:{value:new I(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}getSeperableBlurMaterial(t){return new Xe({defines:{MAX_RADIUS:t},uniforms:{colorTexture:{value:null},texSize:{value:new g(.5,.5)},direction:{value:new g(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}getOverlayMaterial(){return new Xe({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n\t\t\t\t}",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}Ed.BlurDirectionX=new g(1,0),Ed.BlurDirectionY=new g(0,1);class Pd extends fd{constructor(t,e,n,r){super(),this.scene=t,this.camera=e,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==r?r:0,this._oldClearColor=new te,void 0===wd&&console.error("THREE.SSAARenderPass relies on CopyShader");const i=wd;this.copyUniforms=We.clone(i.uniforms),this.copyMaterial=new Xe({uniforms:this.copyUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.fsQuad=new vd(this.copyMaterial)}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)}setSize(t,e){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(t,e)}render(t,e,n){this.sampleRenderTarget||(this.sampleRenderTarget=new P(n.width,n.height,{minFilter:1006,magFilter:1006,format:1023}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");const r=Cd[Math.max(0,Math.min(this.sampleLevel,5))],i=t.autoClear;t.autoClear=!1,t.getClearColor(this._oldClearColor);const s=t.getClearAlpha(),a=1/r.length;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture;const o={fullWidth:n.width,fullHeight:n.height,offsetX:0,offsetY:0,width:n.width,height:n.height},l=Object.assign({},this.camera.view);l.enabled&&Object.assign(o,l);for(let n=0;n<r.length;n++){const i=r[n];this.camera.setViewOffset&&this.camera.setViewOffset(o.fullWidth,o.fullHeight,o.offsetX+.0625*i[0],o.offsetY+.0625*i[1],o.width,o.height);let s=a;if(this.unbiased){s+=.03125*((n+.5)/r.length-.5)}this.copyUniforms.opacity.value=s,t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(this.renderToScreen?null:e),0===n&&(t.setClearColor(0,0),t.clear()),this.fsQuad.render(t)}this.camera.setViewOffset&&l.enabled?this.camera.setViewOffset(l.fullWidth,l.fullHeight,l.offsetX,l.offsetY,l.width,l.height):this.camera.clearViewOffset&&this.camera.clearViewOffset(),t.autoClear=i,t.setClearColor(this._oldClearColor,s)}}const Cd=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],Ld={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new te(0)},defaultOpacity:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec3 defaultColor;\n\t\tuniform float defaultOpacity;\n\t\tuniform float luminosityThreshold;\n\t\tuniform float smoothWidth;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\n\t\t\tvec3 luma = vec3( 0.299, 0.587, 0.114 );\n\n\t\t\tfloat v = dot( texel.xyz, luma );\n\n\t\t\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n\t\t\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n\t\t\tgl_FragColor = mix( outputColor, texel, alpha );\n\n\t\t}"};class Rd extends fd{constructor(t,e,n,r){super(),this.strength=void 0!==e?e:1,this.radius=n,this.threshold=r,this.resolution=void 0!==t?new g(t.x,t.y):new g(256,256),this.clearColor=new te(0,0,0);const i={minFilter:1006,magFilter:1006,format:1023};this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let s=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new P(s,a,i),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let t=0;t<this.nMips;t++){const e=new P(s,a,i);e.texture.name="UnrealBloomPass.h"+t,e.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e);const n=new P(s,a,i);n.texture.name="UnrealBloomPass.v"+t,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),s=Math.round(s/2),a=Math.round(a/2)}void 0===Ld&&console.error("THREE.UnrealBloomPass relies on LuminosityHighPassShader");const o=Ld;this.highPassUniforms=We.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new Xe({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,defines:{}}),this.separableBlurMaterials=[];const l=[3,5,7,9,11];s=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let t=0;t<this.nMips;t++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(l[t])),this.separableBlurMaterials[t].uniforms.texSize.value=new g(s,a),s=Math.round(s/2),a=Math.round(a/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=e,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new I(1,1,1),new I(1,1,1),new I(1,1,1),new I(1,1,1),new I(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,void 0===wd&&console.error("THREE.UnrealBloomPass relies on CopyShader");const c=wd;this.copyUniforms=We.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Xe({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:2,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new te,this.oldClearAlpha=1,this.basic=new ee,this.fsQuad=new vd(null)}dispose(){for(let t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(let t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose()}setSize(t,e){let n=Math.round(t/2),r=Math.round(e/2);this.renderTargetBright.setSize(n,r);for(let t=0;t<this.nMips;t++)this.renderTargetsHorizontal[t].setSize(n,r),this.renderTargetsVertical[t].setSize(n,r),this.separableBlurMaterials[t].uniforms.texSize.value=new g(n,r),n=Math.round(n/2),r=Math.round(r/2)}render(t,e,n,r,i){t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const s=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),i&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,t.setRenderTarget(null),t.clear(),this.fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this.fsQuad.render(t);let a=this.renderTargetBright;for(let e=0;e<this.nMips;e++)this.fsQuad.material=this.separableBlurMaterials[e],this.separableBlurMaterials[e].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[e].uniforms.direction.value=Rd.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[e]),t.clear(),this.fsQuad.render(t),this.separableBlurMaterials[e].uniforms.colorTexture.value=this.renderTargetsHorizontal[e].texture,this.separableBlurMaterials[e].uniforms.direction.value=Rd.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[e]),t.clear(),this.fsQuad.render(t),a=this.renderTargetsVertical[e];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,i&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(n),this.fsQuad.render(t)),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=s}getSeperableBlurMaterial(t){return new Xe({defines:{KERNEL_RADIUS:t,SIGMA:t},uniforms:{colorTexture:{value:null},texSize:{value:new g(.5,.5)},direction:{value:new g(.5,.5)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include <common>\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat fSigma = float(SIGMA);\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(t){return new Xe({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform sampler2D dirtTexture;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}}Rd.BlurDirectionX=new g(1,0),Rd.BlurDirectionY=new g(0,1);class Id extends fd{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,n){const r=t.getContext(),i=t.state;let s,a;i.buffers.color.setMask(!1),i.buffers.depth.setMask(!1),i.buffers.color.setLocked(!0),i.buffers.depth.setLocked(!0),this.inverse?(s=0,a=1):(s=1,a=0),i.buffers.stencil.setTest(!0),i.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),i.buffers.stencil.setFunc(r.ALWAYS,s,4294967295),i.buffers.stencil.setClear(a),i.buffers.stencil.setLocked(!0),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),i.buffers.color.setLocked(!1),i.buffers.depth.setLocked(!1),i.buffers.stencil.setLocked(!1),i.buffers.stencil.setFunc(r.EQUAL,1,4294967295),i.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),i.buffers.stencil.setLocked(!0)}}class Fd extends fd{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class Dd{constructor(t,e){if(this.renderer=t,void 0===e){const n={minFilter:1006,magFilter:1006,format:1023},r=t.getSize(new g);this._pixelRatio=t.getPixelRatio(),this._width=r.width,this._height=r.height,(e=new P(this._width*this._pixelRatio,this._height*this._pixelRatio,n)).texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===wd&&console.error("THREE.EffectComposer relies on CopyShader"),void 0===Ad&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Ad(wd),this.clock=new ql}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);-1!==e&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){void 0===t&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let n=!1;for(let e=0,r=this.passes.length;e<r;e++){const r=this.passes[e];if(!1!==r.enabled){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(e),r.render(this.renderer,this.writeBuffer,this.readBuffer,t,n),r.needsSwap){if(n){const e=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(e.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),n.setFunc(e.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==Id&&(r instanceof Id?n=!0:r instanceof Fd&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new g);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,(t=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let t=0;t<this.passes.length;t++)this.passes[t].setSize(n,r)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}}new yn(-1,1,1,-1,0,1);const Nd=new we;Nd.setAttribute("position",new pe([-1,3,0,-1,-1,0,3,-1,0],3)),Nd.setAttribute("uv",new pe([0,2,0,0,2,0],2));const Od={uniforms:{tDiffuse:{value:null},resolution:{value:new g(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:'\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\t#define FXAA_PC 1\n\t\t#define FXAA_GLSL_100 1\n\t\t#define FXAA_QUALITY_PRESET 12\n\n\t\t#define FXAA_GREEN_AS_LUMA 1\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_PC_CONSOLE\n\t\t\t\t//\n\t\t\t\t// The console algorithm for PC is included\n\t\t\t\t// for developers targeting really low spec machines.\n\t\t\t\t// Likely better to just run FXAA_PC, and use a really low preset.\n\t\t\t\t//\n\t\t\t\t#define FXAA_PC_CONSOLE 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_GLSL_120\n\t\t\t\t#define FXAA_GLSL_120 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_GLSL_130\n\t\t\t\t#define FXAA_GLSL_130 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_HLSL_3\n\t\t\t\t#define FXAA_HLSL_3 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_HLSL_4\n\t\t\t\t#define FXAA_HLSL_4 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_HLSL_5\n\t\t\t\t#define FXAA_HLSL_5 0\n\t\t#endif\n\t\t/*==========================================================================*/\n\t\t#ifndef FXAA_GREEN_AS_LUMA\n\t\t\t\t//\n\t\t\t\t// For those using non-linear color,\n\t\t\t\t// and either not able to get luma in alpha, or not wanting to,\n\t\t\t\t// this enables FXAA to run using green as a proxy for luma.\n\t\t\t\t// So with this enabled, no need to pack luma in alpha.\n\t\t\t\t//\n\t\t\t\t// This will turn off AA on anything which lacks some amount of green.\n\t\t\t\t// Pure red and blue or combination of only R and B, will get no AA.\n\t\t\t\t//\n\t\t\t\t// Might want to lower the settings for both,\n\t\t\t\t//\t\tfxaaConsoleEdgeThresholdMin\n\t\t\t\t//\t\tfxaaQualityEdgeThresholdMin\n\t\t\t\t// In order to insure AA does not get turned off on colors\n\t\t\t\t// which contain a minor amount of green.\n\t\t\t\t//\n\t\t\t\t// 1 = On.\n\t\t\t\t// 0 = Off.\n\t\t\t\t//\n\t\t\t\t#define FXAA_GREEN_AS_LUMA 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_EARLY_EXIT\n\t\t\t\t//\n\t\t\t\t// Controls algorithm\'s early exit path.\n\t\t\t\t// On PS3 turning this ON adds 2 cycles to the shader.\n\t\t\t\t// On 360 turning this OFF adds 10ths of a millisecond to the shader.\n\t\t\t\t// Turning this off on console will result in a more blurry image.\n\t\t\t\t// So this defaults to on.\n\t\t\t\t//\n\t\t\t\t// 1 = On.\n\t\t\t\t// 0 = Off.\n\t\t\t\t//\n\t\t\t\t#define FXAA_EARLY_EXIT 1\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_DISCARD\n\t\t\t\t//\n\t\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t\t//\n\t\t\t\t// 1 = Use discard on pixels which don\'t need AA.\n\t\t\t\t//\t\t For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t\t// 0 = Return unchanged color on pixels which don\'t need AA.\n\t\t\t\t//\n\t\t\t\t#define FXAA_DISCARD 0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_FAST_PIXEL_OFFSET\n\t\t\t\t//\n\t\t\t\t// Used for GLSL 120 only.\n\t\t\t\t//\n\t\t\t\t// 1 = GL API supports fast pixel offsets\n\t\t\t\t// 0 = do not use fast pixel offsets\n\t\t\t\t//\n\t\t\t\t#ifdef GL_EXT_gpu_shader4\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_NV_gpu_shader5\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_ARB_gpu_shader5\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 1\n\t\t\t\t#endif\n\t\t\t\t#ifndef FXAA_FAST_PIXEL_OFFSET\n\t\t\t\t\t\t#define FXAA_FAST_PIXEL_OFFSET 0\n\t\t\t\t#endif\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#ifndef FXAA_GATHER4_ALPHA\n\t\t\t\t//\n\t\t\t\t// 1 = API supports gather4 on alpha channel.\n\t\t\t\t// 0 = API does not support gather4 on alpha channel.\n\t\t\t\t//\n\t\t\t\t#if (FXAA_HLSL_5 == 1)\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_ARB_gpu_shader5\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 1\n\t\t\t\t#endif\n\t\t\t\t#ifdef GL_NV_gpu_shader5\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 1\n\t\t\t\t#endif\n\t\t\t\t#ifndef FXAA_GATHER4_ALPHA\n\t\t\t\t\t\t#define FXAA_GATHER4_ALPHA 0\n\t\t\t\t#endif\n\t\t#endif\n\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFXAA QUALITY - TUNING KNOBS\n\t\t------------------------------------------------------------------------------\n\t\tNOTE the other tuning knobs are now in the shader function inputs!\n\t\t============================================================================*/\n\t\t#ifndef FXAA_QUALITY_PRESET\n\t\t\t\t//\n\t\t\t\t// Choose the quality preset.\n\t\t\t\t// This needs to be compiled into the shader as it effects code.\n\t\t\t\t// Best option to include multiple presets is to\n\t\t\t\t// in each shader define the preset, then include this file.\n\t\t\t\t//\n\t\t\t\t// OPTIONS\n\t\t\t\t// -----------------------------------------------------------------------\n\t\t\t\t// 10 to 15 - default medium dither (10=fastest, 15=highest quality)\n\t\t\t\t// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)\n\t\t\t\t// 39\t\t\t - no dither, very expensive\n\t\t\t\t//\n\t\t\t\t// NOTES\n\t\t\t\t// -----------------------------------------------------------------------\n\t\t\t\t// 12 = slightly faster then FXAA 3.9 and higher edge quality (default)\n\t\t\t\t// 13 = about same speed as FXAA 3.9 and better than 12\n\t\t\t\t// 23 = closest to FXAA 3.9 visually and performance wise\n\t\t\t\t//\t_ = the lowest digit is directly related to performance\n\t\t\t\t// _\t= the highest digit is directly related to style\n\t\t\t\t//\n\t\t\t\t#define FXAA_QUALITY_PRESET 12\n\t\t#endif\n\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - PRESETS\n\n\t\t============================================================================*/\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - MEDIUM DITHER PRESETS\n\t\t============================================================================*/\n\t\t#if (FXAA_QUALITY_PRESET == 10)\n\t\t\t\t#define FXAA_QUALITY_PS 3\n\t\t\t\t#define FXAA_QUALITY_P0 1.5\n\t\t\t\t#define FXAA_QUALITY_P1 3.0\n\t\t\t\t#define FXAA_QUALITY_P2 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 11)\n\t\t\t\t#define FXAA_QUALITY_PS 4\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 3.0\n\t\t\t\t#define FXAA_QUALITY_P3 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 12)\n\t\t\t\t#define FXAA_QUALITY_PS 5\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 4.0\n\t\t\t\t#define FXAA_QUALITY_P4 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 13)\n\t\t\t\t#define FXAA_QUALITY_PS 6\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 4.0\n\t\t\t\t#define FXAA_QUALITY_P5 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 14)\n\t\t\t\t#define FXAA_QUALITY_PS 7\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 4.0\n\t\t\t\t#define FXAA_QUALITY_P6 12.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 15)\n\t\t\t\t#define FXAA_QUALITY_PS 8\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 4.0\n\t\t\t\t#define FXAA_QUALITY_P7 12.0\n\t\t#endif\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - LOW DITHER PRESETS\n\t\t============================================================================*/\n\t\t#if (FXAA_QUALITY_PRESET == 20)\n\t\t\t\t#define FXAA_QUALITY_PS 3\n\t\t\t\t#define FXAA_QUALITY_P0 1.5\n\t\t\t\t#define FXAA_QUALITY_P1 2.0\n\t\t\t\t#define FXAA_QUALITY_P2 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 21)\n\t\t\t\t#define FXAA_QUALITY_PS 4\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 22)\n\t\t\t\t#define FXAA_QUALITY_PS 5\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 23)\n\t\t\t\t#define FXAA_QUALITY_PS 6\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 24)\n\t\t\t\t#define FXAA_QUALITY_PS 7\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 3.0\n\t\t\t\t#define FXAA_QUALITY_P6 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 25)\n\t\t\t\t#define FXAA_QUALITY_PS 8\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 4.0\n\t\t\t\t#define FXAA_QUALITY_P7 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 26)\n\t\t\t\t#define FXAA_QUALITY_PS 9\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 4.0\n\t\t\t\t#define FXAA_QUALITY_P8 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 27)\n\t\t\t\t#define FXAA_QUALITY_PS 10\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 4.0\n\t\t\t\t#define FXAA_QUALITY_P9 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 28)\n\t\t\t\t#define FXAA_QUALITY_PS 11\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 2.0\n\t\t\t\t#define FXAA_QUALITY_P9 4.0\n\t\t\t\t#define FXAA_QUALITY_P10 8.0\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_QUALITY_PRESET == 29)\n\t\t\t\t#define FXAA_QUALITY_PS 12\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.5\n\t\t\t\t#define FXAA_QUALITY_P2 2.0\n\t\t\t\t#define FXAA_QUALITY_P3 2.0\n\t\t\t\t#define FXAA_QUALITY_P4 2.0\n\t\t\t\t#define FXAA_QUALITY_P5 2.0\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 2.0\n\t\t\t\t#define FXAA_QUALITY_P9 2.0\n\t\t\t\t#define FXAA_QUALITY_P10 4.0\n\t\t\t\t#define FXAA_QUALITY_P11 8.0\n\t\t#endif\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t\t FXAA QUALITY - EXTREME QUALITY\n\t\t============================================================================*/\n\t\t#if (FXAA_QUALITY_PRESET == 39)\n\t\t\t\t#define FXAA_QUALITY_PS 12\n\t\t\t\t#define FXAA_QUALITY_P0 1.0\n\t\t\t\t#define FXAA_QUALITY_P1 1.0\n\t\t\t\t#define FXAA_QUALITY_P2 1.0\n\t\t\t\t#define FXAA_QUALITY_P3 1.0\n\t\t\t\t#define FXAA_QUALITY_P4 1.0\n\t\t\t\t#define FXAA_QUALITY_P5 1.5\n\t\t\t\t#define FXAA_QUALITY_P6 2.0\n\t\t\t\t#define FXAA_QUALITY_P7 2.0\n\t\t\t\t#define FXAA_QUALITY_P8 2.0\n\t\t\t\t#define FXAA_QUALITY_P9 2.0\n\t\t\t\t#define FXAA_QUALITY_P10 4.0\n\t\t\t\t#define FXAA_QUALITY_P11 8.0\n\t\t#endif\n\n\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAPI PORTING\n\n\t\t============================================================================*/\n\t\t#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)\n\t\t\t\t#define FxaaBool bool\n\t\t\t\t#define FxaaDiscard discard\n\t\t\t\t#define FxaaFloat float\n\t\t\t\t#define FxaaFloat2 vec2\n\t\t\t\t#define FxaaFloat3 vec3\n\t\t\t\t#define FxaaFloat4 vec4\n\t\t\t\t#define FxaaHalf float\n\t\t\t\t#define FxaaHalf2 vec2\n\t\t\t\t#define FxaaHalf3 vec3\n\t\t\t\t#define FxaaHalf4 vec4\n\t\t\t\t#define FxaaInt2 ivec2\n\t\t\t\t#define FxaaSat(x) clamp(x, 0.0, 1.0)\n\t\t\t\t#define FxaaTex sampler2D\n\t\t#else\n\t\t\t\t#define FxaaBool bool\n\t\t\t\t#define FxaaDiscard clip(-1)\n\t\t\t\t#define FxaaFloat float\n\t\t\t\t#define FxaaFloat2 float2\n\t\t\t\t#define FxaaFloat3 float3\n\t\t\t\t#define FxaaFloat4 float4\n\t\t\t\t#define FxaaHalf half\n\t\t\t\t#define FxaaHalf2 half2\n\t\t\t\t#define FxaaHalf3 half3\n\t\t\t\t#define FxaaHalf4 half4\n\t\t\t\t#define FxaaSat(x) saturate(x)\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_GLSL_100 == 1)\n\t\t\t#define FxaaTexTop(t, p) texture2D(t, p, 0.0)\n\t\t\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_GLSL_120 == 1)\n\t\t\t\t// Requires,\n\t\t\t\t//\t#version 120\n\t\t\t\t// And at least,\n\t\t\t\t//\t#extension GL_EXT_gpu_shader4 : enable\n\t\t\t\t//\t(or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)\n\t\t\t\t#define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n\t\t\t\t#if (FXAA_FAST_PIXEL_OFFSET == 1)\n\t\t\t\t\t\t#define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n\t\t\t\t#else\n\t\t\t\t\t\t#define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n\t\t\t\t#endif\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 1)\n\t\t\t\t\t\t// use #extension GL_ARB_gpu_shader5 : enable\n\t\t\t\t\t\t#define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n\t\t\t\t\t\t#define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n\t\t\t\t\t\t#define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n\t\t\t\t\t\t#define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n\t\t\t\t#endif\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_GLSL_130 == 1)\n\t\t\t\t// Requires "#version 130" or better\n\t\t\t\t#define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n\t\t\t\t#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 1)\n\t\t\t\t\t\t// use #extension GL_ARB_gpu_shader5 : enable\n\t\t\t\t\t\t#define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n\t\t\t\t\t\t#define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n\t\t\t\t\t\t#define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n\t\t\t\t\t\t#define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n\t\t\t\t#endif\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_HLSL_3 == 1)\n\t\t\t\t#define FxaaInt2 float2\n\t\t\t\t#define FxaaTex sampler2D\n\t\t\t\t#define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))\n\t\t\t\t#define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_HLSL_4 == 1)\n\t\t\t\t#define FxaaInt2 int2\n\t\t\t\tstruct FxaaTex { SamplerState smpl; Texture2D tex; };\n\t\t\t\t#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n\t\t\t\t#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#if (FXAA_HLSL_5 == 1)\n\t\t\t\t#define FxaaInt2 int2\n\t\t\t\tstruct FxaaTex { SamplerState smpl; Texture2D tex; };\n\t\t\t\t#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n\t\t\t\t#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n\t\t\t\t#define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)\n\t\t\t\t#define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)\n\t\t\t\t#define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)\n\t\t\t\t#define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)\n\t\t#endif\n\n\n\t\t/*============================================================================\n\t\t\t\t\t\t\t\t\t\t\t GREEN AS LUMA OPTION SUPPORT FUNCTION\n\t\t============================================================================*/\n\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\tFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n\t\t#else\n\t\t\t\tFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n\t\t#endif\n\n\n\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FXAA3 QUALITY - PC\n\n\t\t============================================================================*/\n\t\t#if (FXAA_PC == 1)\n\t\t/*--------------------------------------------------------------------------*/\n\t\tFxaaFloat4 FxaaPixelShader(\n\t\t\t\t//\n\t\t\t\t// Use noperspective interpolation here (turn off perspective interpolation).\n\t\t\t\t// {xy} = center of pixel\n\t\t\t\tFxaaFloat2 pos,\n\t\t\t\t//\n\t\t\t\t// Used only for FXAA Console, and not used on the 360 version.\n\t\t\t\t// Use noperspective interpolation here (turn off perspective interpolation).\n\t\t\t\t// {xy_} = upper left of pixel\n\t\t\t\t// {_zw} = lower right of pixel\n\t\t\t\tFxaaFloat4 fxaaConsolePosPos,\n\t\t\t\t//\n\t\t\t\t// Input color texture.\n\t\t\t\t// {rgb_} = color in linear or perceptual color space\n\t\t\t\t// if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t//\t\t {__a} = luma in perceptual color space (not linear)\n\t\t\t\tFxaaTex tex,\n\t\t\t\t//\n\t\t\t\t// Only used on the optimized 360 version of FXAA Console.\n\t\t\t\t// For everything but 360, just use the same input here as for "tex".\n\t\t\t\t// For 360, same texture, just alias with a 2nd sampler.\n\t\t\t\t// This sampler needs to have an exponent bias of -1.\n\t\t\t\tFxaaTex fxaaConsole360TexExpBiasNegOne,\n\t\t\t\t//\n\t\t\t\t// Only used on the optimized 360 version of FXAA Console.\n\t\t\t\t// For everything but 360, just use the same input here as for "tex".\n\t\t\t\t// For 360, same texture, just alias with a 3nd sampler.\n\t\t\t\t// This sampler needs to have an exponent bias of -2.\n\t\t\t\tFxaaTex fxaaConsole360TexExpBiasNegTwo,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// {x_} = 1.0/screenWidthInPixels\n\t\t\t\t// {_y} = 1.0/screenHeightInPixels\n\t\t\t\tFxaaFloat2 fxaaQualityRcpFrame,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// This effects sub-pixel AA quality and inversely sharpness.\n\t\t\t\t//\t Where N ranges between,\n\t\t\t\t//\t\t N = 0.50 (default)\n\t\t\t\t//\t\t N = 0.33 (sharper)\n\t\t\t\t// {x__} = -N/screenWidthInPixels\n\t\t\t\t// {_y_} = -N/screenHeightInPixels\n\t\t\t\t// {_z_} =\tN/screenWidthInPixels\n\t\t\t\t// {__w} =\tN/screenHeightInPixels\n\t\t\t\tFxaaFloat4 fxaaConsoleRcpFrameOpt,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// Not used on 360, but used on PS3 and PC.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// {x__} = -2.0/screenWidthInPixels\n\t\t\t\t// {_y_} = -2.0/screenHeightInPixels\n\t\t\t\t// {_z_} =\t2.0/screenWidthInPixels\n\t\t\t\t// {__w} =\t2.0/screenHeightInPixels\n\t\t\t\tFxaaFloat4 fxaaConsoleRcpFrameOpt2,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// Only used on 360 in place of fxaaConsoleRcpFrameOpt2.\n\t\t\t\t// This must be from a constant/uniform.\n\t\t\t\t// {x__} =\t8.0/screenWidthInPixels\n\t\t\t\t// {_y_} =\t8.0/screenHeightInPixels\n\t\t\t\t// {_z_} = -4.0/screenWidthInPixels\n\t\t\t\t// {__w} = -4.0/screenHeightInPixels\n\t\t\t\tFxaaFloat4 fxaaConsole360RcpFrameOpt2,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This used to be the FXAA_QUALITY_SUBPIX define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// Choose the amount of sub-pixel aliasing removal.\n\t\t\t\t// This can effect sharpness.\n\t\t\t\t//\t 1.00 - upper limit (softer)\n\t\t\t\t//\t 0.75 - default amount of filtering\n\t\t\t\t//\t 0.50 - lower limit (sharper, less sub-pixel aliasing removal)\n\t\t\t\t//\t 0.25 - almost off\n\t\t\t\t//\t 0.00 - completely off\n\t\t\t\tFxaaFloat fxaaQualitySubpix,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// The minimum amount of local contrast required to apply algorithm.\n\t\t\t\t//\t 0.333 - too little (faster)\n\t\t\t\t//\t 0.250 - low quality\n\t\t\t\t//\t 0.166 - default\n\t\t\t\t//\t 0.125 - high quality\n\t\t\t\t//\t 0.063 - overkill (slower)\n\t\t\t\tFxaaFloat fxaaQualityEdgeThreshold,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Quality.\n\t\t\t\t// This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// Trims the algorithm from processing darks.\n\t\t\t\t//\t 0.0833 - upper limit (default, the start of visible unfiltered edges)\n\t\t\t\t//\t 0.0625 - high quality (faster)\n\t\t\t\t//\t 0.0312 - visible limit (slower)\n\t\t\t\t// Special notes when using FXAA_GREEN_AS_LUMA,\n\t\t\t\t//\t Likely want to set this to zero.\n\t\t\t\t//\t As colors that are mostly not-green\n\t\t\t\t//\t will appear very dark in the green channel!\n\t\t\t\t//\t Tune by looking at mostly non-green content,\n\t\t\t\t//\t then start at zero and increase until aliasing is a problem.\n\t\t\t\tFxaaFloat fxaaQualityEdgeThresholdMin,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// This does not effect PS3, as this needs to be compiled in.\n\t\t\t\t//\t Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.\n\t\t\t\t//\t Due to the PS3 being ALU bound,\n\t\t\t\t//\t there are only three safe values here: 2 and 4 and 8.\n\t\t\t\t//\t These options use the shaders ability to a free *|/ by 2|4|8.\n\t\t\t\t// For all other platforms can be a non-power of two.\n\t\t\t\t//\t 8.0 is sharper (default!!!)\n\t\t\t\t//\t 4.0 is softer\n\t\t\t\t//\t 2.0 is really soft (good only for vector graphics inputs)\n\t\t\t\tFxaaFloat fxaaConsoleEdgeSharpness,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// This does not effect PS3, as this needs to be compiled in.\n\t\t\t\t//\t Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.\n\t\t\t\t//\t Due to the PS3 being ALU bound,\n\t\t\t\t//\t there are only two safe values here: 1/4 and 1/8.\n\t\t\t\t//\t These options use the shaders ability to a free *|/ by 2|4|8.\n\t\t\t\t// The console setting has a different mapping than the quality setting.\n\t\t\t\t// Other platforms can use other values.\n\t\t\t\t//\t 0.125 leaves less aliasing, but is softer (default!!!)\n\t\t\t\t//\t 0.25 leaves more aliasing, and is sharper\n\t\t\t\tFxaaFloat fxaaConsoleEdgeThreshold,\n\t\t\t\t//\n\t\t\t\t// Only used on FXAA Console.\n\t\t\t\t// This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.\n\t\t\t\t// It is here now to allow easier tuning.\n\t\t\t\t// Trims the algorithm from processing darks.\n\t\t\t\t// The console setting has a different mapping than the quality setting.\n\t\t\t\t// This only applies when FXAA_EARLY_EXIT is 1.\n\t\t\t\t// This does not apply to PS3,\n\t\t\t\t// PS3 was simplified to avoid more shader instructions.\n\t\t\t\t//\t 0.06 - faster but more aliasing in darks\n\t\t\t\t//\t 0.05 - default\n\t\t\t\t//\t 0.04 - slower and less aliasing in darks\n\t\t\t\t// Special notes when using FXAA_GREEN_AS_LUMA,\n\t\t\t\t//\t Likely want to set this to zero.\n\t\t\t\t//\t As colors that are mostly not-green\n\t\t\t\t//\t will appear very dark in the green channel!\n\t\t\t\t//\t Tune by looking at mostly non-green content,\n\t\t\t\t//\t then start at zero and increase until aliasing is a problem.\n\t\t\t\tFxaaFloat fxaaConsoleEdgeThresholdMin,\n\t\t\t\t//\n\t\t\t\t// Extra constants for 360 FXAA Console only.\n\t\t\t\t// Use zeros or anything else for other platforms.\n\t\t\t\t// These must be in physical constant registers and NOT immediates.\n\t\t\t\t// Immediates will result in compiler un-optimizing.\n\t\t\t\t// {xyzw} = float4(1.0, -1.0, 0.25, -0.25)\n\t\t\t\tFxaaFloat4 fxaaConsole360ConstDir\n\t\t) {\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat2 posM;\n\t\t\t\tposM.x = pos.x;\n\t\t\t\tposM.y = pos.y;\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 1)\n\t\t\t\t\t\t#if (FXAA_DISCARD == 0)\n\t\t\t\t\t\t\t\tFxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n\t\t\t\t\t\t\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t\t\t\t\t\t\t#define lumaM rgbyM.w\n\t\t\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t\t\t#define lumaM rgbyM.y\n\t\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\n\t\t\t\t\t\t\t\tFxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\t\t\t\t#define lumaM luma4A.w\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#define lumaE luma4A.z\n\t\t\t\t\t\t#define lumaS luma4A.x\n\t\t\t\t\t\t#define lumaSE luma4A.y\n\t\t\t\t\t\t#define lumaNW luma4B.w\n\t\t\t\t\t\t#define lumaN luma4B.z\n\t\t\t\t\t\t#define lumaW luma4B.x\n\t\t\t\t#else\n\t\t\t\t\t\tFxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n\t\t\t\t\t\t#if (FXAA_GREEN_AS_LUMA == 0)\n\t\t\t\t\t\t\t\t#define lumaM rgbyM.w\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\t#define lumaM rgbyM.y\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t#if (FXAA_GLSL_100 == 1)\n\t\t\t\t\t\t\tFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat maxSM = max(lumaS, lumaM);\n\t\t\t\tFxaaFloat minSM = min(lumaS, lumaM);\n\t\t\t\tFxaaFloat maxESM = max(lumaE, maxSM);\n\t\t\t\tFxaaFloat minESM = min(lumaE, minSM);\n\t\t\t\tFxaaFloat maxWN = max(lumaN, lumaW);\n\t\t\t\tFxaaFloat minWN = min(lumaN, lumaW);\n\t\t\t\tFxaaFloat rangeMax = max(maxWN, maxESM);\n\t\t\t\tFxaaFloat rangeMin = min(minWN, minESM);\n\t\t\t\tFxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n\t\t\t\tFxaaFloat range = rangeMax - rangeMin;\n\t\t\t\tFxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n\t\t\t\tFxaaBool earlyExit = range < rangeMaxClamped;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(earlyExit)\n\t\t\t\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\t\t\t\tFxaaDiscard;\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\t\treturn rgbyM;\n\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t#if (FXAA_GATHER4_ALPHA == 0)\n\t\t\t\t\t\t#if (FXAA_GLSL_100 == 1)\n\t\t\t\t\t\t\tFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t\tFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\t#endif\n\t\t\t\t#else\n\t\t\t\t\t\tFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));\n\t\t\t\t\t\tFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat lumaNS = lumaN + lumaS;\n\t\t\t\tFxaaFloat lumaWE = lumaW + lumaE;\n\t\t\t\tFxaaFloat subpixRcpRange = 1.0/range;\n\t\t\t\tFxaaFloat subpixNSWE = lumaNS + lumaWE;\n\t\t\t\tFxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n\t\t\t\tFxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat lumaNESE = lumaNE + lumaSE;\n\t\t\t\tFxaaFloat lumaNWNE = lumaNW + lumaNE;\n\t\t\t\tFxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n\t\t\t\tFxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat lumaNWSW = lumaNW + lumaSW;\n\t\t\t\tFxaaFloat lumaSWSE = lumaSW + lumaSE;\n\t\t\t\tFxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n\t\t\t\tFxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n\t\t\t\tFxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n\t\t\t\tFxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n\t\t\t\tFxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n\t\t\t\tFxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n\t\t\t\tFxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n\t\t\t\tFxaaBool horzSpan = edgeHorz >= edgeVert;\n\t\t\t\tFxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(!horzSpan) lumaN = lumaW;\n\t\t\t\tif(!horzSpan) lumaS = lumaE;\n\t\t\t\tif(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n\t\t\t\tFxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat gradientN = lumaN - lumaM;\n\t\t\t\tFxaaFloat gradientS = lumaS - lumaM;\n\t\t\t\tFxaaFloat lumaNN = lumaN + lumaM;\n\t\t\t\tFxaaFloat lumaSS = lumaS + lumaM;\n\t\t\t\tFxaaBool pairN = abs(gradientN) >= abs(gradientS);\n\t\t\t\tFxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n\t\t\t\tif(pairN) lengthSign = -lengthSign;\n\t\t\t\tFxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat2 posB;\n\t\t\t\tposB.x = posM.x;\n\t\t\t\tposB.y = posM.y;\n\t\t\t\tFxaaFloat2 offNP;\n\t\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\t\t\t\tif(!horzSpan) posB.x += lengthSign * 0.5;\n\t\t\t\tif( horzSpan) posB.y += lengthSign * 0.5;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat2 posN;\n\t\t\t\tposN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n\t\t\t\tposN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n\t\t\t\tFxaaFloat2 posP;\n\t\t\t\tposP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n\t\t\t\tposP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n\t\t\t\tFxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n\t\t\t\tFxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));\n\t\t\t\tFxaaFloat subpixE = subpixC * subpixC;\n\t\t\t\tFxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(!pairN) lumaNN = lumaSS;\n\t\t\t\tFxaaFloat gradientScaled = gradient * 1.0/4.0;\n\t\t\t\tFxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n\t\t\t\tFxaaFloat subpixF = subpixD * subpixE;\n\t\t\t\tFxaaBool lumaMLTZero = lumaMM < 0.0;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tlumaEndN -= lumaNN * 0.5;\n\t\t\t\tlumaEndP -= lumaNN * 0.5;\n\t\t\t\tFxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\tFxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n\t\t\t\tFxaaBool doneNP = (!doneN) || (!doneP);\n\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tif(doneNP) {\n\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 3)\n\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 4)\n\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 5)\n\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 6)\n\t\t\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t#if (FXAA_QUALITY_PS > 8)\n\t\t\t\tif(doneNP) {\n\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 9)\n\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 10)\n\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 11)\n\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t#if (FXAA_QUALITY_PS > 12)\n\t\t\t\t\t\t\t\t\t\t\t\tif(doneNP) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneN = abs(lumaEndN) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneP = abs(lumaEndP) >= gradientScaled;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdoneNP = (!doneN) || (!doneP);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#endif\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\t}\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat dstN = posM.x - posN.x;\n\t\t\t\tFxaaFloat dstP = posP.x - posM.x;\n\t\t\t\tif(!horzSpan) dstN = posM.y - posN.y;\n\t\t\t\tif(!horzSpan) dstP = posP.y - posM.y;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n\t\t\t\tFxaaFloat spanLength = (dstP + dstN);\n\t\t\t\tFxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n\t\t\t\tFxaaFloat spanLengthRcp = 1.0/spanLength;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaBool directionN = dstN < dstP;\n\t\t\t\tFxaaFloat dst = min(dstN, dstP);\n\t\t\t\tFxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n\t\t\t\tFxaaFloat subpixG = subpixF * subpixF;\n\t\t\t\tFxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n\t\t\t\tFxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n\t\t/*--------------------------------------------------------------------------*/\n\t\t\t\tFxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n\t\t\t\tFxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n\t\t\t\tif(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n\t\t\t\tif( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n\t\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\t\treturn FxaaTexTop(tex, posM);\n\t\t\t\t#else\n\t\t\t\t\t\treturn FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n\t\t\t\t#endif\n\t\t}\n\t\t/*==========================================================================*/\n\t\t#endif\n\n\t\tvoid main() {\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\tvUv,\n\t\t\t\tvec4(0.0),\n\t\t\t\ttDiffuse,\n\t\t\t\ttDiffuse,\n\t\t\t\ttDiffuse,\n\t\t\t\tresolution,\n\t\t\t\tvec4(0.0),\n\t\t\t\tvec4(0.0),\n\t\t\t\tvec4(0.0),\n\t\t\t\t0.75,\n\t\t\t\t0.166,\n\t\t\t\t0.0833,\n\t\t\t\t0.0,\n\t\t\t\t0.0,\n\t\t\t\t0.0,\n\t\t\t\tvec4(0.0)\n\t\t\t);\n\n\t\t\t// TODO avoid querying texture twice for same texel\n\t\t\tgl_FragColor.a = texture2D(tDiffuse, vUv).a;\n\t\t}'},Ud={uniforms:{tDiffuse:{type:"t",value:null},time:{type:"f",value:-1}},vertexShader:"\nvarying vec2 vUv;\nvarying vec3 iPosition;\nvoid main(){\n vUv = uv;\n iPosition = position;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\nuniform float time;\nuniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvarying vec3 iPosition;\nvoid main(){\n\tvec4 texel = texture2D(tDiffuse, vUv);\n\tfloat x = iPosition.x;\n\tfloat lighty = -x*2.0 + time;\n\tfloat alpha = abs(iPosition.y - lighty);\n\tif(alpha < 0.1){\n float a = 1.0 - alpha / 0.1;\n float enda = smoothstep(0.0,1.0,a) + 0.3;\n gl_FragColor = texel * enda+vec4(1.0,0,0,0);\n\t}else{\n gl_FragColor = texel * 0.3;\n\t}\n} \n"};class Bd{constructor(t,e){this.scene=t,this.options=e,this.internalOptions={enableRenderCss2D:!1,enableRenderCss2DHalf:!1,enableRenderCss3D:!1},this.effectComposer=null,this.container=this._initContainer(),this.renderer=this._initRenderer(),this.rendererCSS2D=this._initRenderCSS2D(),this.rendererCSS3D=this._initRenderCSS3D(),this.rendererCSS2DHalf=this._initRenderCSS2DHalf(),this.interactiveContainer=this._initInteractiveContainer()}initEffectComposer(t){return this.effectComposer=new Dd(this.renderer),this.effectComposer.addPass(new Td(this.scene,t)),this.effectComposer}initAllPass(t){const e={ssaaPass:this._initSsaaPass(t),outlinePass:this._initOutlinePass(t)};for(let t in e)this.addPass(e[t]);return e}addPass(t){this.effectComposer&&this.effectComposer.addPass(t)}setInternalState(t,e){this.internalOptions[t]=e}getWidth(){return this.renderer.domElement.width}getHeight(){return this.renderer.domElement.height}getMouseRelativeConRatio(t){let e=this.container.getBoundingClientRect();return[(t.offsetX-e.left)/e.width,(t.offsetY-e.top)/e.height]}getMousePoint(t){let e=new g(0,0);return e.fromArray(this.getMouseRelativeConRatio(t)),e}_initContainer(){const t=document.createElement("div");return t.style.position="relative",t.style.width="100%",t.style.height="100%",t}_initRenderer(){const{background:t={},logarithmicDepthBuffer:e}=this.options,{color:n,alpha:r}=t,i=new Ji({antialias:!0,alpha:r,logarithmicDepthBuffer:e,preserveDrawingBuffer:!0}),s=r?0:1;i.setClearColor(n||0,s),i.setPixelRatio(window.devicePixelRatio),i.autoClear=!1,i.outputEncoding=3e3,i.localClippingEnabled=!0,i.sortObjects=!0,i.shadowMap.type=2,i.shadowMap.enabled=!0;const{offsetWidth:a,offsetHeight:o}=this.container;return i.domElement.style.width=a.toString(),i.domElement.style.height=o.toString(),this.container.appendChild(i.domElement),i}_initRenderCSS2D(){const t=new fu;return t.domElement.id="ssp_view_2DPoi",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.width="100%",t.domElement.style.height="100%",t.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(t.domElement),t}_initRenderCSS3D(){const t=new wu;return t.domElement.id="ssp_view_3DPoi",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.width="100%",t.domElement.style.height="100%",t.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(t.domElement),t}_initRenderCSS2DHalf(){const t=new Au(this.rendererCSS3D.domElement,this.rendererCSS3D.cameraElement);return t.setSize(this.container.offsetWidth,this.container.offsetHeight),t}_initInteractiveContainer(){return this.rendererCSS3D.domElement}_initFxaaPass(){const t=new Ad(Od),e=this.renderer.getPixelRatio();return t.material.uniforms.resolution.value.x=1/(this.container.offsetWidth*e),t.material.uniforms.resolution.value.y=1/(this.container.offsetHeight*e),t}_initSsaaPass(t){let e=new Pd(this.scene,t,0,0);return e.unbiased=!0,e.sampleLevel=1,e}_initOutlinePass(t){return new Ed(new g(window.innerWidth,window.innerHeight),this.scene,t)}_initSweepingLightShaderPass(){return new Ad(Ud)}_initUnrealBloomPass(){return new Rd(new g(this.getWidth(),this.getHeight()),0,.4,.85)}_initSAOPass(t){const e=new Sd(this.scene,t,!1,!0);return e.params.saoScale=368900,e}}const zd=new ct,kd=(t,e)=>{const n=zd.clone(),r=zd.clone(),i=zd.clone();n.makeRotationY(t),r.makeRotationX(e);const s=new xt;return i.multiplyMatrices(n,r),s.setFromRotationMatrix(i),s},Hd=kd(-Math.PI/2,-Math.PI/4),Gd=kd(Math.PI/2,-Math.PI/4),jd=kd(-Math.PI/4,-Math.PI/4),Vd=kd(Math.PI/4,-Math.PI/4),Wd=kd(1.25*Math.PI,-Math.PI/4),Xd=kd(.75*Math.PI,-Math.PI/4),Yd={LEFT:new xt(0,-Math.PI/2,0),RIGHT:new xt(0,Math.PI/2,0),FRONT:new xt(0,0,0),BACK:new xt(0,Math.PI,0),TOP:new xt(-Math.PI/2,0,0),BOTTOM:new xt(Math.PI/2,0,0),FRONTTOP:new xt(-Math.PI/4,0,0),BACKTOP:new xt(Math.PI/4,Math.PI,0),LEFTTOP:new xt(Hd.x,Hd.y,Hd.z),RIGHTTOP:new xt(Gd.x,Gd.y,Gd.z),LEFTFRONTTOP:new xt(jd.x,jd.y,jd.z),RIGHTFRONTTOP:new xt(Vd.x,Vd.y,Vd.z),LEFTBACKTOP:new xt(Wd.x,Wd.y,Wd.z),RIGHTBACKTOP:new xt(Xd.x,Xd.y,Xd.z)},qd=t=>Sh(t)?t:t.includes("%")?.01*Number(t.split("%")[0]):isNaN(+t)?0:Number(t),Qd=new qe(50,1,.1,5e5);Qd.name="Camera",Qd.position.set(500,1e3,500),Qd.lookAt(new I);class Zd{constructor(t){this.viewport=t,this.mainCamera=Qd.clone(),this.currentCamera=this.mainCamera,this.cameras={}}createCamera(t){const e=Qd.clone();return this.cameras[t]=e,e}removeCamera(t){return"fullFreeCamera"!==t&&(delete this.cameras[t],!0)}setCurrentCamera(t){this.currentCamera=this.viewport.camera=t,this.viewport.signals.cameraObjectChange.dispatch()}getMainCamera(){return this.mainCamera}getCameraViewpoint(){return{position:this.currentCamera.position.clone(),rotation:{x:this.currentCamera.rotation.x,y:this.currentCamera.rotation.y,z:this.currentCamera.rotation.z}}}setCameraViewpoint(t){const{position:e,rotation:n}=t;this.currentCamera.position.set(e.x,e.y,e.z),this.currentCamera.rotation.set(n.x,n.y,n.z),this.viewport.signals.cameraChange.dispatch(this.currentCamera.position.clone())}rotateTo(t,e){return $h(this.currentCamera.rotation,t,e)}moveTo(t,e){return $h(this.currentCamera.position,t,e,(t=>this.viewport.signals.cameraChange.dispatch(t)))}flyTo(t,e="frontTop",n){const r=this.viewport.controls.enableAutoRotate;this.viewport.controls.enableAutoRotate=!1;const i=new xt;if(wh(e)){const t=e.toLocaleUpperCase();"CURRENT"===t?i.copy(this.currentCamera.rotation):Yd[t]&&i.copy(Yd[t])}else e instanceof xt?i.copy(e):Ch(e)&&i.set(e.x,e.y,e.z);return i.copy(dh(this.currentCamera.rotation,i.clone())),Promise.all([this.moveTo(t,n),this.rotateTo(i,n)]).then((()=>(this.viewport.controls.enableAutoRotate=r,Promise.resolve())))}flyToBoundingBox(t,e="frontTop",n){if(wh(e)){if("CURRENT"===e.toLocaleUpperCase())return this.flyTo(this.getMovePosByBBox(t),e,n);{const r=Yd[e.toLocaleUpperCase()],i=this.getObjectLabelPos(t,r);return this.flyTo(i,e,n)}}{const r=ch(e),i=this.getObjectLabelPos(t,r);return this.flyTo(i,r,n)}}flyToObj(t,e="frontTop",n={}){if(t instanceof vp||t instanceof Eu){const{padding:r=50}=n,i=qd(r);return this.flyToBoundingBox(t.getBoundingBox(i),e,n)}{const{padding:r="30%"}=n,i=hh(t),s=i.getSize(new I);let a=0;if(wh(r)){const t=Math.max(s.x,s.y,s.z);a=qd(r)*t}else a=r;let o=a,l=a;if(a<0){const t=Math.min(s.x,s.z),e=s.y-1;o=Math.abs(a)>t?-t:a,l=Math.abs(o)>e?-e:o}return 0!==r&&(i.max.add(new I(o/2,l/2,o/2)),i.min.sub(new I(o/2,l/2,o/2))),this.flyToBoundingBox(i,e,n)}}surroundOnTarget(t,e={}){const{speed:n=1,angle:r=360,onStart:i}=e,s=lh(t),a=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),o=Math.abs(r);return $h({angle:0},{angle:Math.PI/180*o},{duration:o/360*5e3/n},(t=>{const e=r>0?t.angle:2*Math.PI-t.angle;this.currentCamera.position.x=Math.sin(e)*a+s.x,this.currentCamera.position.z=Math.cos(e)*a+s.z,this.currentCamera.lookAt(s)}),i)}surroundOnObject(t,e={}){const n=new N(new I,new I).setFromObject(t).getCenter(new I);return this.surroundOnTarget(n,e)}getMovePosByBBox(t){const e=this.currentCamera.position,n=t.getCenter(new I);(new I).subVectors(n,e).normalize();let r=new tt;r=t.getBoundingSphere(r);let i=this.currentCamera.fov/2*Math.PI/180,s=Math.sin(i),a=r.radius/s,o=new I;this.currentCamera.getWorldDirection(o);let l=o.clone();return l.multiplyScalar(-a),n.clone().add(l)}getObjectLabelPos(t,e="frontTop",n={}){t instanceof eu&&(t=new N(new I,new I).setFromObject(t));const{extendScale:r=1.6,mode:i="scene"}=n;if("scene"===i){const n=t.getCenter(new I),i=t.max.clone().sub(t.min),s=Math.max(i.x,i.y,i.z);let a=n.clone();const o=t=>{const e=(r-.5)*Math.abs(s),n=Math.max(e,this.viewport.camera.near);a.add(t.multiplyScalar(n))};let l;return l=wh(e)?Yd[e.toLocaleUpperCase()]:ch(e),o(new I(0,0,1).applyEuler(l)),a}return"screen"===i?t.getCenter(new I):new I}}const Jd=navigator.userAgent.toLowerCase().includes("mac");var Kd;!function(t){t[t.NONE=-1]="NONE",t[t.ROTATE=0]="ROTATE",t[t.ZOOM=1]="ZOOM",t[t.PAN=2]="PAN"}(Kd||(Kd={}));const $d=new I,tp=new g,ep=new g,np=[new I,new I,new I],rp=[new I,new I,new I];class ip{constructor(t,e){this.viewport=t,this.camera=e,this.domElement=t.interactiveContainer,this.enabled=!0,this.enabledMousePointInteractive=!0,this.enableZoom=!0,this.zoomSpeed=1,this.zoomMinDistance=50,this.zoomMaxDistance=1e5,this.zoomMinStepDistance=20,this.zoomMaxStepDistance=2e4,this.enableRotate=!0,this.enableRotateX=!0,this.enableRotateY=!0,this.rotateSpeed=1,this.rotateTiltRange={max:Math.PI,min:0},this.enableAutoRotate=!1,this.autoRotateSpeed=1,this.autoRotateClockwise=!0,this.enableOutOfScene=!0,this.unOffsetOfScene=0,this.enablePan=!0,this.enablePanX=!0,this.enablePanY=!0,this.enablePanAxisX=!0,this.enablePanAxisY=!0,this.enablePanAxisZ=!0,this.panSpeed=2,this.interactivePosition=null,this.state=Kd.NONE,this.init()}setOptions(t){for(let e in t)this[e]=t[e]}init(){const t=t=>{if(t.preventDefault(),!1===this.enabled)return;const e=this.domElement.getBoundingClientRect(),n=t.pageX-e.left,r=t.pageY-e.top;tp.set(n,r);const i=tp.x-ep.x,s=tp.y-ep.y;this.state===Kd.ROTATE?this.rotate(new I(.00375*-i,.00375*-s,0)):this.state===Kd.PAN&&this.pan(new I(-i,s,0)),ep.set(n,r)},e=n=>{n.preventDefault(),this.domElement.removeEventListener("mousemove",t,!1),window.removeEventListener("mouseup",e,!0),this.state=Kd.NONE},n=t=>{if(t.preventDefault(),!1!==this.enabled){switch(t.touches.length){case 1:np[0].set(t.touches[0].pageX,t.touches[0].pageY,0),np[1].set(t.touches[0].pageX,t.touches[0].pageY,0);var e=np[0].clone().sub(function(t,e){var n=e[0];for(var r in e)n.distanceTo(t)>e[r].distanceTo(t)&&(n=e[r]);return n}(np[0],rp));e.x=-e.x;const r=e.multiplyScalar(.9);this.pan(r);break;case 2:np[0].set(t.touches[0].pageX,t.touches[0].pageY,0),np[1].set(t.touches[1].pageX,t.touches[1].pageY,0);const i=rp[0].distanceTo(rp[1])-np[0].distanceTo(np[1]);this.zoom_touch(new I(0,0,i*this.zoomSpeed/25)),this.rotate(n(np,rp,"x"));break;case 3:case 4:case 5:np[0].set(t.touches[0].pageX,t.touches[0].pageY,0),np[1].set(t.touches[2].pageX,t.touches[2].pageY,0),this.rotate(n(np,rp,"y"))}rp[0].copy(np[0]),rp[1].copy(np[1])}function n(t,e,n="y"){const r=new g(t[1].x-t[0].x,t[1].y-t[0].y),i=new g(e[1].x-e[0].x,e[1].y-e[0].y),s=r.angle(),a=i.angle();r.normalize(),i.normalize();const o=e[0].y-t[0].y;return"y"===n?new I(0,.005*o,0):"x"===n?new I(s-a,0,0):new I}},r=t=>{t.preventDefault(),this.state=Kd.NONE,this.domElement.removeEventListener("touchmove",n,!1),this.domElement.removeEventListener("touchend",r,!1)};this.domElement.addEventListener("mousedown",(n=>{if(n.preventDefault(),!1===this.enabled)return;0===n.button?this.state=Kd.ROTATE:1===n.button?this.state=Kd.ZOOM:2===n.button&&(this.state=Kd.PAN);const r=this.domElement.getBoundingClientRect(),i=n.pageX-r.left,s=n.pageY-r.top;ep.set(i,s),this.state!==Kd.ROTATE&&this.state!==Kd.PAN||(this.interactivePosition=this.getInteractivePosition(n),this.domElement.addEventListener("mousemove",t,!1),window.addEventListener("mouseup",e,!0))}),!1),this.domElement.addEventListener("wheel",(t=>{if(t.preventDefault(),!this.enabled)return;let e=0;e=Jd&&t.shiftKey?120*-t.deltaX:120*-t.deltaY,this.zoom_on_point(new I(0,0,e),t)}),!1),this.domElement.addEventListener("touchstart",(t=>{if(t.preventDefault(),!1===this.enabled)return;const e=t.touches;switch(e.length){case 1:np[0].set(e[0].pageX,e[0].pageY,0),np[1].set(e[0].pageX,e[0].pageY,0);break;case 2:np[0].set(e[0].pageX,e[0].pageY,0),np[1].set(e[1].pageX,e[1].pageY,0);break;case 3:case 4:case 5:np[0].set(e[0].pageX,e[0].pageY,0),np[1].set(e[2].pageX,e[2].pageY,0)}rp[0].copy(np[0]),rp[1].copy(np[1]),this.interactivePosition=this.getInteractivePosition({offsetX:(np[0].x+np[1].x)/2,offsetY:(np[0].y+np[1].y)/2}),this.domElement.addEventListener("touchmove",n,!1),this.domElement.addEventListener("touchend",r,!1)}),!1)}getInteractivePosition(t){var e;if(this.enabledMousePointInteractive){const n=this.viewport.getIntersects(t);return n.length?null===(e=n[0].point)||void 0===e?void 0:e.clone():null}return null}intersectsBox(t){const e=this.getSceneBbox();let n=new I;e.getSize(n);let r=Math.max(n.x,n.y,n.z);0!=this.unOffsetOfScene&&(r=this.unOffsetOfScene);const i=e.clone();i.min.addScalar(r/2),i.max.addScalar(-r/2);let s=(new qe).copy(this.camera);return s.position.add(t),s.updateMatrixWorld(),s.updateProjectionMatrix(),(new sn).setFromProjectionMatrix((new ct).multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse)).intersectsBox(e)}caculateContainPoint(t,e){let n=(new I).copy(t).applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);return!(Math.abs(n.x)>1||Math.abs(n.y)>1||Math.abs(n.z)>1)}panLeft(t){const e=new I,n=this.camera.matrix.elements;this.enablePanAxisX&&e.setX(n[0]),this.enablePanAxisY&&e.setY(n[1]),this.enablePanAxisZ&&e.setZ(n[2]),e.multiplyScalar(t);let r=!0;this.enableOutOfScene||(r=this.intersectsBox(e)),r&&this.camera.position.add(e)}panUp(t){const e=new I,n=this.camera.matrix.elements;this.enablePanAxisX&&e.setX(n[4]),this.enablePanAxisY&&e.setY(n[5]),this.enablePanAxisZ&&e.setZ(n[6]),e.multiplyScalar(t);let r=!0;this.enableOutOfScene||(r=this.intersectsBox(e)),r&&this.camera.position.add(e)}pan(t){if(!this.enablePan)return;this.enablePanX||t.setX(0),this.enablePanY||t.setY(0);const e=this.interactivePosition||this.getSceneBbox().getCenter(new I);let n=this.camera.position.clone().sub(e).length();n*=Math.tan(this.camera.fov/2*Math.PI/180),n<50&&(n=50*this.panSpeed),this.panLeft(this.panSpeed*t.x*n/this.domElement.offsetHeight),this.panUp(this.panSpeed*t.y*n/this.domElement.offsetHeight),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}zoom_on_point(t,e){if(!this.enableZoom)return;this.interactivePosition=this.getInteractivePosition(e);let n=t.z>0?6:-6;const r=new I(0,0,0);let i;if(this.interactivePosition){i=this.interactivePosition.distanceTo(this.camera.position);const t=this.domElement.getBoundingClientRect();r.set(e.offsetX/t.width*2-1,-e.offsetY/t.height*2+1,.1)}else i=this.camera.position.y,r.set(0,0,.1);let s=!1;i>this.zoomMaxDistance&&n<0?(s=!0,i=this.zoomMaxDistance,n*=2):i<this.zoomMinDistance&&n>0&&(s=!0,i=this.zoomMinDistance,n*=2),r.unproject(this.camera),r.sub(this.camera.position);let a=i/n*this.zoomSpeed;if(s){if(!e.shiftKey)return;a>0?a>this.zoomMaxStepDistance?a=this.zoomMaxStepDistance:a<this.zoomMinStepDistance&&(a=this.zoomMinStepDistance):a<0&&(a<-this.zoomMaxStepDistance?a=-this.zoomMaxStepDistance:a>-this.zoomMinStepDistance&&(a=-this.zoomMinStepDistance))}const o=this.camera.position.clone().addVectors(this.camera.position,r.setLength(a));this.camera.position.copy(o),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}zoom_touch(t){if(!this.enableZoom)return;let e=t.z;const n=new I(0,0,0);let r;if(this.interactivePosition){const t=this.domElement.getBoundingClientRect(),e={offsetX:(rp[0].x+rp[1].x)/2,offsetY:(rp[0].y+rp[1].y)/2};r=this.interactivePosition.distanceTo(this.camera.position),n.set(e.offsetX/t.width*2-1,-e.offsetY/t.height*2+1,.1)}else r=this.camera.position.y,n.set(0,0,.1);if(r>this.zoomMaxDistance&&e>0?(r=this.zoomMaxDistance,e=0):r<this.zoomMinDistance&&e<0&&(r=this.zoomMinDistance,e=0),0===e)return;n.unproject(this.camera),n.sub(this.camera.position);let i=r*-e*this.zoomSpeed*.1;i>0?i>this.zoomMaxStepDistance?i=this.zoomMaxStepDistance:i<this.zoomMinStepDistance&&(i=this.zoomMinStepDistance):i<0&&(i<-this.zoomMaxStepDistance?i=-this.zoomMaxStepDistance:i>-this.zoomMinStepDistance&&(i=-this.zoomMinStepDistance));const s=this.camera.position.clone().addVectors(this.camera.position,n.setLength(i));this.camera.position.copy(s),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}rotate(t){if(!this.enableRotate)return;t.x*=this.rotateSpeed,t.y*=this.rotateSpeed;const e=new I(0,0,-1);e.applyQuaternion(this.camera.quaternion);const n=e.angleTo(new I(0,1,0));(n-t.y>this.rotateTiltRange.max&&t.y<0||n-t.y<this.rotateTiltRange.min&&t.y>0)&&(t.y=0);const r=this.interactivePosition||this.getSceneBbox().getCenter(new I);$d.copy(this.camera.position).sub(r);const i=new ct;let s=new I(1,0,0);this.enableRotateX&&i.makeRotationAxis(new I(0,1,0),t.x);const a=new ct;this.enableRotateY&&(s.applyEuler(this.camera.rotation),a.makeRotationAxis(s,t.y),i.multiply(a)),$d.applyMatrix4(i),e.applyMatrix4(i),this.camera.position.copy(r).add($d),this.camera.lookAt(e.add(this.camera.position)),this.viewport.signals.cameraChange.dispatch(this.camera.position.clone())}autoRotate(){const t=this.autoRotateClockwise?.01:-.01;this.rotate(new I(t*this.autoRotateSpeed,0,0))}update(){this.enableAutoRotate&&this.autoRotate()}getSceneBbox(){const t=this.viewport._getManagerScene("sbm"),e=this.viewport._getManagerScene("model"),n=new N;return t&&n.setFromObject(t),e&&n.union((new N).setFromObject(e)),n}}class sp{constructor(t,e){const n=document.createElement("div");function r(t,e=!0){const n=document.createElement("span");return e&&(n.style.marginLeft="6px"),n.innerHTML=t,n}function i(){return document.createElement("br")}n.style.position="absolute",n.style.left="12px",n.style.bottom="12px",n.style.fontSize="12px",n.style.color="#fff",this.container=n,this.state={objects:0,vertices:0,triangles:0,frametime:0,lodFrametime:0};const s=r("0"),a=r("0"),o=r("0"),l=r("0"),c=r("0");this.container.appendChild(r("objects",!1)),this.container.appendChild(s),this.container.appendChild(i()),this.container.appendChild(r("triangles",!1)),this.container.appendChild(a),this.container.appendChild(i()),this.container.appendChild(r("vertices",!1)),this.container.appendChild(o),this.container.appendChild(i()),this.container.appendChild(r("frametime",!1)),this.container.appendChild(l),this.container.appendChild(i()),this.container.appendChild(r("lodFrametime",!1)),this.container.appendChild(c);const h=()=>{this.state.objects=0,this.state.vertices=0,this.state.triangles=0;for(let e=0;e<t.children.length;e++){t.children[e].traverseVisible((t=>{var e,n,r,i;if("SceneManager"!==t.stype&&this.state.objects++,t.isMesh){let s=t.geometry;s.isGeometry?(this.state.vertices+=(null===(e=s.vertices)||void 0===e?void 0:e.length)||0,this.state.triangles+=(null===(n=s.faces)||void 0===n?void 0:n.length)||0):s.isBufferGeometry&&(this.state.vertices+=(null===(r=s.attributes.position)||void 0===r?void 0:r.count)||0,null!==s.index?this.state.triangles+=s.index.count/3:this.state.triangles+=(null===(i=s.attributes.position)||void 0===i?void 0:i.count)/3||0)}}))}s.innerHTML=String(this.state.objects),o.innerHTML=String(this.state.vertices),a.innerHTML=String(this.state.triangles)};e.objectAdded.add(h),e.objectRemoved.add(h),e.geometryChanged.add(h);e.sceneRendered.add((t=>{this.state.frametime=t,l.innerHTML=Number(t).toFixed(2)+" ms"}));e.loadRendered.add((t=>{this.state.lodFrametime=t,c.innerHTML=Number(t).toFixed(2)+" ms"}))}}const ap={needRender:!1};let op=0,lp=0;const cp=new ql;class hp{constructor(t){this.options=t,this.state={useFreq:1,animationTotal:0},this.signals={windowResize:new ud,cameraObjectChange:new ud,sceneChanged:new ud,backgroundChanged:new ud,beforeRender:new ud,afterRender:new ud,sceneRendered:new ud,loadRendered:new ud,tweenUpdate:new ud,hover:new ud,click:new ud,dblClick:new ud,rightClick:new ud,mouseDown:new ud,mouseMove:new ud,mouseUp:new ud,mouseWheel:new ud,keyDown:new ud,keyUp:new ud,modelHover:new ud,modelUnHover:new ud,modelClick:new ud,modelDblClick:new ud,modelRightClick:new ud,poiHover:new ud,poiUnHover:new ud,poiClick:new ud,poiDblClick:new ud,poiRightClick:new ud,selectPosition:new ud,sceneClick:new ud,objectAdded:new ud,objectRemoved:new ud,objectChanged:new ud,geometryChanged:new ud,materialAdded:new ud,materialChanged:new ud,materialRemoved:new ud,cameraChange:new ud,outlineChange:new ud,modelAnimation:new ud,getSceneInfo:new ud},this.scener=new pd(this.signals),this.scene=this.scener.scene,this.rendererManager=new Bd(this.scene,t),this.container=this.rendererManager.container,this.interactiveContainer=this.rendererManager.interactiveContainer,this.renderer=this.rendererManager.renderer,this.rendererCSS3D=this.rendererManager.rendererCSS3D,this.rendererCSS2D=this.rendererManager.rendererCSS2D,this.rendererCSS2DHalf=this.rendererManager.rendererCSS2DHalf,this.info=new sp(this.scene,this.signals),this.cameraManager=new Zd(this),this.camera=this.cameraManager.currentCamera,this.controls=new ip(this,this.camera),this.effectComposer=this.rendererManager.initEffectComposer(this.camera),this.pass=this.rendererManager.initAllPass(this.camera),this.mixer=new yc(this.scene),this.postUpdate=new Map,this.postRender=new Map,this.selectModel=null,this.selectPoi=null,this._loop=0,this.initInfo(),this._signalsEventListenr(),this._containerAddEventListener(this.container),this.animate(0)}initInfo(){if(this.options.showInfo){const{container:t}=this.info;t.style.zIndex="1",this.container.appendChild(t)}}setSphereSkyBackground(t){(new dl).load(t,(t=>{t.mapping=303,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setSkyBackground(t,e){yh(t,e).then((t=>{this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setBackgroundColor(t){this.renderer.setClearColor(t),this.scene.background=new te(t),this.signals.backgroundChanged.dispatch()}setBackgroundImage(t){(new dl).load(t,(t=>{t.wrapS=1002,t.wrapT=1002,t.encoding=3e3,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}playModelAnimation(t,e){let n;if(e instanceof el?n=e:Sh(e)?n=t.animations[e]:Lh(e)&&(n=t.animations.find(e)),!n)return;const r=this.mixer.clipAction(n,t);return r.play(),this.state.animationTotal++,r}stopModelAnimation(t,e){let n;e instanceof el?n=e:Sh(e)?n=t.animations[e]:Lh(e)&&(n=t.animations.find(e)),n&&(this.mixer.uncacheAction(n,t),this.state.animationTotal--)}render(t){return Pu(this,void 0,void 0,(function*(){return ap.needRender=!0,yield null==t?void 0:t(),new Promise((t=>{const e=()=>{ap.needRender=!1,this.signals.afterRender.remove(e),t()};this.signals.afterRender.add(e),this.trigerRender()}))}))}trigerRender(t=1){this.state.useFreq+=t,this.state.useFreq>50&&(this.state.useFreq=10)}autoRender(t){if(this.state.useFreq<=0&&!ap.needRender)return;this.state.useFreq>0&&this.state.useFreq--,ap.needRender&&(ap.needRender=!1),op=performance.now(),this.renderer.clear(),this.signals.beforeRender.dispatch(),this.renderer.render(this.scene,this.camera);const e=this.scene.autoUpdate;this.scene.autoUpdate=!1,this.rendererCSS2D&&this.rendererManager.internalOptions.enableRenderCss2D&&this.rendererCSS2D.render(this.scene,this.camera),this.rendererCSS2DHalf&&this.rendererManager.internalOptions.enableRenderCss2DHalf&&this.rendererCSS2DHalf.render(this.scene,this.camera),this.rendererCSS3D&&this.rendererManager.internalOptions.enableRenderCss3D&&this.rendererCSS3D.render(this.scene,this.camera),this.scene.autoUpdate=e,this.postRender.forEach((e=>e(t))),this.signals.afterRender.dispatch(),lp=performance.now(),this.signals.sceneRendered.dispatch(lp-op)}animate(t){this._loop=requestAnimationFrame((t=>{this.animate(t)}));const e=cp.getDelta();this.controls.update(),this.state.animationTotal>0&&(this.mixer.update(e),this.signals.modelAnimation.dispatch()),Jh.update()&&this.signals.tweenUpdate.dispatch(),this.postUpdate.forEach((e=>e(t))),this.autoRender(t),this.signals.getSceneInfo.dispatch(this.info.state)}getOffsetByPosition(t){const e=new I(t.x,t.y,t.z).project(this.camera),n=this.renderer.domElement.getBoundingClientRect();return{left:Math.round(n.left+n.width/2*(e.x+1)),top:Math.round(n.top+n.height/2*(1-e.y))}}getPositionByOffset(t,e=.1){const n=new I(0,0,0),r=new I(0,0,0),i=this.renderer.domElement.getBoundingClientRect();r.set(t.offsetX/i.width*2-1,-t.offsetY/i.height*2+1,e),r.unproject(this.camera),r.sub(this.camera.position).normalize();const s=r.distanceTo(this.camera.position);return n.copy(this.camera.position).add(r.multiplyScalar(s)),n}getIntersects(t,e=this.scener.intersectsList.getAll()){let n={offsetX:0,offsetY:0};if(t instanceof MouseEvent)n={offsetX:t.offsetX,offsetY:t.offsetY};else if(t instanceof TouchEvent){const{changedTouches:e}=t,r=this.renderer.domElement.getBoundingClientRect();n={offsetX:e[0].pageX-r.left,offsetY:e[0].pageY-r.top}}else n=t;const r=new g;r.set(n.offsetX/this.container.offsetWidth*2-1,-n.offsetY/this.container.offsetHeight*2+1);const i=new wc;return i.setFromCamera(r,this.camera),Ph(e)?i.intersectObjects(e,!0):i.intersectObject(e,!0)}rayClash(t=this.camera.position,e=new I(0,-1,0),n=this.scener.intersectsList.meshOfModelList){const r=new wc;return r.set(t,e),Ph(n)?r.intersectObjects(n,!0):r.intersectObject(n,!0)}setHoverEnabled(t){this.options.hoverEnabled=t}clearSignals(){for(let t in this.signals)this.signals[t].removeAll()}dispose(){return new Promise((t=>{cancelAnimationFrame(this._loop),setTimeout((()=>{Jh.removeAll(),this.clearSignals(),this.scene.remove(),this.renderer.forceContextLoss(),this.renderer.dispose(),this.container.remove(),t()}),100)}))}_signalsEventListenr(){const t=()=>{this.camera.aspect=this.container.offsetWidth/this.container.offsetHeight,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.rendererCSS3D&&this.rendererCSS3D.setSize(this.container.offsetWidth,this.container.offsetHeight),this.rendererCSS2D&&this.rendererCSS2D.setSize(this.container.offsetWidth,this.container.offsetHeight),this.rendererCSS2DHalf&&this.rendererCSS2DHalf.setSize(this.container.offsetWidth,this.container.offsetHeight),this.effectComposer&&this.effectComposer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.trigerRender()};setTimeout((()=>t())),this.signals.windowResize.add(t),this.signals.cameraObjectChange.add(t),this.signals.sceneChanged.add((()=>this.trigerRender())),this.signals.backgroundChanged.add((()=>this.trigerRender())),this.signals.objectAdded.add((()=>this.trigerRender())),this.signals.objectRemoved.add((()=>this.trigerRender())),this.signals.objectChanged.add((()=>this.trigerRender())),this.signals.materialAdded.add((()=>this.trigerRender())),this.signals.materialRemoved.add((()=>this.trigerRender())),this.signals.materialChanged.add((()=>this.trigerRender())),this.signals.geometryChanged.add((()=>this.trigerRender())),this.signals.cameraChange.add((()=>this.trigerRender())),this.signals.tweenUpdate.add((()=>this.trigerRender())),this.signals.modelAnimation.add((()=>this.trigerRender())),this.signals.outlineChange.add((t=>{const{objects:e,options:n}=t,{color:r,hideColor:i,edgeThickness:s,edgeStrength:a,pulsePeriod:o}=Object.assign(Object.assign({},{color:"#fff",hideColor:"#999",edgeThickness:3,edgeStrength:10,pulsePeriod:0}),n);this.pass.outlinePass.selectedObjects=e,this.pass.outlinePass.visibleEdgeColor.set(r),this.pass.outlinePass.hiddenEdgeColor.set(i),this.pass.outlinePass.edgeThickness=s,this.pass.outlinePass.edgeStrength=a,this.pass.outlinePass.pulsePeriod=o,this.trigerRender()}))}_containerAddEventListener(t){const e=[0,0];let n=null;const r=i=>{this.signals.mouseUp.dispatch(i);const s=i.offsetX-(null==n?void 0:n.offsetX),a=i.offsetY-(null==n?void 0:n.offsetY);if(Math.abs(s)>2||Math.abs(a)>2)return e[0]=0,void(e[1]=0);setTimeout((()=>{0!==e[0]&&0===e[1]&&(0===i.button?(this.signals.click.dispatch(i),this._triggerSceneEventInAllObject("click",i)):2===i.button&&(this.signals.rightClick.dispatch(i),this._triggerSceneEventInAllObject("rightClick",i))),e[0]=0,e[1]=0}),300),t.removeEventListener("mouseup",r,!1)};let i=!1,s=null;const a=[0,0],o=e=>{s&&clearTimeout(s),i||(setTimeout((()=>{0!==a[0]&&0===a[1]?(this.signals.click.dispatch(e),this._triggerSceneEventInAllObject("click",e)):0!==a[0]&&0!==a[1]&&a[1]-a[0]<=300&&(this.signals.dblClick.dispatch(e),this._triggerSceneEventInAllObject("dblClick",e)),a[0]=0,a[1]=0}),300),t.removeEventListener("touchend",o,!1))};t.addEventListener("mousedown",(i=>{n=i,this.signals.mouseDown.dispatch(i),0===e[0]?e[0]=performance.now():0===e[1]&&(e[1]=performance.now()),t.addEventListener("mouseup",r,!1)}),!1),t.addEventListener("mousemove",(t=>{this.signals.mouseMove.dispatch(t),this.options.hoverEnabled&&this._triggerSceneEventInAllObject("hover",t)}),!1),t.addEventListener("dblclick",(t=>{this.signals.dblClick.dispatch(t),this._triggerSceneEventInAllObject("dblClick",t)}),!1),t.addEventListener("wheel",(t=>{this.signals.mouseWheel.dispatch(t)}),!1),t.addEventListener("touchstart",(e=>{0===a[0]?a[0]=performance.now():0===a[1]&&(a[1]=performance.now()),s=setTimeout((()=>{i=!0,a[0]=0,a[1]=0,this.signals.rightClick.dispatch(e),this._triggerSceneEventInAllObject("rightClick",e)}),800),t.addEventListener("touchend",o,!1)}),!1),t.addEventListener("contextmenu",(t=>t.preventDefault()),!1),document.addEventListener("keydown",(t=>{this.signals.keyDown.dispatch(t)}),!1),document.addEventListener("keyup",(t=>{this.signals.keyUp.dispatch(t)}),!1)}_triggerSceneEventInAllObject(t,e){const n=this.getIntersects(e,this.scener.intersectsList.getAll());if(0===n.length)return this.selectModel&&this.signals.modelHover.numListeners>0&&this.signals.modelUnHover.dispatch(this.selectModel),this.selectPoi&&this.signals.poiHover.numListeners>0&&this.signals.poiUnHover.dispatch(this.selectPoi),this.selectModel=null,this.selectPoi=null,void this.signals.sceneClick.dispatch({type:t,event:e});"click"===t&&n.length>0&&this.signals.selectPosition.dispatch(n[0].point);const r={object:null,type:null},i=[],s=[];function a(t){return t.parent?"Sbm"===t.parent.stype||"Model"===t.parent.stype?t.parent:a(t.parent):void 0}function o(t){return!!t.visible&&(!t.parent||o(t.parent))}n.forEach((t=>{if(t.object.parent instanceof vp){const e=t.object.parent;if(o(e)){r.object||(r.type="Poi",r.object=t.object);-1===i.findIndex((t=>t.poi.uuid===e.uuid))&&i.push({poi:e,sourceData:t})}}else if(t.object instanceof Dt){const e=a(t.object);if(e&&o(e)){r.object||(r.type="Model",r.object=t.object);-1===s.findIndex((t=>t.model.uuid===e.uuid))&&s.push({model:e,sourceData:t})}}}));const l=t.slice(0,1).toUpperCase()+t.slice(1),c=t=>{var e;const{model:n}=t[0];if(n)if("Hover"===l)(null===(e=this.selectModel)||void 0===e?void 0:e.uuid)!==n.uuid&&(this.signals.modelHover.dispatch({target:n,currentTarget:r.object,intersects:t}),this.selectModel=n);else{let e=null;"Click"===l?e=n.onClick:"RightClick"===l?e=n.onRightClick:"DblClick"===l&&(e=n.onDblClick),e?e(n):n.isEventPropagation=!0,n.isEventPropagation&&(this.signals[`model${l}`].dispatch({target:n,currentTarget:r.object,intersects:t}),n.isEventPropagation=!1)}},h=t=>{var e;const{poi:n}=t[0];if(n)if("Hover"===l)(null===(e=this.selectPoi)||void 0===e?void 0:e.uuid)!==n.uuid&&(this.signals.poiHover.dispatch(n),this.selectPoi=n);else{let t=null;"Click"===l?t=n.onClick:"RightClick"===l?t=n.onRightClick:"DblClick"===l&&(t=n.onDblClick),t?t(n):n.isEventPropagation=!0,n.isEventPropagation&&(this.signals[`poi${l}`].dispatch(n),n.isEventPropagation=!1)}};"Model"===r.type?c(s):"Poi"===r.type&&h(i)}_getManagerScene(t){return this.scene.children.find((e=>e.name===`${t.toLocaleLowerCase()}Manager`))}}const up={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class dp extends eu{constructor(t){super(t,"Sbm"),this.isEventPropagation=!1;const{onLoad:e,onClick:n,onDblClick:r,onRightClick:i}=Object.assign(Object.assign({},up),t);this.onLoad=(null==e?void 0:e.bind(this))||null,this.onClick=(null==n?void 0:n.bind(this))||null,this.onDblClick=(null==r?void 0:r.bind(this))||null,this.onRightClick=(null==i?void 0:i.bind(this))||null}getBoundingBox(){return new N(new I,new I).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){yh(t,e).then((t=>{this.traverse((e=>{if(e instanceof ke&&e.material instanceof No){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,ap.needRender=!0}}))}))}sClone(t){return new dp({id:`${this.sid}_clone`,url:""}).sCopy(this,t)}}const pp={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class fp extends eu{constructor(t){super(t,"Model");const{format:e,onLoad:n,onClick:r,onDblClick:i,onRightClick:s}=Object.assign(Object.assign({},pp),t);this.formatType=e,this.isEventPropagation=!1,this.onLoad=(null==n?void 0:n.bind(this))||null,this.onClick=(null==r?void 0:r.bind(this))||null,this.onDblClick=(null==i?void 0:i.bind(this))||null,this.onRightClick=(null==s?void 0:s.bind(this))||null}getBoundingBox(){return new N(new I,new I).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){yh(t,e).then((t=>{this.traverse((e=>{if(e instanceof ke&&e.material instanceof No){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,ap.needRender=!0}}))}))}sClone(t){return new fp({id:`${this.sid}_clone`,url:"",format:this.formatType}).sCopy(this,t)}}const mp={position:{x:0,y:0,z:0},scale:{x:16,y:16,z:1},stype:"Icon"};class gp extends xs{constructor(t,e){super(t);const{position:n,scale:r,stype:i}=Object.assign(Object.assign({},mp),e);this.stype=i,this.position.set(n.x,n.y,n.z),this.scale.set(r.x,r.y,r.z),this.renderOrder=1}}class vp extends eu{constructor(t,e){super(e,"Poi"),this.isEventPropagation=!1;const{name:n,nameScale:r={x:16,y:16,z:1},onClick:i,onDblClick:s,onRightClick:a}=e;this.onClick=(null==i?void 0:i.bind(this))||null,this.onDblClick=(null==s?void 0:s.bind(this))||null,this.onRightClick=(null==a?void 0:a.bind(this))||null,this.icon=this._createIcon(t),this.text=null,this.name&&this._createText({position:{x:0,y:10,z:0},name:n,scale:r}),this.renderOrder=11}getBoundingBox(t=50){t=t<=0?50:t;let e=new I,n=new I,r=new I(t,t,t);return e.copy(this.position),n.copy(this.position),e.sub(r),n.add(r),new N(e,n)}eventPropagation(){this.isEventPropagation=!0}sClone(t){return new vp(this.icon.material,{id:`${this.sid}_clone`,url:"",name:this.name}).sCopy(this,t)}_createIcon(t){const e=new gp(t);return this.add(e),e}_createText(t){const e=this._createCanvasText(t.name||""),n=new T(e);n.flipY=!0,n.version+=1;const r=new ss({map:n,depthTest:!0});this.text=new gp(r,t),this.add(this.text)}_createCanvasText(t,e){const n=256,r=document.createElement("canvas");r.width=n,r.height=n;const i=r.getContext("2d"),{fontFamily:s,fontSize:a,color:o,textAlign:l,textBaseline:c}=Object.assign(Object.assign({},{fontFamily:"Microsoft YaHei",fontSize:32,color:"#fff",textAlign:"center",textBaseline:"bottom"}),e);return i&&(i.save(),i.font=a+"px "+s,i.textAlign=l,i.textBaseline=c,i.shadowColor="black",i.strokeStyle="black",i.lineWidth=3,i.fillStyle=o,i.strokeText(t,128,128),i.fillText(t,128,128),i.restore()),r}}class yp extends tu{constructor(t,e="Point"){const{radius:n=10,color:r=255,opacity:i=1}=t;super(function(t){return new So(t,32,32)}(n),function(t,e){return new ee({color:t,opacity:e,transparent:!0})}(r,i),t,e)}setOptions(t){const{color:e,opacity:n,radius:r,position:i}=t,s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&(this.geometry=new So(r,32,32)),i&&this.position.copy(lh(i)),s.version++,ap.needRender=!0}}class xp extends yp{constructor(t){super(t,"Node"),this.graphs=t.graphs}}class _p extends tu{constructor(t){const{radius:e=50,color:n=65280,opacity:r=1}=t;super(function(t){return new ca(t,64)}(e),function(t,e){return new ee({color:t,opacity:e,transparent:!0,side:2})}(n,r),t,"Circle"),this.rotation.set(Math.PI/2,0,0)}setOptions(t){const{color:e,opacity:n,radius:r,position:i}=t,s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&(this.geometry=new ca(r,64)),i&&this.position.copy(lh(i)),s.version++,ap.needRender=!0}}class bp extends tu{constructor(t){const{start:e,end:n,imgUrl:r,width:i=20,color:s=65280,opacity:a=1,animation:o=!1,passable:l=0,restrict:c=0}=t,h=lh(e),u=lh(n),d=h.distanceTo(u);super(function(t,e,n,r=new I(0,1,0)){const i=n/2,s=new I,a=new I;s.subVectors(e,t),s.normalize(),a.crossVectors(s,r);const o=new I(a.x*i,a.y*i,a.z*i),l=new I(-a.x*i,-a.y*i,-a.z*i),c=new I;c.addVectors(t,o);const h=new I;h.addVectors(t,l);const u=new I;u.addVectors(e,l);const d=new I;d.addVectors(e,o);const p=new we;return p.setAttribute("position",new pe([c.x,c.y,c.z,h.x,h.y,h.z,u.x,u.y,u.z,u.x,u.y,u.z,d.x,d.y,d.z,c.x,c.y,c.z],3)),p.setAttribute("uv",new pe([0,0,1,0,1,1,1,1,0,1,0,0],2)),p}(h,u,i),function(t,e,n,r,i,s){const a=new ee({color:n,side:2,transparent:!0,opacity:r});let o;return i&&(o=(new dl).load(i,(n=>{o.repeat.set(1,t/(e*(n.image.height/n.image.width))*.63*(n.image.height/n.image.height)),a.color.set(16777215)})),o.wrapS=1e3,o.wrapT=1e3,o.flipY=!0,o.matrixAutoUpdate=!0,Mh(s)&&s?$h(o.offset,{y:-1,x:0},{repeat:!0,duration:500}):Ch(s)&&$h(o.offset,{y:-1,x:0},Object.assign(Object.assign({},s),{repeat:!0})),a.map=o),a}(d,i,s,a,r,o),t,"Link"),this.passable=l,this.restrict=c}}class wp extends eu{constructor(t){super(t,"Topology");const{type:e="line"}=t;this.type=e,this.nodes=[],this.links=[],this.info=t,this.create()}create(){const{nodes:t,renderLink:e=!0,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255,nodeRadius:a=n/2,imgUrl:o,animation:l=!1}=this.info,c=[];for(let h of t){const t=this.createNode(Object.assign(Object.assign({},h),{radius:a,color:s}));if(!1===i&&t.hide(),this.nodes.push(t),!o&&e){const t=Ph(r)?r[h.graphs[0].passable]?r[h.graphs[0].passable]:r[0]:r;this.createCircle({id:`${h.id}_circle`,name:`${h.name||h.id}_circle`,position:h.position,radius:n/2,color:t})}if(e)for(let t=0;t<h.graphs.length;t++){const{linkInfo:e,targetNodeId:i,passable:s,restrict:a}=h.graphs[t],{id:u,name:d}=e,p=this.info.nodes.find((t=>t.id===i));if(!c.includes(u)&&p){c.push(u);const t=Ph(r)?r[s]?r[s]:r[0]:r,e=this.createLink({id:u,name:d,start:h.position,end:p.position,width:n,color:t,imgUrl:o,animation:l,passable:s,restrict:a});this.links.push(e)}}}}createNode(t){const e=new xp(Object.assign({},t));return this.add(e),e}createCircle(t){const e=new _p(Object.assign(Object.assign({},t),{rotation:{x:Math.PI/2,y:0,z:0}}));return this.add(e),e}createLink(t){const e=new bp(Object.assign({},t));return this.add(e),e}resetNodes(t){const{linkWidth:e=20,linkColor:n=65280,nodeColor:r=255,imgUrl:i,animation:s=!1}=this.info,a=[...this.info.nodes];this.info.nodes=[...t];const o=[];for(let e=0;e<a.length;e++){const n=t.find((t=>t.id===a[e].id));(!n||lh(n.position).distanceTo(lh(a[e].position))>1)&&o.push(a[e])}for(let t=0;t<o.length;t++){const e=this.nodes.findIndex((e=>o[t].id===e.sid));this.remove(this.nodes[e]),this.nodes.splice(e,1)}const l=[];for(let e=0;e<t.length;e++){const n=a.find((n=>n.id===t[e].id));(!n||lh(n.position).distanceTo(lh(t[e].position))>1)&&l.push(t[e])}for(let t=0;t<l.length;t++){const n=this.createNode(Object.assign(Object.assign({},l[t]),{radius:e/2,color:r}));this.nodes.push(n)}const c=[];for(let t=0;t<a.length;t++)for(let e=0;e<a[t].graphs.length;e++)c.push(Object.assign(Object.assign({},a[t].graphs[e]),{sourceNodeId:a[t].id.toString()}));const h=[];for(let e=0;e<t.length;e++)for(let n=0;n<t[e].graphs.length;n++)h.push(Object.assign(Object.assign({},t[e].graphs[n]),{sourceNodeId:t[e].id.toString()}));const u=[];for(let e=0;e<c.length;e++){const n=h.find((t=>t.linkInfo.id===c[e].linkInfo.id));if(n){const r=a.find((t=>t.id===n.targetNodeId)),i=t.find((t=>t.id===n.targetNodeId));r&&i&&lh(r.position).distanceTo(lh(i.position))>1&&u.push(c[e])}else u.push(c[e])}for(let t=0;t<u.length;t++){const e=this.links.findIndex((e=>u[t].linkInfo.id===e.sid));this.remove(this.links[e]),this.links.splice(e,1)}const d=[];for(let e=0;e<h.length;e++){const n=c.find((t=>t.linkInfo.id===h[e].linkInfo.id));if(n){const r=a.find((t=>t.id===n.targetNodeId)),i=t.find((t=>t.id===n.targetNodeId));r&&i&&lh(r.position).distanceTo(lh(i.position))>1&&d.push(h[e])}else d.push(h[e])}for(let r=0;r<d.length;r++){const{linkInfo:a,targetNodeId:o,sourceNodeId:l,passable:c,restrict:h}=d[r],{id:u,name:p}=a,f=t.find((t=>t.id===l)),m=t.find((t=>t.id===o));if(f&&m){const t=Ph(n)?n[c]?n[c]:n[0]:n,r=this.createLink({id:u,name:p,start:f.position,end:m.position,width:e,color:t,imgUrl:i,animation:s,passable:c,restrict:h});this.links.push(r)}}}}function Mp(t,e,n=new I(0,1,0)){const r=e/2,i=new we;let s=[],a=[];if(t.length<2)return i;for(let e=0;e<t.length-1;e++){const i=lh(t[e]),o=lh(t[e+1]),l=new I,c=new I;l.subVectors(o,i),l.normalize(),c.crossVectors(l,n);const h=new I(c.x*r,c.y*r,c.z*r),u=new I(-c.x*r,-c.y*r,-c.z*r),d=new I;d.addVectors(i,h);const p=new I;p.addVectors(i,u);const f=new I;f.addVectors(o,u);const m=new I;m.addVectors(o,h),s=[...s,d.x,d.y,d.z,p.x,p.y,p.z,f.x,f.y,f.z,f.x,f.y,f.z,m.x,m.y,m.z,d.x,d.y,d.z],a=[...a,0,0,1,0,1,1,1,1,0,1,0,0]}return i.setAttribute("position",new pe(s,3)),i.setAttribute("uv",new pe(a,2)),i}class Sp extends tu{constructor(t,e="Line"){const{points:n,width:r=20,color:i=65280,opacity:s=1}=t;super(Mp(n,r),function(t,e){return new ee({color:t,side:2,transparent:!0,opacity:e})}(i,s),t,e),this.params=t,this.points=n,this.frustumCulled=!1}setOptions(t){const{color:e,opacity:n,points:r,width:i}=t;this.points=r;const s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&i?this.geometry=Mp(r,i):r?this.geometry=Mp(r,this.params.width||20):i&&(this.geometry=Mp(this.points,i)),s.version++,ap.needRender=!0}}function Tp(t){const e=[];for(let n=0;n<t.length;n++)e.push(new g(t[n].x,t[n].z));return e.length>2?new Mo(new Ha(e)):new we}class Ap extends tu{constructor(t,e="Polygon"){const{yHeight:n,points:r,color:i=16776960,opacity:s=1}=t;super(Tp(r),function(t,e){return new ee({color:t,opacity:e,transparent:!0,side:2})}(i,s),t,e),this.points=r,this.position.set(0,n,0),this.rotation.set(Math.PI/2,0,0)}setOptions(t){const{color:e,opacity:n,yHeight:r,points:i}=t,s=this.material;e&&(s.color=new te(e)),n&&(s.opacity=n),r&&this.position.set(0,r,0),i&&(this.geometry=Tp(i)),s.version++,ap.needRender=!0}}class Ep extends eu{constructor(t){super(t,"Canvas3D"),this.create(t)}create(t){const{points:e=[],lines:n=[],polygons:r=[],circles:i=[]}=t;for(let t=0;t<e.length;t++)this.createPoint(e[t]);for(let t=0;t<n.length;t++)this.createLine(n[t]);for(let t=0;t<r.length;t++)this.createPolygon(r[t]);for(let t=0;t<i.length;t++)this.createCircle(i[t])}createPoint(t){const e=new yp(t);return this.add(e),ap.needRender=!0,e}getPoint(t){return this.getChildForType("Point",t)}removePoint(t){const e=this.getPoint(t);e&&this.remove(e),ap.needRender=!0}createLine(t){const e=new Sp(t);return this.add(e),ap.needRender=!0,e}getLine(t){return this.getChildForType("Line",t)}removeLine(t){const e=this.getLine(t);e&&this.remove(e),ap.needRender=!0}createPolygon(t){const e=new Ap(t);return this.add(e),ap.needRender=!0,e}getPolygon(t){return this.getChildForType("Polygon",t)}removePolygon(t){const e=this.getPolygon(t);e&&this.remove(e),ap.needRender=!0}createCircle(t){const e=new _p(t);return this.add(e),ap.needRender=!0,e}getCircle(t){return this.getChildForType("Circle",t)}removeCircle(t){const e=this.getCircle(t);e&&this.remove(e),ap.needRender=!0}getChildForType(t,e){for(let n=0;n<this.children.length;n++)if(this.children[n].stype===t&&this.children[n].sid===e)return this.children[n];return null}}class Pp extends tu{constructor(t,e,n){super(t,e,n,"Ground")}}var Cp=Object.freeze({__proto__:null,BaseObject3D:eu,BaseMesh:tu,SceneManage:nu,Group:ru,PluginObject:iu,PoiNode:Eu,Sbm:dp,Model:fp,Poi:vp,Icon:gp,Topology:wp,Point:yp,Line:Sp,Polygon:Ap,Circle:_p,Node:xp,Link:bp,Canvas3D:Ep,Ground:Pp});class Lp{constructor(t,e){this.type=t,this.scene=new nu({id:`${t.toLocaleLowerCase()}Manager`}),this.viewport=e,this.viewport.scener.addObject(this.scene)}update(){if(0===this.scene.children.length)return;const t=(t,e)=>{t.visible!==e&&(t instanceof Eu&&t._setElementDisplay(e),t.visible=e,t.matrixAutoUpdate=e,t.autoUpdate=!0)},e=e=>{const{level:n,handleHide:r,autoUpdate:i}=e,{max:s=null,min:a=null}=n;if(i)e.autoUpdate=!1,this.viewport.signals.objectChanged.dispatch();else if(!r&&(s||a)){const n=this.viewport.camera.position.distanceTo(e.position);t(e,!(s&&n>s)&&!(a&&n<a))}};this.scene.traverse((t=>{(t instanceof eu||t instanceof tu)&&e(t)}))}getById(t,e=this.type){return this._getChildByTypeAndProp(e,"sid",t)[0]||null}getByName(t,e=this.type){return this._getChildByTypeAndProp(e,"name",t)}getByUserDataProperty(t,e){const n=[];return this.scene.traverse((r=>{r instanceof eu&&Ch(r)&&r.stype===this.type&&(Lh(t)&&t(r.userData)||wh(t)&&r.userData[t]===e)&&n.push(r)})),n}removeById(t){const e=this.getById(t);return!!e&&(this.viewport.scener.removeObject(e),!0)}createGroup(t){const e=new ru(t);return this.viewport.scener.addObject(e,this.scene),e}getGroupById(t){return this._getChildByTypeAndProp("Group","sid",t)[0]||null}getGroupByName(t){return this._getChildByTypeAndProp("Group","name",t)}getAllGroup(){const t=[];return this.scene.traverse((e=>{e instanceof ru&&Ch(e)&&"Group"===e.stype&&t.push(e)})),t}removeGroupById(t){const e=this.getGroupById(t);return!!e&&(this.viewport.scener.removeObject(e),!0)}clear(){if(0===this.scene.children.length)return;for(let t=this.scene.children.length-1;t>=0;t--)this.viewport.scener.removeObject(this.scene.children[t])}getAll(){const t=[];return this.scene.traverse((e=>{((e instanceof eu||e instanceof tu)&&Ch(e)&&e.stype===this.type||Ch(e)&&e.userData.stype===this.type)&&t.push(e)})),t}hideAll(){this.getAll().forEach((t=>{t.hide?t.hide():t.visible=!1})),this.viewport.signals.objectChanged.dispatch()}showAll(){this.getAll().forEach((t=>{t.show?t.show():t.visible=!0})),this.viewport.signals.objectChanged.dispatch()}_getChildByTypeAndProp(t,e,n){const r=[];return e&&n?(this.scene.traverse((i=>{((i instanceof eu||i instanceof tu)&&Ch(i)&&i.stype===t&&i[e]===n||Ch(i)&&i.userData.stype===t&&i.userData[e]===n)&&r.push(i)})),r):r}}class Rp extends Lp{constructor(t){super("Light",t)}createAmbientLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1}=t,s=new Pl(r,i);return s.name=n||"",s.userData.sid=e,s.userData.stype="Light",this.viewport.scener.addObject(s,this.scene),s}setAmbientLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1}=t,s=this.getById(e);return!!s&&(s.name=n||"",s.color=new te(r),s.intensity=i,this.viewport.signals.objectChanged.dispatch(),!0)}createDirectionalLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1,position:s={x:1e3,y:1e3,z:1e3},target:a={x:-1e3,y:-1e3,z:-1e3},openShadow:o=!1}=t,l=new El(r,i);if(l.name=n||"",l.position.set(s.x,s.y,s.z),l.userData.sid=e,l.userData.stype="Light",l.castShadow=o,l.receiveShadow=!0,l.target.position.set(a.x,a.y,a.z),l.target.castShadow=o,l.target.receiveShadow=!0,l.target.updateMatrixWorld(),o){const t=l.position.distanceTo(l.target.position);l.shadow.camera.left=-t,l.shadow.camera.right=t,l.shadow.camera.top=t,l.shadow.camera.bottom=-t,l.shadow.camera.far=t,l.shadow.camera.updateProjectionMatrix()}return this.viewport.scener.addObject(l,this.scene),l}setDirectionalLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1,position:s={x:1e3,y:1e3,z:1e3},target:a={x:-1e3,y:-1e3,z:-1e3},openShadow:o=!1}=t,l=this.getById(e);if(!l)return!1;if(l.name=n||"",l.color=new te(r),l.intensity=i,l.position.set(s.x,s.y,s.z),l.castShadow=o,l.target.position.set(a.x,a.y,a.z),l.target.castShadow=o,l.target.updateMatrixWorld(),o){const t=l.position.distanceTo(l.target.position);l.shadow.camera.left=-t,l.shadow.camera.right=t,l.shadow.camera.top=t,l.shadow.camera.bottom=-t,l.shadow.camera.far=t,l.shadow.camera.updateProjectionMatrix()}return this.viewport.signals.objectChanged.dispatch(),!0}createHemisphereLight(t){const{id:e,name:n,skyColor:r=16777215,groundColor:i=14540253,intensity:s=1,position:a={x:0,y:0,z:0}}=t,o=new fl(r,i,s);return o.name=n||"",o.position.set(a.x,a.y,a.z),o.userData.sid=e,o.userData.stype="Light",o.castShadow=!0,o.receiveShadow=!0,this.viewport.scener.addObject(o,this.scene),o}setHemisphereLight(t){const{id:e,name:n,skyColor:r=16777215,groundColor:i=14540253,intensity:s=1,position:a={x:0,y:0,z:0}}=t,o=this.getById(e);return!!o&&(o.name=n||"",o.color=new te(r),o.groundColor=new te(i),o.intensity=s,o.position.set(a.x,a.y,a.z),this.viewport.signals.objectChanged.dispatch(),!0)}createSpotLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,angle:s=45,position:a={x:0,y:500,z:0},target:o={x:0,y:0,z:0},openShadow:l=!1}=t,c=lh(a).distanceTo(lh(o)),h=new _l(r,i,c,Math.PI/360*s,0,0);if(h.name=n||"",h.position.set(a.x,a.y,a.z),h.userData.sid=e,h.userData.stype="Light",h.castShadow=l,h.receiveShadow=!0,h.target.position.set(o.x,o.y,o.z),h.target.castShadow=l,h.target.receiveShadow=!0,h.target.updateMatrixWorld(),l){const t=h.position.distanceTo(h.target.position);h.shadow.focus=.6,h.shadow.camera.far=t,h.shadow.camera.updateProjectionMatrix()}return this.viewport.scener.addObject(h,this.scene),h}setSpotLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,angle:s=45,position:a={x:0,y:500,z:0},target:o={x:0,y:0,z:0},openShadow:l=!1}=t,c=this.getById(e);if(!c)return!1;const h=lh(a).distanceTo(lh(o));if(c.name=n||"",c.color=new te(r),c.intensity=i,c.distance=h,c.angle=Math.PI/360*s,c.position.set(a.x,a.y,a.z),c.castShadow=l,c.target.position.set(o.x,o.y,o.z),c.target.castShadow=l,c.target.updateMatrixWorld(),l){const t=c.position.distanceTo(c.target.position);c.shadow.focus=.6,c.shadow.camera.far=t,c.shadow.camera.updateProjectionMatrix()}return this.viewport.signals.objectChanged.dispatch(),!0}createPointLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,distance:s=5e3,position:a={x:0,y:500,z:0}}=t,o=new Tl(r,i,s);return o.name=n||"",o.userData.sid=e,o.userData.stype="Light",o.castShadow=!0,o.receiveShadow=!0,o.position.set(a.x,a.y,a.z),this.viewport.scener.addObject(o,this.scene),o}setPointLight(t){const{id:e,name:n,color:r=16777215,intensity:i=1,distance:s=5e3,position:a={x:0,y:500,z:0}}=t,o=this.getById(e);return!!o&&(o.name=n||"",o.color=new te(r),o.intensity=i,o.distance=s,o.position.set(a.x,a.y,a.z),this.viewport.signals.objectChanged.dispatch(),!0)}}
35
35
  /*!
36
36
  localForage -- Offline Storage, Improved
37
37
  Version 1.9.0