soonspacejs 2.3.7 → 2.3.8
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 +3 -3
- package/dist/index.js +3 -3
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var t="soonspacejs",e="2.3.
|
|
1
|
+
var t="soonspacejs",e="2.3.8",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){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?i=!1:(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,powerPreference:"high-performance"}),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?i=!1:(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),this.viewport.scener.addObject(l.target,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
|
|
@@ -43,4 +43,4 @@ fflate - fast JavaScript compression/decompression
|
|
|
43
43
|
<https://101arrowz.github.io/fflate>
|
|
44
44
|
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
45
45
|
version 0.6.9
|
|
46
|
-
*/var jp={},Vp=function(t){return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))},Wp=function(t){return new Worker(t)};try{URL.revokeObjectURL(Vp(""))}catch(zp){Vp=function(t){return"data:application/javascript;charset=UTF-8,"+encodeURI(t)},Wp=function(t){return new Worker(t,{type:"module"})}}var Xp=Uint8Array,Yp=Uint16Array,qp=Uint32Array,Qp=new Xp([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Zp=new Xp([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jp=new Xp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kp=function(t,e){for(var n=new Yp(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var i=new qp(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},$p=Kp(Qp,2),tf=$p[0],ef=$p[1];tf[28]=258,ef[258]=28;for(var nf=Kp(Zp,0),rf=nf[0],sf=nf[1],af=new Yp(32768),of=0;of<32768;++of){var lf=(43690&of)>>>1|(21845&of)<<1;lf=(61680&(lf=(52428&lf)>>>2|(13107&lf)<<2))>>>4|(3855&lf)<<4,af[of]=((65280&lf)>>>8|(255&lf)<<8)>>>1}var cf=function(t,e,n){for(var r=t.length,i=0,s=new Yp(e);i<r;++i)++s[t[i]-1];var a,o=new Yp(e);for(i=0;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;if(n){a=new Yp(1<<e);var l=15-e;for(i=0;i<r;++i)if(t[i])for(var c=i<<4|t[i],h=e-t[i],u=o[t[i]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[af[u]>>>l]=c}else for(a=new Yp(r),i=0;i<r;++i)t[i]&&(a[i]=af[o[t[i]-1]++]>>>15-t[i]);return a},hf=new Xp(288);for(of=0;of<144;++of)hf[of]=8;for(of=144;of<256;++of)hf[of]=9;for(of=256;of<280;++of)hf[of]=7;for(of=280;of<288;++of)hf[of]=8;var uf=new Xp(32);for(of=0;of<32;++of)uf[of]=5;var df=cf(hf,9,0),pf=cf(hf,9,1),ff=cf(uf,5,0),mf=cf(uf,5,1),gf=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},vf=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&n},yf=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},xf=function(t){return(t/8|0)+(7&t&&1)},_f=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var r=new(t instanceof Yp?Yp:t instanceof qp?qp:Xp)(n-e);return r.set(t.subarray(e,n)),r},bf=function(t,e,n){var r=t.length;if(!r||n&&!n.l&&r<5)return e||new Xp(0);var i=!e||n,s=!n||n.i;n||(n={}),e||(e=new Xp(3*r));var a=function(t){var n=e.length;if(t>n){var r=new Xp(Math.max(2*n,t));r.set(e),e=r}},o=n.f||0,l=n.p||0,c=n.b||0,h=n.l,u=n.d,d=n.m,p=n.n,f=8*r;do{if(!h){n.f=o=vf(t,l,1);var m=vf(t,l+1,3);if(l+=3,!m){var g=t[(E=xf(l)+4)-4]|t[E-3]<<8,v=E+g;if(v>r){if(s)throw"unexpected EOF";break}i&&a(c+g),e.set(t.subarray(E,v),c),n.b=c+=g,n.p=l=8*v;continue}if(1==m)h=pf,u=mf,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=vf(t,l,31)+257,x=vf(t,l+10,15)+4,_=y+vf(t,l+5,31)+1;l+=14;for(var b=new Xp(_),w=new Xp(19),M=0;M<x;++M)w[Jp[M]]=vf(t,l+3*M,7);l+=3*x;var S=gf(w),T=(1<<S)-1,A=cf(w,S,1);for(M=0;M<_;){var E,P=A[vf(t,l,T)];if(l+=15&P,(E=P>>>4)<16)b[M++]=E;else{var C=0,L=0;for(16==E?(L=3+vf(t,l,3),l+=2,C=b[M-1]):17==E?(L=3+vf(t,l,7),l+=3):18==E&&(L=11+vf(t,l,127),l+=7);L--;)b[M++]=C}}var R=b.subarray(0,y),I=b.subarray(y);d=gf(R),p=gf(I),h=cf(R,d,1),u=cf(I,p,1)}if(l>f){if(s)throw"unexpected EOF";break}}i&&a(c+131072);for(var F=(1<<d)-1,D=(1<<p)-1,N=l;;N=l){var O=(C=h[yf(t,l)&F])>>>4;if((l+=15&C)>f){if(s)throw"unexpected EOF";break}if(!C)throw"invalid length/literal";if(O<256)e[c++]=O;else{if(256==O){N=l,h=null;break}var U=O-254;if(O>264){var B=Qp[M=O-257];U=vf(t,l,(1<<B)-1)+tf[M],l+=B}var z=u[yf(t,l)&D],k=z>>>4;if(!z)throw"invalid distance";l+=15&z;I=rf[k];if(k>3){B=Zp[k];I+=yf(t,l)&(1<<B)-1,l+=B}if(l>f){if(s)throw"unexpected EOF";break}i&&a(c+131072);for(var H=c+U;c<H;c+=4)e[c]=e[c-I],e[c+1]=e[c+1-I],e[c+2]=e[c+2-I],e[c+3]=e[c+3-I];c=H}}n.l=h,n.p=N,n.b=c,h&&(o=1,n.m=d,n.d=u,n.n=p)}while(!o);return c==e.length?e:_f(e,0,c)},wf=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>>8},Mf=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>>8,t[r+2]|=n>>>16},Sf=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var i=n.length,s=n.slice();if(!i)return[Rf,0];if(1==i){var a=new Xp(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort((function(t,e){return t.f-e.f})),n.push({s:-1,f:25001});var o=n[0],l=n[1],c=0,h=1,u=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};h!=i-1;)o=n[n[c].f<n[u].f?c++:u++],l=n[c!=h&&n[c].f<n[u].f?c++:u++],n[h++]={s:-1,f:o.f+l.f,l:o,r:l};var d=s[0].s;for(r=1;r<i;++r)s[r].s>d&&(d=s[r].s);var p=new Yp(d+1),f=Tf(n[h-1],p,0);if(f>e){r=0;var m=0,g=f-e,v=1<<g;for(s.sort((function(t,e){return p[e.s]-p[t.s]||t.f-e.f}));r<i;++r){var y=s[r].s;if(!(p[y]>e))break;m+=v-(1<<f-p[y]),p[y]=e}for(m>>>=g;m>0;){var x=s[r].s;p[x]<e?m-=1<<e-p[x]++-1:++r}for(;r>=0&&m;--r){var _=s[r].s;p[_]==e&&(--p[_],++m)}f=e}return[new Xp(p),f]},Tf=function(t,e,n){return-1==t.s?Math.max(Tf(t.l,e,n+1),Tf(t.r,e,n+1)):e[t.s]=n},Af=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Yp(++e),r=0,i=t[0],s=1,a=function(t){n[r++]=t},o=1;o<=e;++o)if(t[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=t[o]}return[n.subarray(0,r),e]},Ef=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},Pf=function(t,e,n){var r=n.length,i=xf(e+2);t[i]=255&r,t[i+1]=r>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var s=0;s<r;++s)t[i+s+4]=n[s];return 8*(i+4+r)},Cf=function(t,e,n,r,i,s,a,o,l,c,h){wf(e,h++,n),++i[256];for(var u=Sf(i,15),d=u[0],p=u[1],f=Sf(s,15),m=f[0],g=f[1],v=Af(d),y=v[0],x=v[1],_=Af(m),b=_[0],w=_[1],M=new Yp(19),S=0;S<y.length;++S)M[31&y[S]]++;for(S=0;S<b.length;++S)M[31&b[S]]++;for(var T=Sf(M,7),A=T[0],E=T[1],P=19;P>4&&!A[Jp[P-1]];--P);var C,L,R,I,F=c+5<<3,D=Ef(i,hf)+Ef(s,uf)+a,N=Ef(i,d)+Ef(s,m)+a+14+3*P+Ef(M,A)+(2*M[16]+3*M[17]+7*M[18]);if(F<=D&&F<=N)return Pf(e,h,t.subarray(l,l+c));if(wf(e,h,1+(N<D)),h+=2,N<D){C=cf(d,p,0),L=d,R=cf(m,g,0),I=m;var O=cf(A,E,0);wf(e,h,x-257),wf(e,h+5,w-1),wf(e,h+10,P-4),h+=14;for(S=0;S<P;++S)wf(e,h+3*S,A[Jp[S]]);h+=3*P;for(var U=[y,b],B=0;B<2;++B){var z=U[B];for(S=0;S<z.length;++S){var k=31&z[S];wf(e,h,O[k]),h+=A[k],k>15&&(wf(e,h,z[S]>>>5&127),h+=z[S]>>>12)}}}else C=df,L=hf,R=ff,I=uf;for(S=0;S<o;++S)if(r[S]>255){k=r[S]>>>18&31;Mf(e,h,C[k+257]),h+=L[k+257],k>7&&(wf(e,h,r[S]>>>23&31),h+=Qp[k]);var H=31&r[S];Mf(e,h,R[H]),h+=I[H],H>3&&(Mf(e,h,r[S]>>>5&8191),h+=Zp[H])}else Mf(e,h,C[r[S]]),h+=L[r[S]];return Mf(e,h,C[256]),h+L[256]},Lf=new qp([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Rf=new Xp(0),If=function(t,e,n,r,i,s){var a=t.length,o=new Xp(r+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(r,o.length-i),c=0;if(!e||a<8)for(var h=0;h<=a;h+=65535){var u=h+65535;u<a?c=Pf(l,c,t.subarray(h,u)):(l[h]=s,c=Pf(l,c,t.subarray(h,a)))}else{for(var d=Lf[e-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new Yp(32768),v=new Yp(m+1),y=Math.ceil(n/3),x=2*y,_=function(e){return(t[e]^t[e+1]<<y^t[e+2]<<x)&m},b=new qp(25e3),w=new Yp(288),M=new Yp(32),S=0,T=0,A=(h=0,0),E=0,P=0;h<a;++h){var C=_(h),L=32767&h,R=v[C];if(g[L]=R,v[C]=L,E<=h){var I=a-h;if((S>7e3||A>24576)&&I>423){c=Cf(t,l,0,b,w,M,T,A,P,h-P,c),A=S=T=0,P=h;for(var F=0;F<286;++F)w[F]=0;for(F=0;F<30;++F)M[F]=0}var D=2,N=0,O=f,U=L-R&32767;if(I>2&&C==_(h-U))for(var B=Math.min(p,I)-1,z=Math.min(32767,h),k=Math.min(258,I);U<=z&&--O&&L!=R;){if(t[h+D]==t[h+D-U]){for(var H=0;H<k&&t[h+H]==t[h+H-U];++H);if(H>D){if(D=H,N=U,H>B)break;var G=Math.min(U,H-2),j=0;for(F=0;F<G;++F){var V=h-U+F+32768&32767,W=V-g[V]+32768&32767;W>j&&(j=W,R=V)}}}U+=(L=R)-(R=g[L])+32768&32767}if(N){b[A++]=268435456|ef[D]<<18|sf[N];var X=31&ef[D],Y=31&sf[N];T+=Qp[X]+Zp[Y],++w[257+X],++M[Y],E=h+D,++S}else b[A++]=t[h],++w[t[h]]}}c=Cf(t,l,s,b,w,M,T,A,P,h-P,c),!s&&7&c&&(c=Pf(l,c+1,Rf))}return _f(o,0,r+xf(c)+i)},Ff=function(){for(var t=new qp(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),Df=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=Ff[255&n^e[r]]^n>>>8;t=n},d:function(){return~t}}},Nf=function(){var t=1,e=0;return{p:function(n){for(var r=t,i=e,s=n.length,a=0;a!=s;){for(var o=Math.min(a+2655,s);a<o;++a)i+=r+=n[a];r=(65535&r)+15*(r>>16),i=(65535&i)+15*(i>>16)}t=r,e=i},d:function(){return(255&(t%=65521))<<24|t>>>8<<16|(255&(e%=65521))<<8|e>>>8}}},Of=function(t,e,n,r,i){return If(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!i)},Uf=function(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n},Bf=function(t,e,n){for(var r=t(),i=t.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a<r.length;++a){var o=r[a],l=s[a];if("function"==typeof o){e+=";"+l+"=";var c=o.toString();if(o.prototype)if(-1!=c.indexOf("[native code]")){var h=c.indexOf(" ",8)+1;e+=c.slice(h,c.indexOf("(",h))}else for(var u in e+=c,o.prototype)e+=";"+l+".prototype."+u+"="+o.prototype[u].toString();else e+=c}else n[l]=o}return[e,n]},zf=[],kf=function(t,e,n,r){var i;if(!zf[n]){for(var s="",a={},o=t.length-1,l=0;l<o;++l)s=(i=Bf(t[l],s,a))[0],a=i[1];zf[n]=Bf(t[o],s,a)}var c=Uf({},zf[n][1]);return function(t,e,n,r,i){var s=Wp(jp[e]||(jp[e]=Vp(t)));return s.onerror=function(t){return i(t.error,null)},s.onmessage=function(t){return i(null,t.data)},s.postMessage(n,r),s}(zf[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,c,function(t){var e=[];for(var n in t)(t[n]instanceof Xp||t[n]instanceof Yp||t[n]instanceof qp)&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e}(c),r)},Hf=function(){return[Xp,Yp,qp,Qp,Zp,Jp,tf,rf,pf,mf,af,cf,gf,vf,yf,xf,_f,bf,gm,Yf,qf]},Gf=function(){return[Xp,Yp,qp,Qp,Zp,Jp,ef,sf,df,hf,ff,uf,af,Lf,Rf,cf,wf,Mf,Sf,Tf,Af,Ef,Pf,Cf,xf,_f,If,Of,dm,Yf]},jf=function(){return[nm,sm,em,Df,Ff]},Vf=function(){return[rm,im]},Wf=function(){return[am,em,Nf]},Xf=function(){return[om]},Yf=function(t){return postMessage(t,[t.buffer])},qf=function(t){return t&&t.size&&new Xp(t.size)},Qf=function(t,e,n,r,i,s){var a=kf(n,r,i,(function(t,e){a.terminate(),s(t,e)}));return a.postMessage([t,e],e.consume?[t.buffer]:[]),function(){a.terminate()}},Zf=function(t){return t.ondata=function(t,e){return postMessage([t,e],[t.buffer])},function(e){return t.push(e.data[0],e.data[1])}},Jf=function(t,e,n,r,i){var s,a=kf(t,r,i,(function(t,n){t?(a.terminate(),e.ondata.call(e,t)):(n[1]&&a.terminate(),e.ondata.call(e,t,n[0],n[1]))}));a.postMessage(n),e.push=function(t,n){if(s)throw"stream finished";if(!e.ondata)throw"no stream handler";a.postMessage([t,s=n],[t.buffer])},e.terminate=function(){a.terminate()}},Kf=function(t,e){return t[e]|t[e+1]<<8},$f=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},tm=function(t,e){return $f(t,e)+4294967296*$f(t,e+4)},em=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},nm=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&em(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},rm=function(t){if(31!=t[0]||139!=t[1]||8!=t[2])throw"invalid gzip data";var e=t[3],n=10;4&e&&(n+=t[10]|2+(t[11]<<8));for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[n++]);return n+(2&e)},im=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},sm=function(t){return 10+(t.filename&&t.filename.length+1||0)},am=function(t,e){var n=e.level,r=0==n?0:n<6?1:9==n?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},om=function(t){if(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)throw"invalid zlib data";if(32&t[1])throw"invalid zlib data: preset dictionaries not supported"};function lm(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var cm=function(){function t(t,e){e||"function"!=typeof t||(e=t,t={}),this.ondata=e,this.o=t||{}}return t.prototype.p=function(t,e){this.ondata(Of(t,this.o,0,0,!e),e)},t.prototype.push=function(t,e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=e,this.p(t,e||!1)},t}(),hm=function(){return function(t,e){Jf([Gf,function(){return[Zf,cm]}],this,lm.call(this,t,e),(function(t){var e=new cm(t.data);onmessage=Zf(e)}),6)}}();function um(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Gf],(function(t){return Yf(dm(t.data[0],t.data[1]))}),0,n)}function dm(t,e){return Of(t,e||{},0,0)}var pm=function(){function t(t){this.s={},this.p=new Xp(0),this.ondata=t}return t.prototype.e=function(t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var e=this.p.length,n=new Xp(e+t.length);n.set(this.p),n.set(t,e),this.p=n},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,n=bf(this.p,this.o,this.s);this.ondata(_f(n,e,this.s.b),this.d),this.o=_f(n,this.s.b-32768),this.s.b=this.o.length,this.p=_f(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),fm=function(){return function(t){this.ondata=t,Jf([Hf,function(){return[Zf,pm]}],this,0,(function(){var t=new pm;onmessage=Zf(t)}),7)}}();function mm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Hf],(function(t){return Yf(gm(t.data[0],qf(t.data[1])))}),1,n)}function gm(t,e){return bf(t,e)}var vm=function(){function t(t,e){this.c=Df(),this.l=0,this.v=1,cm.call(this,t,e)}return t.prototype.push=function(t,e){cm.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=Of(t,this.o,this.v&&sm(this.o),e&&8,!e);this.v&&(nm(n,this.o),this.v=0),e&&(em(n,n.length-8,this.c.d()),em(n,n.length-4,this.l)),this.ondata(n,e)},t}(),ym=function(){return function(t,e){Jf([Gf,jf,function(){return[Zf,cm,vm]}],this,lm.call(this,t,e),(function(t){var e=new vm(t.data);onmessage=Zf(e)}),8)}}();function xm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Gf,jf,function(){return[_m]}],(function(t){return Yf(_m(t.data[0],t.data[1]))}),2,n)}function _m(t,e){e||(e={});var n=Df(),r=t.length;n.p(t);var i=Of(t,e,sm(e),8),s=i.length;return nm(i,e),em(i,s-8,n.d()),em(i,s-4,r),i}var bm=function(){function t(t){this.v=1,pm.call(this,t)}return t.prototype.push=function(t,e){if(pm.prototype.e.call(this,t),this.v){var n=this.p.length>3?rm(this.p):4;if(n>=this.p.length&&!e)return;this.p=this.p.subarray(n),this.v=0}if(e){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}pm.prototype.c.call(this,e)},t}(),wm=function(){return function(t){this.ondata=t,Jf([Hf,Vf,function(){return[Zf,pm,bm]}],this,0,(function(){var t=new bm;onmessage=Zf(t)}),9)}}();function Mm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Hf,Vf,function(){return[Sm]}],(function(t){return Yf(Sm(t.data[0]))}),3,n)}function Sm(t,e){return bf(t.subarray(rm(t),-8),e||new Xp(im(t)))}var Tm=function(){function t(t,e){this.c=Nf(),this.v=1,cm.call(this,t,e)}return t.prototype.push=function(t,e){cm.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var n=Of(t,this.o,this.v&&2,e&&4,!e);this.v&&(am(n,this.o),this.v=0),e&&em(n,n.length-4,this.c.d()),this.ondata(n,e)},t}(),Am=function(){return function(t,e){Jf([Gf,Wf,function(){return[Zf,cm,Tm]}],this,lm.call(this,t,e),(function(t){var e=new Tm(t.data);onmessage=Zf(e)}),10)}}();function Em(t,e){e||(e={});var n=Nf();n.p(t);var r=Of(t,e,2,4);return am(r,e),em(r,r.length-4,n.d()),r}var Pm=function(){function t(t){this.v=1,pm.call(this,t)}return t.prototype.push=function(t,e){if(pm.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}if(e){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}pm.prototype.c.call(this,e)},t}(),Cm=function(){return function(t){this.ondata=t,Jf([Hf,Xf,function(){return[Zf,pm,Pm]}],this,0,(function(){var t=new Pm;onmessage=Zf(t)}),11)}}();function Lm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Hf,Xf,function(){return[Rm]}],(function(t){return Yf(Rm(t.data[0],qf(t.data[1])))}),5,n)}function Rm(t,e){return bf((om(t),t.subarray(2,-4)),e)}var Im=function(){function t(t){this.G=bm,this.I=pm,this.Z=Pm,this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var n=new Xp(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,i=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(i):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(i):new this.Z(i),this.s.push(this.p,e),this.p=null}}},t}(),Fm=function(){function t(t){this.G=wm,this.I=fm,this.Z=Cm,this.ondata=t}return t.prototype.push=function(t,e){Im.prototype.push.call(this,t,e)},t}();var Dm=function(t,e,n,r){for(var i in t){var s=t[i],a=e+i;s instanceof Xp?n[a]=[s,r]:Array.isArray(s)?n[a]=[s[0],Uf(r,s[1])]:Dm(s,a+"/",n,r)}},Nm="undefined"!=typeof TextEncoder&&new TextEncoder,Om="undefined"!=typeof TextDecoder&&new TextDecoder,Um=0;try{Om.decode(Rf,{stream:!0}),Um=1}catch(zp){}var Bm=function(t){for(var e="",n=0;;){var r=t[n++],i=(r>127)+(r>223)+(r>239);if(n+i>t.length)return[e,_f(t,n-1)];i?3==i?(r=((15&r)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536,e+=String.fromCharCode(55296|r>>10,56320|1023&r)):e+=1&i?String.fromCharCode((31&r)<<6|63&t[n++]):String.fromCharCode((15&r)<<12|(63&t[n++])<<6|63&t[n++]):e+=String.fromCharCode(r)}},zm=function(){function t(t){this.ondata=t,Um?this.t=new TextDecoder:this.p=Rf}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";if(e=!!e,this.t){if(this.ondata(this.t.decode(t,{stream:!0}),e),e){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new Xp(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var r=Bm(n),i=r[0],s=r[1];if(e){if(s.length)throw"invalid utf-8 data";this.p=null}else this.p=s;this.ondata(i,e)}},t}(),km=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(Hm(t),this.d=e||!1)},t}();function Hm(t,e){if(e){for(var n=new Xp(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}if(Nm)return Nm.encode(t);var i=t.length,s=new Xp(t.length+(t.length>>1)),a=0,o=function(t){s[a++]=t};for(r=0;r<i;++r){if(a+5>s.length){var l=new Xp(a+8+(i-r<<1));l.set(s),s=l}var c=t.charCodeAt(r);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++r))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return _f(s,0,a)}function Gm(t,e){if(e){for(var n="",r=0;r<t.length;r+=16384)n+=String.fromCharCode.apply(null,t.subarray(r,r+16384));return n}if(Om)return Om.decode(t);var i=Bm(t),s=i[0];if(i[1].length)throw"invalid utf-8 data";return s}var jm=function(t){return 1==t?3:t<6?2:9==t?1:0},Vm=function(t,e){return e+30+Kf(t,e+26)+Kf(t,e+28)},Wm=function(t,e,n){var r=Kf(t,e+28),i=Gm(t.subarray(e+46,e+46+r),!(2048&Kf(t,e+8))),s=e+46+r,a=$f(t,e+20),o=n&&4294967295==a?Xm(t,s):[a,$f(t,e+24),$f(t,e+42)],l=o[0],c=o[1],h=o[2];return[Kf(t,e+10),l,c,i,s+Kf(t,e+30)+Kf(t,e+32),h]},Xm=function(t,e){for(;1!=Kf(t,e);e+=4+Kf(t,e+2));return[tm(t,e+12),tm(t,e+4),tm(t,e+20)]},Ym=function(t){var e=0;if(t)for(var n in t){var r=t[n].length;if(r>65535)throw"extra field too long";e+=r+4}return e},qm=function(t,e,n,r,i,s,a,o){var l=r.length,c=n.extra,h=o&&o.length,u=Ym(c);em(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(null==s&&8),t[e++]=i&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(em(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),e+=4,null!=s&&(em(t,e,n.crc),em(t,e+4,s),em(t,e+8,n.size)),em(t,e+12,l),em(t,e+14,u),e+=16,null!=a&&(em(t,e,h),em(t,e+6,n.attrs),em(t,e+10,a),e+=14),t.set(r,e),e+=l,u)for(var f in c){var m=c[f],g=m.length;em(t,e,+f),em(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e},Qm=function(t,e,n,r,i){em(t,e,101010256),em(t,e+8,n),em(t,e+10,n),em(t,e+12,r),em(t,e+16,i)},Zm=function(){function t(t){this.filename=t,this.c=Df(),this.size=0,this.compression=0}return t.prototype.process=function(t,e){this.ondata(null,t,e)},t.prototype.push=function(t,e){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},t}(),Jm=function(){function t(t,e){var n=this;e||(e={}),Zm.call(this,t),this.d=new cm(e,(function(t,e){n.ondata(null,t,e)})),this.compression=8,this.flag=jm(e.level)}return t.prototype.process=function(t,e){try{this.d.push(t,e)}catch(t){this.ondata(t,null,e)}},t.prototype.push=function(t,e){Zm.prototype.push.call(this,t,e)},t}(),Km=function(){function t(t,e){var n=this;e||(e={}),Zm.call(this,t),this.d=new hm(e,(function(t,e,r){n.ondata(t,e,r)})),this.compression=8,this.flag=jm(e.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,e){this.d.push(t,e)},t.prototype.push=function(t,e){Zm.prototype.push.call(this,t,e)},t}(),$m=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var e=this;if(2&this.d)throw"stream finished";var n=Hm(t.filename),r=n.length,i=t.comment,s=i&&Hm(i),a=r!=t.filename.length||s&&i.length!=s.length,o=r+Ym(t.extra)+30;if(r>65535)throw"filename too long";var l=new Xp(o);qm(l,0,t,n,a);var c=[l],h=function(){for(var t=0,n=c;t<n.length;t++){var r=n[t];e.ondata(null,r,!1)}c=[]},u=this.d;this.d=0;var d=this.u.length,p=Uf(t,{f:n,u:a,o:s,t:function(){t.terminate&&t.terminate()},r:function(){if(h(),u){var t=e.u[d+1];t?t.r():e.d=1}u=1}}),f=0;t.ondata=function(n,r,i){if(n)e.ondata(n,r,i),e.terminate();else if(f+=r.length,c.push(r),i){var s=new Xp(16);em(s,0,134695760),em(s,4,t.crc),em(s,8,f),em(s,12,t.size),c.push(s),p.c=f,p.b=o+f+16,p.crc=t.crc,p.size=t.size,u&&p.r(),u=1}else u&&h()},this.u.push(p)},t.prototype.end=function(){var t=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3},t.prototype.e=function(){for(var t=0,e=0,n=0,r=0,i=this.u;r<i.length;r++){n+=46+(l=i[r]).f.length+Ym(l.extra)+(l.o?l.o.length:0)}for(var s=new Xp(n+22),a=0,o=this.u;a<o.length;a++){var l=o[a];qm(s,t,l,l.f,l.u,l.c,e,l.o),t+=46+l.f.length+Ym(l.extra)+(l.o?l.o.length:0),e+=l.b}Qm(s,t,this.u.length,n,e),this.ondata(null,s,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,e=this.u;t<e.length;t++){e[t].t()}this.d=2},t}();var tg=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}(),eg=function(){function t(){var t=this;this.i=new pm((function(e,n){t.ondata(null,e,n)}))}return t.prototype.push=function(t,e){try{this.i.push(t,e)}catch(n){this.ondata(n,t,e)}},t.compression=8,t}(),ng=function(){function t(t,e){var n=this;e<32e4?this.i=new pm((function(t,e){n.ondata(null,t,e)})):(this.i=new fm((function(t,e,r){n.ondata(t,e,r)})),this.terminate=this.i.terminate)}return t.prototype.push=function(t,e){this.i.terminate&&(t=_f(t,0)),this.i.push(t,e)},t.compression=8,t}(),rg=function(){function t(t){this.onfile=t,this.k=[],this.o={0:tg},this.p=Rf}return t.prototype.push=function(t,e){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var r=Math.min(this.c,t.length),i=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(i,!this.c):this.k[0].push(i),(t=t.subarray(r)).length)return this.push(t,e)}else{var s=0,a=0,o=void 0,l=void 0;this.p.length?t.length?((l=new Xp(this.p.length+t.length)).set(this.p),l.set(t,this.p.length)):l=this.p:l=t;for(var c=l.length,h=this.c,u=h&&this.d,d=function(){var t,e=$f(l,a);if(67324752==e){s=1,o=a,p.d=null,p.c=0;var r=Kf(l,a+6),i=Kf(l,a+8),u=2048&r,d=8&r,f=Kf(l,a+26),m=Kf(l,a+28);if(c>a+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=$f(l,a+18),x=$f(l,a+22),_=Gm(l.subarray(a+30,a+=30+f),!u);4294967295==y?(t=d?[-2]:Xm(l,a),y=t[0],x=t[1]):d&&(y=-1),a+=m,p.c=y;var b={name:_,compression:i,start:function(){if(!b.ondata)throw"no callback";if(y){var t=n.o[i];if(!t)throw"unknown compression type "+i;(v=y<0?new t(_):new t(_,y,x)).ondata=function(t,e,n){b.ondata(t,e,n)};for(var e=0,r=g;e<r.length;e++){var s=r[e];v.push(s,!1)}n.k[0]==g&&n.c?n.d=v:v.push(Rf,!0)}else b.ondata(null,Rf,!0)},terminate:function(){v&&v.terminate&&v.terminate()}};y>=0&&(b.size=y,b.originalSize=x),p.onfile(b)}return"break"}if(h){if(134695760==e)return o=a+=12+(-2==h&&8),s=3,p.c=0,"break";if(33639248==e)return o=a-=4,s=3,p.c=0,"break"}},p=this;a<c-4;++a){if("break"===d())break}if(this.p=Rf,h<0){var f=s?l.subarray(0,o-12-(-2==h&&8)-(134695760==$f(l,o-16)&&4)):l.subarray(0,a);u?u.push(f,!!s):this.k[+(2==s)].push(f)}if(2&s)return this.push(l.subarray(a),e);this.p=l.subarray(a)}if(e){if(this.c)throw"invalid zip file";this.p=null}},t.prototype.register=function(t){this.o[t.compression]=t},t}();var ig=Object.freeze({__proto__:null,Deflate:cm,AsyncDeflate:hm,deflate:um,deflateSync:dm,Inflate:pm,AsyncInflate:fm,inflate:mm,inflateSync:gm,Gzip:vm,AsyncGzip:ym,gzip:xm,gzipSync:_m,Gunzip:bm,AsyncGunzip:wm,gunzip:Mm,gunzipSync:Sm,Zlib:Tm,AsyncZlib:Am,zlib:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Gf,Wf,function(){return[Em]}],(function(t){return Yf(Em(t.data[0],t.data[1]))}),4,n)},zlibSync:Em,Unzlib:Pm,AsyncUnzlib:Cm,unzlib:Lm,unzlibSync:Rm,compress:xm,AsyncCompress:ym,compressSync:_m,Compress:vm,Decompress:Im,AsyncDecompress:Fm,decompress:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return 31==t[0]&&139==t[1]&&8==t[2]?Mm(t,e,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?mm(t,e,n):Lm(t,e,n)},decompressSync:function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?Sm(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?gm(t,e):Rm(t,e)},DecodeUTF8:zm,EncodeUTF8:km,strToU8:Hm,strFromU8:Gm,ZipPassThrough:Zm,ZipDeflate:Jm,AsyncZipDeflate:Km,Zip:$m,zip:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";var r={};Dm(t,"",r,e);var i=Object.keys(r),s=i.length,a=0,o=0,l=s,c=new Array(s),h=[],u=function(){for(var t=0;t<h.length;++t)h[t]()},d=function(){var t=new Xp(o+22),e=a,r=o-a;o=0;for(var i=0;i<l;++i){var s=c[i];try{var h=s.c.length;qm(t,o,s,s.f,s.u,h);var u=30+s.f.length+Ym(s.extra),d=o+u;t.set(s.c,d),qm(t,a,s,s.f,s.u,h,o,s.m),a+=16+u+(s.m?s.m.length:0),o=d+h}catch(t){return n(t,null)}}Qm(t,a,c.length,r,e),n(null,t)};s||d();for(var p=function(t){var e=i[t],l=r[e],p=l[0],f=l[1],m=Df(),g=p.length;m.p(p);var v=Hm(e),y=v.length,x=f.comment,_=x&&Hm(x),b=_&&_.length,w=Ym(f.extra),M=0==f.level?0:8,S=function(r,i){if(r)u(),n(r,null);else{var l=i.length;c[t]=Uf(f,{size:g,crc:m.d(),c:i,f:v,m:_,u:y!=e.length||_&&x.length!=b,compression:M}),a+=30+y+w+l,o+=76+2*(y+w)+(b||0)+l,--s||d()}};if(y>65535&&S("filename too long",null),M)if(g<16e4)try{S(null,dm(p,f))}catch(t){S(t,null)}else h.push(um(p,f,S));else S(null,p)},f=0;f<l;++f)p(f);return u},zipSync:function(t,e){e||(e={});var n={},r=[];Dm(t,"",n,e);var i=0,s=0;for(var a in n){var o=n[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(M=Hm(a)).length,d=c.comment,p=d&&Hm(d),f=p&&p.length,m=Ym(c.extra);if(u>65535)throw"filename too long";var g=h?dm(l,c):l,v=g.length,y=Df();y.p(l),r.push(Uf(c,{size:l.length,crc:y.d(),c:g,f:M,m:p,u:u!=a.length||p&&d.length!=f,o:i,compression:h})),i+=30+u+m+v,s+=76+2*(u+m)+(f||0)+v}for(var x=new Xp(s+22),_=i,b=s-i,w=0;w<r.length;++w){var M=r[w];qm(x,M.o,M,M.f,M.u,M.c.length);var S=30+M.f.length+Ym(M.extra);x.set(M.c,M.o+S),qm(x,i,M,M.f,M.u,M.c.length,M.o,M.m),i+=16+S+(M.m?M.m.length:0)}return Qm(x,i,r.length,b,_),x},UnzipPassThrough:tg,UnzipInflate:eg,AsyncUnzipInflate:ng,Unzip:rg,unzip:function(t,e){if("function"!=typeof e)throw"no callback";for(var n=[],r=function(){for(var t=0;t<n.length;++t)n[t]()},i={},s=t.length-22;101010256!=$f(t,s);--s)if(!s||t.length-s>65558)return void e("invalid zip file",null);var a=Kf(t,s+8);a||e(null,{});var o=a,l=$f(t,s+16),c=4294967295==l;if(c){if(s=$f(t,s-12),101075792!=$f(t,s))return void e("invalid zip file",null);o=a=$f(t,s+32),l=$f(t,s+48)}for(var h=function(s){var o=Wm(t,l,c),h=o[0],u=o[1],d=o[2],p=o[3],f=o[4],m=o[5],g=Vm(t,m);l=f;var v=function(t,n){t?(r(),e(t,null)):(i[p]=n,--a||e(null,i))};if(h)if(8==h){var y=t.subarray(g,g+u);if(u<32e4)try{v(null,gm(y,new Xp(d)))}catch(t){v(t,null)}else n.push(mm(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,_f(t,g,g+u))},u=0;u<o;++u)h();return r},unzipSync:function(t){for(var e={},n=t.length-22;101010256!=$f(t,n);--n)if(!n||t.length-n>65558)throw"invalid zip file";var r=Kf(t,n+8);if(!r)return{};var i=$f(t,n+16),s=4294967295==i;if(s){if(n=$f(t,n-12),101075792!=$f(t,n))throw"invalid zip file";r=$f(t,n+32),i=$f(t,n+48)}for(var a=0;a<r;++a){var o=Wm(t,i,s),l=o[0],c=o[1],h=o[2],u=o[3],d=o[4],p=o[5],f=Vm(t,p);if(i=d,l){if(8!=l)throw"unknown compression type "+l;e[u]=gm(t.subarray(f,f+c),new Xp(h))}else e[u]=_f(t,f,f+c)}return e}});function sg(t,e,n){const r=n.length-t-1;if(e>=n[r])return r-1;if(e<=n[t])return t;let i=t,s=r,a=Math.floor((i+s)/2);for(;e<n[a]||e>=n[a+1];)e<n[a]?s=a:i=a,a=Math.floor((i+s)/2);return a}function ag(t,e){let n=1;for(let e=2;e<=t;++e)n*=e;let r=1;for(let t=2;t<=e;++t)r*=t;for(let n=2;n<=t-e;++n)r*=n;return n/r}function og(t,e,n,r,i){return function(t){const e=t.length,n=[],r=[];for(let i=0;i<e;++i){const e=t[i];n[i]=new I(e.x,e.y,e.z),r[i]=e.w}const i=[];for(let t=0;t<e;++t){const e=n[t].clone();for(let n=1;n<=t;++n)e.sub(i[t-n].clone().multiplyScalar(ag(t,n)*r[n]));i[t]=e.divideScalar(r[0])}return i}(function(t,e,n,r,i){const s=i<t?i:t,a=[],o=sg(t,r,e),l=function(t,e,n,r,i){const s=[];for(let t=0;t<=n;++t)s[t]=0;const a=[];for(let t=0;t<=r;++t)a[t]=s.slice(0);const o=[];for(let t=0;t<=n;++t)o[t]=s.slice(0);o[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let r=1;r<=n;++r){l[r]=e-i[t+1-r],c[r]=i[t+r]-e;let n=0;for(let t=0;t<r;++t){const e=c[t+1],i=l[r-t];o[r][t]=e+i;const s=o[t][r-1]/o[r][t];o[t][r]=n+e*s,n=i*s}o[r][r]=n}for(let t=0;t<=n;++t)a[0][t]=o[t][n];for(let t=0;t<=n;++t){let e=0,i=1;const l=[];for(let t=0;t<=n;++t)l[t]=s.slice(0);l[0][0]=1;for(let s=1;s<=r;++s){let r=0;const c=t-s,h=n-s;t>=s&&(l[i][0]=l[e][0]/o[h+1][c],r=l[i][0]*o[c][h]);const u=t-1<=h?s-1:n-t;for(let t=c>=-1?1:-c;t<=u;++t)l[i][t]=(l[e][t]-l[e][t-1])/o[h+1][c+t],r+=l[i][t]*o[c+t][h];t<=h&&(l[i][s]=-l[e][s-1]/o[h+1][t],r+=l[i][s]*o[t][h]),a[s][t]=r;const d=e;e=i,i=d}}let h=n;for(let t=1;t<=r;++t){for(let e=0;e<=n;++e)a[t][e]*=h;h*=n-t}return a}(o,r,t,s,e),c=[];for(let t=0;t<n.length;++t){const e=n[t].clone(),r=e.w;e.x*=r,e.y*=r,e.z*=r,c[t]=e}for(let e=0;e<=s;++e){const n=c[o-t].clone().multiplyScalar(l[e][0]);for(let r=1;r<=t;++r)n.add(c[o-t+r].clone().multiplyScalar(l[e][r]));a[e]=n}for(let t=s+1;t<=i+1;++t)a[t]=new E(0,0,0);return a}(t,e,n,r,i))}class lg extends xa{constructor(t,e,n,r,i){super(),this.degree=t,this.knots=e,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||this.knots.length-1;for(let t=0;t<n.length;++t){const e=n[t];this.controlPoints[t]=new E(e.x,e.y,e.z,e.w)}}getPoint(t,e=new I){const n=e,r=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(t,e,n,r){const i=sg(t,r,e),s=function(t,e,n,r){const i=[],s=[],a=[];i[0]=1;for(let o=1;o<=n;++o){s[o]=e-r[t+1-o],a[o]=r[t+o]-e;let n=0;for(let t=0;t<o;++t){const e=a[t+1],r=s[o-t],l=i[t]/(e+r);i[t]=n+e*l,n=r*l}i[o]=n}return i}(i,r,t,e),a=new E(0,0,0,0);for(let e=0;e<=t;++e){const r=n[i-t+e],o=s[e],l=r.w*o;a.x+=r.x*l,a.y+=r.y*l,a.z+=r.z*l,a.w+=r.w*o}return a}(this.degree,this.knots,this.controlPoints,r);return 1!==i.w&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(t,e=new I){const n=e,r=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),i=og(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}}let cg,hg,ug;class dg extends al{constructor(t){super(t)}load(t,e,n,r){const i=this,s=""===i.path?Fl.extractUrlBase(t):i.path,a=new ll(this.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(n){try{e(i.parse(n,s))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)}parse(t,e){if(function(t){const e="Kaydara FBX Binary \0";return t.byteLength>=e.length&&e===Cg(t,0,e.length)}(t))cg=(new vg).parse(t);else{const e=Cg(t);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(e){const r=t[e-1];return t=t.slice(n+e),n++,r}for(let t=0;t<e.length;++t){if(r(1)===e[t])return!1}return!0}(e))throw new Error("THREE.FBXLoader: Unknown format.");if(_g(e)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+_g(e));cg=(new gg).parse(e)}const n=new dl(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new pg(n,this.manager).parse(cg)}}class pg{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){hg=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),n=this.parseMaterials(e),r=this.parseDeformers(),i=(new fg).parse(r);return this.parseScene(r,i,n),ug}parseConnections(){const t=new Map;if("Connections"in cg){cg.Connections.connections.forEach((function(e){const n=e[0],r=e[1],i=e[2];t.has(n)||t.set(n,{parents:[],children:[]});const s={ID:r,relationship:i};t.get(n).parents.push(s),t.has(r)||t.set(r,{parents:[],children:[]});const a={ID:n,relationship:i};t.get(r).children.push(a)}))}return t}parseImages(){const t={},e={};if("Video"in cg.Objects){const n=cg.Objects.Video;for(const r in n){const i=n[r];if(t[parseInt(r)]=i.RelativeFilename||i.Filename,"Content"in i){const t=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,s="string"==typeof i.Content&&""!==i.Content;if(t||s){const t=this.parseImage(n[r]);e[i.RelativeFilename||i.Filename]=t}}}}for(const n in t){const r=t[n];void 0!==e[r]?t[n]=e[r]:t[n]=t[n].split("\\").pop()}return t}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof e)return"data:"+i+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:i}))}}parseTextures(t){const e=new Map;if("Texture"in cg.Objects){const n=cg.Objects.Texture;for(const r in n){const i=this.parseTexture(n[r],t);e.set(parseInt(r),i)}}return e}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const r=t.WrapModeU,i=t.WrapModeV,s=void 0!==r?r.value:0,a=void 0!==i?i.value:0;if(n.wrapS=0===s?1e3:1001,n.wrapT=0===a?1e3:1001,"Scaling"in t){const e=t.Scaling.value;n.repeat.x=e[0],n.repeat.y=e[1]}return n}loadTexture(t,e){let n;const r=this.textureLoader.path,i=hg.get(t.id).children;let s;void 0!==i&&i.length>0&&void 0!==e[i[0].ID]&&(n=e[i[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const a=t.FileName.slice(-3).toLowerCase();if("tga"===a){const e=this.manager.getHandler(".tga");null===e?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new T):(e.setPath(this.textureLoader.path),s=e.load(n))}else"psd"===a?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new T):s=this.textureLoader.load(n);return this.textureLoader.setPath(r),s}parseMaterials(t){const e=new Map;if("Material"in cg.Objects){const n=cg.Objects.Material;for(const r in n){const i=this.parseMaterial(n[r],t);null!==i&&e.set(parseInt(r),i)}}return e}parseMaterial(t,e){const n=t.id,r=t.attrName;let i=t.ShadingModel;if("object"==typeof i&&(i=i.value),!hg.has(n))return null;const s=this.parseParameters(t,e,n);let a;switch(i.toLowerCase()){case"phong":a=new No;break;case"lambert":a=new Bo;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),a=new No}return a.setValues(s),a.name=r,a}parseParameters(t,e,n){const r={};t.BumpFactor&&(r.bumpScale=t.BumpFactor.value),t.Diffuse?r.color=(new te).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(r.color=(new te).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(r.displacementScale=t.DisplacementFactor.value),t.Emissive?r.emissive=(new te).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(r.emissive=(new te).fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(r.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(r.opacity=parseFloat(t.Opacity.value)),r.opacity<1&&(r.transparent=!0),t.ReflectionFactor&&(r.reflectivity=t.ReflectionFactor.value),t.Shininess&&(r.shininess=t.Shininess.value),t.Specular?r.specular=(new te).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(r.specular=(new te).fromArray(t.SpecularColor.value));const i=this;return hg.get(n).children.forEach((function(t){const n=t.relationship;switch(n){case"Bump":r.bumpMap=i.getTexture(e,t.ID);break;case"Maya|TEX_ao_map":r.aoMap=i.getTexture(e,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=i.getTexture(e,t.ID),void 0!==r.map&&(r.map.encoding=3001);break;case"DisplacementColor":r.displacementMap=i.getTexture(e,t.ID);break;case"EmissiveColor":r.emissiveMap=i.getTexture(e,t.ID),void 0!==r.emissiveMap&&(r.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=i.getTexture(e,t.ID);break;case"ReflectionColor":r.envMap=i.getTexture(e,t.ID),void 0!==r.envMap&&(r.envMap.mapping=303,r.envMap.encoding=3001);break;case"SpecularColor":r.specularMap=i.getTexture(e,t.ID),void 0!==r.specularMap&&(r.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=i.getTexture(e,t.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),r}getTexture(t,e){return"LayeredTexture"in cg.Objects&&e in cg.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=hg.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in cg.Objects){const n=cg.Objects.Deformer;for(const r in n){const i=n[r],s=hg.get(parseInt(r));if("Skin"===i.attrType){const e=this.parseSkeleton(s,n);e.ID=r,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=s.parents[0].ID,t[r]=e}else if("BlendShape"===i.attrType){const t={id:r};t.rawTargets=this.parseMorphTargets(s,n),t.id=r,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[r]=t}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const n=[];return t.children.forEach((function(t){const r=e[t.ID];if("Cluster"!==r.attrType)return;const i={ID:t.ID,indices:[],weights:[],transformLink:(new ct).fromArray(r.TransformLink.a)};"Indexes"in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)})),{rawBones:n,bones:[]}}parseMorphTargets(t,e){const n=[];for(let r=0;r<t.children.length;r++){const i=t.children[r],s=e[i.ID],a={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;a.geoID=hg.get(parseInt(i.ID)).children.filter((function(t){return void 0===t.relationship}))[0].ID,n.push(a)}return n}parseScene(t,e,n){ug=new Wi;const r=this.parseModels(t.skeletons,e,n),i=cg.Objects.Model,s=this;r.forEach((function(t){const e=i[t.ID];s.setLookAtProperties(t,e);hg.get(t.ID).parents.forEach((function(e){const n=r.get(e.ID);void 0!==n&&n.add(t)})),null===t.parent&&ug.add(t)})),this.bindSkeleton(t.skeletons,e,r),this.createAmbientLight(),ug.traverse((function(t){if(t.userData.transformData){t.parent&&(t.userData.transformData.parentMatrix=t.parent.matrix,t.userData.transformData.parentMatrixWorld=t.parent.matrixWorld);const e=Ag(t.userData.transformData);t.applyMatrix4(e),t.updateWorldMatrix()}}));const a=(new mg).parse();1===ug.children.length&&ug.children[0].isGroup&&(ug.children[0].animations=a,ug=ug.children[0]),ug.animations=a}parseModels(t,e,n){const r=new Map,i=cg.Objects.Model;for(const s in i){const a=parseInt(s),o=i[s],l=hg.get(a);let c=this.buildSkeleton(l,t,a,o.attrName);if(!c){switch(o.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,e,n);break;case"NurbsCurve":c=this.createCurve(l,e);break;case"LimbNode":case"Root":c=new Ls;break;case"Null":default:c=new Wi}c.name=o.attrName?mc.sanitizeNodeName(o.attrName):"",c.ID=a}this.getTransformData(c,o),r.set(a,c)}return r}buildSkeleton(t,e,n,r){let i=null;return t.parents.forEach((function(t){for(const s in e){const a=e[s];a.rawBones.forEach((function(e,s){if(e.ID===t.ID){const t=i;i=new Ls,i.matrixWorld.copy(e.transformLink),i.name=r?mc.sanitizeNodeName(r):"",i.ID=n,a.bones[s]=i,null!==t&&i.add(t)}}))}})),i}createCamera(t){let e,n;if(t.children.forEach((function(t){const e=cg.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Dt;else{let t=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(t=1);let r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);let i=1e3;void 0!==n.FarPlane&&(i=n.FarPlane.value/1e3);let s=window.innerWidth,a=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,a=n.AspectHeight.value);const o=s/a;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(t){case 0:e=new qe(l,o,r,i),null!==c&&e.setFocalLength(c);break;case 1:e=new yn(-s/2,s/2,a/2,-a/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+t+"."),e=new Dt}}return e}createLight(t){let e,n;if(t.children.forEach((function(t){const e=cg.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Dt;else{let t;t=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=(new te).fromArray(n.Color.value));let i=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(i=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const a=1;switch(t){case 0:e=new Tl(r,i,s,a);break;case 1:e=new El(r,i);break;case 2:let t=Math.PI/3;void 0!==n.InnerAngle&&(t=m.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=m.degToRad(n.OuterAngle.value),o=Math.max(o,1)),e=new _l(r,i,s,t,o,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),e=new Tl(r,i)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(e.castShadow=!0)}return e}createMesh(t,e,n){let r,i=null,s=null;const a=[];return t.children.forEach((function(t){e.has(t.ID)&&(i=e.get(t.ID)),n.has(t.ID)&&a.push(n.get(t.ID))})),a.length>1?s=a:a.length>0?s=a[0]:(s=new No({color:13421772}),a.push(s)),"color"in i.attributes&&a.forEach((function(t){t.vertexColors=!0})),i.FBX_Deformer?(r=new Cs(i,s),r.normalizeSkinWeights()):r=new ke(i,s),r}createCurve(t,e){const n=t.children.reduce((function(t,n){return e.has(n.ID)&&(t=e.get(n.ID)),t}),null),r=new Hs({color:3342591,linewidth:1});return new Ys(n,r)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),n.eulerOrder="RotationOrder"in e?Eg(e.RotationOrder.value):"ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(t,e){if("LookAtProperty"in e){hg.get(t.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const n=cg.Objects.Model[e.ID];if("Lcl_Translation"in n){const e=n.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(e),ug.add(t.target)):t.lookAt((new I).fromArray(e))}}}))}}bindSkeleton(t,e,n){const r=this.parsePoseNodes();for(const i in t){const s=t[i];hg.get(parseInt(s.ID)).parents.forEach((function(t){if(e.has(t.ID)){const e=t.ID;hg.get(e).parents.forEach((function(t){if(n.has(t.ID)){n.get(t.ID).bind(new Ds(s.bones),r[t.ID])}}))}}))}}parsePoseNodes(){const t={};if("Pose"in cg.Objects){const e=cg.Objects.Pose;for(const n in e)if("BindPose"===e[n].attrType&&e[n].NbPoseNodes>0){const r=e[n].PoseNode;Array.isArray(r)?r.forEach((function(e){t[e.Node]=(new ct).fromArray(e.Matrix.a)})):t[r.Node]=(new ct).fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in cg&&"AmbientColor"in cg.GlobalSettings){const t=cg.GlobalSettings.AmbientColor.value,e=t[0],n=t[1],r=t[2];if(0!==e||0!==n||0!==r){const t=new te(e,n,r);ug.add(new Pl(t,1))}}}}class fg{parse(t){const e=new Map;if("Geometry"in cg.Objects){const n=cg.Objects.Geometry;for(const r in n){const i=hg.get(parseInt(r)),s=this.parseGeometry(i,n[r],t);e.set(parseInt(r),s)}}return e}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,n){const r=n.skeletons,i=[],s=t.parents.map((function(t){return cg.Objects.Model[t.ID]}));if(0===s.length)return;const a=t.children.reduce((function(t,e){return void 0!==r[e.ID]&&(t=r[e.ID]),t}),null);t.children.forEach((function(t){void 0!==n.morphTargets[t.ID]&&i.push(n.morphTargets[t.ID])}));const o=s[0],l={};"RotationOrder"in o&&(l.eulerOrder=Eg(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);const c=Ag(l);return this.genGeometry(e,a,i,c)}genGeometry(t,e,n,r){const i=new we;t.attrName&&(i.name=t.attrName);const s=this.parseGeoNode(t,e),a=this.genBuffers(s),o=new pe(a.vertex,3);if(o.applyMatrix4(r),i.setAttribute("position",o),a.colors.length>0&&i.setAttribute("color",new pe(a.colors,3)),e&&(i.setAttribute("skinIndex",new ce(a.weightsIndices,4)),i.setAttribute("skinWeight",new pe(a.vertexWeights,4)),i.FBX_Deformer=e),a.normal.length>0){const t=(new v).getNormalMatrix(r),e=new pe(a.normal,3);e.applyNormalMatrix(t),i.setAttribute("normal",e)}if(a.uvs.forEach((function(t,e){let n="uv"+(e+1).toString();0===e&&(n="uv"),i.setAttribute(n,new pe(a.uvs[e],2))})),s.material&&"AllSame"!==s.material.mappingType){let t=a.materialIndex[0],e=0;if(a.materialIndex.forEach((function(n,r){n!==t&&(i.addGroup(e,r-e,t),t=n,e=r)})),i.groups.length>0){const e=i.groups[i.groups.length-1],n=e.start+e.count;n!==a.materialIndex.length&&i.addGroup(n,a.materialIndex.length-n,t)}0===i.groups.length&&i.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(i,t,n,r),i}parseGeoNode(t,e){const n={};if(n.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],n.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return n.weightTable={},null!==e&&(n.skeleton=e,e.rawBones.forEach((function(t,e){t.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:e,weight:t.weights[i]})}))}))),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,s=[],a=[],o=[],l=[],c=[],h=[];const u=this;return t.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(s.push(3*d,3*d+1,3*d+2),t.color){const e=Mg(p,n,d,t.color);o.push(e[0],e[1],e[2])}if(t.skeleton){if(void 0!==t.weightTable[d]&&t.weightTable[d].forEach((function(t){v.push(t.weight),g.push(t.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const t=[0,0,0,0],e=[0,0,0,0];v.forEach((function(n,r){let i=n,s=g[r];e.forEach((function(e,n,r){if(i>e){r[n]=i,i=e;const a=t[n];t[n]=s,s=a}}))})),g=t,v=e}for(;v.length<4;)v.push(0),g.push(0);for(let t=0;t<4;++t)c.push(v[t]),h.push(g[t])}if(t.normal){const e=Mg(p,n,d,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(f=Mg(p,n,d,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=Mg(p,n,d,t);void 0===l[e]&&(l[e]=[]),l[e].push(r[0]),l[e].push(r[1])})),r++,m&&(u.genFace(e,t,s,f,a,o,l,c,h,r),n++,r=0,s=[],a=[],o=[],l=[],c=[],h=[])})),e}genFace(t,e,n,r,i,s,a,o,l,c){for(let h=2;h<c;h++)t.vertex.push(e.vertexPositions[n[0]]),t.vertex.push(e.vertexPositions[n[1]]),t.vertex.push(e.vertexPositions[n[2]]),t.vertex.push(e.vertexPositions[n[3*(h-1)]]),t.vertex.push(e.vertexPositions[n[3*(h-1)+1]]),t.vertex.push(e.vertexPositions[n[3*(h-1)+2]]),t.vertex.push(e.vertexPositions[n[3*h]]),t.vertex.push(e.vertexPositions[n[3*h+1]]),t.vertex.push(e.vertexPositions[n[3*h+2]]),e.skeleton&&(t.vertexWeights.push(o[0]),t.vertexWeights.push(o[1]),t.vertexWeights.push(o[2]),t.vertexWeights.push(o[3]),t.vertexWeights.push(o[4*(h-1)]),t.vertexWeights.push(o[4*(h-1)+1]),t.vertexWeights.push(o[4*(h-1)+2]),t.vertexWeights.push(o[4*(h-1)+3]),t.vertexWeights.push(o[4*h]),t.vertexWeights.push(o[4*h+1]),t.vertexWeights.push(o[4*h+2]),t.vertexWeights.push(o[4*h+3]),t.weightsIndices.push(l[0]),t.weightsIndices.push(l[1]),t.weightsIndices.push(l[2]),t.weightsIndices.push(l[3]),t.weightsIndices.push(l[4*(h-1)]),t.weightsIndices.push(l[4*(h-1)+1]),t.weightsIndices.push(l[4*(h-1)+2]),t.weightsIndices.push(l[4*(h-1)+3]),t.weightsIndices.push(l[4*h]),t.weightsIndices.push(l[4*h+1]),t.weightsIndices.push(l[4*h+2]),t.weightsIndices.push(l[4*h+3])),e.color&&(t.colors.push(s[0]),t.colors.push(s[1]),t.colors.push(s[2]),t.colors.push(s[3*(h-1)]),t.colors.push(s[3*(h-1)+1]),t.colors.push(s[3*(h-1)+2]),t.colors.push(s[3*h]),t.colors.push(s[3*h+1]),t.colors.push(s[3*h+2])),e.material&&"AllSame"!==e.material.mappingType&&(t.materialIndex.push(r),t.materialIndex.push(r),t.materialIndex.push(r)),e.normal&&(t.normal.push(i[0]),t.normal.push(i[1]),t.normal.push(i[2]),t.normal.push(i[3*(h-1)]),t.normal.push(i[3*(h-1)+1]),t.normal.push(i[3*(h-1)+2]),t.normal.push(i[3*h]),t.normal.push(i[3*h+1]),t.normal.push(i[3*h+2])),e.uv&&e.uv.forEach((function(e,n){void 0===t.uvs[n]&&(t.uvs[n]=[]),t.uvs[n].push(a[n][0]),t.uvs[n].push(a[n][1]),t.uvs[n].push(a[n][2*(h-1)]),t.uvs[n].push(a[n][2*(h-1)+1]),t.uvs[n].push(a[n][2*h]),t.uvs[n].push(a[n][2*h+1])}))}addMorphTargets(t,e,n,r){if(0===n.length)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const i=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=cg.Objects.Geometry[n.geoID];void 0!==s&&i.genMorphGeometry(t,e,s,r,n.name)}))}))}genMorphGeometry(t,e,n,r,i){const s=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],a=void 0!==n.Vertices?n.Vertices.a:[],o=void 0!==n.Indexes?n.Indexes.a:[],l=3*t.attributes.position.count,c=new Float32Array(l);for(let t=0;t<o.length;t++){const e=3*o[t];c[e]=a[3*t],c[e+1]=a[3*t+1],c[e+2]=a[3*t+2]}const h={vertexIndices:s,vertexPositions:c},u=this.genBuffers(h),d=new pe(u.vertex,3);d.name=i||n.attrName,d.applyMatrix4(r),t.morphAttributes.position.push(d)}parseNormals(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Normals.a;let i=[];return"IndexToDirect"===n&&("NormalIndex"in t?i=t.NormalIndex.a:"NormalsIndex"in t&&(i=t.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:e,referenceType:n}}parseUVs(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.UV.a;let i=[];return"IndexToDirect"===n&&(i=t.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:e,referenceType:n}}parseVertexColors(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Colors.a;let i=[];return"IndexToDirect"===n&&(i=t.ColorIndex.a),{dataSize:4,buffer:r,indices:i,mappingType:e,referenceType:n}}parseMaterialIndices(t){const e=t.MappingInformationType,n=t.ReferenceInformationType;if("NoMappingInformation"===e)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=t.Materials.a,i=[];for(let t=0;t<r.length;++t)i.push(t);return{dataSize:1,buffer:r,indices:i,mappingType:e,referenceType:n}}parseNurbsGeometry(t){if(void 0===lg)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new we;const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new we;const n=e-1,r=t.KnotVector.a,i=[],s=t.Points.a;for(let t=0,e=s.length;t<e;t+=4)i.push((new E).fromArray(s,t));let a,o;if("Closed"===t.Form)i.push(i[0]);else if("Periodic"===t.Form){a=n,o=r.length-1-a;for(let t=0;t<n;++t)i.push(i[t])}const l=new lg(n,r,i,a,o).getPoints(12*i.length);return(new we).setFromPoints(l)}}class mg{parse(){const t=[],e=this.parseClips();if(void 0!==e)for(const n in e){const r=e[n],i=this.addClip(r);t.push(i)}return t}parseClips(){if(void 0===cg.Objects.AnimationCurve)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=cg.Objects.AnimationCurveNode,e=new Map;for(const n in t){const r=t[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const t={id:r.id,attr:r.attrName,curves:{}};e.set(t.id,t)}}return e}parseAnimationCurves(t){const e=cg.Objects.AnimationCurve;for(const n in e){const r={id:e[n].id,times:e[n].KeyTime.a.map(bg),values:e[n].KeyValueFloat.a},i=hg.get(r.id);if(void 0!==i){const e=i.parents[0].ID,n=i.parents[0].relationship;n.match(/X/)?t.get(e).curves.x=r:n.match(/Y/)?t.get(e).curves.y=r:n.match(/Z/)?t.get(e).curves.z=r:n.match(/d|DeformPercent/)&&t.has(e)&&(t.get(e).curves.morph=r)}}}parseAnimationLayers(t){const e=cg.Objects.AnimationLayer,n=new Map;for(const r in e){const e=[],i=hg.get(parseInt(r));if(void 0!==i){i.children.forEach((function(n,r){if(t.has(n.ID)){const i=t.get(n.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===e[r]){const t=hg.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID;if(void 0!==t){const i=cg.Objects.Model[t.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:i.attrName?mc.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ug.traverse((function(t){t.ID===i.id&&(s.transform=t.matrix,t.userData.transformData&&(s.eulerOrder=t.userData.transformData.eulerOrder))})),s.transform||(s.transform=new ct),"PreRotation"in i&&(s.preRotation=i.PreRotation.value),"PostRotation"in i&&(s.postRotation=i.PostRotation.value),e[r]=s}}e[r]&&(e[r][i.attr]=i)}else if(void 0!==i.curves.morph){if(void 0===e[r]){const t=hg.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID,i=hg.get(t).parents[0].ID,s=hg.get(i).parents[0].ID,a=hg.get(s).parents[0].ID,o=cg.Objects.Model[a],l={modelName:o.attrName?mc.sanitizeNodeName(o.attrName):"",morphName:cg.Objects.Deformer[t].attrName};e[r]=l}e[r][i.attr]=i}}})),n.set(parseInt(r),e)}}return n}parseAnimStacks(t){const e=cg.Objects.AnimationStack,n={};for(const r in e){const i=hg.get(parseInt(r)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=t.get(i[0].ID);n[r]={name:e[r].attrName,layer:s}}return n}addClip(t){let e=[];const n=this;return t.layer.forEach((function(t){e=e.concat(n.generateTracks(t))})),new el(t.name,-1,e)}generateTracks(t){const e=[];let n=new I,r=new R,i=new I;if(t.transform&&t.transform.decompose(n,r,i),n=n.toArray(),r=(new xt).setFromQuaternion(r,t.eulerOrder).toArray(),i=i.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const r=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");void 0!==r&&e.push(r)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const n=this.generateRotationTrack(t.modelName,t.R.curves,r,t.preRotation,t.postRotation,t.eulerOrder);void 0!==n&&e.push(n)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const n=this.generateVectorTrack(t.modelName,t.S.curves,i,"scale");void 0!==n&&e.push(n)}if(void 0!==t.DeformPercent){const n=this.generateMorphTrack(t);void 0!==n&&e.push(n)}return e}generateVectorTrack(t,e,n,r){const i=this.getTimesForAllAxes(e),s=this.getKeyframeTrackValues(i,e,n);return new tl(t+"."+r,i,s)}generateRotationTrack(t,e,n,r,i,s){void 0!==e.x&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(m.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(m.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(m.degToRad));const a=this.getTimesForAllAxes(e),o=this.getKeyframeTrackValues(a,e,n);void 0!==r&&((r=r.map(m.degToRad)).push(s),r=(new xt).fromArray(r),r=(new R).setFromEuler(r)),void 0!==i&&((i=i.map(m.degToRad)).push(s),i=(new xt).fromArray(i),i=(new R).setFromEuler(i).invert());const l=new R,c=new xt,h=[];for(let t=0;t<o.length;t+=3)c.set(o[t],o[t+1],o[t+2],s),l.setFromEuler(c),void 0!==r&&l.premultiply(r),void 0!==i&&l.multiply(i),l.toArray(h,t/3*4);return new Ko(t+".quaternion",a,h)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,n=e.values.map((function(t){return t/100})),r=ug.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new Zo(t.modelName+".morphTargetInfluences["+r+"]",e.times,n)}getTimesForAllAxes(t){let e=[];if(void 0!==t.x&&(e=e.concat(t.x.times)),void 0!==t.y&&(e=e.concat(t.y.times)),void 0!==t.z&&(e=e.concat(t.z.times)),e=e.sort((function(t,e){return t-e})),e.length>1){let t=1,n=e[0];for(let r=1;r<e.length;r++){const i=e[r];i!==n&&(e[t]=i,n=i,t++)}e=e.slice(0,t)}return e}getKeyframeTrackValues(t,e,n){const r=n,i=[];let s=-1,a=-1,o=-1;return t.forEach((function(t){if(e.x&&(s=e.x.times.indexOf(t)),e.y&&(a=e.y.times.indexOf(t)),e.z&&(o=e.z.times.indexOf(t)),-1!==s){const t=e.x.values[s];i.push(t),r[0]=t}else i.push(r[0]);if(-1!==a){const t=e.y.values[a];i.push(t),r[1]=t}else i.push(r[1]);if(-1!==o){const t=e.z.values[o];i.push(t),r[2]=t}else i.push(r[2])})),i}interpolateRotations(t){for(let e=1;e<t.values.length;e++){const n=t.values[e-1],r=t.values[e]-n,i=Math.abs(r);if(i>=180){const s=i/180,a=r/s;let o=n+a;const l=t.times[e-1],c=(t.times[e]-l)/s;let h=l+c;const u=[],d=[];for(;h<t.times[e];)u.push(h),h+=c,d.push(o),o+=a;t.times=Lg(t.times,e,u),t.values=Lg(t.values,e,d)}}}}class gg{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new xg,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,n=t.split(/[\r\n]+/);return n.forEach((function(t,r){const i=t.match(/^[\s\t]*;/),s=t.match(/^[\s\t]*$/);if(i||s)return;const a=t.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),o=t.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=t.match("^\\t{"+(e.currentIndent-1)+"}}");a?e.parseNodeBegin(t,a):o?e.parseNodeProperty(t,o,n[++r]):l?e.popStack():t.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(t)})),this.allNodes}parseNodeBegin(t,e){const n=e[1].trim().replace(/^"/,"").replace(/"$/,""),r=e[2].split(",").map((function(t){return t.trim().replace(/^"/,"").replace(/"$/,"")})),i={name:n},s=this.parseNodeAttr(r),a=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,i):n in a?("PoseNode"===n?a.PoseNode.push(i):void 0!==a[n].id&&(a[n]={},a[n][a[n].id]=a[n]),""!==s.id&&(a[n][s.id]=i)):"number"==typeof s.id?(a[n]={},a[n][s.id]=i):"Properties70"!==n&&(a[n]="PoseNode"===n?[i]:i),"number"==typeof s.id&&(i.id=s.id),""!==s.name&&(i.attrName=s.name),""!==s.type&&(i.attrType=s.type),this.pushStack(i)}parseNodeAttr(t){let e=t[0];""!==t[0]&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let n="",r="";return t.length>1&&(n=t[1].replace(/^(\w+)::/,""),r=t[2]),{id:e,name:n,type:r}}parseNodeProperty(t,e,n){let r=e[1].replace(/^"/,"").replace(/"$/,"").trim(),i=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===r){const t=i.split(",").slice(1),e=parseInt(t[0]),n=parseInt(t[1]);let a=i.split(",").slice(3);a=a.map((function(t){return t.trim().replace(/^"/,"")})),r="connections",i=[e,n],function(t,e){for(let n=0,r=t.length,i=e.length;n<i;n++,r++)t[r]=e[n]}(i,a),void 0===s[r]&&(s[r]=[])}"Node"===r&&(s.id=i),r in s&&Array.isArray(s[r])?s[r].push(i):"a"!==r?s[r]=i:s.a=i,this.setCurrentProp(s,r),"a"===r&&","!==i.slice(-1)&&(s.a=Pg(i))}else this.parseNodeSpecialProperty(t,r,i)}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,","!==t.slice(-1)&&(e.a=Pg(e.a))}parseNodeSpecialProperty(t,e,n){const r=n.split('",').map((function(t){return t.trim().replace(/^\"/,"").replace(/\s/,"_")})),i=r[0],s=r[1],a=r[2],o=r[3];let l=r[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=Pg(l)}this.getPrevNode()[i]={type:s,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class vg{parse(t){const e=new yg(t);e.skip(23);const n=e.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new xg;for(;!this.endOfContent(e);){const t=this.parseNode(e,n);null!==t&&r.add(t.name,t)}return r}endOfContent(t){return t.size()%16==0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},r=e>=7500?t.getUint64():t.getUint32(),i=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const s=t.getUint8(),a=t.getString(s);if(0===r)return null;const o=[];for(let e=0;e<i;e++)o.push(this.parseProperty(t));const l=o.length>0?o[0]:"",c=o.length>1?o[1]:"",h=o.length>2?o[2]:"";for(n.singleProperty=1===i&&t.getOffset()===r;r>t.getOffset();){const r=this.parseNode(t,e);null!==r&&this.parseSubNode(a,n,r)}return n.propertyList=o,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==h&&(n.attrType=h),""!==a&&(n.name=a),n}parseSubNode(t,e,n){if(!0===n.singleProperty){const t=n.propertyList[0];Array.isArray(t)?(e[n.name]=n,n.a=t):e[n.name]=t}else if("Connections"===t&&"C"===n.name){const t=[];n.propertyList.forEach((function(e,n){0!==n&&t.push(e)})),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===n.name){Object.keys(n).forEach((function(t){e[t]=n[t]}))}else if("Properties70"===t&&"P"===n.name){let t=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],s=n.propertyList[3];let a;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),a="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],e[t]={type:r,type2:i,flag:s,value:a}}else void 0===e[n.name]?"number"==typeof n.id?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:"PoseNode"===n.name?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):void 0===e[n.name][n.id]&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),i=t.getUint32(),s=t.getUint32();if(0===i)switch(e){case"b":case"c":return t.getBooleanArray(r);case"d":return t.getFloat64Array(r);case"f":return t.getFloat32Array(r);case"i":return t.getInt32Array(r);case"l":return t.getInt64Array(r)}void 0===ig&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=Rm(new Uint8Array(t.getArrayBuffer(s))),o=new yg(a.buffer);switch(e){case"b":case"c":return o.getBooleanArray(r);case"d":return o.getFloat64Array(r);case"f":return o.getFloat32Array(r);case"i":return o.getInt32Array(r);case"l":return o.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class yg{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===e||e}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(t){const e=[];for(let n=0;n<t;n++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),2147483648&e?(e=4294967295&~e,t=4294967295&~t,4294967295===t&&(e=e+1&4294967295),t=t+1&4294967295,-(4294967296*e+t)):4294967296*e+t}getInt64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),4294967296*e+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){let e=[];for(let n=0;n<t;n++)e[n]=this.getUint8();const n=e.indexOf(0);return n>=0&&(e=e.slice(0,n)),Fl.decodeText(new Uint8Array(e))}}class xg{add(t,e){this[t]=e}}function _g(t){const e=t.match(/FBXVersion: (\d+)/);if(e){return parseInt(e[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function bg(t){return t/46186158e3}const wg=[];function Mg(t,e,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=t;break;case"ByPolygon":i=e;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const s=i*r.dataSize,a=s+r.dataSize;return function(t,e,n,r){for(let i=n,s=0;i<r;i++,s++)t[s]=e[i];return t}(wg,r.buffer,s,a)}const Sg=new xt,Tg=new I;function Ag(t){const e=new ct,n=new ct,r=new ct,i=new ct,s=new ct,a=new ct,o=new ct,l=new ct,c=new ct,h=new ct,u=new ct,d=new ct,p=t.inheritType?t.inheritType:0;if(t.translation&&e.setPosition(Tg.fromArray(t.translation)),t.preRotation){const e=t.preRotation.map(m.degToRad);e.push(t.eulerOrder),n.makeRotationFromEuler(Sg.fromArray(e))}if(t.rotation){const e=t.rotation.map(m.degToRad);e.push(t.eulerOrder),r.makeRotationFromEuler(Sg.fromArray(e))}if(t.postRotation){const e=t.postRotation.map(m.degToRad);e.push(t.eulerOrder),i.makeRotationFromEuler(Sg.fromArray(e)),i.invert()}t.scale&&s.scale(Tg.fromArray(t.scale)),t.scalingOffset&&o.setPosition(Tg.fromArray(t.scalingOffset)),t.scalingPivot&&a.setPosition(Tg.fromArray(t.scalingPivot)),t.rotationOffset&&l.setPosition(Tg.fromArray(t.rotationOffset)),t.rotationPivot&&c.setPosition(Tg.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(u.copy(t.parentMatrix),h.copy(t.parentMatrixWorld));const f=n.clone().multiply(r).multiply(i),g=new ct;g.extractRotation(h);const v=new ct;v.copyPosition(h);const y=v.clone().invert().multiply(h),x=g.clone().invert().multiply(y),_=s,b=new ct;if(0===p)b.copy(g).multiply(f).multiply(x).multiply(_);else if(1===p)b.copy(g).multiply(x).multiply(f).multiply(_);else{const t=(new ct).scale((new I).setFromMatrixScale(u)).clone().invert(),e=x.clone().multiply(t);b.copy(g).multiply(f).multiply(e).multiply(_)}const w=c.clone().invert(),M=a.clone().invert();let S=e.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(w).multiply(o).multiply(a).multiply(s).multiply(M);const T=(new ct).copyPosition(S),A=h.clone().multiply(T);return d.copyPosition(A),S=d.clone().multiply(b),S.premultiply(h.invert()),S}function Eg(t){const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(t=t||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[t]}function Pg(t){return t.split(",").map((function(t){return parseFloat(t)}))}function Cg(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=t.byteLength),Fl.decodeText(new Uint8Array(t,e,n))}function Lg(t,e,n){return t.slice(0,e).concat(n).concat(t.slice(e))}class Rg extends al{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new Og(t)})),this.register((function(t){return new Gg(t)})),this.register((function(t){return new jg(t)})),this.register((function(t){return new Ug(t)})),this.register((function(t){return new Bg(t)})),this.register((function(t){return new zg(t)})),this.register((function(t){return new kg(t)})),this.register((function(t){return new Hg(t)})),this.register((function(t){return new Dg(t)})),this.register((function(t){return new Vg(t)}))}load(t,e,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Fl.extractUrlBase(t),this.manager.itemStart(t);const a=function(e){r?r(e):console.error(e),i.manager.itemError(t),i.manager.itemEnd(t)},o=new ll(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){try{i.parse(n,s,(function(n){e(n),i.manager.itemEnd(t)}),a)}catch(t){a(t)}}),n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,r){let i;const s={},a={};if("string"==typeof t)i=t;else{if(Fl.decodeText(new Uint8Array(t,0,4))===Wg){try{s[Fg.KHR_BINARY_GLTF]=new qg(t)}catch(t){return void(r&&r(t))}i=s[Fg.KHR_BINARY_GLTF].content}else i=Fl.decodeText(new Uint8Array(t))}const o=JSON.parse(i);if(void 0===o.asset||o.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Ev(o,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](l);a[e.name]=e,s[e.name]=!0}if(o.extensionsUsed)for(let t=0;t<o.extensionsUsed.length;++t){const e=o.extensionsUsed[t],n=o.extensionsRequired||[];switch(e){case Fg.KHR_MATERIALS_UNLIT:s[e]=new Ng;break;case Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[e]=new Kg;break;case Fg.KHR_DRACO_MESH_COMPRESSION:s[e]=new Qg(o,this.dracoLoader);break;case Fg.KHR_TEXTURE_TRANSFORM:s[e]=new Zg;break;case Fg.KHR_MESH_QUANTIZATION:s[e]=new $g;break;default:n.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,r)}parseAsync(t,e){const n=this;return new Promise((function(r,i){n.parse(t,e,r,i)}))}}function Ig(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Fg={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class Dg{constructor(t){this.parser=t,this.name=Fg.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,r=e.length;n<r;n++){const r=e[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let r=e.cache.get(n);if(r)return r;const i=e.json,s=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let a;const o=new te(16777215);void 0!==s.color&&o.fromArray(s.color);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new El(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Tl(o),a.distance=l;break;case"spot":a=new _l(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),r=Promise.resolve(a),e.cache.add(n,r),r}createNodeAttachment(t){const e=this,n=this.parser,r=n.json.nodes[t],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(t){return n._getNodeRef(e.cache,i,t)}))}}class Ng{constructor(){this.name=Fg.KHR_MATERIALS_UNLIT}getMaterialType(){return ee}extendParams(t,e,n){const r=[];t.color=new te(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(t,"map",i.baseColorTexture))}return Promise.all(r)}}class Og{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&i.push(n.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&i.push(n.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(i.push(n.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new g(t,t)}return Promise.all(i)}}class Ug{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new te(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=r.extensions[this.name];return void 0!==s.sheenColorFactor&&e.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(e,"sheenColorMap",s.sheenColorTexture)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class Bg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class zg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=new te(a[0],a[1],a[2]),Promise.all(i)}}class kg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return e.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class Hg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=new te(a[0],a[1],a[2]),void 0!==s.specularColorTexture&&i.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture).then((function(t){t.encoding=3001}))),Promise.all(i)}}class Gg{constructor(t){this.parser=t,this.name=Fg.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,r=n.textures[t];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=n.images[i.source],a=e.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,s,a)}}class jg{constructor(t){this.parser=t,this.name=Fg.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,r=n.json,i=r.textures[t];if(!i.extensions||!i.extensions[e])return null;const s=i.extensions[e],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(t,a,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Vg{constructor(t){this.name=Fg.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],r=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,i.ready]).then((function(e){const n=t.byteOffset||0,r=t.byteLength||0,s=t.count,a=t.byteStride,o=new ArrayBuffer(s*a),l=new Uint8Array(e[0],n,r);return i.decodeGltfBuffer(new Uint8Array(o),s,a,l,t.mode,t.filter),o}))}return null}}const Wg="glTF",Xg=1313821514,Yg=5130562;class qg{constructor(t){this.name=Fg.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:Fl.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Wg)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(t,12);let i=0;for(;i<n;){const e=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===Xg){const n=new Uint8Array(t,12+i,e);this.content=Fl.decodeText(n)}else if(n===Yg){const n=12+i;this.body=t.slice(n,n+e)}i+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Qg{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Fg.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,r=this.dracoLoader,i=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},l={};for(const t in s){const e=fv[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const r=fv[e]||e.toLowerCase();if(void 0!==s[e]){const i=n.accessors[t.attributes[e]],s=hv[i.componentType];l[r]=s,o[r]=!0===i.normalized}}return e.getDependency("bufferView",i).then((function(t){return new Promise((function(e){r.decodeDracoFile(t,(function(t){for(const e in t.attributes){const n=t.attributes[e],r=o[e];void 0!==r&&(n.normalized=r)}e(t)}),a,l)}))}))}}class Zg{constructor(){this.name=Fg.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===e.offset&&void 0===e.rotation&&void 0===e.scale||(t=t.clone(),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Jg extends Fo{constructor(t){super(),this.isGLTFSpecularGlossinessMaterial=!0;const e=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),r=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new te).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(t){for(const e in a)t.uniforms[e]=a[e];t.fragmentShader=t.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",e).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",r).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(t){a.specular.value=t}},specularMap:{get:function(){return a.specularMap.value},set:function(t){a.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(t){a.glossiness.value=t}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(t){a.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Kg{constructor(){this.name=Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return Jg}extendParams(t,e,n){const r=e.extensions[this.name];t.color=new te(1,1,1),t.opacity=1;const i=[];if(Array.isArray(r.diffuseFactor)){const e=r.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==r.diffuseTexture&&i.push(n.assignTexture(t,"map",r.diffuseTexture)),t.emissive=new te(0,0,0),t.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,t.specular=new te(1,1,1),Array.isArray(r.specularFactor)&&t.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const e=r.specularGlossinessTexture;i.push(n.assignTexture(t,"glossinessMap",e)),i.push(n.assignTexture(t,"specularMap",e))}return Promise.all(i)}createMaterial(t){const e=new Jg(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=0,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}class $g{constructor(){this.name=Fg.KHR_MESH_QUANTIZATION}}class tv extends jo{constructor(t,e,n,r){super(t,e,n,r)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=t*r*3+r;for(let t=0;t!==r;t++)e[t]=n[i+t];return e}}tv.prototype.beforeStart_=tv.prototype.copySampleValue_,tv.prototype.afterEnd_=tv.prototype.copySampleValue_,tv.prototype.interpolate_=function(t,e,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,c=r-e,h=(n-e)/c,u=h*h,d=u*h,p=t*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+h;for(let t=0;t!==a;t++){const e=s[f+t+a],n=s[f+t+o]*c,r=s[p+t+a],l=s[p+t]*c;i[t]=v*e+y*n+m*r+g*l}return i};const ev=new R;class nv extends tv{interpolate_(t,e,n,r){const i=super.interpolate_(t,e,n,r);return ev.fromArray(i).normalize().toArray(i),i}}const rv=0,iv=1,sv=2,av=3,ov=4,lv=5,cv=6,hv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},uv={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},dv={33071:1001,33648:1002,10497:1e3},pv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fv={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},mv={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},gv={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},vv="OPAQUE",yv="MASK",xv="BLEND";function _v(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new Fo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),t.DefaultMaterial}function bv(t,e,n){for(const r in n.extensions)void 0===t[r]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=n.extensions[r])}function wv(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Mv(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,r=e.weights.length;n<r;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,r=n.length;e<r;e++)t.morphTargetDictionary[n[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Sv(t){const e=t.extensions&&t.extensions[Fg.KHR_DRACO_MESH_COMPRESSION];let n;return n=e?"draco:"+e.bufferView+":"+e.indices+":"+Tv(e.attributes):t.indices+":"+Tv(t.attributes)+":"+t.mode,n}function Tv(t){let e="";const n=Object.keys(t).sort();for(let r=0,i=n.length;r<i;r++)e+=n[r]+":"+t[n[r]]+";";return e}function Av(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class Ev{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Ig,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox|Safari/.test(navigator.userAgent)?this.textureLoader=new zl(this.options.manager):this.textureLoader=new dl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ll(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][r.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:r.asset,parser:n,userData:{}};bv(i,s,r),wv(s,r),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const r=e[n].joints;for(let e=0,n=r.length;e<n;e++)t[r[e]].isBone=!0}for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const r=n.clone(),i=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,r]of t.children.entries())i(r,e.children[n])};return i(n,r),r.name+="_instance_"+t.uses[e]++,r}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const r=t(e[n]);if(r)return r}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let r=0;r<e.length;r++){const i=t(e[r]);i&&n.push(i)}return n}getDependency(t,e){const n=t+":"+e;let r=this.cache.get(n);if(!r){switch(t){case"scene":r=this.loadScene(e);break;case"node":r=this.loadNode(e);break;case"mesh":r=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":r=this.loadAccessor(e);break;case"bufferView":r=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":r=this.loadBuffer(e);break;case"material":r=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":r=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":r=this.loadSkin(e);break;case"animation":r=this.loadAnimation(e);break;case"camera":r=this.loadCamera(e);break;default:throw new Error("Unknown type: "+t)}this.cache.add(n,r)}return r}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,r=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(r.map((function(e,r){return n.getDependency(t,r)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[Fg.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(t,i){n.load(Fl.resolveURL(e.uri,r.path),t,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const n=e.byteLength||0,r=e.byteOffset||0;return t.slice(r,r+n)}))}loadAccessor(t){const e=this,n=this.json,r=this.json.accessors[t];if(void 0===r.bufferView&&void 0===r.sparse)return Promise.resolve(null);const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(t){const i=t[0],s=pv[r.type],a=hv[r.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,c=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,u=!0===r.normalized;let d,p;if(h&&h!==l){const t=Math.floor(c/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+t+":"+r.count;let l=e.cache.get(n);l||(d=new a(i,t*h,r.count*h/o),l=new ns(d,h/o),e.cache.add(n,l)),p=new is(l,s,c%h/o,u)}else d=null===i?new a(r.count*s):new a(i,c,r.count*s),p=new ie(d,s,u);if(void 0!==r.sparse){const e=pv.SCALAR,n=hv[r.sparse.indices.componentType],o=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(t[1],o,r.sparse.count*e),h=new a(t[2],l,r.sparse.count*s);null!==i&&(p=new ie(p.array.slice(),p.itemSize,p.normalized));for(let t=0,e=c.length;t<e;t++){const e=c[t];if(p.setX(e,h[t*s]),s>=2&&p.setY(e,h[t*s+1]),s>=3&&p.setZ(e,h[t*s+2]),s>=4&&p.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t],i=e.images[r.source];let s=this.textureLoader;if(i.uri){const t=n.manager.getHandler(i.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const r=this,i=this.json,s=this.options,a=i.textures[t],o=(e.uri||e.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=self.URL||self.webkitURL;let c=e.uri||"",h=!1;if(void 0!==e.bufferView)c=r.getDependency("bufferView",e.bufferView).then((function(t){h=!0;const n=new Blob([t],{type:e.mimeType});return c=l.createObjectURL(n),c}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(c).then((function(t){return new Promise((function(e,r){let i=e;!0===n.isImageBitmapLoader&&(i=function(t){const n=new T(t);n.needsUpdate=!0,e(n)}),n.load(Fl.resolveURL(t,s.path),i,void 0,r)}))})).then((function(e){!0===h&&l.revokeObjectURL(c),e.flipY=!1,a.name&&(e.name=a.name);const n=(i.samplers||{})[a.sampler]||{};return e.magFilter=uv[n.magFilter]||1006,e.minFilter=uv[n.minFilter]||1008,e.wrapS=dv[n.wrapS]||1e3,e.wrapT=dv[n.wrapT]||1e3,r.associations.set(e,{textures:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",c),null}));return this.textureCache[o]=u,u}assignTexture(t,e,n){const r=this;return this.getDependency("texture",n.index).then((function(i){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===e&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+e+" not yet supported."),r.extensions[Fg.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Fg.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(i);i=r.extensions[Fg.KHR_TEXTURE_TRANSFORM].extendTexture(i,t),r.associations.set(i,e)}}return t[e]=i,i}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const r=void 0===e.attributes.tangent,i=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Ks,Yt.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Hs,Yt.prototype.copy.call(e,n),e.color.copy(n.color),this.cache.add(t,e)),n=e}if(r||i||s){let t="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),r&&(t+="derivative-tangents:"),i&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),i&&(e.vertexColors=!0),s&&(e.flatShading=!0),r&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}n.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=n}getMaterialType(){return Fo}loadMaterial(t){const e=this,n=this.json,r=this.extensions,i=n.materials[t];let s;const a={},o=i.extensions||{},l=[];if(o[Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=r[Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else if(o[Fg.KHR_MATERIALS_UNLIT]){const t=r[Fg.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new te(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.fromArray(t),a.opacity=t[3]}void 0!==n.baseColorTexture&&l.push(e.assignTexture(a,"map",n.baseColorTexture)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),l.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===i.doubleSided&&(a.side=2);const c=i.alphaMode||vv;if(c===xv?(a.transparent=!0,a.depthWrite=!1):(a.format=1022,a.transparent=!1,c===yv&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==ee&&(l.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new g(1,1),void 0!==i.normalTexture.scale)){const t=i.normalTexture.scale;a.normalScale.set(t,t)}return void 0!==i.occlusionTexture&&s!==ee&&(l.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==ee&&(a.emissive=(new te).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&s!==ee&&l.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){let n;return n=s===Jg?r[Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new s(a),i.name&&(n.name=i.name),n.map&&(n.map.encoding=3001),n.emissiveMap&&(n.emissiveMap.encoding=3001),wv(n,i),e.associations.set(n,{materials:t}),i.extensions&&bv(r,n,i),n}))}createUniqueName(t){const e=mc.sanitizeNodeName(t||"");let n=e;for(let t=1;this.nodeNamesUsed[n];++t)n=e+"_"+t;return this.nodeNamesUsed[n]=!0,n}loadGeometries(t){const e=this,n=this.extensions,r=this.primitiveCache;function i(t){return n[Fg.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return Cv(n,t,e)}))}const s=[];for(let n=0,a=t.length;n<a;n++){const a=t[n],o=Sv(a),l=r[o];if(l)s.push(l.promise);else{let t;t=a.extensions&&a.extensions[Fg.KHR_DRACO_MESH_COMPRESSION]?i(a):Cv(new we,a,e),r[o]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,r=this.extensions,i=n.meshes[t],s=i.primitives,a=[];for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?_v(this.cache):this.getDependency("material",s[t].material);a.push(e)}return a.push(e.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,c=o.length;n<c;n++){const c=o[n],h=s[n];let u;const d=a[n];if(h.mode===ov||h.mode===lv||h.mode===cv||void 0===h.mode)u=!0===i.isSkinnedMesh?new Cs(c,d):new ke(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===lv?u.geometry=Lv(u.geometry,1):h.mode===cv&&(u.geometry=Lv(u.geometry,2));else if(h.mode===iv)u=new Zs(c,d);else if(h.mode===av)u=new Ys(c,d);else if(h.mode===sv)u=new Js(c,d);else{if(h.mode!==rv)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new ra(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&Mv(u,i),u.name=e.createUniqueName(i.name||"mesh_"+t),wv(u,i),h.extensions&&bv(r,u,h),e.assignFinalMaterial(u),l.push(u)}for(let n=0,r=l.length;n<r;n++)e.associations.set(l[n],{meshes:t,primitives:n});if(1===l.length)return l[0];const c=new Wi;e.associations.set(c,{meshes:t});for(let t=0,e=l.length;t<e;t++)c.add(l[t]);return c}))}loadCamera(t){let e;const n=this.json.cameras[t],r=n[n.type];if(r)return"perspective"===n.type?e=new qe(m.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(e=new yn(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),wv(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],n={joints:e.joints};return void 0===e.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",e.inverseBindMatrices).then((function(t){return n.inverseBindMatrices=t,n}))}loadAnimation(t){const e=this.json.animations[t],n=[],r=[],i=[],s=[],a=[];for(let t=0,o=e.channels.length;t<o;t++){const o=e.channels[t],l=e.samplers[o.sampler],c=o.target,h=void 0!==c.node?c.node:c.id,u=void 0!==e.parameters?e.parameters[l.input]:l.input,d=void 0!==e.parameters?e.parameters[l.output]:l.output;n.push(this.getDependency("node",h)),r.push(this.getDependency("accessor",u)),i.push(this.getDependency("accessor",d)),s.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(s),Promise.all(a)]).then((function(n){const r=n[0],i=n[1],s=n[2],a=n[3],o=n[4],l=[];for(let t=0,e=r.length;t<e;t++){const e=r[t],n=i[t],c=s[t],h=a[t],u=o[t];if(void 0===e)continue;let d;switch(e.updateMatrix(),e.matrixAutoUpdate=!0,mv[u.path]){case mv.weights:d=Zo;break;case mv.rotation:d=Ko;break;case mv.position:case mv.scale:default:d=tl}const p=e.name?e.name:e.uuid,f=void 0!==h.interpolation?gv[h.interpolation]:2301,m=[];mv[u.path]===mv.weights?e.traverse((function(t){t.morphTargetInfluences&&m.push(t.name?t.name:t.uuid)})):m.push(p);let g=c.array;if(c.normalized){const t=Av(g.constructor),e=new Float32Array(g.length);for(let n=0,r=g.length;n<r;n++)e[n]=g[n]*t;g=e}for(let t=0,e=m.length;t<e;t++){const e=new d(m[t]+"."+mv[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(e.createInterpolant=function(t){return new(this instanceof Ko?nv:tv)(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(e)}}const c=e.name?e.name:"animation_"+t;return new el(c,void 0,l)}))}createNodeMesh(t){const e=this.json,n=this,r=e.nodes[t];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(t){const e=n._getNodeRef(n.meshCache,r.mesh,t);return void 0!==r.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,n=r.weights.length;e<n;e++)t.morphTargetInfluences[e]=r.weights[e]})),e}))}loadNode(t){const e=this.json,n=this.extensions,r=this,i=e.nodes[t],s=i.name?r.createUniqueName(i.name):"";return function(){const e=[],n=r._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return n&&e.push(n),void 0!==i.camera&&e.push(r.getDependency("camera",i.camera).then((function(t){return r._getNodeRef(r.cameraCache,i.camera,t)}))),r._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){e.push(t)})),Promise.all(e)}().then((function(e){let a;if(a=!0===i.isBone?new Ls:e.length>1?new Wi:1===e.length?e[0]:new Dt,a!==e[0])for(let t=0,n=e.length;t<n;t++)a.add(e[t]);if(i.name&&(a.userData.name=i.name,a.name=s),wv(a,i),i.extensions&&bv(n,a,i),void 0!==i.matrix){const t=new ct;t.fromArray(i.matrix),a.applyMatrix4(t)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=t,a}))}loadScene(t){const e=this.json,n=this.extensions,r=this.json.scenes[t],i=this,s=new Wi;r.name&&(s.name=i.createUniqueName(r.name)),wv(s,r),r.extensions&&bv(n,s,r);const a=r.nodes||[],o=[];for(let t=0,n=a.length;t<n;t++)o.push(Pv(a[t],s,e,i));return Promise.all(o).then((function(){return i.associations=(t=>{const e=new Map;for(const[t,n]of i.associations)(t instanceof Yt||t instanceof T)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(s),s}))}}function Pv(t,e,n,r){const i=n.nodes[t];return r.getDependency("node",t).then((function(t){if(void 0===i.skin)return t;let e;return r.getDependency("skin",i.skin).then((function(t){e=t;const n=[];for(let t=0,i=e.joints.length;t<i;t++)n.push(r.getDependency("node",e.joints[t]));return Promise.all(n)})).then((function(n){return t.traverse((function(t){if(!t.isMesh)return;const r=[],i=[];for(let t=0,s=n.length;t<s;t++){const s=n[t];if(s){r.push(s);const n=new ct;void 0!==e.inverseBindMatrices&&n.fromArray(e.inverseBindMatrices.array,16*t),i.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}t.bind(new Ds(r,i),t.matrixWorld)})),t}))})).then((function(t){e.add(t);const s=[];if(i.children){const e=i.children;for(let i=0,a=e.length;i<a;i++){const a=e[i];s.push(Pv(a,t,n,r))}}return Promise.all(s)}))}function Cv(t,e,n){const r=e.attributes,i=[];function s(e,r){return n.getDependency("accessor",e).then((function(e){t.setAttribute(r,e)}))}for(const e in r){const n=fv[e]||e.toLowerCase();n in t.attributes||i.push(s(r[e],n))}if(void 0!==e.indices&&!t.index){const r=n.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));i.push(r)}return wv(t,e),function(t,e,n){const r=e.attributes,i=new N;if(void 0===r.POSITION)return;{const t=n.json.accessors[r.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new I(e[0],e[1],e[2]),new I(s[0],s[1],s[2])),t.normalized){const e=Av(hv[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new I,e=new I;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,a=r.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),r.normalized){const t=Av(hv[r.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(t)}t.boundingBox=i;const a=new tt;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=a}(t,e,n),Promise.all(i).then((function(){return void 0!==e.targets?function(t,e,n){let r=!1,i=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),r&&i)break}if(!r&&!i)return Promise.resolve(t);const s=[],a=[];for(let o=0,l=e.length;o<l;o++){const l=e[o];if(r){const e=void 0!==l.POSITION?n.getDependency("accessor",l.POSITION):t.attributes.position;s.push(e)}if(i){const e=void 0!==l.NORMAL?n.getDependency("accessor",l.NORMAL):t.attributes.normal;a.push(e)}}return Promise.all([Promise.all(s),Promise.all(a)]).then((function(e){const n=e[0],s=e[1];return r&&(t.morphAttributes.position=n),i&&(t.morphAttributes.normal=s),t.morphTargetsRelative=!0,t}))}(t,e.targets,n):t}))}function Lv(t,e){let n=t.getIndex();if(null===n){const e=[],r=t.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<r.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const r=n.count-2,i=[];if(2===e)for(let t=1;t<=r;t++)i.push(n.getX(0)),i.push(n.getX(t)),i.push(n.getX(t+1));else for(let t=0;t<r;t++)t%2==0?(i.push(n.getX(t)),i.push(n.getX(t+1)),i.push(n.getX(t+2))):(i.push(n.getX(t+2)),i.push(n.getX(t+1)),i.push(n.getX(t)));i.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(i),s}const Rv=new WeakMap;class Iv extends al{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,n,r){const i=new ll(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,(t=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(t,n).then(e).catch(r)}),n,r)}decodeDracoFile(t,e,n,r){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(t,i).then(e)}decodeGeometry(t,e){for(const t in e.attributeTypes){const n=e.attributeTypes[t];void 0!==n.BYTES_PER_ELEMENT&&(e.attributeTypes[t]=n.name)}const n=JSON.stringify(e);if(Rv.has(t)){const e=Rv.get(t);if(e.key===n)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(i,s).then((n=>(r=n,new Promise(((n,s)=>{r._callbacks[i]={resolve:n,reject:s},r.postMessage({type:"decode",id:i,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),Rv.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new we;t.index&&e.setIndex(new ie(t.index.array,1));for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n],i=r.name,s=r.array,a=r.itemSize;e.setAttribute(i,new ie(s,a))}return e}_loadLibrary(t,e){const n=new ll(this.manager);return n.setPath(this.decoderPath),n.setResponseType(e),n.setWithCredentials(this.withCredentials),new Promise(((e,r)=>{n.load(t,e,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const n=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const r=Fv.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const t=new Worker(this.workerSourceURL);t._callbacks={},t._taskCosts={},t._taskLoad=0,t.postMessage({type:"init",decoderConfig:this.decoderConfig}),t.onmessage=function(e){const n=e.data;switch(n.type){case"decode":t._callbacks[n.id].resolve(n);break;case"error":t._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(t)}else this.workerPool.sort((function(t,e){return t._taskLoad>e._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this}}function Fv(){let t,e;function n(t,e,n,r,i,s){const a=s.num_components(),o=n.num_points()*a,l=o*i.BYTES_PER_ELEMENT,c=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32}}(t,i),h=t._malloc(l);e.GetAttributeDataArrayForAllPoints(n,s,c,l,h);const u=new i(t.HEAPF32.buffer,h,o).slice();return t._free(h),{name:r,array:u,itemSize:a}}onmessage=function(r){const i=r.data;switch(i.type){case"init":t=i.decoderConfig,e=new Promise((function(e){t.onModuleLoaded=function(t){e({draco:t})},DracoDecoderModule(t)}));break;case"decode":const r=i.buffer,s=i.taskConfig;e.then((t=>{const e=t.draco,a=new e.Decoder,o=new e.DecoderBuffer;o.Init(new Int8Array(r),r.byteLength);try{const t=function(t,e,r,i){const s=i.attributeIDs,a=i.attributeTypes;let o,l;const c=e.GetEncodedGeometryType(r);if(c===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeBufferToMesh(r,o);else{if(c!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeBufferToPointCloud(r,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const r in s){const l=self[a[r]];let c,u;if(i.useUniqueIDs)u=s[r],c=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[r]]),-1===u)continue;c=e.GetAttribute(o,u)}h.attributes.push(n(t,e,o,r,l,c))}c===t.TRIANGULAR_MESH&&(h.index=function(t,e,n){const r=3*n.num_faces(),i=4*r,s=t._malloc(i);e.GetTrianglesUInt32Array(n,i,s);const a=new Uint32Array(t.HEAPF32.buffer,s,r).slice();return t._free(s),{array:a,itemSize:1}}(t,e,o));return t.destroy(o),h}(e,a,o,s),r=t.attributes.map((t=>t.array.buffer));t.index&&r.push(t.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:t},r)}catch(t){console.error(t),self.postMessage({type:"error",id:i.id,error:t.message})}finally{e.destroy(o),e.destroy(a)}}))}}}class Dv extends Lp{constructor(t){super("Model",t),this.viewport=t,this.gltfLoader=null,this.fbxLoader=null,this.modelMaps=new Map,this.store=Fp.createInstance({name:"soonspace",version:2,storeName:"modelData"}),this.dracoDecoderPath=null}setDracoDecoderPath(t){this.dracoDecoderPath=t}load(t){return this._loadItem(t)}parse(t,e,n){return new Promise(((r,i)=>{const s=new fp(Object.assign({format:t},n)),{url:a}=n,o=t.toLocaleUpperCase(),l="SBMX"===o;if("GLTF"===o||"GLB"===o||l){const t=a.substring(0,a.lastIndexOf("/")+1);if(this.gltfLoader||(this.gltfLoader=new Rg),this.dracoDecoderPath&&!this.gltfLoader.dracoLoader){const t=new Iv;t.setDecoderPath(this.dracoDecoderPath),this.gltfLoader.setDRACOLoader(t)}l&&(e=xh(e)),this.gltfLoader.parse(e,t,(t=>{const{animations:e}=t;if(e&&e.length>0&&(s.animations=e),t.scene.traverse((t=>{"AmbientLight"!==t.type&&"DirectionalLight"!==t.type||(t.visible=!1),t.castShadow=!0,t.receiveShadow=!0})),s.add(t.scene),!this.modelMaps.get(a)){const t=s.sClone();this.modelMaps.set(a,t)}r(s)}),(t=>{i(t)}))}else if("FBX"===o){this.fbxLoader||(this.fbxLoader=new dg);const t=this.fbxLoader.parse(e,""),{animations:n}=t;if(n&&n.length>0&&(s.animations=n),t.traverse((t=>{"AmbientLight"!==t.type&&"DirectionalLight"!==t.type||(t.visible=!1),t.castShadow=!0,t.receiveShadow=!0})),s.add(t),!this.modelMaps.get(a)){const t=s.sClone();this.modelMaps.set(a,t)}r(s)}else i(`In soonspacejs: 加载通用模型资源(${a})格式错误,当前支持 fbx、gltf、glb !`)}))}clone(t,e,n){return new Promise(((r,i)=>Pu(this,void 0,void 0,(function*(){"Model"!==t.stype&&i("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:s,name:a,level:o,visible:l,position:c,rotation:h,scale:u,onClick:d,onDblClick:p,onRightClick:f,onLoad:m,userData:g}=e;function v(t,e,n){n(t,e);for(var r=0;r<t.children.length;r++)v(t.children[r],e.children[r],n)}const y=yield function(t){const e=new Map,n=new Map;let r;return r=t instanceof eu||t instanceof tu?t.sClone():t.clone(),v(t,r,(function(t,r){e.set(r,t),n.set(t,r)})),r.traverse((function(t){if(t instanceof Cs){const r=t,i=e.get(t),s=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=s.map((function(t){return n.get(t)})),r.bind(r.skeleton,r.bindMatrix)}})),r}(t);y.animations=yield y.animations.map((t=>t.clone())),yield this._copyMaterial(y),s&&(y.sid=s),a&&(y.name=a),o&&(y.level=o),!1===l&&y.hide(),c&&y.position.set(c.x,c.y,c.z),h&&y.rotation.set(h.x,h.y,h.z),u&&y.scale.set(u.x,u.y,u.z),y.onClick=d?d.bind(y):null,y.onDblClick=p?p.bind(y):null,y.onRightClick=f?f.bind(y):null,y.onLoad=m?m.bind(y):null,y.onLoad&&y.onLoad(y),g&&(y.userData=g),null!==n&&this.viewport.scener.addObject(y,n||t.parent||this.scene),r(y)}))))}loadToGroup(t,e){return new Promise((n=>Pu(this,void 0,void 0,(function*(){const r=new ru(t);for(let t=0;t<e.length;t++){const n=yield this._loadItem(e[t],null);r.add(n)}this.viewport.scener.addObject(r,this.scene),n(r)}))))}addForGroup(t,e){return new Promise((n=>Pu(this,void 0,void 0,(function*(){const r=this.getGroupById(t);if(r){for(let t=0;t<e.length;t++){const n=yield this._loadItem(e[t],null);r.add(n)}this.viewport.scener.addObject(r,this.scene)}n(r)}))))}clearIdb(){return this.store.clear()}_loadItem(t,e=this.scene){return Pu(this,void 0,void 0,(function*(){const{url:n}=t,{useIndexedDB:r}=this.viewport.options,i=n.slice(n.lastIndexOf(".")+1),s=this.modelMaps.get(n);let a=null;if(s)return this.clone(s,t,e);r&&(a=yield this.store.getItem(n)),a||(a=yield this._fetchBuffer(t));const o=yield this.parse(i,a,t);return null!==e&&this.viewport.scener.addObject(o,e||this.scene),Promise.resolve(o)}))}_fetchBuffer(t){const{url:e}=t,{useIndexedDB:n}=this.viewport.options;return fetch(e).then((t=>t.arrayBuffer())).then((t=>(n&&this.store.setItem(e,t),Promise.resolve(t))))}_copyMaterial(t){t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof Yt&&(t.material=t.material.clone()))}))}}class Nv extends Lp{constructor(t){super("Poi",t),this.materials=new Map}create(t){const e=this._createMaterial(t.url),n=new vp(e,t);return this.viewport.scener.addObject(n,this.scene),n}clone(t,e,n){"Poi"!==t.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:r,name:i,level:s,visible:a,position:o,rotation:l,scale:c,onClick:h,onDblClick:u,onRightClick:d,userData:p}=e,f=t.sClone();return this._copyMaterial(f),r&&(f.sid=r),i&&(f.name=i),s&&(f.level=s),Mh(a)&&(f.visible=a),o&&f.position.set(o.x,o.y,o.z),l&&f.rotation.set(l.x,l.y,l.z),c&&f.scale.set(c.x,c.y,c.z),f.onClick=h?h.bind(f):null,f.onDblClick=u?u.bind(f):null,f.onRightClick=d?d.bind(f):null,p&&(f.userData=p),null!==n&&this.viewport.scener.addObject(f,n||this.scene||t.parent),f}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{const e=this._createMaterial(t.url),r=new vp(e,t);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&(e.forEach((t=>{const e=this._createMaterial(t.url),r=new vp(e,t);n.add(r)})),this.viewport.scener.addObject(n,this.scene)),n}_createMaterial(t){const e=this.materials.get(t);if(!e){const e=(new dl).load(t);e.flipY=!0;const n=new ss({map:e,color:16777215});return this.materials.set(t,n),n}return e}_copyMaterial(t){t.traverse((t=>{(t instanceof ke||t instanceof xs)&&(Ph(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof Yt&&(t.material=t.material.clone()))}))}}class Ov extends Lp{constructor(t){super("PoiNode",t)}create(t){this._openEnableRenderCss(t);const e=new Eu(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{this._openEnableRenderCss(t);const e=new Eu(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&(e.forEach((t=>{const e=new Eu(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene)),n}_openEnableRenderCss(t){switch(t.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class Uv extends Lp{constructor(t){super("Canvas3D",t)}create(t){const e=new Ep(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{const e=new Ep(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&(e.forEach((t=>{const e=new Ep(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene)),n}}class Bv{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(t){if(!Ph(t))return console.error("In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph isn't an array )");if(!(t.length<1))for(let e=0;e<t.length;e++){const n=t[e];if(2!==n.length)return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph item must be an array and contain 2 values [name, vertices], Failed at index: ${e} )`);const r=n[0],i=n[1];this.graph[r]=[];for(let t=0;t<i.length;t++){const e=i[t],n=e[0],s=e[1];this.graph[r][n]=s}}}getPath(t,e){if(void 0===this.graph[t])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method source ${t} doesn't exist )`),[];if(void 0===this.graph[e])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method target ${e} doesn't exist )`),[];if(t===e)return[];let n;for(this.queue=new vh,this.queue.add(t,0),this.previous[t]=null;n=this.queue.shift();){if(n===e){const t=[];for(;Sh(n)&&null!==this.previous[n];)t.unshift(n),n=this.previous[n];return t}const t=this.queue.getDistance(n);if(t===1/0)return[];for(let e in this.graph[n]){const r=this.queue.getDistance(Number(e)),i=t+this.graph[n][e];i<r&&(this.queue.update(Number(e),i),this.previous[e]=n)}}return[]}}class zv extends Lp{constructor(t){super("Topology",t),this.dijkstra=new Bv}createFromGml(t){const{url:e,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255}=t;return kp(e).then((e=>{if(!e||!e.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const a=[],o=new Map;let l=[],c=[];const h=e.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;Ph(h)?h.forEach((t=>{l=[...l,...t.state],c=[...c,...t.transition]})):(l=[...l,...h.state],c=[...c,...h.transition]),l.forEach(((t,e)=>{const n=t.State._attributes["gml:id"],r=t.State.topoNode["gml:Node"].node_name;a.push({id:wh(n)?n:"",name:wh(r)?r:"",position:{x:Number(t.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(t.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(t.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),o.set(n,e)})),c.forEach((t=>{const e=t.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=t.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],r=t.Transition.topoEdge["gml:Edge"].length["#text"],i=t.Transition.topoEdge["gml:Edge"].restrict["#text"],s=t.Transition.topoEdge["gml:Edge"].passable["#text"],l=o.get(e),c=o.get(n),h=t.Transition._attributes["gml:id"],u=t.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==l&&void 0!==c&&("2"!==s&&"3"!==s&&a[l].graphs.push({targetNodeId:n,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}),"1"!==s&&"3"!==s&&a[c].graphs.push({targetNodeId:e,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}))})),this.setDijkstraGraph(a);const u=new wp(Object.assign(Object.assign({},t),{type:"network",nodes:a,linkWidth:n,renderLink:!0,linkColor:r,renderNode:i,nodeColor:s}));return this.viewport.scener.addObject(u,this.scene),Promise.resolve(u)}))}create(t){const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const n=new wp(e);return this.viewport.scener.addObject(n,this.scene),n}resetNodes(t,e){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},t.info),{nodes:e}));return t.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),t}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const r=new wp(e);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&e.forEach((t=>{const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const r=new wp(e);n.add(r)})),n}getShortestPath(t,e){const{nodes:n}=t.info,r=lh(e.start),i=lh(e.end);let s=null,a=1/0,o=null,l=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=lh(t.position),n=e.distanceTo(r),c=e.distanceTo(i);n<a&&(a=n,s=Number(t.id)),c<l&&(l=c,o=Number(t.id))}})),s&&o){const a=this.dijkstra.getPath(s,o);if(a.length>0){const s=[{id:"startPoint",position:r,graphs:[]}];a.forEach((t=>{const e=n.find((e=>e.id==t));e&&s.push(e)})),s.push({id:"endPoint",position:i,graphs:[]});for(let t=0;t<s.length;t++)s[t].position.y+=1;const o=Object.assign(Object.assign(Object.assign({},e),{type:"line",nodes:s}),t.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(o);const l=new wp(o);return this.viewport.scener.addObject(l,this.scene),l}}return null}getShortestPathByMultipleStartPoints(t,e){const{nodes:n}=t.info,r=[];e.start.forEach((t=>{const i=lh(t),s=lh(e.end);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=lh(t.position),n=e.distanceTo(i),r=e.distanceTo(s);n<o&&(o=n,a=Number(t.id)),r<c&&(c=r,l=Number(t.id))}})),a&&l){let t=0;const e=this.dijkstra.getPath(a,l);if(e.length>0){const a=[{id:"startPoint",position:i,graphs:[]}];e.forEach(((e,r)=>{const s=n.find((t=>t.id==e));s&&(t+=0===r?lh(s.position).distanceTo(i):lh(s.position).distanceTo(lh(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(lh(a[a.length-1].position)),r.push({nodeInfo:a,pathLength:t})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:t,pathLength:e})=>{e<s&&(s=e,i=t)})),i.length){for(let t=0;t<i.length;t++)i[t].position.y+=1;const n=Object.assign(Object.assign({},e),{type:"line",nodes:i,position:t.getWorldPosition(new I),rotation:(new xt).setFromQuaternion(t.getWorldQuaternion(new R)),scale:t.getWorldScale(new I)});this.generateLineTopologyInfoNodeGraphs(n);const r=new wp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}getShortestPathByMultipleEndPoints(t,e){const{nodes:n}=t.info,r=[];e.end.forEach((t=>{const i=lh(e.start),s=lh(t);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=lh(t.position),n=e.distanceTo(i),r=e.distanceTo(s);n<o&&(o=n,a=Number(t.id)),r<c&&(c=r,l=Number(t.id))}})),a&&l){let t=0;const e=this.dijkstra.getPath(a,l);if(e.length>0){const a=[{id:"startPoint",position:i,graphs:[]}];e.forEach(((e,r)=>{const s=n.find((t=>t.id==e));s&&(t+=0===r?lh(s.position).distanceTo(i):lh(s.position).distanceTo(lh(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(lh(a[a.length-1].position)),r.push({nodeInfo:a,pathLength:t})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:t,pathLength:e})=>{e<s&&(s=e,i=t)})),i.length){for(let t=0;t<i.length;t++)i[t].position.y+=1;const n=Object.assign(Object.assign({},e),{type:"line",nodes:i,position:t.getWorldPosition(new I),rotation:(new xt).setFromQuaternion(t.getWorldQuaternion(new R)),scale:t.getWorldScale(new I)});this.generateLineTopologyInfoNodeGraphs(n);const r=new wp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}setDijkstraGraph(t){const e=[];t.forEach((n=>{if(n.graphs&&n.graphs.length>0){const r=[];n.graphs.forEach((e=>{const i=t.find((t=>t.id===e.targetNodeId));i&&r.push([Number(e.targetNodeId),e.length||lh(n.position).distanceTo(lh(i.position))])})),e.push([Number(n.id),r])}})),e.length>0&&this.dijkstra.setGraph(e)}generateLineTopologyInfoNodeGraphs(t){if("line"===t.type)for(let e=0;e<t.nodes.length;e++)if(e===t.nodes.length-1)t.nodes[e].graphs=[];else{const n=t.nodes[e],r=t.nodes[e+1];t.nodes[e].graphs=[{targetNodeId:r.id.toString(),linkInfo:{id:`${n.id}_to_${r.id}`,name:`${n.name||n.id}_to_${r.name||r.id}`},enable:!0,length:lh(t.nodes[e].position).distanceTo(lh(r.position)),restrict:0,passable:0}]}return t}}class kv extends Lp{constructor(t){super("Helper",t)}addGridHelper(t){const{id:e,size:n=1e3,divisions:r=20,color:i="#fff",position:s={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:o={x:1,y:1,z:1}}=t,l=new Gc(n,r,i,i);return l.position.set(s.x,s.y,s.z),l.rotation.set(a.x,a.y,a.z),l.scale.set(o.x,o.y,o.z),l.userData.sid=e,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(t){const{id:e,axesLength:n=1e3}=t,r=new nh(n);return r.userData.sid=e,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addBoxHelper(t){const{id:e,box:n,color:r="#00ff00"}=t,i=new Kc(n,new te(r));return i.userData.sid=e,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPlaneHelper(t){const{id:e,width:n=500,height:r=500,color:i="#00ff00",opacity:s=.2,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=t,c=new tu(new ln(n,r),new ee({color:i,opacity:s,transparent:!0,side:2}),{id:e,position:a,rotation:o,scale:l});return c.userData.sid=e,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(t){const{imgUrl:e,id:n,width:r=500,height:i=500,opacity:s=1,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=t,h=(new dl).load(e),u=new ln(r,i);u.computeBoundingBox();const d=new Fo({side:2,map:h,transparent:!0,opacity:s,roughness:.8});d.map&&(d.map.repeat.set(c.x,c.x),d.map.wrapS=1e3,d.map.wrapT=1e3,d.map.version++),o.x-=Math.PI/2,d.version++;const p=new Pp(u,d,{id:n,position:a,rotation:o,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(t){const{id:e,light:n,color:r,size:i=50}=t,s=new Xc(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(t){const{id:e,light:n,color:r,size:i=20}=t,s=new Hc(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(t){const{id:e,light:n,color:r}=t,i=new Rc(n,r);return i.userData.sid=e,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPointLightHelper(t){const{id:e,light:n,color:r,size:i=20}=t,s=new Uc(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}}class Hv extends Lp{constructor(t){super("PluginObject",t)}createObject(t,e){const n=new iu(t);return e&&n.add(e),this.viewport.scener.addObject(n,this.scene),n}addToObject(t,e){const n=this.getById(t);return n?(this.viewport.scener.addObject(e,n),n):null}}class Gv{constructor(t){this.viewport=t,this.needUpdate=!1,this.store={LightManager:new Rp(t),sbmManager:new Gp(t),modelManager:new Dv(t),poiManager:new Nv(t),poiNodeManager:new Ov(t),canvas3DManager:new Uv(t),topologyManager:new zv(t),helperManager:new kv(t),pluginObjectManager:new Hv(t)},this.postUpdate=new Map;for(let t in this.store)this.postUpdate.set(t,this.store[t].update.bind(this.store[t]));t.postUpdate.set("ManagerRender",this.update.bind(this))}update(){const t=performance.now();this.postUpdate.forEach((t=>t())),this.viewport.signals.loadRendered.dispatch(performance.now()-t)}clearObject(){this.store.sbmManager.clear(),this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.LightManager.clear()}}export default class{constructor(t){this.THREE=ah,this.version=e,this.animation=$h,this.library=Cp,this.utils=Oh,this.plugins={};const{el:n,options:r={},events:i={}}=t;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showGrid:!1,background:{color:0,alpha:!1},fog:!1,controls:{},hoverEnabled:!1,closeInfoLog:!1,closeWarnLog:!0,useIndexedDB:!0,logarithmicDepthBuffer:!0}),r),this.viewport=new hp(this.options),this.signals=this.viewport.signals,this.manager=new Gv(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(i),this._initDefaultLight()}_init(){const{showGrid:e,background:n,fog:r,controls:i,closeInfoLog:s,closeWarnLog:a,useIndexedDB:o}=this.options;if(!s){oh(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),oh(t,{color:"#3eaf7c","font-size":"24px"}),oh(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),oh("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),oh("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),oh("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}e&&this.addGridHelper(!0===e?{id:"defaultGridHelper"}:e),(null==n?void 0:n.skyBox)?wh(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):Ch(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),r&&this.openSceneFog(!0===r?void 0:r),i&&this.setControlsOptions(i),a&&(window.console.warn=function(){}),o&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(t){const{modelHover:e,modelUnHover:n,modelClick:r,modelRightClick:i,modelDblClick:s,poiHover:a,poiUnHover:o,poiClick:l,poiRightClick:c,poiDblClick:h,selectPosition:u,sceneClick:d,resize:p}=t;e&&this.signals.modelHover.add(e),n&&this.signals.modelUnHover.add(n),r&&this.signals.modelClick.add(r),i&&this.signals.modelRightClick.add(i),s&&this.signals.modelDblClick.add(s),a&&this.signals.poiHover.add(a),o&&this.signals.poiUnHover.add(o),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),h&&this.signals.poiDblClick.add(h),u&&this.signals.selectPosition.add(u),d&&this.signals.sceneClick.add(d),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultLight(){this.createAmbientLight({id:"defaultAmbientLight",name:"defaultAmbientLight"}),this.createDirectionalLight({id:"defaultDirectionalLight",name:"defaultDirectionalLight"}),this.createHemisphereLight({id:"defaultHemisphereLight",name:"defaulHemisphereLight",intensity:.1})}registerPlugin(t,e){const n=new t(this);return this.plugins[e]=n,n}getPlugin(t){return this.plugins[t]?this.plugins[t]:null}createPluginObject(t,e){return this.manager.store.pluginObjectManager.createObject(t,e)}addToPluginObject(t,e){return this.manager.store.pluginObjectManager.addToObject(t,e)}getPluginObjectById(t){return this.manager.store.pluginObjectManager.getById(t)}getPluginObjectByName(t){return this.manager.store.pluginObjectManager.getByName(t)}removePluginObjectById(t){return this.manager.store.pluginObjectManager.removeById(t)}setHoverEnabled(t){this.viewport.setHoverEnabled(t)}setBackgroundColor(t){this.viewport.setBackgroundColor(t)}setBackgroundImage(t){this.viewport.setBackgroundImage(t)}setSphereSkyBackground(t){this.viewport.setSphereSkyBackground(t)}setSkyBackground(t,e){this.viewport.setSkyBackground(t,e)}playModelAnimation(t,e){return this.viewport.playModelAnimation(t,e)}stopModelAnimation(t,e){this.viewport.stopModelAnimation(t,e)}getOffsetByPosition(t){return this.viewport.getOffsetByPosition(t)}getPositionByOffset(t,e){return this.viewport.getPositionByOffset(t,e)}render(t){return this.viewport.render(t)}clearSignals(){this.viewport.clearSignals()}dispose(){return this.clear(),this.clearSignals(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(t){this.viewport.cameraManager.setCameraViewpoint(t)}flyTo(t,e="frontTop",n){return this.viewport.cameraManager.flyTo(t,e,n)}flyToBoundingBox(t,e="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(t,e,n)}flyToObj(t,e="frontTop",n){return this.viewport.cameraManager.flyToObj(t,e,n)}flyMainViewpoint(t="frontTop",e){return this.flyToObj(this.viewport.scene,t,e)}surroundOnTarget(t,e){return this.viewport.cameraManager.surroundOnTarget(t,e)}surroundOnObject(t,e){return this.viewport.cameraManager.surroundOnObject(t,e)}getObjectLabelPos(t,e="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(t,e,n)}setControlsOptions(t){return this.viewport.controls.setOptions(t)}addObject(t,e){this.viewport.scener.addObject(t,e)}removeObject(t){this.viewport.scener.removeObject(t)}openSceneFog(t){this.viewport.scener.openSceneFog(t)}closeSceneFog(){this.viewport.scener.closeSceneFog()}edgeShow(t,e){return this.viewport.scener.edgeShow(t,e)}unEdgeShow(t){return this.viewport.scener.unEdgeShow(t)}strokeShow(t,e){return this.viewport.scener.strokeShow(t,e)}unStrokeShow(t){return this.viewport.scener.unStrokeShow(t)}opacityShow(t,e){return this.viewport.scener.opacityShow(t,e)}unOpacityShow(t){return this.viewport.scener.unOpacityShow(t)}highlightShow(t,e){return this.viewport.scener.highlightShow(t,e)}unHighlightShow(t){return this.viewport.scener.unHighlightShow(t)}emissiveShow(t,e){return this.viewport.scener.emissiveShow(t,e)}unEmissiveShow(t){return this.viewport.scener.unEmissiveShow(t)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(t){return this.manager.store.LightManager.createAmbientLight(t)}setAmbientLight(t){return this.manager.store.LightManager.setAmbientLight(t)}createDirectionalLight(t){return this.manager.store.LightManager.createDirectionalLight(t)}setDirectionalLight(t){return this.manager.store.LightManager.setDirectionalLight(t)}createHemisphereLight(t){return this.manager.store.LightManager.createHemisphereLight(t)}setHemisphereLight(t){return this.manager.store.LightManager.setHemisphereLight(t)}createSpotLight(t){return this.manager.store.LightManager.createSpotLight(t)}setSpotLight(t){return this.manager.store.LightManager.setSpotLight(t)}createPointLight(t){return this.manager.store.LightManager.createPointLight(t)}setPointLight(t){return this.manager.store.LightManager.setPointLight(t)}getLightById(t){return this.manager.store.LightManager.getById(t)}removeLightById(t){return this.manager.store.LightManager.removeById(t)}getAllLight(){return this.manager.store.LightManager.getAll()}clearLight(){return this.manager.store.LightManager.clear()}showAllLight(){return this.manager.store.LightManager.showAll()}hideAllLight(){return this.manager.store.LightManager.hideAll()}loadSbm(t,e){return this.manager.store.sbmManager.load(t,e)}parseSbm(t,e,n){return this.manager.store.sbmManager.parse(t,e,n)}cloneSbm(t,e,n){return this.manager.store.sbmManager.clone(t,e,n)}getSbmById(t){return this.manager.store.sbmManager.getById(t)}getSbmByName(t){return this.manager.store.sbmManager.getByName(t)}getSbmByUserDataProperty(t,e){return this.manager.store.sbmManager.getByUserDataProperty(t,e)}removeSbmById(t){return this.manager.store.sbmManager.removeById(t)}createGroupForSbm(t){return this.manager.store.sbmManager.createGroup(t)}loadSbmToGroup(t,e,n){return this.manager.store.sbmManager.loadToGroup(t,e,n)}addSbmForGroup(t,e,n){return this.manager.store.sbmManager.addForGroup(t,e,n)}createSbmGroupFromXml(t,e){return this.manager.store.sbmManager.createGroupFromXml(t,e)}getSbmGroupById(t){return this.manager.store.sbmManager.getGroupById(t)}getSbmGroupByName(t){return this.manager.store.sbmManager.getGroupByName(t)}getAllSbmGroup(){return this.manager.store.sbmManager.getAllGroup()}removeSbmGroupById(t){return this.manager.store.sbmManager.removeGroupById(t)}clearSbm(){return this.manager.store.sbmManager.clear()}getAllSbm(){return this.manager.store.sbmManager.getAll()}showAllSbm(){return this.manager.store.sbmManager.showAll()}hideAllSbm(){return this.manager.store.sbmManager.hideAll()}getSbmModelMaps(){return this.manager.store.sbmManager.modelMaps}setSbmModelMaps(t){this.manager.store.sbmManager.modelMaps=t}clearIdb(){return Promise.all([this.manager.store.sbmManager.clearIdb(),this.manager.store.modelManager.clearIdb()])}setModelDracoDecoderPath(t){return this.manager.store.modelManager.setDracoDecoderPath(t)}loadModel(t){return this.manager.store.modelManager.load(t)}cloneModel(t,e,n){return this.manager.store.modelManager.clone(t,e,n)}getModelById(t){return this.manager.store.modelManager.getById(t)}getModelByName(t){return this.manager.store.modelManager.getByName(t)}getModelByUserDataProperty(t,e){return this.manager.store.modelManager.getByUserDataProperty(t,e)}removeModelById(t){return this.manager.store.modelManager.removeById(t)}createGroupForModel(t){return this.manager.store.modelManager.createGroup(t)}loadModelToGroup(t,e){return this.manager.store.modelManager.loadToGroup(t,e)}addModelForGroup(t,e){return this.manager.store.modelManager.addForGroup(t,e)}getModelGroupById(t){return this.manager.store.modelManager.getGroupById(t)}getModelGroupByName(t){return this.manager.store.modelManager.getGroupByName(t)}getAllModelGroup(){return this.manager.store.modelManager.getAllGroup()}removeModelGroupById(t){return this.manager.store.modelManager.removeGroupById(t)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}createPoi(t){return this.manager.store.poiManager.create(t)}clonePoi(t,e,n){return this.manager.store.poiManager.clone(t,e,n)}getPoiById(t){return this.manager.store.poiManager.getById(t)}getPoiByName(t){return this.manager.store.poiManager.getByName(t)}getPoiByUserDataProperty(t,e){return this.manager.store.poiManager.getByUserDataProperty(t,e)}removePoiById(t){return this.manager.store.poiManager.removeById(t)}createGroupForPoi(t){return this.manager.store.poiManager.createGroup(t)}createPoiToGroup(t,e){return this.manager.store.poiManager.createToGroup(t,e)}addPoiForGroup(t,e){return this.manager.store.poiManager.addForGroup(t,e)}getPoiGroupById(t){return this.manager.store.poiManager.getGroupById(t)}getPoiGroupByName(t){return this.manager.store.poiManager.getGroupByName(t)}getAllPoiGroup(){return this.manager.store.poiManager.getAllGroup()}removePoiGroupById(t){return this.manager.store.poiManager.removeGroupById(t)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(t){return this.manager.store.poiNodeManager.create(t)}getPoiNodeById(t){return this.manager.store.poiNodeManager.getById(t)}getPoiNodeByName(t){return this.manager.store.poiNodeManager.getByName(t)}getPoiNodeByUserDataProperty(t,e){return this.manager.store.poiNodeManager.getByUserDataProperty(t,e)}removePoiNodeById(t){return this.manager.store.poiNodeManager.removeById(t)}createGroupForPoiNode(t){return this.manager.store.poiNodeManager.createGroup(t)}createPoiNodeToGroup(t,e){return this.manager.store.poiNodeManager.createToGroup(t,e)}addPoiNodeForGroup(t,e){return this.manager.store.poiNodeManager.addForGroup(t,e)}getPoiNodeGroupById(t){return this.manager.store.poiNodeManager.getGroupById(t)}getPoiNodeGroupByName(t){return this.manager.store.poiNodeManager.getGroupByName(t)}getAllPoiNodeGroup(){return this.manager.store.poiNodeManager.getAllGroup()}removePoiNodeGroupById(t){return this.manager.store.poiNodeManager.removeGroupById(t)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createCanvas3D(t){return this.manager.store.canvas3DManager.create(t)}getCanvas3DById(t){return this.manager.store.canvas3DManager.getById(t)}getCanvas3DByName(t){return this.manager.store.canvas3DManager.getByName(t)}getCanvas3DByUserDataProperty(t,e){return this.manager.store.canvas3DManager.getByUserDataProperty(t,e)}removeCanvas3DById(t){return this.manager.store.canvas3DManager.removeById(t)}createGroupForCanvas3D(t){return this.manager.store.canvas3DManager.createGroup(t)}createCanvas3DToGroup(t,e){return this.manager.store.canvas3DManager.createToGroup(t,e)}addCanvas3DForGroup(t,e){return this.manager.store.canvas3DManager.addForGroup(t,e)}getCanvas3DGroupById(t){return this.manager.store.canvas3DManager.getGroupById(t)}getCanvas3DGroupByName(t){return this.manager.store.canvas3DManager.getGroupByName(t)}getAllCanvas3DGroup(){return this.manager.store.canvas3DManager.getAllGroup()}removeCanvas3DGroupById(t){return this.manager.store.canvas3DManager.removeGroupById(t)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(t,e){return this.manager.store.topologyManager.getShortestPath(t,e)}getShortestPathByMultipleStartPoints(t,e){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(t,e)}getShortestPathByMultipleEndPoints(t,e){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(t,e)}createTopologyFromGml(t){return this.manager.store.topologyManager.createFromGml(t)}createTopology(t){return this.manager.store.topologyManager.create(t)}resetTopologyNodes(t,e){return this.manager.store.topologyManager.resetNodes(t,e)}getTopologyById(t){return this.manager.store.topologyManager.getById(t)}getTopologyByName(t){return this.manager.store.topologyManager.getByName(t)}getTopologyByUserDataProperty(t,e){return this.manager.store.topologyManager.getByUserDataProperty(t,e)}removeTopologyById(t){return this.manager.store.topologyManager.removeById(t)}createGroupForTopology(t){return this.manager.store.topologyManager.createGroup(t)}createTopologyToGroup(t,e){return this.manager.store.topologyManager.createToGroup(t,e)}addTopologyForGroup(t,e){return this.manager.store.topologyManager.addForGroup(t,e)}getTopologyGroupById(t){return this.manager.store.topologyManager.getGroupById(t)}getTopologyGroupByName(t){return this.manager.store.topologyManager.getGroupByName(t)}getAllTopologyGroup(){return this.manager.store.topologyManager.getAllGroup()}removeTopologyGroupById(t){return this.manager.store.topologyManager.removeGroupById(t)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(t){return this.manager.store.helperManager.addGridHelper(t)}addAxesHelper(t){return this.manager.store.helperManager.addAxesHelper(t)}addBoxHelper(t){return this.manager.store.helperManager.addBoxHelper(t)}addPlaneHelper(t){return this.manager.store.helperManager.addPlaneHelper(t)}createGround(t){return console.warn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(t)}addGroundHelper(t){return this.manager.store.helperManager.addGroundHelper(t)}addDirectionalLightHelper(t){return this.manager.store.helperManager.addDirectionalLightHelper(t)}addHemisphereLightHelper(t){return this.manager.store.helperManager.addHemisphereLightHelper(t)}addSpotLightHelper(t){return this.manager.store.helperManager.addSpotLightHelper(t)}addPointLightHelper(t){return this.manager.store.helperManager.addPointLightHelper(t)}getHelperById(t){return this.manager.store.helperManager.getById(t)}removeHelperById(t){return this.manager.store.helperManager.removeById(t)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}}export{tu as BaseMesh,eu as BaseObject3D,Ep as Canvas3D,_p as Circle,Pp as Ground,ru as Group,ch as IVector3ToEuler,lh as IVector3ToVector3,gp as Icon,Sp as Line,bp as Link,vh as MinHeap,fp as Model,xp as Node,iu as PluginObject,vp as Poi,Eu as PoiNode,yp as Point,Ap as Polygon,dp as Sbm,nu as SceneManage,wp as Topology,ph as deg2Euler,fh as euler2Deg,Dh as getAsciiString,hh as getBoundingBox,yh as getCubeTexture,mh as getSpaceAttributeFromObject,bh as hasOwn,Ph as isArray,Mh as isBoolean,Eh as isDate,Lh as isFunction,Th as isNull,Sh as isNumber,Ch as isObject,Rh as isPromise,wh as isString,Ah as isSymbol,oh as log,xh as parseSbmx,dh as rotationAFix,uh as rotationAxisFix,Fh as sleep,gh as syncSpaceAttributeToObject,Ih as typeJudge};
|
|
46
|
+
*/var jp={},Vp=function(t){return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))},Wp=function(t){return new Worker(t)};try{URL.revokeObjectURL(Vp(""))}catch(zp){Vp=function(t){return"data:application/javascript;charset=UTF-8,"+encodeURI(t)},Wp=function(t){return new Worker(t,{type:"module"})}}var Xp=Uint8Array,Yp=Uint16Array,qp=Uint32Array,Qp=new Xp([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Zp=new Xp([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jp=new Xp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kp=function(t,e){for(var n=new Yp(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var i=new qp(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},$p=Kp(Qp,2),tf=$p[0],ef=$p[1];tf[28]=258,ef[258]=28;for(var nf=Kp(Zp,0),rf=nf[0],sf=nf[1],af=new Yp(32768),of=0;of<32768;++of){var lf=(43690&of)>>>1|(21845&of)<<1;lf=(61680&(lf=(52428&lf)>>>2|(13107&lf)<<2))>>>4|(3855&lf)<<4,af[of]=((65280&lf)>>>8|(255&lf)<<8)>>>1}var cf=function(t,e,n){for(var r=t.length,i=0,s=new Yp(e);i<r;++i)++s[t[i]-1];var a,o=new Yp(e);for(i=0;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;if(n){a=new Yp(1<<e);var l=15-e;for(i=0;i<r;++i)if(t[i])for(var c=i<<4|t[i],h=e-t[i],u=o[t[i]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[af[u]>>>l]=c}else for(a=new Yp(r),i=0;i<r;++i)t[i]&&(a[i]=af[o[t[i]-1]++]>>>15-t[i]);return a},hf=new Xp(288);for(of=0;of<144;++of)hf[of]=8;for(of=144;of<256;++of)hf[of]=9;for(of=256;of<280;++of)hf[of]=7;for(of=280;of<288;++of)hf[of]=8;var uf=new Xp(32);for(of=0;of<32;++of)uf[of]=5;var df=cf(hf,9,0),pf=cf(hf,9,1),ff=cf(uf,5,0),mf=cf(uf,5,1),gf=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},vf=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&n},yf=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},xf=function(t){return(t/8|0)+(7&t&&1)},_f=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var r=new(t instanceof Yp?Yp:t instanceof qp?qp:Xp)(n-e);return r.set(t.subarray(e,n)),r},bf=function(t,e,n){var r=t.length;if(!r||n&&!n.l&&r<5)return e||new Xp(0);var i=!e||n,s=!n||n.i;n||(n={}),e||(e=new Xp(3*r));var a=function(t){var n=e.length;if(t>n){var r=new Xp(Math.max(2*n,t));r.set(e),e=r}},o=n.f||0,l=n.p||0,c=n.b||0,h=n.l,u=n.d,d=n.m,p=n.n,f=8*r;do{if(!h){n.f=o=vf(t,l,1);var m=vf(t,l+1,3);if(l+=3,!m){var g=t[(E=xf(l)+4)-4]|t[E-3]<<8,v=E+g;if(v>r){if(s)throw"unexpected EOF";break}i&&a(c+g),e.set(t.subarray(E,v),c),n.b=c+=g,n.p=l=8*v;continue}if(1==m)h=pf,u=mf,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=vf(t,l,31)+257,x=vf(t,l+10,15)+4,_=y+vf(t,l+5,31)+1;l+=14;for(var b=new Xp(_),w=new Xp(19),M=0;M<x;++M)w[Jp[M]]=vf(t,l+3*M,7);l+=3*x;var S=gf(w),T=(1<<S)-1,A=cf(w,S,1);for(M=0;M<_;){var E,P=A[vf(t,l,T)];if(l+=15&P,(E=P>>>4)<16)b[M++]=E;else{var C=0,L=0;for(16==E?(L=3+vf(t,l,3),l+=2,C=b[M-1]):17==E?(L=3+vf(t,l,7),l+=3):18==E&&(L=11+vf(t,l,127),l+=7);L--;)b[M++]=C}}var R=b.subarray(0,y),I=b.subarray(y);d=gf(R),p=gf(I),h=cf(R,d,1),u=cf(I,p,1)}if(l>f){if(s)throw"unexpected EOF";break}}i&&a(c+131072);for(var F=(1<<d)-1,D=(1<<p)-1,N=l;;N=l){var O=(C=h[yf(t,l)&F])>>>4;if((l+=15&C)>f){if(s)throw"unexpected EOF";break}if(!C)throw"invalid length/literal";if(O<256)e[c++]=O;else{if(256==O){N=l,h=null;break}var U=O-254;if(O>264){var B=Qp[M=O-257];U=vf(t,l,(1<<B)-1)+tf[M],l+=B}var z=u[yf(t,l)&D],k=z>>>4;if(!z)throw"invalid distance";l+=15&z;I=rf[k];if(k>3){B=Zp[k];I+=yf(t,l)&(1<<B)-1,l+=B}if(l>f){if(s)throw"unexpected EOF";break}i&&a(c+131072);for(var H=c+U;c<H;c+=4)e[c]=e[c-I],e[c+1]=e[c+1-I],e[c+2]=e[c+2-I],e[c+3]=e[c+3-I];c=H}}n.l=h,n.p=N,n.b=c,h&&(o=1,n.m=d,n.d=u,n.n=p)}while(!o);return c==e.length?e:_f(e,0,c)},wf=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>>8},Mf=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>>8,t[r+2]|=n>>>16},Sf=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var i=n.length,s=n.slice();if(!i)return[Rf,0];if(1==i){var a=new Xp(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort((function(t,e){return t.f-e.f})),n.push({s:-1,f:25001});var o=n[0],l=n[1],c=0,h=1,u=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};h!=i-1;)o=n[n[c].f<n[u].f?c++:u++],l=n[c!=h&&n[c].f<n[u].f?c++:u++],n[h++]={s:-1,f:o.f+l.f,l:o,r:l};var d=s[0].s;for(r=1;r<i;++r)s[r].s>d&&(d=s[r].s);var p=new Yp(d+1),f=Tf(n[h-1],p,0);if(f>e){r=0;var m=0,g=f-e,v=1<<g;for(s.sort((function(t,e){return p[e.s]-p[t.s]||t.f-e.f}));r<i;++r){var y=s[r].s;if(!(p[y]>e))break;m+=v-(1<<f-p[y]),p[y]=e}for(m>>>=g;m>0;){var x=s[r].s;p[x]<e?m-=1<<e-p[x]++-1:++r}for(;r>=0&&m;--r){var _=s[r].s;p[_]==e&&(--p[_],++m)}f=e}return[new Xp(p),f]},Tf=function(t,e,n){return-1==t.s?Math.max(Tf(t.l,e,n+1),Tf(t.r,e,n+1)):e[t.s]=n},Af=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Yp(++e),r=0,i=t[0],s=1,a=function(t){n[r++]=t},o=1;o<=e;++o)if(t[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=t[o]}return[n.subarray(0,r),e]},Ef=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},Pf=function(t,e,n){var r=n.length,i=xf(e+2);t[i]=255&r,t[i+1]=r>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var s=0;s<r;++s)t[i+s+4]=n[s];return 8*(i+4+r)},Cf=function(t,e,n,r,i,s,a,o,l,c,h){wf(e,h++,n),++i[256];for(var u=Sf(i,15),d=u[0],p=u[1],f=Sf(s,15),m=f[0],g=f[1],v=Af(d),y=v[0],x=v[1],_=Af(m),b=_[0],w=_[1],M=new Yp(19),S=0;S<y.length;++S)M[31&y[S]]++;for(S=0;S<b.length;++S)M[31&b[S]]++;for(var T=Sf(M,7),A=T[0],E=T[1],P=19;P>4&&!A[Jp[P-1]];--P);var C,L,R,I,F=c+5<<3,D=Ef(i,hf)+Ef(s,uf)+a,N=Ef(i,d)+Ef(s,m)+a+14+3*P+Ef(M,A)+(2*M[16]+3*M[17]+7*M[18]);if(F<=D&&F<=N)return Pf(e,h,t.subarray(l,l+c));if(wf(e,h,1+(N<D)),h+=2,N<D){C=cf(d,p,0),L=d,R=cf(m,g,0),I=m;var O=cf(A,E,0);wf(e,h,x-257),wf(e,h+5,w-1),wf(e,h+10,P-4),h+=14;for(S=0;S<P;++S)wf(e,h+3*S,A[Jp[S]]);h+=3*P;for(var U=[y,b],B=0;B<2;++B){var z=U[B];for(S=0;S<z.length;++S){var k=31&z[S];wf(e,h,O[k]),h+=A[k],k>15&&(wf(e,h,z[S]>>>5&127),h+=z[S]>>>12)}}}else C=df,L=hf,R=ff,I=uf;for(S=0;S<o;++S)if(r[S]>255){k=r[S]>>>18&31;Mf(e,h,C[k+257]),h+=L[k+257],k>7&&(wf(e,h,r[S]>>>23&31),h+=Qp[k]);var H=31&r[S];Mf(e,h,R[H]),h+=I[H],H>3&&(Mf(e,h,r[S]>>>5&8191),h+=Zp[H])}else Mf(e,h,C[r[S]]),h+=L[r[S]];return Mf(e,h,C[256]),h+L[256]},Lf=new qp([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Rf=new Xp(0),If=function(t,e,n,r,i,s){var a=t.length,o=new Xp(r+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(r,o.length-i),c=0;if(!e||a<8)for(var h=0;h<=a;h+=65535){var u=h+65535;u<a?c=Pf(l,c,t.subarray(h,u)):(l[h]=s,c=Pf(l,c,t.subarray(h,a)))}else{for(var d=Lf[e-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new Yp(32768),v=new Yp(m+1),y=Math.ceil(n/3),x=2*y,_=function(e){return(t[e]^t[e+1]<<y^t[e+2]<<x)&m},b=new qp(25e3),w=new Yp(288),M=new Yp(32),S=0,T=0,A=(h=0,0),E=0,P=0;h<a;++h){var C=_(h),L=32767&h,R=v[C];if(g[L]=R,v[C]=L,E<=h){var I=a-h;if((S>7e3||A>24576)&&I>423){c=Cf(t,l,0,b,w,M,T,A,P,h-P,c),A=S=T=0,P=h;for(var F=0;F<286;++F)w[F]=0;for(F=0;F<30;++F)M[F]=0}var D=2,N=0,O=f,U=L-R&32767;if(I>2&&C==_(h-U))for(var B=Math.min(p,I)-1,z=Math.min(32767,h),k=Math.min(258,I);U<=z&&--O&&L!=R;){if(t[h+D]==t[h+D-U]){for(var H=0;H<k&&t[h+H]==t[h+H-U];++H);if(H>D){if(D=H,N=U,H>B)break;var G=Math.min(U,H-2),j=0;for(F=0;F<G;++F){var V=h-U+F+32768&32767,W=V-g[V]+32768&32767;W>j&&(j=W,R=V)}}}U+=(L=R)-(R=g[L])+32768&32767}if(N){b[A++]=268435456|ef[D]<<18|sf[N];var X=31&ef[D],Y=31&sf[N];T+=Qp[X]+Zp[Y],++w[257+X],++M[Y],E=h+D,++S}else b[A++]=t[h],++w[t[h]]}}c=Cf(t,l,s,b,w,M,T,A,P,h-P,c),!s&&7&c&&(c=Pf(l,c+1,Rf))}return _f(o,0,r+xf(c)+i)},Ff=function(){for(var t=new qp(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),Df=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=Ff[255&n^e[r]]^n>>>8;t=n},d:function(){return~t}}},Nf=function(){var t=1,e=0;return{p:function(n){for(var r=t,i=e,s=n.length,a=0;a!=s;){for(var o=Math.min(a+2655,s);a<o;++a)i+=r+=n[a];r=(65535&r)+15*(r>>16),i=(65535&i)+15*(i>>16)}t=r,e=i},d:function(){return(255&(t%=65521))<<24|t>>>8<<16|(255&(e%=65521))<<8|e>>>8}}},Of=function(t,e,n,r,i){return If(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!i)},Uf=function(t,e){var n={};for(var r in t)n[r]=t[r];for(var r in e)n[r]=e[r];return n},Bf=function(t,e,n){for(var r=t(),i=t.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),a=0;a<r.length;++a){var o=r[a],l=s[a];if("function"==typeof o){e+=";"+l+"=";var c=o.toString();if(o.prototype)if(-1!=c.indexOf("[native code]")){var h=c.indexOf(" ",8)+1;e+=c.slice(h,c.indexOf("(",h))}else for(var u in e+=c,o.prototype)e+=";"+l+".prototype."+u+"="+o.prototype[u].toString();else e+=c}else n[l]=o}return[e,n]},zf=[],kf=function(t,e,n,r){var i;if(!zf[n]){for(var s="",a={},o=t.length-1,l=0;l<o;++l)s=(i=Bf(t[l],s,a))[0],a=i[1];zf[n]=Bf(t[o],s,a)}var c=Uf({},zf[n][1]);return function(t,e,n,r,i){var s=Wp(jp[e]||(jp[e]=Vp(t)));return s.onerror=function(t){return i(t.error,null)},s.onmessage=function(t){return i(null,t.data)},s.postMessage(n,r),s}(zf[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",n,c,function(t){var e=[];for(var n in t)(t[n]instanceof Xp||t[n]instanceof Yp||t[n]instanceof qp)&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e}(c),r)},Hf=function(){return[Xp,Yp,qp,Qp,Zp,Jp,tf,rf,pf,mf,af,cf,gf,vf,yf,xf,_f,bf,gm,Yf,qf]},Gf=function(){return[Xp,Yp,qp,Qp,Zp,Jp,ef,sf,df,hf,ff,uf,af,Lf,Rf,cf,wf,Mf,Sf,Tf,Af,Ef,Pf,Cf,xf,_f,If,Of,dm,Yf]},jf=function(){return[nm,sm,em,Df,Ff]},Vf=function(){return[rm,im]},Wf=function(){return[am,em,Nf]},Xf=function(){return[om]},Yf=function(t){return postMessage(t,[t.buffer])},qf=function(t){return t&&t.size&&new Xp(t.size)},Qf=function(t,e,n,r,i,s){var a=kf(n,r,i,(function(t,e){a.terminate(),s(t,e)}));return a.postMessage([t,e],e.consume?[t.buffer]:[]),function(){a.terminate()}},Zf=function(t){return t.ondata=function(t,e){return postMessage([t,e],[t.buffer])},function(e){return t.push(e.data[0],e.data[1])}},Jf=function(t,e,n,r,i){var s,a=kf(t,r,i,(function(t,n){t?(a.terminate(),e.ondata.call(e,t)):(n[1]&&a.terminate(),e.ondata.call(e,t,n[0],n[1]))}));a.postMessage(n),e.push=function(t,n){if(s)throw"stream finished";if(!e.ondata)throw"no stream handler";a.postMessage([t,s=n],[t.buffer])},e.terminate=function(){a.terminate()}},Kf=function(t,e){return t[e]|t[e+1]<<8},$f=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},tm=function(t,e){return $f(t,e)+4294967296*$f(t,e+4)},em=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},nm=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&em(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},rm=function(t){if(31!=t[0]||139!=t[1]||8!=t[2])throw"invalid gzip data";var e=t[3],n=10;4&e&&(n+=t[10]|2+(t[11]<<8));for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[n++]);return n+(2&e)},im=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},sm=function(t){return 10+(t.filename&&t.filename.length+1||0)},am=function(t,e){var n=e.level,r=0==n?0:n<6?1:9==n?3:2;t[0]=120,t[1]=r<<6|(r?32-2*r:1)},om=function(t){if(8!=(15&t[0])||t[0]>>>4>7||(t[0]<<8|t[1])%31)throw"invalid zlib data";if(32&t[1])throw"invalid zlib data: preset dictionaries not supported"};function lm(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var cm=function(){function t(t,e){e||"function"!=typeof t||(e=t,t={}),this.ondata=e,this.o=t||{}}return t.prototype.p=function(t,e){this.ondata(Of(t,this.o,0,0,!e),e)},t.prototype.push=function(t,e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=e,this.p(t,e||!1)},t}(),hm=function(){return function(t,e){Jf([Gf,function(){return[Zf,cm]}],this,lm.call(this,t,e),(function(t){var e=new cm(t.data);onmessage=Zf(e)}),6)}}();function um(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Gf],(function(t){return Yf(dm(t.data[0],t.data[1]))}),0,n)}function dm(t,e){return Of(t,e||{},0,0)}var pm=function(){function t(t){this.s={},this.p=new Xp(0),this.ondata=t}return t.prototype.e=function(t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var e=this.p.length,n=new Xp(e+t.length);n.set(this.p),n.set(t,e),this.p=n},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,n=bf(this.p,this.o,this.s);this.ondata(_f(n,e,this.s.b),this.d),this.o=_f(n,this.s.b-32768),this.s.b=this.o.length,this.p=_f(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),fm=function(){return function(t){this.ondata=t,Jf([Hf,function(){return[Zf,pm]}],this,0,(function(){var t=new pm;onmessage=Zf(t)}),7)}}();function mm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Hf],(function(t){return Yf(gm(t.data[0],qf(t.data[1])))}),1,n)}function gm(t,e){return bf(t,e)}var vm=function(){function t(t,e){this.c=Df(),this.l=0,this.v=1,cm.call(this,t,e)}return t.prototype.push=function(t,e){cm.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=Of(t,this.o,this.v&&sm(this.o),e&&8,!e);this.v&&(nm(n,this.o),this.v=0),e&&(em(n,n.length-8,this.c.d()),em(n,n.length-4,this.l)),this.ondata(n,e)},t}(),ym=function(){return function(t,e){Jf([Gf,jf,function(){return[Zf,cm,vm]}],this,lm.call(this,t,e),(function(t){var e=new vm(t.data);onmessage=Zf(e)}),8)}}();function xm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Gf,jf,function(){return[_m]}],(function(t){return Yf(_m(t.data[0],t.data[1]))}),2,n)}function _m(t,e){e||(e={});var n=Df(),r=t.length;n.p(t);var i=Of(t,e,sm(e),8),s=i.length;return nm(i,e),em(i,s-8,n.d()),em(i,s-4,r),i}var bm=function(){function t(t){this.v=1,pm.call(this,t)}return t.prototype.push=function(t,e){if(pm.prototype.e.call(this,t),this.v){var n=this.p.length>3?rm(this.p):4;if(n>=this.p.length&&!e)return;this.p=this.p.subarray(n),this.v=0}if(e){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}pm.prototype.c.call(this,e)},t}(),wm=function(){return function(t){this.ondata=t,Jf([Hf,Vf,function(){return[Zf,pm,bm]}],this,0,(function(){var t=new bm;onmessage=Zf(t)}),9)}}();function Mm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Hf,Vf,function(){return[Sm]}],(function(t){return Yf(Sm(t.data[0]))}),3,n)}function Sm(t,e){return bf(t.subarray(rm(t),-8),e||new Xp(im(t)))}var Tm=function(){function t(t,e){this.c=Nf(),this.v=1,cm.call(this,t,e)}return t.prototype.push=function(t,e){cm.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var n=Of(t,this.o,this.v&&2,e&&4,!e);this.v&&(am(n,this.o),this.v=0),e&&em(n,n.length-4,this.c.d()),this.ondata(n,e)},t}(),Am=function(){return function(t,e){Jf([Gf,Wf,function(){return[Zf,cm,Tm]}],this,lm.call(this,t,e),(function(t){var e=new Tm(t.data);onmessage=Zf(e)}),10)}}();function Em(t,e){e||(e={});var n=Nf();n.p(t);var r=Of(t,e,2,4);return am(r,e),em(r,r.length-4,n.d()),r}var Pm=function(){function t(t){this.v=1,pm.call(this,t)}return t.prototype.push=function(t,e){if(pm.prototype.e.call(this,t),this.v){if(this.p.length<2&&!e)return;this.p=this.p.subarray(2),this.v=0}if(e){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}pm.prototype.c.call(this,e)},t}(),Cm=function(){return function(t){this.ondata=t,Jf([Hf,Xf,function(){return[Zf,pm,Pm]}],this,0,(function(){var t=new Pm;onmessage=Zf(t)}),11)}}();function Lm(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Hf,Xf,function(){return[Rm]}],(function(t){return Yf(Rm(t.data[0],qf(t.data[1])))}),5,n)}function Rm(t,e){return bf((om(t),t.subarray(2,-4)),e)}var Im=function(){function t(t){this.G=bm,this.I=pm,this.Z=Pm,this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(t,e);else{if(this.p&&this.p.length){var n=new Xp(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,i=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(i):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(i):new this.Z(i),this.s.push(this.p,e),this.p=null}}},t}(),Fm=function(){function t(t){this.G=wm,this.I=fm,this.Z=Cm,this.ondata=t}return t.prototype.push=function(t,e){Im.prototype.push.call(this,t,e)},t}();var Dm=function(t,e,n,r){for(var i in t){var s=t[i],a=e+i;s instanceof Xp?n[a]=[s,r]:Array.isArray(s)?n[a]=[s[0],Uf(r,s[1])]:Dm(s,a+"/",n,r)}},Nm="undefined"!=typeof TextEncoder&&new TextEncoder,Om="undefined"!=typeof TextDecoder&&new TextDecoder,Um=0;try{Om.decode(Rf,{stream:!0}),Um=1}catch(zp){}var Bm=function(t){for(var e="",n=0;;){var r=t[n++],i=(r>127)+(r>223)+(r>239);if(n+i>t.length)return[e,_f(t,n-1)];i?3==i?(r=((15&r)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536,e+=String.fromCharCode(55296|r>>10,56320|1023&r)):e+=1&i?String.fromCharCode((31&r)<<6|63&t[n++]):String.fromCharCode((15&r)<<12|(63&t[n++])<<6|63&t[n++]):e+=String.fromCharCode(r)}},zm=function(){function t(t){this.ondata=t,Um?this.t=new TextDecoder:this.p=Rf}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";if(e=!!e,this.t){if(this.ondata(this.t.decode(t,{stream:!0}),e),e){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new Xp(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var r=Bm(n),i=r[0],s=r[1];if(e){if(s.length)throw"invalid utf-8 data";this.p=null}else this.p=s;this.ondata(i,e)}},t}(),km=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(Hm(t),this.d=e||!1)},t}();function Hm(t,e){if(e){for(var n=new Xp(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}if(Nm)return Nm.encode(t);var i=t.length,s=new Xp(t.length+(t.length>>1)),a=0,o=function(t){s[a++]=t};for(r=0;r<i;++r){if(a+5>s.length){var l=new Xp(a+8+(i-r<<1));l.set(s),s=l}var c=t.charCodeAt(r);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++r))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return _f(s,0,a)}function Gm(t,e){if(e){for(var n="",r=0;r<t.length;r+=16384)n+=String.fromCharCode.apply(null,t.subarray(r,r+16384));return n}if(Om)return Om.decode(t);var i=Bm(t),s=i[0];if(i[1].length)throw"invalid utf-8 data";return s}var jm=function(t){return 1==t?3:t<6?2:9==t?1:0},Vm=function(t,e){return e+30+Kf(t,e+26)+Kf(t,e+28)},Wm=function(t,e,n){var r=Kf(t,e+28),i=Gm(t.subarray(e+46,e+46+r),!(2048&Kf(t,e+8))),s=e+46+r,a=$f(t,e+20),o=n&&4294967295==a?Xm(t,s):[a,$f(t,e+24),$f(t,e+42)],l=o[0],c=o[1],h=o[2];return[Kf(t,e+10),l,c,i,s+Kf(t,e+30)+Kf(t,e+32),h]},Xm=function(t,e){for(;1!=Kf(t,e);e+=4+Kf(t,e+2));return[tm(t,e+12),tm(t,e+4),tm(t,e+20)]},Ym=function(t){var e=0;if(t)for(var n in t){var r=t[n].length;if(r>65535)throw"extra field too long";e+=r+4}return e},qm=function(t,e,n,r,i,s,a,o){var l=r.length,c=n.extra,h=o&&o.length,u=Ym(c);em(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=n.os),t[e]=20,e+=2,t[e++]=n.flag<<1|(null==s&&8),t[e++]=i&&8,t[e++]=255&n.compression,t[e++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(em(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),e+=4,null!=s&&(em(t,e,n.crc),em(t,e+4,s),em(t,e+8,n.size)),em(t,e+12,l),em(t,e+14,u),e+=16,null!=a&&(em(t,e,h),em(t,e+6,n.attrs),em(t,e+10,a),e+=14),t.set(r,e),e+=l,u)for(var f in c){var m=c[f],g=m.length;em(t,e,+f),em(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e},Qm=function(t,e,n,r,i){em(t,e,101010256),em(t,e+8,n),em(t,e+10,n),em(t,e+12,r),em(t,e+16,i)},Zm=function(){function t(t){this.filename=t,this.c=Df(),this.size=0,this.compression=0}return t.prototype.process=function(t,e){this.ondata(null,t,e)},t.prototype.push=function(t,e){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(t),this.size+=t.length,e&&(this.crc=this.c.d()),this.process(t,e||!1)},t}(),Jm=function(){function t(t,e){var n=this;e||(e={}),Zm.call(this,t),this.d=new cm(e,(function(t,e){n.ondata(null,t,e)})),this.compression=8,this.flag=jm(e.level)}return t.prototype.process=function(t,e){try{this.d.push(t,e)}catch(t){this.ondata(t,null,e)}},t.prototype.push=function(t,e){Zm.prototype.push.call(this,t,e)},t}(),Km=function(){function t(t,e){var n=this;e||(e={}),Zm.call(this,t),this.d=new hm(e,(function(t,e,r){n.ondata(t,e,r)})),this.compression=8,this.flag=jm(e.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,e){this.d.push(t,e)},t.prototype.push=function(t,e){Zm.prototype.push.call(this,t,e)},t}(),$m=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var e=this;if(2&this.d)throw"stream finished";var n=Hm(t.filename),r=n.length,i=t.comment,s=i&&Hm(i),a=r!=t.filename.length||s&&i.length!=s.length,o=r+Ym(t.extra)+30;if(r>65535)throw"filename too long";var l=new Xp(o);qm(l,0,t,n,a);var c=[l],h=function(){for(var t=0,n=c;t<n.length;t++){var r=n[t];e.ondata(null,r,!1)}c=[]},u=this.d;this.d=0;var d=this.u.length,p=Uf(t,{f:n,u:a,o:s,t:function(){t.terminate&&t.terminate()},r:function(){if(h(),u){var t=e.u[d+1];t?t.r():e.d=1}u=1}}),f=0;t.ondata=function(n,r,i){if(n)e.ondata(n,r,i),e.terminate();else if(f+=r.length,c.push(r),i){var s=new Xp(16);em(s,0,134695760),em(s,4,t.crc),em(s,8,f),em(s,12,t.size),c.push(s),p.c=f,p.b=o+f+16,p.crc=t.crc,p.size=t.size,u&&p.r(),u=1}else u&&h()},this.u.push(p)},t.prototype.end=function(){var t=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3},t.prototype.e=function(){for(var t=0,e=0,n=0,r=0,i=this.u;r<i.length;r++){n+=46+(l=i[r]).f.length+Ym(l.extra)+(l.o?l.o.length:0)}for(var s=new Xp(n+22),a=0,o=this.u;a<o.length;a++){var l=o[a];qm(s,t,l,l.f,l.u,l.c,e,l.o),t+=46+l.f.length+Ym(l.extra)+(l.o?l.o.length:0),e+=l.b}Qm(s,t,this.u.length,n,e),this.ondata(null,s,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,e=this.u;t<e.length;t++){e[t].t()}this.d=2},t}();var tg=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}(),eg=function(){function t(){var t=this;this.i=new pm((function(e,n){t.ondata(null,e,n)}))}return t.prototype.push=function(t,e){try{this.i.push(t,e)}catch(n){this.ondata(n,t,e)}},t.compression=8,t}(),ng=function(){function t(t,e){var n=this;e<32e4?this.i=new pm((function(t,e){n.ondata(null,t,e)})):(this.i=new fm((function(t,e,r){n.ondata(t,e,r)})),this.terminate=this.i.terminate)}return t.prototype.push=function(t,e){this.i.terminate&&(t=_f(t,0)),this.i.push(t,e)},t.compression=8,t}(),rg=function(){function t(t){this.onfile=t,this.k=[],this.o={0:tg},this.p=Rf}return t.prototype.push=function(t,e){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var r=Math.min(this.c,t.length),i=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(i,!this.c):this.k[0].push(i),(t=t.subarray(r)).length)return this.push(t,e)}else{var s=0,a=0,o=void 0,l=void 0;this.p.length?t.length?((l=new Xp(this.p.length+t.length)).set(this.p),l.set(t,this.p.length)):l=this.p:l=t;for(var c=l.length,h=this.c,u=h&&this.d,d=function(){var t,e=$f(l,a);if(67324752==e){s=1,o=a,p.d=null,p.c=0;var r=Kf(l,a+6),i=Kf(l,a+8),u=2048&r,d=8&r,f=Kf(l,a+26),m=Kf(l,a+28);if(c>a+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=$f(l,a+18),x=$f(l,a+22),_=Gm(l.subarray(a+30,a+=30+f),!u);4294967295==y?(t=d?[-2]:Xm(l,a),y=t[0],x=t[1]):d&&(y=-1),a+=m,p.c=y;var b={name:_,compression:i,start:function(){if(!b.ondata)throw"no callback";if(y){var t=n.o[i];if(!t)throw"unknown compression type "+i;(v=y<0?new t(_):new t(_,y,x)).ondata=function(t,e,n){b.ondata(t,e,n)};for(var e=0,r=g;e<r.length;e++){var s=r[e];v.push(s,!1)}n.k[0]==g&&n.c?n.d=v:v.push(Rf,!0)}else b.ondata(null,Rf,!0)},terminate:function(){v&&v.terminate&&v.terminate()}};y>=0&&(b.size=y,b.originalSize=x),p.onfile(b)}return"break"}if(h){if(134695760==e)return o=a+=12+(-2==h&&8),s=3,p.c=0,"break";if(33639248==e)return o=a-=4,s=3,p.c=0,"break"}},p=this;a<c-4;++a){if("break"===d())break}if(this.p=Rf,h<0){var f=s?l.subarray(0,o-12-(-2==h&&8)-(134695760==$f(l,o-16)&&4)):l.subarray(0,a);u?u.push(f,!!s):this.k[+(2==s)].push(f)}if(2&s)return this.push(l.subarray(a),e);this.p=l.subarray(a)}if(e){if(this.c)throw"invalid zip file";this.p=null}},t.prototype.register=function(t){this.o[t.compression]=t},t}();var ig=Object.freeze({__proto__:null,Deflate:cm,AsyncDeflate:hm,deflate:um,deflateSync:dm,Inflate:pm,AsyncInflate:fm,inflate:mm,inflateSync:gm,Gzip:vm,AsyncGzip:ym,gzip:xm,gzipSync:_m,Gunzip:bm,AsyncGunzip:wm,gunzip:Mm,gunzipSync:Sm,Zlib:Tm,AsyncZlib:Am,zlib:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return Qf(t,e,[Gf,Wf,function(){return[Em]}],(function(t){return Yf(Em(t.data[0],t.data[1]))}),4,n)},zlibSync:Em,Unzlib:Pm,AsyncUnzlib:Cm,unzlib:Lm,unzlibSync:Rm,compress:xm,AsyncCompress:ym,compressSync:_m,Compress:vm,Decompress:Im,AsyncDecompress:Fm,decompress:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return 31==t[0]&&139==t[1]&&8==t[2]?Mm(t,e,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?mm(t,e,n):Lm(t,e,n)},decompressSync:function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?Sm(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?gm(t,e):Rm(t,e)},DecodeUTF8:zm,EncodeUTF8:km,strToU8:Hm,strFromU8:Gm,ZipPassThrough:Zm,ZipDeflate:Jm,AsyncZipDeflate:Km,Zip:$m,zip:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";var r={};Dm(t,"",r,e);var i=Object.keys(r),s=i.length,a=0,o=0,l=s,c=new Array(s),h=[],u=function(){for(var t=0;t<h.length;++t)h[t]()},d=function(){var t=new Xp(o+22),e=a,r=o-a;o=0;for(var i=0;i<l;++i){var s=c[i];try{var h=s.c.length;qm(t,o,s,s.f,s.u,h);var u=30+s.f.length+Ym(s.extra),d=o+u;t.set(s.c,d),qm(t,a,s,s.f,s.u,h,o,s.m),a+=16+u+(s.m?s.m.length:0),o=d+h}catch(t){return n(t,null)}}Qm(t,a,c.length,r,e),n(null,t)};s||d();for(var p=function(t){var e=i[t],l=r[e],p=l[0],f=l[1],m=Df(),g=p.length;m.p(p);var v=Hm(e),y=v.length,x=f.comment,_=x&&Hm(x),b=_&&_.length,w=Ym(f.extra),M=0==f.level?0:8,S=function(r,i){if(r)u(),n(r,null);else{var l=i.length;c[t]=Uf(f,{size:g,crc:m.d(),c:i,f:v,m:_,u:y!=e.length||_&&x.length!=b,compression:M}),a+=30+y+w+l,o+=76+2*(y+w)+(b||0)+l,--s||d()}};if(y>65535&&S("filename too long",null),M)if(g<16e4)try{S(null,dm(p,f))}catch(t){S(t,null)}else h.push(um(p,f,S));else S(null,p)},f=0;f<l;++f)p(f);return u},zipSync:function(t,e){e||(e={});var n={},r=[];Dm(t,"",n,e);var i=0,s=0;for(var a in n){var o=n[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(M=Hm(a)).length,d=c.comment,p=d&&Hm(d),f=p&&p.length,m=Ym(c.extra);if(u>65535)throw"filename too long";var g=h?dm(l,c):l,v=g.length,y=Df();y.p(l),r.push(Uf(c,{size:l.length,crc:y.d(),c:g,f:M,m:p,u:u!=a.length||p&&d.length!=f,o:i,compression:h})),i+=30+u+m+v,s+=76+2*(u+m)+(f||0)+v}for(var x=new Xp(s+22),_=i,b=s-i,w=0;w<r.length;++w){var M=r[w];qm(x,M.o,M,M.f,M.u,M.c.length);var S=30+M.f.length+Ym(M.extra);x.set(M.c,M.o+S),qm(x,i,M,M.f,M.u,M.c.length,M.o,M.m),i+=16+S+(M.m?M.m.length:0)}return Qm(x,i,r.length,b,_),x},UnzipPassThrough:tg,UnzipInflate:eg,AsyncUnzipInflate:ng,Unzip:rg,unzip:function(t,e){if("function"!=typeof e)throw"no callback";for(var n=[],r=function(){for(var t=0;t<n.length;++t)n[t]()},i={},s=t.length-22;101010256!=$f(t,s);--s)if(!s||t.length-s>65558)return void e("invalid zip file",null);var a=Kf(t,s+8);a||e(null,{});var o=a,l=$f(t,s+16),c=4294967295==l;if(c){if(s=$f(t,s-12),101075792!=$f(t,s))return void e("invalid zip file",null);o=a=$f(t,s+32),l=$f(t,s+48)}for(var h=function(s){var o=Wm(t,l,c),h=o[0],u=o[1],d=o[2],p=o[3],f=o[4],m=o[5],g=Vm(t,m);l=f;var v=function(t,n){t?(r(),e(t,null)):(i[p]=n,--a||e(null,i))};if(h)if(8==h){var y=t.subarray(g,g+u);if(u<32e4)try{v(null,gm(y,new Xp(d)))}catch(t){v(t,null)}else n.push(mm(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,_f(t,g,g+u))},u=0;u<o;++u)h();return r},unzipSync:function(t){for(var e={},n=t.length-22;101010256!=$f(t,n);--n)if(!n||t.length-n>65558)throw"invalid zip file";var r=Kf(t,n+8);if(!r)return{};var i=$f(t,n+16),s=4294967295==i;if(s){if(n=$f(t,n-12),101075792!=$f(t,n))throw"invalid zip file";r=$f(t,n+32),i=$f(t,n+48)}for(var a=0;a<r;++a){var o=Wm(t,i,s),l=o[0],c=o[1],h=o[2],u=o[3],d=o[4],p=o[5],f=Vm(t,p);if(i=d,l){if(8!=l)throw"unknown compression type "+l;e[u]=gm(t.subarray(f,f+c),new Xp(h))}else e[u]=_f(t,f,f+c)}return e}});function sg(t,e,n){const r=n.length-t-1;if(e>=n[r])return r-1;if(e<=n[t])return t;let i=t,s=r,a=Math.floor((i+s)/2);for(;e<n[a]||e>=n[a+1];)e<n[a]?s=a:i=a,a=Math.floor((i+s)/2);return a}function ag(t,e){let n=1;for(let e=2;e<=t;++e)n*=e;let r=1;for(let t=2;t<=e;++t)r*=t;for(let n=2;n<=t-e;++n)r*=n;return n/r}function og(t,e,n,r,i){return function(t){const e=t.length,n=[],r=[];for(let i=0;i<e;++i){const e=t[i];n[i]=new I(e.x,e.y,e.z),r[i]=e.w}const i=[];for(let t=0;t<e;++t){const e=n[t].clone();for(let n=1;n<=t;++n)e.sub(i[t-n].clone().multiplyScalar(ag(t,n)*r[n]));i[t]=e.divideScalar(r[0])}return i}(function(t,e,n,r,i){const s=i<t?i:t,a=[],o=sg(t,r,e),l=function(t,e,n,r,i){const s=[];for(let t=0;t<=n;++t)s[t]=0;const a=[];for(let t=0;t<=r;++t)a[t]=s.slice(0);const o=[];for(let t=0;t<=n;++t)o[t]=s.slice(0);o[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let r=1;r<=n;++r){l[r]=e-i[t+1-r],c[r]=i[t+r]-e;let n=0;for(let t=0;t<r;++t){const e=c[t+1],i=l[r-t];o[r][t]=e+i;const s=o[t][r-1]/o[r][t];o[t][r]=n+e*s,n=i*s}o[r][r]=n}for(let t=0;t<=n;++t)a[0][t]=o[t][n];for(let t=0;t<=n;++t){let e=0,i=1;const l=[];for(let t=0;t<=n;++t)l[t]=s.slice(0);l[0][0]=1;for(let s=1;s<=r;++s){let r=0;const c=t-s,h=n-s;t>=s&&(l[i][0]=l[e][0]/o[h+1][c],r=l[i][0]*o[c][h]);const u=t-1<=h?s-1:n-t;for(let t=c>=-1?1:-c;t<=u;++t)l[i][t]=(l[e][t]-l[e][t-1])/o[h+1][c+t],r+=l[i][t]*o[c+t][h];t<=h&&(l[i][s]=-l[e][s-1]/o[h+1][t],r+=l[i][s]*o[t][h]),a[s][t]=r;const d=e;e=i,i=d}}let h=n;for(let t=1;t<=r;++t){for(let e=0;e<=n;++e)a[t][e]*=h;h*=n-t}return a}(o,r,t,s,e),c=[];for(let t=0;t<n.length;++t){const e=n[t].clone(),r=e.w;e.x*=r,e.y*=r,e.z*=r,c[t]=e}for(let e=0;e<=s;++e){const n=c[o-t].clone().multiplyScalar(l[e][0]);for(let r=1;r<=t;++r)n.add(c[o-t+r].clone().multiplyScalar(l[e][r]));a[e]=n}for(let t=s+1;t<=i+1;++t)a[t]=new E(0,0,0);return a}(t,e,n,r,i))}class lg extends xa{constructor(t,e,n,r,i){super(),this.degree=t,this.knots=e,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||this.knots.length-1;for(let t=0;t<n.length;++t){const e=n[t];this.controlPoints[t]=new E(e.x,e.y,e.z,e.w)}}getPoint(t,e=new I){const n=e,r=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(t,e,n,r){const i=sg(t,r,e),s=function(t,e,n,r){const i=[],s=[],a=[];i[0]=1;for(let o=1;o<=n;++o){s[o]=e-r[t+1-o],a[o]=r[t+o]-e;let n=0;for(let t=0;t<o;++t){const e=a[t+1],r=s[o-t],l=i[t]/(e+r);i[t]=n+e*l,n=r*l}i[o]=n}return i}(i,r,t,e),a=new E(0,0,0,0);for(let e=0;e<=t;++e){const r=n[i-t+e],o=s[e],l=r.w*o;a.x+=r.x*l,a.y+=r.y*l,a.z+=r.z*l,a.w+=r.w*o}return a}(this.degree,this.knots,this.controlPoints,r);return 1!==i.w&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(t,e=new I){const n=e,r=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),i=og(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}}let cg,hg,ug;class dg extends al{constructor(t){super(t)}load(t,e,n,r){const i=this,s=""===i.path?Fl.extractUrlBase(t):i.path,a=new ll(this.manager);a.setPath(i.path),a.setResponseType("arraybuffer"),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(t,(function(n){try{e(i.parse(n,s))}catch(e){r?r(e):console.error(e),i.manager.itemError(t)}}),n,r)}parse(t,e){if(function(t){const e="Kaydara FBX Binary \0";return t.byteLength>=e.length&&e===Cg(t,0,e.length)}(t))cg=(new vg).parse(t);else{const e=Cg(t);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(e){const r=t[e-1];return t=t.slice(n+e),n++,r}for(let t=0;t<e.length;++t){if(r(1)===e[t])return!1}return!0}(e))throw new Error("THREE.FBXLoader: Unknown format.");if(_g(e)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+_g(e));cg=(new gg).parse(e)}const n=new dl(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new pg(n,this.manager).parse(cg)}}class pg{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){hg=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),n=this.parseMaterials(e),r=this.parseDeformers(),i=(new fg).parse(r);return this.parseScene(r,i,n),ug}parseConnections(){const t=new Map;if("Connections"in cg){cg.Connections.connections.forEach((function(e){const n=e[0],r=e[1],i=e[2];t.has(n)||t.set(n,{parents:[],children:[]});const s={ID:r,relationship:i};t.get(n).parents.push(s),t.has(r)||t.set(r,{parents:[],children:[]});const a={ID:n,relationship:i};t.get(r).children.push(a)}))}return t}parseImages(){const t={},e={};if("Video"in cg.Objects){const n=cg.Objects.Video;for(const r in n){const i=n[r];if(t[parseInt(r)]=i.RelativeFilename||i.Filename,"Content"in i){const t=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,s="string"==typeof i.Content&&""!==i.Content;if(t||s){const t=this.parseImage(n[r]);e[i.RelativeFilename||i.Filename]=t}}}}for(const n in t){const r=t[n];void 0!==e[r]?t[n]=e[r]:t[n]=t[n].split("\\").pop()}return t}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof e)return"data:"+i+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:i}))}}parseTextures(t){const e=new Map;if("Texture"in cg.Objects){const n=cg.Objects.Texture;for(const r in n){const i=this.parseTexture(n[r],t);e.set(parseInt(r),i)}}return e}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const r=t.WrapModeU,i=t.WrapModeV,s=void 0!==r?r.value:0,a=void 0!==i?i.value:0;if(n.wrapS=0===s?1e3:1001,n.wrapT=0===a?1e3:1001,"Scaling"in t){const e=t.Scaling.value;n.repeat.x=e[0],n.repeat.y=e[1]}return n}loadTexture(t,e){let n;const r=this.textureLoader.path,i=hg.get(t.id).children;let s;void 0!==i&&i.length>0&&void 0!==e[i[0].ID]&&(n=e[i[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const a=t.FileName.slice(-3).toLowerCase();if("tga"===a){const e=this.manager.getHandler(".tga");null===e?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new T):(e.setPath(this.textureLoader.path),s=e.load(n))}else"psd"===a?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new T):s=this.textureLoader.load(n);return this.textureLoader.setPath(r),s}parseMaterials(t){const e=new Map;if("Material"in cg.Objects){const n=cg.Objects.Material;for(const r in n){const i=this.parseMaterial(n[r],t);null!==i&&e.set(parseInt(r),i)}}return e}parseMaterial(t,e){const n=t.id,r=t.attrName;let i=t.ShadingModel;if("object"==typeof i&&(i=i.value),!hg.has(n))return null;const s=this.parseParameters(t,e,n);let a;switch(i.toLowerCase()){case"phong":a=new No;break;case"lambert":a=new Bo;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),a=new No}return a.setValues(s),a.name=r,a}parseParameters(t,e,n){const r={};t.BumpFactor&&(r.bumpScale=t.BumpFactor.value),t.Diffuse?r.color=(new te).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(r.color=(new te).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(r.displacementScale=t.DisplacementFactor.value),t.Emissive?r.emissive=(new te).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(r.emissive=(new te).fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(r.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(r.opacity=parseFloat(t.Opacity.value)),r.opacity<1&&(r.transparent=!0),t.ReflectionFactor&&(r.reflectivity=t.ReflectionFactor.value),t.Shininess&&(r.shininess=t.Shininess.value),t.Specular?r.specular=(new te).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(r.specular=(new te).fromArray(t.SpecularColor.value));const i=this;return hg.get(n).children.forEach((function(t){const n=t.relationship;switch(n){case"Bump":r.bumpMap=i.getTexture(e,t.ID);break;case"Maya|TEX_ao_map":r.aoMap=i.getTexture(e,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=i.getTexture(e,t.ID),void 0!==r.map&&(r.map.encoding=3001);break;case"DisplacementColor":r.displacementMap=i.getTexture(e,t.ID);break;case"EmissiveColor":r.emissiveMap=i.getTexture(e,t.ID),void 0!==r.emissiveMap&&(r.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=i.getTexture(e,t.ID);break;case"ReflectionColor":r.envMap=i.getTexture(e,t.ID),void 0!==r.envMap&&(r.envMap.mapping=303,r.envMap.encoding=3001);break;case"SpecularColor":r.specularMap=i.getTexture(e,t.ID),void 0!==r.specularMap&&(r.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=i.getTexture(e,t.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),r}getTexture(t,e){return"LayeredTexture"in cg.Objects&&e in cg.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=hg.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in cg.Objects){const n=cg.Objects.Deformer;for(const r in n){const i=n[r],s=hg.get(parseInt(r));if("Skin"===i.attrType){const e=this.parseSkeleton(s,n);e.ID=r,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=s.parents[0].ID,t[r]=e}else if("BlendShape"===i.attrType){const t={id:r};t.rawTargets=this.parseMorphTargets(s,n),t.id=r,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[r]=t}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const n=[];return t.children.forEach((function(t){const r=e[t.ID];if("Cluster"!==r.attrType)return;const i={ID:t.ID,indices:[],weights:[],transformLink:(new ct).fromArray(r.TransformLink.a)};"Indexes"in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)})),{rawBones:n,bones:[]}}parseMorphTargets(t,e){const n=[];for(let r=0;r<t.children.length;r++){const i=t.children[r],s=e[i.ID],a={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;a.geoID=hg.get(parseInt(i.ID)).children.filter((function(t){return void 0===t.relationship}))[0].ID,n.push(a)}return n}parseScene(t,e,n){ug=new Wi;const r=this.parseModels(t.skeletons,e,n),i=cg.Objects.Model,s=this;r.forEach((function(t){const e=i[t.ID];s.setLookAtProperties(t,e);hg.get(t.ID).parents.forEach((function(e){const n=r.get(e.ID);void 0!==n&&n.add(t)})),null===t.parent&&ug.add(t)})),this.bindSkeleton(t.skeletons,e,r),this.createAmbientLight(),ug.traverse((function(t){if(t.userData.transformData){t.parent&&(t.userData.transformData.parentMatrix=t.parent.matrix,t.userData.transformData.parentMatrixWorld=t.parent.matrixWorld);const e=Ag(t.userData.transformData);t.applyMatrix4(e),t.updateWorldMatrix()}}));const a=(new mg).parse();1===ug.children.length&&ug.children[0].isGroup&&(ug.children[0].animations=a,ug=ug.children[0]),ug.animations=a}parseModels(t,e,n){const r=new Map,i=cg.Objects.Model;for(const s in i){const a=parseInt(s),o=i[s],l=hg.get(a);let c=this.buildSkeleton(l,t,a,o.attrName);if(!c){switch(o.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,e,n);break;case"NurbsCurve":c=this.createCurve(l,e);break;case"LimbNode":case"Root":c=new Ls;break;case"Null":default:c=new Wi}c.name=o.attrName?mc.sanitizeNodeName(o.attrName):"",c.ID=a}this.getTransformData(c,o),r.set(a,c)}return r}buildSkeleton(t,e,n,r){let i=null;return t.parents.forEach((function(t){for(const s in e){const a=e[s];a.rawBones.forEach((function(e,s){if(e.ID===t.ID){const t=i;i=new Ls,i.matrixWorld.copy(e.transformLink),i.name=r?mc.sanitizeNodeName(r):"",i.ID=n,a.bones[s]=i,null!==t&&i.add(t)}}))}})),i}createCamera(t){let e,n;if(t.children.forEach((function(t){const e=cg.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Dt;else{let t=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(t=1);let r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);let i=1e3;void 0!==n.FarPlane&&(i=n.FarPlane.value/1e3);let s=window.innerWidth,a=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,a=n.AspectHeight.value);const o=s/a;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(t){case 0:e=new qe(l,o,r,i),null!==c&&e.setFocalLength(c);break;case 1:e=new yn(-s/2,s/2,a/2,-a/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+t+"."),e=new Dt}}return e}createLight(t){let e,n;if(t.children.forEach((function(t){const e=cg.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Dt;else{let t;t=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=(new te).fromArray(n.Color.value));let i=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(i=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const a=1;switch(t){case 0:e=new Tl(r,i,s,a);break;case 1:e=new El(r,i);break;case 2:let t=Math.PI/3;void 0!==n.InnerAngle&&(t=m.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=m.degToRad(n.OuterAngle.value),o=Math.max(o,1)),e=new _l(r,i,s,t,o,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),e=new Tl(r,i)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(e.castShadow=!0)}return e}createMesh(t,e,n){let r,i=null,s=null;const a=[];return t.children.forEach((function(t){e.has(t.ID)&&(i=e.get(t.ID)),n.has(t.ID)&&a.push(n.get(t.ID))})),a.length>1?s=a:a.length>0?s=a[0]:(s=new No({color:13421772}),a.push(s)),"color"in i.attributes&&a.forEach((function(t){t.vertexColors=!0})),i.FBX_Deformer?(r=new Cs(i,s),r.normalizeSkinWeights()):r=new ke(i,s),r}createCurve(t,e){const n=t.children.reduce((function(t,n){return e.has(n.ID)&&(t=e.get(n.ID)),t}),null),r=new Hs({color:3342591,linewidth:1});return new Ys(n,r)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),n.eulerOrder="RotationOrder"in e?Eg(e.RotationOrder.value):"ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(t,e){if("LookAtProperty"in e){hg.get(t.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const n=cg.Objects.Model[e.ID];if("Lcl_Translation"in n){const e=n.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(e),ug.add(t.target)):t.lookAt((new I).fromArray(e))}}}))}}bindSkeleton(t,e,n){const r=this.parsePoseNodes();for(const i in t){const s=t[i];hg.get(parseInt(s.ID)).parents.forEach((function(t){if(e.has(t.ID)){const e=t.ID;hg.get(e).parents.forEach((function(t){if(n.has(t.ID)){n.get(t.ID).bind(new Ds(s.bones),r[t.ID])}}))}}))}}parsePoseNodes(){const t={};if("Pose"in cg.Objects){const e=cg.Objects.Pose;for(const n in e)if("BindPose"===e[n].attrType&&e[n].NbPoseNodes>0){const r=e[n].PoseNode;Array.isArray(r)?r.forEach((function(e){t[e.Node]=(new ct).fromArray(e.Matrix.a)})):t[r.Node]=(new ct).fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in cg&&"AmbientColor"in cg.GlobalSettings){const t=cg.GlobalSettings.AmbientColor.value,e=t[0],n=t[1],r=t[2];if(0!==e||0!==n||0!==r){const t=new te(e,n,r);ug.add(new Pl(t,1))}}}}class fg{parse(t){const e=new Map;if("Geometry"in cg.Objects){const n=cg.Objects.Geometry;for(const r in n){const i=hg.get(parseInt(r)),s=this.parseGeometry(i,n[r],t);e.set(parseInt(r),s)}}return e}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,n){const r=n.skeletons,i=[],s=t.parents.map((function(t){return cg.Objects.Model[t.ID]}));if(0===s.length)return;const a=t.children.reduce((function(t,e){return void 0!==r[e.ID]&&(t=r[e.ID]),t}),null);t.children.forEach((function(t){void 0!==n.morphTargets[t.ID]&&i.push(n.morphTargets[t.ID])}));const o=s[0],l={};"RotationOrder"in o&&(l.eulerOrder=Eg(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);const c=Ag(l);return this.genGeometry(e,a,i,c)}genGeometry(t,e,n,r){const i=new we;t.attrName&&(i.name=t.attrName);const s=this.parseGeoNode(t,e),a=this.genBuffers(s),o=new pe(a.vertex,3);if(o.applyMatrix4(r),i.setAttribute("position",o),a.colors.length>0&&i.setAttribute("color",new pe(a.colors,3)),e&&(i.setAttribute("skinIndex",new ce(a.weightsIndices,4)),i.setAttribute("skinWeight",new pe(a.vertexWeights,4)),i.FBX_Deformer=e),a.normal.length>0){const t=(new v).getNormalMatrix(r),e=new pe(a.normal,3);e.applyNormalMatrix(t),i.setAttribute("normal",e)}if(a.uvs.forEach((function(t,e){let n="uv"+(e+1).toString();0===e&&(n="uv"),i.setAttribute(n,new pe(a.uvs[e],2))})),s.material&&"AllSame"!==s.material.mappingType){let t=a.materialIndex[0],e=0;if(a.materialIndex.forEach((function(n,r){n!==t&&(i.addGroup(e,r-e,t),t=n,e=r)})),i.groups.length>0){const e=i.groups[i.groups.length-1],n=e.start+e.count;n!==a.materialIndex.length&&i.addGroup(n,a.materialIndex.length-n,t)}0===i.groups.length&&i.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(i,t,n,r),i}parseGeoNode(t,e){const n={};if(n.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],n.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return n.weightTable={},null!==e&&(n.skeleton=e,e.rawBones.forEach((function(t,e){t.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:e,weight:t.weights[i]})}))}))),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,s=[],a=[],o=[],l=[],c=[],h=[];const u=this;return t.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(s.push(3*d,3*d+1,3*d+2),t.color){const e=Mg(p,n,d,t.color);o.push(e[0],e[1],e[2])}if(t.skeleton){if(void 0!==t.weightTable[d]&&t.weightTable[d].forEach((function(t){v.push(t.weight),g.push(t.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const t=[0,0,0,0],e=[0,0,0,0];v.forEach((function(n,r){let i=n,s=g[r];e.forEach((function(e,n,r){if(i>e){r[n]=i,i=e;const a=t[n];t[n]=s,s=a}}))})),g=t,v=e}for(;v.length<4;)v.push(0),g.push(0);for(let t=0;t<4;++t)c.push(v[t]),h.push(g[t])}if(t.normal){const e=Mg(p,n,d,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(f=Mg(p,n,d,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=Mg(p,n,d,t);void 0===l[e]&&(l[e]=[]),l[e].push(r[0]),l[e].push(r[1])})),r++,m&&(u.genFace(e,t,s,f,a,o,l,c,h,r),n++,r=0,s=[],a=[],o=[],l=[],c=[],h=[])})),e}genFace(t,e,n,r,i,s,a,o,l,c){for(let h=2;h<c;h++)t.vertex.push(e.vertexPositions[n[0]]),t.vertex.push(e.vertexPositions[n[1]]),t.vertex.push(e.vertexPositions[n[2]]),t.vertex.push(e.vertexPositions[n[3*(h-1)]]),t.vertex.push(e.vertexPositions[n[3*(h-1)+1]]),t.vertex.push(e.vertexPositions[n[3*(h-1)+2]]),t.vertex.push(e.vertexPositions[n[3*h]]),t.vertex.push(e.vertexPositions[n[3*h+1]]),t.vertex.push(e.vertexPositions[n[3*h+2]]),e.skeleton&&(t.vertexWeights.push(o[0]),t.vertexWeights.push(o[1]),t.vertexWeights.push(o[2]),t.vertexWeights.push(o[3]),t.vertexWeights.push(o[4*(h-1)]),t.vertexWeights.push(o[4*(h-1)+1]),t.vertexWeights.push(o[4*(h-1)+2]),t.vertexWeights.push(o[4*(h-1)+3]),t.vertexWeights.push(o[4*h]),t.vertexWeights.push(o[4*h+1]),t.vertexWeights.push(o[4*h+2]),t.vertexWeights.push(o[4*h+3]),t.weightsIndices.push(l[0]),t.weightsIndices.push(l[1]),t.weightsIndices.push(l[2]),t.weightsIndices.push(l[3]),t.weightsIndices.push(l[4*(h-1)]),t.weightsIndices.push(l[4*(h-1)+1]),t.weightsIndices.push(l[4*(h-1)+2]),t.weightsIndices.push(l[4*(h-1)+3]),t.weightsIndices.push(l[4*h]),t.weightsIndices.push(l[4*h+1]),t.weightsIndices.push(l[4*h+2]),t.weightsIndices.push(l[4*h+3])),e.color&&(t.colors.push(s[0]),t.colors.push(s[1]),t.colors.push(s[2]),t.colors.push(s[3*(h-1)]),t.colors.push(s[3*(h-1)+1]),t.colors.push(s[3*(h-1)+2]),t.colors.push(s[3*h]),t.colors.push(s[3*h+1]),t.colors.push(s[3*h+2])),e.material&&"AllSame"!==e.material.mappingType&&(t.materialIndex.push(r),t.materialIndex.push(r),t.materialIndex.push(r)),e.normal&&(t.normal.push(i[0]),t.normal.push(i[1]),t.normal.push(i[2]),t.normal.push(i[3*(h-1)]),t.normal.push(i[3*(h-1)+1]),t.normal.push(i[3*(h-1)+2]),t.normal.push(i[3*h]),t.normal.push(i[3*h+1]),t.normal.push(i[3*h+2])),e.uv&&e.uv.forEach((function(e,n){void 0===t.uvs[n]&&(t.uvs[n]=[]),t.uvs[n].push(a[n][0]),t.uvs[n].push(a[n][1]),t.uvs[n].push(a[n][2*(h-1)]),t.uvs[n].push(a[n][2*(h-1)+1]),t.uvs[n].push(a[n][2*h]),t.uvs[n].push(a[n][2*h+1])}))}addMorphTargets(t,e,n,r){if(0===n.length)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const i=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=cg.Objects.Geometry[n.geoID];void 0!==s&&i.genMorphGeometry(t,e,s,r,n.name)}))}))}genMorphGeometry(t,e,n,r,i){const s=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],a=void 0!==n.Vertices?n.Vertices.a:[],o=void 0!==n.Indexes?n.Indexes.a:[],l=3*t.attributes.position.count,c=new Float32Array(l);for(let t=0;t<o.length;t++){const e=3*o[t];c[e]=a[3*t],c[e+1]=a[3*t+1],c[e+2]=a[3*t+2]}const h={vertexIndices:s,vertexPositions:c},u=this.genBuffers(h),d=new pe(u.vertex,3);d.name=i||n.attrName,d.applyMatrix4(r),t.morphAttributes.position.push(d)}parseNormals(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Normals.a;let i=[];return"IndexToDirect"===n&&("NormalIndex"in t?i=t.NormalIndex.a:"NormalsIndex"in t&&(i=t.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:e,referenceType:n}}parseUVs(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.UV.a;let i=[];return"IndexToDirect"===n&&(i=t.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:e,referenceType:n}}parseVertexColors(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Colors.a;let i=[];return"IndexToDirect"===n&&(i=t.ColorIndex.a),{dataSize:4,buffer:r,indices:i,mappingType:e,referenceType:n}}parseMaterialIndices(t){const e=t.MappingInformationType,n=t.ReferenceInformationType;if("NoMappingInformation"===e)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=t.Materials.a,i=[];for(let t=0;t<r.length;++t)i.push(t);return{dataSize:1,buffer:r,indices:i,mappingType:e,referenceType:n}}parseNurbsGeometry(t){if(void 0===lg)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new we;const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new we;const n=e-1,r=t.KnotVector.a,i=[],s=t.Points.a;for(let t=0,e=s.length;t<e;t+=4)i.push((new E).fromArray(s,t));let a,o;if("Closed"===t.Form)i.push(i[0]);else if("Periodic"===t.Form){a=n,o=r.length-1-a;for(let t=0;t<n;++t)i.push(i[t])}const l=new lg(n,r,i,a,o).getPoints(12*i.length);return(new we).setFromPoints(l)}}class mg{parse(){const t=[],e=this.parseClips();if(void 0!==e)for(const n in e){const r=e[n],i=this.addClip(r);t.push(i)}return t}parseClips(){if(void 0===cg.Objects.AnimationCurve)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=cg.Objects.AnimationCurveNode,e=new Map;for(const n in t){const r=t[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const t={id:r.id,attr:r.attrName,curves:{}};e.set(t.id,t)}}return e}parseAnimationCurves(t){const e=cg.Objects.AnimationCurve;for(const n in e){const r={id:e[n].id,times:e[n].KeyTime.a.map(bg),values:e[n].KeyValueFloat.a},i=hg.get(r.id);if(void 0!==i){const e=i.parents[0].ID,n=i.parents[0].relationship;n.match(/X/)?t.get(e).curves.x=r:n.match(/Y/)?t.get(e).curves.y=r:n.match(/Z/)?t.get(e).curves.z=r:n.match(/d|DeformPercent/)&&t.has(e)&&(t.get(e).curves.morph=r)}}}parseAnimationLayers(t){const e=cg.Objects.AnimationLayer,n=new Map;for(const r in e){const e=[],i=hg.get(parseInt(r));if(void 0!==i){i.children.forEach((function(n,r){if(t.has(n.ID)){const i=t.get(n.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===e[r]){const t=hg.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID;if(void 0!==t){const i=cg.Objects.Model[t.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:i.attrName?mc.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ug.traverse((function(t){t.ID===i.id&&(s.transform=t.matrix,t.userData.transformData&&(s.eulerOrder=t.userData.transformData.eulerOrder))})),s.transform||(s.transform=new ct),"PreRotation"in i&&(s.preRotation=i.PreRotation.value),"PostRotation"in i&&(s.postRotation=i.PostRotation.value),e[r]=s}}e[r]&&(e[r][i.attr]=i)}else if(void 0!==i.curves.morph){if(void 0===e[r]){const t=hg.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID,i=hg.get(t).parents[0].ID,s=hg.get(i).parents[0].ID,a=hg.get(s).parents[0].ID,o=cg.Objects.Model[a],l={modelName:o.attrName?mc.sanitizeNodeName(o.attrName):"",morphName:cg.Objects.Deformer[t].attrName};e[r]=l}e[r][i.attr]=i}}})),n.set(parseInt(r),e)}}return n}parseAnimStacks(t){const e=cg.Objects.AnimationStack,n={};for(const r in e){const i=hg.get(parseInt(r)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=t.get(i[0].ID);n[r]={name:e[r].attrName,layer:s}}return n}addClip(t){let e=[];const n=this;return t.layer.forEach((function(t){e=e.concat(n.generateTracks(t))})),new el(t.name,-1,e)}generateTracks(t){const e=[];let n=new I,r=new R,i=new I;if(t.transform&&t.transform.decompose(n,r,i),n=n.toArray(),r=(new xt).setFromQuaternion(r,t.eulerOrder).toArray(),i=i.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const r=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");void 0!==r&&e.push(r)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const n=this.generateRotationTrack(t.modelName,t.R.curves,r,t.preRotation,t.postRotation,t.eulerOrder);void 0!==n&&e.push(n)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const n=this.generateVectorTrack(t.modelName,t.S.curves,i,"scale");void 0!==n&&e.push(n)}if(void 0!==t.DeformPercent){const n=this.generateMorphTrack(t);void 0!==n&&e.push(n)}return e}generateVectorTrack(t,e,n,r){const i=this.getTimesForAllAxes(e),s=this.getKeyframeTrackValues(i,e,n);return new tl(t+"."+r,i,s)}generateRotationTrack(t,e,n,r,i,s){void 0!==e.x&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(m.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(m.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(m.degToRad));const a=this.getTimesForAllAxes(e),o=this.getKeyframeTrackValues(a,e,n);void 0!==r&&((r=r.map(m.degToRad)).push(s),r=(new xt).fromArray(r),r=(new R).setFromEuler(r)),void 0!==i&&((i=i.map(m.degToRad)).push(s),i=(new xt).fromArray(i),i=(new R).setFromEuler(i).invert());const l=new R,c=new xt,h=[];for(let t=0;t<o.length;t+=3)c.set(o[t],o[t+1],o[t+2],s),l.setFromEuler(c),void 0!==r&&l.premultiply(r),void 0!==i&&l.multiply(i),l.toArray(h,t/3*4);return new Ko(t+".quaternion",a,h)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,n=e.values.map((function(t){return t/100})),r=ug.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new Zo(t.modelName+".morphTargetInfluences["+r+"]",e.times,n)}getTimesForAllAxes(t){let e=[];if(void 0!==t.x&&(e=e.concat(t.x.times)),void 0!==t.y&&(e=e.concat(t.y.times)),void 0!==t.z&&(e=e.concat(t.z.times)),e=e.sort((function(t,e){return t-e})),e.length>1){let t=1,n=e[0];for(let r=1;r<e.length;r++){const i=e[r];i!==n&&(e[t]=i,n=i,t++)}e=e.slice(0,t)}return e}getKeyframeTrackValues(t,e,n){const r=n,i=[];let s=-1,a=-1,o=-1;return t.forEach((function(t){if(e.x&&(s=e.x.times.indexOf(t)),e.y&&(a=e.y.times.indexOf(t)),e.z&&(o=e.z.times.indexOf(t)),-1!==s){const t=e.x.values[s];i.push(t),r[0]=t}else i.push(r[0]);if(-1!==a){const t=e.y.values[a];i.push(t),r[1]=t}else i.push(r[1]);if(-1!==o){const t=e.z.values[o];i.push(t),r[2]=t}else i.push(r[2])})),i}interpolateRotations(t){for(let e=1;e<t.values.length;e++){const n=t.values[e-1],r=t.values[e]-n,i=Math.abs(r);if(i>=180){const s=i/180,a=r/s;let o=n+a;const l=t.times[e-1],c=(t.times[e]-l)/s;let h=l+c;const u=[],d=[];for(;h<t.times[e];)u.push(h),h+=c,d.push(o),o+=a;t.times=Lg(t.times,e,u),t.values=Lg(t.values,e,d)}}}}class gg{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new xg,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,n=t.split(/[\r\n]+/);return n.forEach((function(t,r){const i=t.match(/^[\s\t]*;/),s=t.match(/^[\s\t]*$/);if(i||s)return;const a=t.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),o=t.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=t.match("^\\t{"+(e.currentIndent-1)+"}}");a?e.parseNodeBegin(t,a):o?e.parseNodeProperty(t,o,n[++r]):l?e.popStack():t.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(t)})),this.allNodes}parseNodeBegin(t,e){const n=e[1].trim().replace(/^"/,"").replace(/"$/,""),r=e[2].split(",").map((function(t){return t.trim().replace(/^"/,"").replace(/"$/,"")})),i={name:n},s=this.parseNodeAttr(r),a=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,i):n in a?("PoseNode"===n?a.PoseNode.push(i):void 0!==a[n].id&&(a[n]={},a[n][a[n].id]=a[n]),""!==s.id&&(a[n][s.id]=i)):"number"==typeof s.id?(a[n]={},a[n][s.id]=i):"Properties70"!==n&&(a[n]="PoseNode"===n?[i]:i),"number"==typeof s.id&&(i.id=s.id),""!==s.name&&(i.attrName=s.name),""!==s.type&&(i.attrType=s.type),this.pushStack(i)}parseNodeAttr(t){let e=t[0];""!==t[0]&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let n="",r="";return t.length>1&&(n=t[1].replace(/^(\w+)::/,""),r=t[2]),{id:e,name:n,type:r}}parseNodeProperty(t,e,n){let r=e[1].replace(/^"/,"").replace(/"$/,"").trim(),i=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===r){const t=i.split(",").slice(1),e=parseInt(t[0]),n=parseInt(t[1]);let a=i.split(",").slice(3);a=a.map((function(t){return t.trim().replace(/^"/,"")})),r="connections",i=[e,n],function(t,e){for(let n=0,r=t.length,i=e.length;n<i;n++,r++)t[r]=e[n]}(i,a),void 0===s[r]&&(s[r]=[])}"Node"===r&&(s.id=i),r in s&&Array.isArray(s[r])?s[r].push(i):"a"!==r?s[r]=i:s.a=i,this.setCurrentProp(s,r),"a"===r&&","!==i.slice(-1)&&(s.a=Pg(i))}else this.parseNodeSpecialProperty(t,r,i)}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,","!==t.slice(-1)&&(e.a=Pg(e.a))}parseNodeSpecialProperty(t,e,n){const r=n.split('",').map((function(t){return t.trim().replace(/^\"/,"").replace(/\s/,"_")})),i=r[0],s=r[1],a=r[2],o=r[3];let l=r[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=Pg(l)}this.getPrevNode()[i]={type:s,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class vg{parse(t){const e=new yg(t);e.skip(23);const n=e.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new xg;for(;!this.endOfContent(e);){const t=this.parseNode(e,n);null!==t&&r.add(t.name,t)}return r}endOfContent(t){return t.size()%16==0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},r=e>=7500?t.getUint64():t.getUint32(),i=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const s=t.getUint8(),a=t.getString(s);if(0===r)return null;const o=[];for(let e=0;e<i;e++)o.push(this.parseProperty(t));const l=o.length>0?o[0]:"",c=o.length>1?o[1]:"",h=o.length>2?o[2]:"";for(n.singleProperty=1===i&&t.getOffset()===r;r>t.getOffset();){const r=this.parseNode(t,e);null!==r&&this.parseSubNode(a,n,r)}return n.propertyList=o,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==h&&(n.attrType=h),""!==a&&(n.name=a),n}parseSubNode(t,e,n){if(!0===n.singleProperty){const t=n.propertyList[0];Array.isArray(t)?(e[n.name]=n,n.a=t):e[n.name]=t}else if("Connections"===t&&"C"===n.name){const t=[];n.propertyList.forEach((function(e,n){0!==n&&t.push(e)})),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===n.name){Object.keys(n).forEach((function(t){e[t]=n[t]}))}else if("Properties70"===t&&"P"===n.name){let t=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],s=n.propertyList[3];let a;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),a="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],e[t]={type:r,type2:i,flag:s,value:a}}else void 0===e[n.name]?"number"==typeof n.id?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:"PoseNode"===n.name?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):void 0===e[n.name][n.id]&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),i=t.getUint32(),s=t.getUint32();if(0===i)switch(e){case"b":case"c":return t.getBooleanArray(r);case"d":return t.getFloat64Array(r);case"f":return t.getFloat32Array(r);case"i":return t.getInt32Array(r);case"l":return t.getInt64Array(r)}void 0===ig&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=Rm(new Uint8Array(t.getArrayBuffer(s))),o=new yg(a.buffer);switch(e){case"b":case"c":return o.getBooleanArray(r);case"d":return o.getFloat64Array(r);case"f":return o.getFloat32Array(r);case"i":return o.getInt32Array(r);case"l":return o.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class yg{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=void 0===e||e}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(t){const e=[];for(let n=0;n<t;n++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),2147483648&e?(e=4294967295&~e,t=4294967295&~t,4294967295===t&&(e=e+1&4294967295),t=t+1&4294967295,-(4294967296*e+t)):4294967296*e+t}getInt64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),4294967296*e+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){let e=[];for(let n=0;n<t;n++)e[n]=this.getUint8();const n=e.indexOf(0);return n>=0&&(e=e.slice(0,n)),Fl.decodeText(new Uint8Array(e))}}class xg{add(t,e){this[t]=e}}function _g(t){const e=t.match(/FBXVersion: (\d+)/);if(e){return parseInt(e[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function bg(t){return t/46186158e3}const wg=[];function Mg(t,e,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=t;break;case"ByPolygon":i=e;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const s=i*r.dataSize,a=s+r.dataSize;return function(t,e,n,r){for(let i=n,s=0;i<r;i++,s++)t[s]=e[i];return t}(wg,r.buffer,s,a)}const Sg=new xt,Tg=new I;function Ag(t){const e=new ct,n=new ct,r=new ct,i=new ct,s=new ct,a=new ct,o=new ct,l=new ct,c=new ct,h=new ct,u=new ct,d=new ct,p=t.inheritType?t.inheritType:0;if(t.translation&&e.setPosition(Tg.fromArray(t.translation)),t.preRotation){const e=t.preRotation.map(m.degToRad);e.push(t.eulerOrder),n.makeRotationFromEuler(Sg.fromArray(e))}if(t.rotation){const e=t.rotation.map(m.degToRad);e.push(t.eulerOrder),r.makeRotationFromEuler(Sg.fromArray(e))}if(t.postRotation){const e=t.postRotation.map(m.degToRad);e.push(t.eulerOrder),i.makeRotationFromEuler(Sg.fromArray(e)),i.invert()}t.scale&&s.scale(Tg.fromArray(t.scale)),t.scalingOffset&&o.setPosition(Tg.fromArray(t.scalingOffset)),t.scalingPivot&&a.setPosition(Tg.fromArray(t.scalingPivot)),t.rotationOffset&&l.setPosition(Tg.fromArray(t.rotationOffset)),t.rotationPivot&&c.setPosition(Tg.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(u.copy(t.parentMatrix),h.copy(t.parentMatrixWorld));const f=n.clone().multiply(r).multiply(i),g=new ct;g.extractRotation(h);const v=new ct;v.copyPosition(h);const y=v.clone().invert().multiply(h),x=g.clone().invert().multiply(y),_=s,b=new ct;if(0===p)b.copy(g).multiply(f).multiply(x).multiply(_);else if(1===p)b.copy(g).multiply(x).multiply(f).multiply(_);else{const t=(new ct).scale((new I).setFromMatrixScale(u)).clone().invert(),e=x.clone().multiply(t);b.copy(g).multiply(f).multiply(e).multiply(_)}const w=c.clone().invert(),M=a.clone().invert();let S=e.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(w).multiply(o).multiply(a).multiply(s).multiply(M);const T=(new ct).copyPosition(S),A=h.clone().multiply(T);return d.copyPosition(A),S=d.clone().multiply(b),S.premultiply(h.invert()),S}function Eg(t){const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(t=t||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[t]}function Pg(t){return t.split(",").map((function(t){return parseFloat(t)}))}function Cg(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=t.byteLength),Fl.decodeText(new Uint8Array(t,e,n))}function Lg(t,e,n){return t.slice(0,e).concat(n).concat(t.slice(e))}class Rg extends al{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new Og(t)})),this.register((function(t){return new Gg(t)})),this.register((function(t){return new jg(t)})),this.register((function(t){return new Ug(t)})),this.register((function(t){return new Bg(t)})),this.register((function(t){return new zg(t)})),this.register((function(t){return new kg(t)})),this.register((function(t){return new Hg(t)})),this.register((function(t){return new Dg(t)})),this.register((function(t){return new Vg(t)}))}load(t,e,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Fl.extractUrlBase(t),this.manager.itemStart(t);const a=function(e){r?r(e):console.error(e),i.manager.itemError(t),i.manager.itemEnd(t)},o=new ll(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(function(n){try{i.parse(n,s,(function(n){e(n),i.manager.itemEnd(t)}),a)}catch(t){a(t)}}),n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,r){let i;const s={},a={};if("string"==typeof t)i=t;else{if(Fl.decodeText(new Uint8Array(t,0,4))===Wg){try{s[Fg.KHR_BINARY_GLTF]=new qg(t)}catch(t){return void(r&&r(t))}i=s[Fg.KHR_BINARY_GLTF].content}else i=Fl.decodeText(new Uint8Array(t))}const o=JSON.parse(i);if(void 0===o.asset||o.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Ev(o,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](l);a[e.name]=e,s[e.name]=!0}if(o.extensionsUsed)for(let t=0;t<o.extensionsUsed.length;++t){const e=o.extensionsUsed[t],n=o.extensionsRequired||[];switch(e){case Fg.KHR_MATERIALS_UNLIT:s[e]=new Ng;break;case Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[e]=new Kg;break;case Fg.KHR_DRACO_MESH_COMPRESSION:s[e]=new Qg(o,this.dracoLoader);break;case Fg.KHR_TEXTURE_TRANSFORM:s[e]=new Zg;break;case Fg.KHR_MESH_QUANTIZATION:s[e]=new $g;break;default:n.indexOf(e)>=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,r)}parseAsync(t,e){const n=this;return new Promise((function(r,i){n.parse(t,e,r,i)}))}}function Ig(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Fg={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class Dg{constructor(t){this.parser=t,this.name=Fg.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,r=e.length;n<r;n++){const r=e[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let r=e.cache.get(n);if(r)return r;const i=e.json,s=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let a;const o=new te(16777215);void 0!==s.color&&o.fromArray(s.color);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new El(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Tl(o),a.distance=l;break;case"spot":a=new _l(o),a.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),a.decay=2,void 0!==s.intensity&&(a.intensity=s.intensity),a.name=e.createUniqueName(s.name||"light_"+t),r=Promise.resolve(a),e.cache.add(n,r),r}createNodeAttachment(t){const e=this,n=this.parser,r=n.json.nodes[t],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(t){return n._getNodeRef(e.cache,i,t)}))}}class Ng{constructor(){this.name=Fg.KHR_MATERIALS_UNLIT}getMaterialType(){return ee}extendParams(t,e,n){const r=[];t.color=new te(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(t,"map",i.baseColorTexture))}return Promise.all(r)}}class Og{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];if(void 0!==s.clearcoatFactor&&(e.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&i.push(n.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&i.push(n.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(i.push(n.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new g(t,t)}return Promise.all(i)}}class Ug{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new te(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=r.extensions[this.name];return void 0!==s.sheenColorFactor&&e.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(e.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(e,"sheenColorMap",s.sheenColorTexture)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class Bg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(e.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class zg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];e.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=new te(a[0],a[1],a[2]),Promise.all(i)}}class kg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return e.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class Hg{constructor(t){this.parser=t,this.name=Fg.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Do:null}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];e.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=new te(a[0],a[1],a[2]),void 0!==s.specularColorTexture&&i.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture).then((function(t){t.encoding=3001}))),Promise.all(i)}}class Gg{constructor(t){this.parser=t,this.name=Fg.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,r=n.textures[t];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=n.images[i.source],a=e.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,s,a)}}class jg{constructor(t){this.parser=t,this.name=Fg.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,r=n.json,i=r.textures[t];if(!i.extensions||!i.extensions[e])return null;const s=i.extensions[e],a=r.images[s.source];let o=n.textureLoader;if(a.uri){const t=n.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(t,a,o);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Vg{constructor(t){this.name=Fg.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const t=n.extensions[this.name],r=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,i.ready]).then((function(e){const n=t.byteOffset||0,r=t.byteLength||0,s=t.count,a=t.byteStride,o=new ArrayBuffer(s*a),l=new Uint8Array(e[0],n,r);return i.decodeGltfBuffer(new Uint8Array(o),s,a,l,t.mode,t.filter),o}))}return null}}const Wg="glTF",Xg=1313821514,Yg=5130562;class qg{constructor(t){this.name=Fg.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:Fl.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Wg)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(t,12);let i=0;for(;i<n;){const e=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===Xg){const n=new Uint8Array(t,12+i,e);this.content=Fl.decodeText(n)}else if(n===Yg){const n=12+i;this.body=t.slice(n,n+e)}i+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Qg{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Fg.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,r=this.dracoLoader,i=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},o={},l={};for(const t in s){const e=fv[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const r=fv[e]||e.toLowerCase();if(void 0!==s[e]){const i=n.accessors[t.attributes[e]],s=hv[i.componentType];l[r]=s,o[r]=!0===i.normalized}}return e.getDependency("bufferView",i).then((function(t){return new Promise((function(e){r.decodeDracoFile(t,(function(t){for(const e in t.attributes){const n=t.attributes[e],r=o[e];void 0!==r&&(n.normalized=r)}e(t)}),a,l)}))}))}}class Zg{constructor(){this.name=Fg.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===e.offset&&void 0===e.rotation&&void 0===e.scale||(t=t.clone(),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Jg extends Fo{constructor(t){super(),this.isGLTFSpecularGlossinessMaterial=!0;const e=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),r=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new te).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(t){for(const e in a)t.uniforms[e]=a[e];t.fragmentShader=t.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",e).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",r).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(t){a.specular.value=t}},specularMap:{get:function(){return a.specularMap.value},set:function(t){a.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(t){a.glossiness.value=t}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(t){a.glossinessMap.value=t,t?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(t)}copy(t){return super.copy(t),this.specularMap=t.specularMap,this.specular.copy(t.specular),this.glossinessMap=t.glossinessMap,this.glossiness=t.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Kg{constructor(){this.name=Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return Jg}extendParams(t,e,n){const r=e.extensions[this.name];t.color=new te(1,1,1),t.opacity=1;const i=[];if(Array.isArray(r.diffuseFactor)){const e=r.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==r.diffuseTexture&&i.push(n.assignTexture(t,"map",r.diffuseTexture)),t.emissive=new te(0,0,0),t.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,t.specular=new te(1,1,1),Array.isArray(r.specularFactor)&&t.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const e=r.specularGlossinessTexture;i.push(n.assignTexture(t,"glossinessMap",e)),i.push(n.assignTexture(t,"specularMap",e))}return Promise.all(i)}createMaterial(t){const e=new Jg(t);return e.fog=!0,e.color=t.color,e.map=void 0===t.map?null:t.map,e.lightMap=null,e.lightMapIntensity=1,e.aoMap=void 0===t.aoMap?null:t.aoMap,e.aoMapIntensity=1,e.emissive=t.emissive,e.emissiveIntensity=1,e.emissiveMap=void 0===t.emissiveMap?null:t.emissiveMap,e.bumpMap=void 0===t.bumpMap?null:t.bumpMap,e.bumpScale=1,e.normalMap=void 0===t.normalMap?null:t.normalMap,e.normalMapType=0,t.normalScale&&(e.normalScale=t.normalScale),e.displacementMap=null,e.displacementScale=1,e.displacementBias=0,e.specularMap=void 0===t.specularMap?null:t.specularMap,e.specular=t.specular,e.glossinessMap=void 0===t.glossinessMap?null:t.glossinessMap,e.glossiness=t.glossiness,e.alphaMap=null,e.envMap=void 0===t.envMap?null:t.envMap,e.envMapIntensity=1,e.refractionRatio=.98,e}}class $g{constructor(){this.name=Fg.KHR_MESH_QUANTIZATION}}class tv extends jo{constructor(t,e,n,r){super(t,e,n,r)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=t*r*3+r;for(let t=0;t!==r;t++)e[t]=n[i+t];return e}}tv.prototype.beforeStart_=tv.prototype.copySampleValue_,tv.prototype.afterEnd_=tv.prototype.copySampleValue_,tv.prototype.interpolate_=function(t,e,n,r){const i=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=2*a,l=3*a,c=r-e,h=(n-e)/c,u=h*h,d=u*h,p=t*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+h;for(let t=0;t!==a;t++){const e=s[f+t+a],n=s[f+t+o]*c,r=s[p+t+a],l=s[p+t]*c;i[t]=v*e+y*n+m*r+g*l}return i};const ev=new R;class nv extends tv{interpolate_(t,e,n,r){const i=super.interpolate_(t,e,n,r);return ev.fromArray(i).normalize().toArray(i),i}}const rv=0,iv=1,sv=2,av=3,ov=4,lv=5,cv=6,hv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},uv={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},dv={33071:1001,33648:1002,10497:1e3},pv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fv={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},mv={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},gv={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},vv="OPAQUE",yv="MASK",xv="BLEND";function _v(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new Fo({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),t.DefaultMaterial}function bv(t,e,n){for(const r in n.extensions)void 0===t[r]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=n.extensions[r])}function wv(t,e){void 0!==e.extras&&("object"==typeof e.extras?Object.assign(t.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Mv(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let n=0,r=e.weights.length;n<r;n++)t.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(t.morphTargetInfluences.length===n.length){t.morphTargetDictionary={};for(let e=0,r=n.length;e<r;e++)t.morphTargetDictionary[n[e]]=e}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Sv(t){const e=t.extensions&&t.extensions[Fg.KHR_DRACO_MESH_COMPRESSION];let n;return n=e?"draco:"+e.bufferView+":"+e.indices+":"+Tv(e.attributes):t.indices+":"+Tv(t.attributes)+":"+t.mode,n}function Tv(t){let e="";const n=Object.keys(t).sort();for(let r=0,i=n.length;r<i;r++)e+=n[r]+":"+t[n[r]]+";";return e}function Av(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class Ev{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Ig,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox|Safari/.test(navigator.userAgent)?this.textureLoader=new zl(this.options.manager):this.textureLoader=new dl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ll(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(e){const s={scene:e[0][r.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:r.asset,parser:n,userData:{}};bv(i,s,r),wv(s,r),Promise.all(n._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=e.length;n<r;n++){const r=e[n].joints;for(let e=0,n=r.length;e<n;e++)t[r[e]].isBone=!0}for(let e=0,r=t.length;e<r;e++){const r=t[e];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const r=n.clone(),i=(t,e)=>{const n=this.associations.get(t);null!=n&&this.associations.set(e,n);for(const[n,r]of t.children.entries())i(r,e.children[n])};return i(n,r),r.name+="_instance_"+t.uses[e]++,r}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const r=t(e[n]);if(r)return r}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let r=0;r<e.length;r++){const i=t(e[r]);i&&n.push(i)}return n}getDependency(t,e){const n=t+":"+e;let r=this.cache.get(n);if(!r){switch(t){case"scene":r=this.loadScene(e);break;case"node":r=this.loadNode(e);break;case"mesh":r=this._invokeOne((function(t){return t.loadMesh&&t.loadMesh(e)}));break;case"accessor":r=this.loadAccessor(e);break;case"bufferView":r=this._invokeOne((function(t){return t.loadBufferView&&t.loadBufferView(e)}));break;case"buffer":r=this.loadBuffer(e);break;case"material":r=this._invokeOne((function(t){return t.loadMaterial&&t.loadMaterial(e)}));break;case"texture":r=this._invokeOne((function(t){return t.loadTexture&&t.loadTexture(e)}));break;case"skin":r=this.loadSkin(e);break;case"animation":r=this.loadAnimation(e);break;case"camera":r=this.loadCamera(e);break;default:throw new Error("Unknown type: "+t)}this.cache.add(n,r)}return r}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,r=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(r.map((function(e,r){return n.getDependency(t,r)}))),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&"arraybuffer"!==e.type)throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(void 0===e.uri&&0===t)return Promise.resolve(this.extensions[Fg.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(t,i){n.load(Fl.resolveURL(e.uri,r.path),t,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))}))}))}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then((function(t){const n=e.byteLength||0,r=e.byteOffset||0;return t.slice(r,r+n)}))}loadAccessor(t){const e=this,n=this.json,r=this.json.accessors[t];if(void 0===r.bufferView&&void 0===r.sparse)return Promise.resolve(null);const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(t){const i=t[0],s=pv[r.type],a=hv[r.componentType],o=a.BYTES_PER_ELEMENT,l=o*s,c=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,u=!0===r.normalized;let d,p;if(h&&h!==l){const t=Math.floor(c/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+t+":"+r.count;let l=e.cache.get(n);l||(d=new a(i,t*h,r.count*h/o),l=new ns(d,h/o),e.cache.add(n,l)),p=new is(l,s,c%h/o,u)}else d=null===i?new a(r.count*s):new a(i,c,r.count*s),p=new ie(d,s,u);if(void 0!==r.sparse){const e=pv.SCALAR,n=hv[r.sparse.indices.componentType],o=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(t[1],o,r.sparse.count*e),h=new a(t[2],l,r.sparse.count*s);null!==i&&(p=new ie(p.array.slice(),p.itemSize,p.normalized));for(let t=0,e=c.length;t<e;t++){const e=c[t];if(p.setX(e,h[t*s]),s>=2&&p.setY(e,h[t*s+1]),s>=3&&p.setZ(e,h[t*s+2]),s>=4&&p.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t],i=e.images[r.source];let s=this.textureLoader;if(i.uri){const t=n.manager.getHandler(i.uri);null!==t&&(s=t)}return this.loadTextureImage(t,i,s)}loadTextureImage(t,e,n){const r=this,i=this.json,s=this.options,a=i.textures[t],o=(e.uri||e.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=self.URL||self.webkitURL;let c=e.uri||"",h=!1;if(void 0!==e.bufferView)c=r.getDependency("bufferView",e.bufferView).then((function(t){h=!0;const n=new Blob([t],{type:e.mimeType});return c=l.createObjectURL(n),c}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(c).then((function(t){return new Promise((function(e,r){let i=e;!0===n.isImageBitmapLoader&&(i=function(t){const n=new T(t);n.needsUpdate=!0,e(n)}),n.load(Fl.resolveURL(t,s.path),i,void 0,r)}))})).then((function(e){!0===h&&l.revokeObjectURL(c),e.flipY=!1,a.name&&(e.name=a.name);const n=(i.samplers||{})[a.sampler]||{};return e.magFilter=uv[n.magFilter]||1006,e.minFilter=uv[n.minFilter]||1008,e.wrapS=dv[n.wrapS]||1e3,e.wrapT=dv[n.wrapT]||1e3,r.associations.set(e,{textures:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",c),null}));return this.textureCache[o]=u,u}assignTexture(t,e,n){const r=this;return this.getDependency("texture",n.index).then((function(i){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===e&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+e+" not yet supported."),r.extensions[Fg.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Fg.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(i);i=r.extensions[Fg.KHR_TEXTURE_TRANSFORM].extendTexture(i,t),r.associations.set(i,e)}}return t[e]=i,i}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const r=void 0===e.attributes.tangent,i=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Ks,Yt.prototype.copy.call(e,n),e.color.copy(n.color),e.map=n.map,e.sizeAttenuation=!1,this.cache.add(t,e)),n=e}else if(t.isLine){const t="LineBasicMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new Hs,Yt.prototype.copy.call(e,n),e.color.copy(n.color),this.cache.add(t,e)),n=e}if(r||i||s){let t="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),r&&(t+="derivative-tangents:"),i&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),i&&(e.vertexColors=!0),s&&(e.flatShading=!0),r&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(n))),n=e}n.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=n}getMaterialType(){return Fo}loadMaterial(t){const e=this,n=this.json,r=this.extensions,i=n.materials[t];let s;const a={},o=i.extensions||{},l=[];if(o[Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=r[Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else if(o[Fg.KHR_MATERIALS_UNLIT]){const t=r[Fg.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new te(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;a.color.fromArray(t),a.opacity=t[3]}void 0!==n.baseColorTexture&&l.push(e.assignTexture(a,"map",n.baseColorTexture)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(e.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(e.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),l.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===i.doubleSided&&(a.side=2);const c=i.alphaMode||vv;if(c===xv?(a.transparent=!0,a.depthWrite=!1):(a.format=1022,a.transparent=!1,c===yv&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==ee&&(l.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new g(1,1),void 0!==i.normalTexture.scale)){const t=i.normalTexture.scale;a.normalScale.set(t,t)}return void 0!==i.occlusionTexture&&s!==ee&&(l.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==ee&&(a.emissive=(new te).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&s!==ee&&l.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){let n;return n=s===Jg?r[Fg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new s(a),i.name&&(n.name=i.name),n.map&&(n.map.encoding=3001),n.emissiveMap&&(n.emissiveMap.encoding=3001),wv(n,i),e.associations.set(n,{materials:t}),i.extensions&&bv(r,n,i),n}))}createUniqueName(t){const e=mc.sanitizeNodeName(t||"");let n=e;for(let t=1;this.nodeNamesUsed[n];++t)n=e+"_"+t;return this.nodeNamesUsed[n]=!0,n}loadGeometries(t){const e=this,n=this.extensions,r=this.primitiveCache;function i(t){return n[Fg.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return Cv(n,t,e)}))}const s=[];for(let n=0,a=t.length;n<a;n++){const a=t[n],o=Sv(a),l=r[o];if(l)s.push(l.promise);else{let t;t=a.extensions&&a.extensions[Fg.KHR_DRACO_MESH_COMPRESSION]?i(a):Cv(new we,a,e),r[o]={primitive:a,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,r=this.extensions,i=n.meshes[t],s=i.primitives,a=[];for(let t=0,e=s.length;t<e;t++){const e=void 0===s[t].material?_v(this.cache):this.getDependency("material",s[t].material);a.push(e)}return a.push(e.loadGeometries(s)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),o=n[n.length-1],l=[];for(let n=0,c=o.length;n<c;n++){const c=o[n],h=s[n];let u;const d=a[n];if(h.mode===ov||h.mode===lv||h.mode===cv||void 0===h.mode)u=!0===i.isSkinnedMesh?new Cs(c,d):new ke(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===lv?u.geometry=Lv(u.geometry,1):h.mode===cv&&(u.geometry=Lv(u.geometry,2));else if(h.mode===iv)u=new Zs(c,d);else if(h.mode===av)u=new Ys(c,d);else if(h.mode===sv)u=new Js(c,d);else{if(h.mode!==rv)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new ra(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&Mv(u,i),u.name=e.createUniqueName(i.name||"mesh_"+t),wv(u,i),h.extensions&&bv(r,u,h),e.assignFinalMaterial(u),l.push(u)}for(let n=0,r=l.length;n<r;n++)e.associations.set(l[n],{meshes:t,primitives:n});if(1===l.length)return l[0];const c=new Wi;e.associations.set(c,{meshes:t});for(let t=0,e=l.length;t<e;t++)c.add(l[t]);return c}))}loadCamera(t){let e;const n=this.json.cameras[t],r=n[n.type];if(r)return"perspective"===n.type?e=new qe(m.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(e=new yn(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),wv(e,n),Promise.resolve(e);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(t){const e=this.json.skins[t],n={joints:e.joints};return void 0===e.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",e.inverseBindMatrices).then((function(t){return n.inverseBindMatrices=t,n}))}loadAnimation(t){const e=this.json.animations[t],n=[],r=[],i=[],s=[],a=[];for(let t=0,o=e.channels.length;t<o;t++){const o=e.channels[t],l=e.samplers[o.sampler],c=o.target,h=void 0!==c.node?c.node:c.id,u=void 0!==e.parameters?e.parameters[l.input]:l.input,d=void 0!==e.parameters?e.parameters[l.output]:l.output;n.push(this.getDependency("node",h)),r.push(this.getDependency("accessor",u)),i.push(this.getDependency("accessor",d)),s.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(s),Promise.all(a)]).then((function(n){const r=n[0],i=n[1],s=n[2],a=n[3],o=n[4],l=[];for(let t=0,e=r.length;t<e;t++){const e=r[t],n=i[t],c=s[t],h=a[t],u=o[t];if(void 0===e)continue;let d;switch(e.updateMatrix(),e.matrixAutoUpdate=!0,mv[u.path]){case mv.weights:d=Zo;break;case mv.rotation:d=Ko;break;case mv.position:case mv.scale:default:d=tl}const p=e.name?e.name:e.uuid,f=void 0!==h.interpolation?gv[h.interpolation]:2301,m=[];mv[u.path]===mv.weights?e.traverse((function(t){t.morphTargetInfluences&&m.push(t.name?t.name:t.uuid)})):m.push(p);let g=c.array;if(c.normalized){const t=Av(g.constructor),e=new Float32Array(g.length);for(let n=0,r=g.length;n<r;n++)e[n]=g[n]*t;g=e}for(let t=0,e=m.length;t<e;t++){const e=new d(m[t]+"."+mv[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(e.createInterpolant=function(t){return new(this instanceof Ko?nv:tv)(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(e)}}const c=e.name?e.name:"animation_"+t;return new el(c,void 0,l)}))}createNodeMesh(t){const e=this.json,n=this,r=e.nodes[t];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(t){const e=n._getNodeRef(n.meshCache,r.mesh,t);return void 0!==r.weights&&e.traverse((function(t){if(t.isMesh)for(let e=0,n=r.weights.length;e<n;e++)t.morphTargetInfluences[e]=r.weights[e]})),e}))}loadNode(t){const e=this.json,n=this.extensions,r=this,i=e.nodes[t],s=i.name?r.createUniqueName(i.name):"";return function(){const e=[],n=r._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return n&&e.push(n),void 0!==i.camera&&e.push(r.getDependency("camera",i.camera).then((function(t){return r._getNodeRef(r.cameraCache,i.camera,t)}))),r._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(t){e.push(t)})),Promise.all(e)}().then((function(e){let a;if(a=!0===i.isBone?new Ls:e.length>1?new Wi:1===e.length?e[0]:new Dt,a!==e[0])for(let t=0,n=e.length;t<n;t++)a.add(e[t]);if(i.name&&(a.userData.name=i.name,a.name=s),wv(a,i),i.extensions&&bv(n,a,i),void 0!==i.matrix){const t=new ct;t.fromArray(i.matrix),a.applyMatrix4(t)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=t,a}))}loadScene(t){const e=this.json,n=this.extensions,r=this.json.scenes[t],i=this,s=new Wi;r.name&&(s.name=i.createUniqueName(r.name)),wv(s,r),r.extensions&&bv(n,s,r);const a=r.nodes||[],o=[];for(let t=0,n=a.length;t<n;t++)o.push(Pv(a[t],s,e,i));return Promise.all(o).then((function(){return i.associations=(t=>{const e=new Map;for(const[t,n]of i.associations)(t instanceof Yt||t instanceof T)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(s),s}))}}function Pv(t,e,n,r){const i=n.nodes[t];return r.getDependency("node",t).then((function(t){if(void 0===i.skin)return t;let e;return r.getDependency("skin",i.skin).then((function(t){e=t;const n=[];for(let t=0,i=e.joints.length;t<i;t++)n.push(r.getDependency("node",e.joints[t]));return Promise.all(n)})).then((function(n){return t.traverse((function(t){if(!t.isMesh)return;const r=[],i=[];for(let t=0,s=n.length;t<s;t++){const s=n[t];if(s){r.push(s);const n=new ct;void 0!==e.inverseBindMatrices&&n.fromArray(e.inverseBindMatrices.array,16*t),i.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[t])}t.bind(new Ds(r,i),t.matrixWorld)})),t}))})).then((function(t){e.add(t);const s=[];if(i.children){const e=i.children;for(let i=0,a=e.length;i<a;i++){const a=e[i];s.push(Pv(a,t,n,r))}}return Promise.all(s)}))}function Cv(t,e,n){const r=e.attributes,i=[];function s(e,r){return n.getDependency("accessor",e).then((function(e){t.setAttribute(r,e)}))}for(const e in r){const n=fv[e]||e.toLowerCase();n in t.attributes||i.push(s(r[e],n))}if(void 0!==e.indices&&!t.index){const r=n.getDependency("accessor",e.indices).then((function(e){t.setIndex(e)}));i.push(r)}return wv(t,e),function(t,e,n){const r=e.attributes,i=new N;if(void 0===r.POSITION)return;{const t=n.json.accessors[r.POSITION],e=t.min,s=t.max;if(void 0===e||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new I(e[0],e[1],e[2]),new I(s[0],s[1],s[2])),t.normalized){const e=Av(hv[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new I,e=new I;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,a=r.max;if(void 0!==s&&void 0!==a){if(e.setX(Math.max(Math.abs(s[0]),Math.abs(a[0]))),e.setY(Math.max(Math.abs(s[1]),Math.abs(a[1]))),e.setZ(Math.max(Math.abs(s[2]),Math.abs(a[2]))),r.normalized){const t=Av(hv[r.componentType]);e.multiplyScalar(t)}t.max(e)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(t)}t.boundingBox=i;const a=new tt;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=a}(t,e,n),Promise.all(i).then((function(){return void 0!==e.targets?function(t,e,n){let r=!1,i=!1;for(let t=0,n=e.length;t<n;t++){const n=e[t];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),r&&i)break}if(!r&&!i)return Promise.resolve(t);const s=[],a=[];for(let o=0,l=e.length;o<l;o++){const l=e[o];if(r){const e=void 0!==l.POSITION?n.getDependency("accessor",l.POSITION):t.attributes.position;s.push(e)}if(i){const e=void 0!==l.NORMAL?n.getDependency("accessor",l.NORMAL):t.attributes.normal;a.push(e)}}return Promise.all([Promise.all(s),Promise.all(a)]).then((function(e){const n=e[0],s=e[1];return r&&(t.morphAttributes.position=n),i&&(t.morphAttributes.normal=s),t.morphTargetsRelative=!0,t}))}(t,e.targets,n):t}))}function Lv(t,e){let n=t.getIndex();if(null===n){const e=[],r=t.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<r.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const r=n.count-2,i=[];if(2===e)for(let t=1;t<=r;t++)i.push(n.getX(0)),i.push(n.getX(t)),i.push(n.getX(t+1));else for(let t=0;t<r;t++)t%2==0?(i.push(n.getX(t)),i.push(n.getX(t+1)),i.push(n.getX(t+2))):(i.push(n.getX(t+2)),i.push(n.getX(t+1)),i.push(n.getX(t)));i.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=t.clone();return s.setIndex(i),s}const Rv=new WeakMap;class Iv extends al{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,n,r){const i=new ll(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,(t=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(t,n).then(e).catch(r)}),n,r)}decodeDracoFile(t,e,n,r){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(t,i).then(e)}decodeGeometry(t,e){for(const t in e.attributeTypes){const n=e.attributeTypes[t];void 0!==n.BYTES_PER_ELEMENT&&(e.attributeTypes[t]=n.name)}const n=JSON.stringify(e);if(Rv.has(t)){const e=Rv.get(t);if(e.key===n)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(i,s).then((n=>(r=n,new Promise(((n,s)=>{r._callbacks[i]={resolve:n,reject:s},r.postMessage({type:"decode",id:i,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),Rv.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new we;t.index&&e.setIndex(new ie(t.index.array,1));for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n],i=r.name,s=r.array,a=r.itemSize;e.setAttribute(i,new ie(s,a))}return e}_loadLibrary(t,e){const n=new ll(this.manager);return n.setPath(this.decoderPath),n.setResponseType(e),n.setWithCredentials(this.withCredentials),new Promise(((e,r)=>{n.load(t,e,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const n=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const r=Fv.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const t=new Worker(this.workerSourceURL);t._callbacks={},t._taskCosts={},t._taskLoad=0,t.postMessage({type:"init",decoderConfig:this.decoderConfig}),t.onmessage=function(e){const n=e.data;switch(n.type){case"decode":t._callbacks[n.id].resolve(n);break;case"error":t._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(t)}else this.workerPool.sort((function(t,e){return t._taskLoad>e._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this}}function Fv(){let t,e;function n(t,e,n,r,i,s){const a=s.num_components(),o=n.num_points()*a,l=o*i.BYTES_PER_ELEMENT,c=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32}}(t,i),h=t._malloc(l);e.GetAttributeDataArrayForAllPoints(n,s,c,l,h);const u=new i(t.HEAPF32.buffer,h,o).slice();return t._free(h),{name:r,array:u,itemSize:a}}onmessage=function(r){const i=r.data;switch(i.type){case"init":t=i.decoderConfig,e=new Promise((function(e){t.onModuleLoaded=function(t){e({draco:t})},DracoDecoderModule(t)}));break;case"decode":const r=i.buffer,s=i.taskConfig;e.then((t=>{const e=t.draco,a=new e.Decoder,o=new e.DecoderBuffer;o.Init(new Int8Array(r),r.byteLength);try{const t=function(t,e,r,i){const s=i.attributeIDs,a=i.attributeTypes;let o,l;const c=e.GetEncodedGeometryType(r);if(c===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeBufferToMesh(r,o);else{if(c!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeBufferToPointCloud(r,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const r in s){const l=self[a[r]];let c,u;if(i.useUniqueIDs)u=s[r],c=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[r]]),-1===u)continue;c=e.GetAttribute(o,u)}h.attributes.push(n(t,e,o,r,l,c))}c===t.TRIANGULAR_MESH&&(h.index=function(t,e,n){const r=3*n.num_faces(),i=4*r,s=t._malloc(i);e.GetTrianglesUInt32Array(n,i,s);const a=new Uint32Array(t.HEAPF32.buffer,s,r).slice();return t._free(s),{array:a,itemSize:1}}(t,e,o));return t.destroy(o),h}(e,a,o,s),r=t.attributes.map((t=>t.array.buffer));t.index&&r.push(t.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:t},r)}catch(t){console.error(t),self.postMessage({type:"error",id:i.id,error:t.message})}finally{e.destroy(o),e.destroy(a)}}))}}}class Dv extends Lp{constructor(t){super("Model",t),this.viewport=t,this.gltfLoader=null,this.fbxLoader=null,this.modelMaps=new Map,this.store=Fp.createInstance({name:"soonspace",version:2,storeName:"modelData"}),this.dracoDecoderPath=null}setDracoDecoderPath(t){this.dracoDecoderPath=t}load(t){return this._loadItem(t)}parse(t,e,n){return new Promise(((r,i)=>{const s=new fp(Object.assign({format:t},n)),{url:a}=n,o=t.toLocaleUpperCase(),l=a.substring(0,a.lastIndexOf("/")+1),c="SBMX"===o;if("GLTF"===o||"GLB"===o||c){if(this.gltfLoader||(this.gltfLoader=new Rg),this.dracoDecoderPath&&!this.gltfLoader.dracoLoader){const t=new Iv;t.setDecoderPath(this.dracoDecoderPath),this.gltfLoader.setDRACOLoader(t)}c&&(e=xh(e)),this.gltfLoader.parse(e,l,(t=>{const{animations:e}=t;if(e&&e.length>0&&(s.animations=e),t.scene.traverse((t=>{"AmbientLight"!==t.type&&"DirectionalLight"!==t.type||(t.visible=!1),t.castShadow=!0,t.receiveShadow=!0})),s.add(t.scene),!this.modelMaps.get(a)){const t=s.sClone();this.modelMaps.set(a,t)}r(s)}),(t=>{i(t)}))}else if("FBX"===o){this.fbxLoader||(this.fbxLoader=new dg);const t=this.fbxLoader.parse(e,l),{animations:n}=t;if(n&&n.length>0&&(s.animations=n),t.traverse((t=>{"AmbientLight"!==t.type&&"DirectionalLight"!==t.type||(t.visible=!1),t.castShadow=!0,t.receiveShadow=!0})),s.add(t),!this.modelMaps.get(a)){const t=s.sClone();this.modelMaps.set(a,t)}r(s)}else i(`In soonspacejs: 加载通用模型资源(${a})格式错误,当前支持 fbx、gltf、glb !`)}))}clone(t,e,n){return new Promise(((r,i)=>Pu(this,void 0,void 0,(function*(){"Model"!==t.stype&&i("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:s,name:a,level:o,visible:l,position:c,rotation:h,scale:u,onClick:d,onDblClick:p,onRightClick:f,onLoad:m,userData:g}=e;function v(t,e,n){n(t,e);for(var r=0;r<t.children.length;r++)v(t.children[r],e.children[r],n)}const y=yield function(t){const e=new Map,n=new Map;let r;return r=t instanceof eu||t instanceof tu?t.sClone():t.clone(),v(t,r,(function(t,r){e.set(r,t),n.set(t,r)})),r.traverse((function(t){if(t instanceof Cs){const r=t,i=e.get(t),s=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=s.map((function(t){return n.get(t)})),r.bind(r.skeleton,r.bindMatrix)}})),r}(t);y.animations=yield y.animations.map((t=>t.clone())),yield this._copyMaterial(y),s&&(y.sid=s),a&&(y.name=a),o&&(y.level=o),!1===l&&y.hide(),c&&y.position.set(c.x,c.y,c.z),h&&y.rotation.set(h.x,h.y,h.z),u&&y.scale.set(u.x,u.y,u.z),y.onClick=d?d.bind(y):null,y.onDblClick=p?p.bind(y):null,y.onRightClick=f?f.bind(y):null,y.onLoad=m?m.bind(y):null,y.onLoad&&y.onLoad(y),g&&(y.userData=g),null!==n&&this.viewport.scener.addObject(y,n||t.parent||this.scene),r(y)}))))}loadToGroup(t,e){return new Promise((n=>Pu(this,void 0,void 0,(function*(){const r=new ru(t);for(let t=0;t<e.length;t++){const n=yield this._loadItem(e[t],null);r.add(n)}this.viewport.scener.addObject(r,this.scene),n(r)}))))}addForGroup(t,e){return new Promise((n=>Pu(this,void 0,void 0,(function*(){const r=this.getGroupById(t);if(r){for(let t=0;t<e.length;t++){const n=yield this._loadItem(e[t],null);r.add(n)}this.viewport.scener.addObject(r,this.scene)}n(r)}))))}clearIdb(){return this.store.clear()}_loadItem(t,e=this.scene){return Pu(this,void 0,void 0,(function*(){const{url:n}=t,{useIndexedDB:r}=this.viewport.options,i=n.slice(n.lastIndexOf(".")+1),s=this.modelMaps.get(n);let a=null;if(s)return this.clone(s,t,e);r&&(a=yield this.store.getItem(n)),a||(a=yield this._fetchBuffer(t));const o=yield this.parse(i,a,t);return null!==e&&this.viewport.scener.addObject(o,e||this.scene),Promise.resolve(o)}))}_fetchBuffer(t){const{url:e}=t,{useIndexedDB:n}=this.viewport.options;return fetch(e).then((t=>t.arrayBuffer())).then((t=>(n&&this.store.setItem(e,t),Promise.resolve(t))))}_copyMaterial(t){t.traverse((t=>{t instanceof ke&&(Ph(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof Yt&&(t.material=t.material.clone()))}))}}class Nv extends Lp{constructor(t){super("Poi",t),this.materials=new Map}create(t){const e=this._createMaterial(t.url),n=new vp(e,t);return this.viewport.scener.addObject(n,this.scene),n}clone(t,e,n){"Poi"!==t.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:r,name:i,level:s,visible:a,position:o,rotation:l,scale:c,onClick:h,onDblClick:u,onRightClick:d,userData:p}=e,f=t.sClone();return this._copyMaterial(f),r&&(f.sid=r),i&&(f.name=i),s&&(f.level=s),Mh(a)&&(f.visible=a),o&&f.position.set(o.x,o.y,o.z),l&&f.rotation.set(l.x,l.y,l.z),c&&f.scale.set(c.x,c.y,c.z),f.onClick=h?h.bind(f):null,f.onDblClick=u?u.bind(f):null,f.onRightClick=d?d.bind(f):null,p&&(f.userData=p),null!==n&&this.viewport.scener.addObject(f,n||this.scene||t.parent),f}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{const e=this._createMaterial(t.url),r=new vp(e,t);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&(e.forEach((t=>{const e=this._createMaterial(t.url),r=new vp(e,t);n.add(r)})),this.viewport.scener.addObject(n,this.scene)),n}_createMaterial(t){const e=this.materials.get(t);if(!e){const e=(new dl).load(t);e.flipY=!0;const n=new ss({map:e,color:16777215});return this.materials.set(t,n),n}return e}_copyMaterial(t){t.traverse((t=>{(t instanceof ke||t instanceof xs)&&(Ph(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof Yt&&(t.material=t.material.clone()))}))}}class Ov extends Lp{constructor(t){super("PoiNode",t)}create(t){this._openEnableRenderCss(t);const e=new Eu(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{this._openEnableRenderCss(t);const e=new Eu(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&(e.forEach((t=>{const e=new Eu(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene)),n}_openEnableRenderCss(t){switch(t.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class Uv extends Lp{constructor(t){super("Canvas3D",t)}create(t){const e=new Ep(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{const e=new Ep(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&(e.forEach((t=>{const e=new Ep(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene)),n}}class Bv{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(t){if(!Ph(t))return console.error("In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph isn't an array )");if(!(t.length<1))for(let e=0;e<t.length;e++){const n=t[e];if(2!==n.length)return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph item must be an array and contain 2 values [name, vertices], Failed at index: ${e} )`);const r=n[0],i=n[1];this.graph[r]=[];for(let t=0;t<i.length;t++){const e=i[t],n=e[0],s=e[1];this.graph[r][n]=s}}}getPath(t,e){if(void 0===this.graph[t])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method source ${t} doesn't exist )`),[];if(void 0===this.graph[e])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method target ${e} doesn't exist )`),[];if(t===e)return[];let n;for(this.queue=new vh,this.queue.add(t,0),this.previous[t]=null;n=this.queue.shift();){if(n===e){const t=[];for(;Sh(n)&&null!==this.previous[n];)t.unshift(n),n=this.previous[n];return t}const t=this.queue.getDistance(n);if(t===1/0)return[];for(let e in this.graph[n]){const r=this.queue.getDistance(Number(e)),i=t+this.graph[n][e];i<r&&(this.queue.update(Number(e),i),this.previous[e]=n)}}return[]}}class zv extends Lp{constructor(t){super("Topology",t),this.dijkstra=new Bv}createFromGml(t){const{url:e,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255}=t;return kp(e).then((e=>{if(!e||!e.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const a=[],o=new Map;let l=[],c=[];const h=e.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;Ph(h)?h.forEach((t=>{l=[...l,...t.state],c=[...c,...t.transition]})):(l=[...l,...h.state],c=[...c,...h.transition]),l.forEach(((t,e)=>{const n=t.State._attributes["gml:id"],r=t.State.topoNode["gml:Node"].node_name;a.push({id:wh(n)?n:"",name:wh(r)?r:"",position:{x:Number(t.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(t.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(t.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),o.set(n,e)})),c.forEach((t=>{const e=t.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=t.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],r=t.Transition.topoEdge["gml:Edge"].length["#text"],i=t.Transition.topoEdge["gml:Edge"].restrict["#text"],s=t.Transition.topoEdge["gml:Edge"].passable["#text"],l=o.get(e),c=o.get(n),h=t.Transition._attributes["gml:id"],u=t.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==l&&void 0!==c&&("2"!==s&&"3"!==s&&a[l].graphs.push({targetNodeId:n,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}),"1"!==s&&"3"!==s&&a[c].graphs.push({targetNodeId:e,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}))})),this.setDijkstraGraph(a);const u=new wp(Object.assign(Object.assign({},t),{type:"network",nodes:a,linkWidth:n,renderLink:!0,linkColor:r,renderNode:i,nodeColor:s}));return this.viewport.scener.addObject(u,this.scene),Promise.resolve(u)}))}create(t){const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const n=new wp(e);return this.viewport.scener.addObject(n,this.scene),n}resetNodes(t,e){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},t.info),{nodes:e}));return t.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),t}createToGroup(t,e){const n=new ru(t);return e.forEach((t=>{const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const r=new wp(e);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(t,e){const n=this.getGroupById(t);return n&&e.forEach((t=>{const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const r=new wp(e);n.add(r)})),n}getShortestPath(t,e){const{nodes:n}=t.info,r=lh(e.start),i=lh(e.end);let s=null,a=1/0,o=null,l=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=lh(t.position),n=e.distanceTo(r),c=e.distanceTo(i);n<a&&(a=n,s=Number(t.id)),c<l&&(l=c,o=Number(t.id))}})),s&&o){const a=this.dijkstra.getPath(s,o);if(a.length>0){const s=[{id:"startPoint",position:r,graphs:[]}];a.forEach((t=>{const e=n.find((e=>e.id==t));e&&s.push(e)})),s.push({id:"endPoint",position:i,graphs:[]});for(let t=0;t<s.length;t++)s[t].position.y+=1;const o=Object.assign(Object.assign(Object.assign({},e),{type:"line",nodes:s}),t.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(o);const l=new wp(o);return this.viewport.scener.addObject(l,this.scene),l}}return null}getShortestPathByMultipleStartPoints(t,e){const{nodes:n}=t.info,r=[];e.start.forEach((t=>{const i=lh(t),s=lh(e.end);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=lh(t.position),n=e.distanceTo(i),r=e.distanceTo(s);n<o&&(o=n,a=Number(t.id)),r<c&&(c=r,l=Number(t.id))}})),a&&l){let t=0;const e=this.dijkstra.getPath(a,l);if(e.length>0){const a=[{id:"startPoint",position:i,graphs:[]}];e.forEach(((e,r)=>{const s=n.find((t=>t.id==e));s&&(t+=0===r?lh(s.position).distanceTo(i):lh(s.position).distanceTo(lh(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(lh(a[a.length-1].position)),r.push({nodeInfo:a,pathLength:t})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:t,pathLength:e})=>{e<s&&(s=e,i=t)})),i.length){for(let t=0;t<i.length;t++)i[t].position.y+=1;const n=Object.assign(Object.assign({},e),{type:"line",nodes:i,position:t.getWorldPosition(new I),rotation:(new xt).setFromQuaternion(t.getWorldQuaternion(new R)),scale:t.getWorldScale(new I)});this.generateLineTopologyInfoNodeGraphs(n);const r=new wp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}getShortestPathByMultipleEndPoints(t,e){const{nodes:n}=t.info,r=[];e.end.forEach((t=>{const i=lh(e.start),s=lh(t);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=lh(t.position),n=e.distanceTo(i),r=e.distanceTo(s);n<o&&(o=n,a=Number(t.id)),r<c&&(c=r,l=Number(t.id))}})),a&&l){let t=0;const e=this.dijkstra.getPath(a,l);if(e.length>0){const a=[{id:"startPoint",position:i,graphs:[]}];e.forEach(((e,r)=>{const s=n.find((t=>t.id==e));s&&(t+=0===r?lh(s.position).distanceTo(i):lh(s.position).distanceTo(lh(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(lh(a[a.length-1].position)),r.push({nodeInfo:a,pathLength:t})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:t,pathLength:e})=>{e<s&&(s=e,i=t)})),i.length){for(let t=0;t<i.length;t++)i[t].position.y+=1;const n=Object.assign(Object.assign({},e),{type:"line",nodes:i,position:t.getWorldPosition(new I),rotation:(new xt).setFromQuaternion(t.getWorldQuaternion(new R)),scale:t.getWorldScale(new I)});this.generateLineTopologyInfoNodeGraphs(n);const r=new wp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}setDijkstraGraph(t){const e=[];t.forEach((n=>{if(n.graphs&&n.graphs.length>0){const r=[];n.graphs.forEach((e=>{const i=t.find((t=>t.id===e.targetNodeId));i&&r.push([Number(e.targetNodeId),e.length||lh(n.position).distanceTo(lh(i.position))])})),e.push([Number(n.id),r])}})),e.length>0&&this.dijkstra.setGraph(e)}generateLineTopologyInfoNodeGraphs(t){if("line"===t.type)for(let e=0;e<t.nodes.length;e++)if(e===t.nodes.length-1)t.nodes[e].graphs=[];else{const n=t.nodes[e],r=t.nodes[e+1];t.nodes[e].graphs=[{targetNodeId:r.id.toString(),linkInfo:{id:`${n.id}_to_${r.id}`,name:`${n.name||n.id}_to_${r.name||r.id}`},enable:!0,length:lh(t.nodes[e].position).distanceTo(lh(r.position)),restrict:0,passable:0}]}return t}}class kv extends Lp{constructor(t){super("Helper",t)}addGridHelper(t){const{id:e,size:n=1e3,divisions:r=20,color:i="#fff",position:s={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:o={x:1,y:1,z:1}}=t,l=new Gc(n,r,i,i);return l.position.set(s.x,s.y,s.z),l.rotation.set(a.x,a.y,a.z),l.scale.set(o.x,o.y,o.z),l.userData.sid=e,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(t){const{id:e,axesLength:n=1e3}=t,r=new nh(n);return r.userData.sid=e,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addBoxHelper(t){const{id:e,box:n,color:r="#00ff00"}=t,i=new Kc(n,new te(r));return i.userData.sid=e,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPlaneHelper(t){const{id:e,width:n=500,height:r=500,color:i="#00ff00",opacity:s=.2,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=t,c=new tu(new ln(n,r),new ee({color:i,opacity:s,transparent:!0,side:2}),{id:e,position:a,rotation:o,scale:l});return c.userData.sid=e,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(t){const{imgUrl:e,id:n,width:r=500,height:i=500,opacity:s=1,position:a={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=t,h=(new dl).load(e),u=new ln(r,i);u.computeBoundingBox();const d=new Fo({side:2,map:h,transparent:!0,opacity:s,roughness:.8});d.map&&(d.map.repeat.set(c.x,c.x),d.map.wrapS=1e3,d.map.wrapT=1e3,d.map.version++),o.x-=Math.PI/2,d.version++;const p=new Pp(u,d,{id:n,position:a,rotation:o,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(t){const{id:e,light:n,color:r,size:i=50}=t,s=new Xc(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(t){const{id:e,light:n,color:r,size:i=20}=t,s=new Hc(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(t){const{id:e,light:n,color:r}=t,i=new Rc(n,r);return i.userData.sid=e,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPointLightHelper(t){const{id:e,light:n,color:r,size:i=20}=t,s=new Uc(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}}class Hv extends Lp{constructor(t){super("PluginObject",t)}createObject(t,e){const n=new iu(t);return e&&n.add(e),this.viewport.scener.addObject(n,this.scene),n}addToObject(t,e){const n=this.getById(t);return n?(this.viewport.scener.addObject(e,n),n):null}}class Gv{constructor(t){this.viewport=t,this.needUpdate=!1,this.store={LightManager:new Rp(t),sbmManager:new Gp(t),modelManager:new Dv(t),poiManager:new Nv(t),poiNodeManager:new Ov(t),canvas3DManager:new Uv(t),topologyManager:new zv(t),helperManager:new kv(t),pluginObjectManager:new Hv(t)},this.postUpdate=new Map;for(let t in this.store)this.postUpdate.set(t,this.store[t].update.bind(this.store[t]));t.postUpdate.set("ManagerRender",this.update.bind(this))}update(){const t=performance.now();this.postUpdate.forEach((t=>t())),this.viewport.signals.loadRendered.dispatch(performance.now()-t)}clearObject(){this.store.sbmManager.clear(),this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.LightManager.clear()}}export default class{constructor(t){this.THREE=ah,this.version=e,this.animation=$h,this.library=Cp,this.utils=Oh,this.plugins={};const{el:n,options:r={},events:i={}}=t;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showGrid:!1,background:{color:0,alpha:!1},fog:!1,controls:{},hoverEnabled:!1,closeInfoLog:!1,closeWarnLog:!0,useIndexedDB:!0,logarithmicDepthBuffer:!0}),r),this.viewport=new hp(this.options),this.signals=this.viewport.signals,this.manager=new Gv(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(i),this._initDefaultLight()}_init(){const{showGrid:e,background:n,fog:r,controls:i,closeInfoLog:s,closeWarnLog:a,useIndexedDB:o}=this.options;if(!s){oh(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),oh(t,{color:"#3eaf7c","font-size":"24px"}),oh(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),oh("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),oh("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),oh("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}e&&this.addGridHelper(!0===e?{id:"defaultGridHelper"}:e),(null==n?void 0:n.skyBox)?wh(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):Ch(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),r&&this.openSceneFog(!0===r?void 0:r),i&&this.setControlsOptions(i),a&&(window.console.warn=function(){}),o&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(t){const{modelHover:e,modelUnHover:n,modelClick:r,modelRightClick:i,modelDblClick:s,poiHover:a,poiUnHover:o,poiClick:l,poiRightClick:c,poiDblClick:h,selectPosition:u,sceneClick:d,resize:p}=t;e&&this.signals.modelHover.add(e),n&&this.signals.modelUnHover.add(n),r&&this.signals.modelClick.add(r),i&&this.signals.modelRightClick.add(i),s&&this.signals.modelDblClick.add(s),a&&this.signals.poiHover.add(a),o&&this.signals.poiUnHover.add(o),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),h&&this.signals.poiDblClick.add(h),u&&this.signals.selectPosition.add(u),d&&this.signals.sceneClick.add(d),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultLight(){this.createAmbientLight({id:"defaultAmbientLight",name:"defaultAmbientLight"}),this.createDirectionalLight({id:"defaultDirectionalLight",name:"defaultDirectionalLight"}),this.createHemisphereLight({id:"defaultHemisphereLight",name:"defaulHemisphereLight",intensity:.1})}registerPlugin(t,e){const n=new t(this);return this.plugins[e]=n,n}getPlugin(t){return this.plugins[t]?this.plugins[t]:null}createPluginObject(t,e){return this.manager.store.pluginObjectManager.createObject(t,e)}addToPluginObject(t,e){return this.manager.store.pluginObjectManager.addToObject(t,e)}getPluginObjectById(t){return this.manager.store.pluginObjectManager.getById(t)}getPluginObjectByName(t){return this.manager.store.pluginObjectManager.getByName(t)}removePluginObjectById(t){return this.manager.store.pluginObjectManager.removeById(t)}setHoverEnabled(t){this.viewport.setHoverEnabled(t)}setBackgroundColor(t){this.viewport.setBackgroundColor(t)}setBackgroundImage(t){this.viewport.setBackgroundImage(t)}setSphereSkyBackground(t){this.viewport.setSphereSkyBackground(t)}setSkyBackground(t,e){this.viewport.setSkyBackground(t,e)}playModelAnimation(t,e){return this.viewport.playModelAnimation(t,e)}stopModelAnimation(t,e){this.viewport.stopModelAnimation(t,e)}getOffsetByPosition(t){return this.viewport.getOffsetByPosition(t)}getPositionByOffset(t,e){return this.viewport.getPositionByOffset(t,e)}render(t){return this.viewport.render(t)}clearSignals(){this.viewport.clearSignals()}dispose(){return this.clear(),this.clearSignals(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(t){this.viewport.cameraManager.setCameraViewpoint(t)}flyTo(t,e="frontTop",n){return this.viewport.cameraManager.flyTo(t,e,n)}flyToBoundingBox(t,e="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(t,e,n)}flyToObj(t,e="frontTop",n){return this.viewport.cameraManager.flyToObj(t,e,n)}flyMainViewpoint(t="frontTop",e){return this.flyToObj(this.viewport.scene,t,e)}surroundOnTarget(t,e){return this.viewport.cameraManager.surroundOnTarget(t,e)}surroundOnObject(t,e){return this.viewport.cameraManager.surroundOnObject(t,e)}getObjectLabelPos(t,e="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(t,e,n)}setControlsOptions(t){return this.viewport.controls.setOptions(t)}addObject(t,e){this.viewport.scener.addObject(t,e)}removeObject(t){this.viewport.scener.removeObject(t)}openSceneFog(t){this.viewport.scener.openSceneFog(t)}closeSceneFog(){this.viewport.scener.closeSceneFog()}edgeShow(t,e){return this.viewport.scener.edgeShow(t,e)}unEdgeShow(t){return this.viewport.scener.unEdgeShow(t)}strokeShow(t,e){return this.viewport.scener.strokeShow(t,e)}unStrokeShow(t){return this.viewport.scener.unStrokeShow(t)}opacityShow(t,e){return this.viewport.scener.opacityShow(t,e)}unOpacityShow(t){return this.viewport.scener.unOpacityShow(t)}highlightShow(t,e){return this.viewport.scener.highlightShow(t,e)}unHighlightShow(t){return this.viewport.scener.unHighlightShow(t)}emissiveShow(t,e){return this.viewport.scener.emissiveShow(t,e)}unEmissiveShow(t){return this.viewport.scener.unEmissiveShow(t)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(t){return this.manager.store.LightManager.createAmbientLight(t)}setAmbientLight(t){return this.manager.store.LightManager.setAmbientLight(t)}createDirectionalLight(t){return this.manager.store.LightManager.createDirectionalLight(t)}setDirectionalLight(t){return this.manager.store.LightManager.setDirectionalLight(t)}createHemisphereLight(t){return this.manager.store.LightManager.createHemisphereLight(t)}setHemisphereLight(t){return this.manager.store.LightManager.setHemisphereLight(t)}createSpotLight(t){return this.manager.store.LightManager.createSpotLight(t)}setSpotLight(t){return this.manager.store.LightManager.setSpotLight(t)}createPointLight(t){return this.manager.store.LightManager.createPointLight(t)}setPointLight(t){return this.manager.store.LightManager.setPointLight(t)}getLightById(t){return this.manager.store.LightManager.getById(t)}removeLightById(t){return this.manager.store.LightManager.removeById(t)}getAllLight(){return this.manager.store.LightManager.getAll()}clearLight(){return this.manager.store.LightManager.clear()}showAllLight(){return this.manager.store.LightManager.showAll()}hideAllLight(){return this.manager.store.LightManager.hideAll()}loadSbm(t,e){return this.manager.store.sbmManager.load(t,e)}parseSbm(t,e,n){return this.manager.store.sbmManager.parse(t,e,n)}cloneSbm(t,e,n){return this.manager.store.sbmManager.clone(t,e,n)}getSbmById(t){return this.manager.store.sbmManager.getById(t)}getSbmByName(t){return this.manager.store.sbmManager.getByName(t)}getSbmByUserDataProperty(t,e){return this.manager.store.sbmManager.getByUserDataProperty(t,e)}removeSbmById(t){return this.manager.store.sbmManager.removeById(t)}createGroupForSbm(t){return this.manager.store.sbmManager.createGroup(t)}loadSbmToGroup(t,e,n){return this.manager.store.sbmManager.loadToGroup(t,e,n)}addSbmForGroup(t,e,n){return this.manager.store.sbmManager.addForGroup(t,e,n)}createSbmGroupFromXml(t,e){return this.manager.store.sbmManager.createGroupFromXml(t,e)}getSbmGroupById(t){return this.manager.store.sbmManager.getGroupById(t)}getSbmGroupByName(t){return this.manager.store.sbmManager.getGroupByName(t)}getAllSbmGroup(){return this.manager.store.sbmManager.getAllGroup()}removeSbmGroupById(t){return this.manager.store.sbmManager.removeGroupById(t)}clearSbm(){return this.manager.store.sbmManager.clear()}getAllSbm(){return this.manager.store.sbmManager.getAll()}showAllSbm(){return this.manager.store.sbmManager.showAll()}hideAllSbm(){return this.manager.store.sbmManager.hideAll()}getSbmModelMaps(){return this.manager.store.sbmManager.modelMaps}setSbmModelMaps(t){this.manager.store.sbmManager.modelMaps=t}clearIdb(){return Promise.all([this.manager.store.sbmManager.clearIdb(),this.manager.store.modelManager.clearIdb()])}setModelDracoDecoderPath(t){return this.manager.store.modelManager.setDracoDecoderPath(t)}loadModel(t){return this.manager.store.modelManager.load(t)}cloneModel(t,e,n){return this.manager.store.modelManager.clone(t,e,n)}getModelById(t){return this.manager.store.modelManager.getById(t)}getModelByName(t){return this.manager.store.modelManager.getByName(t)}getModelByUserDataProperty(t,e){return this.manager.store.modelManager.getByUserDataProperty(t,e)}removeModelById(t){return this.manager.store.modelManager.removeById(t)}createGroupForModel(t){return this.manager.store.modelManager.createGroup(t)}loadModelToGroup(t,e){return this.manager.store.modelManager.loadToGroup(t,e)}addModelForGroup(t,e){return this.manager.store.modelManager.addForGroup(t,e)}getModelGroupById(t){return this.manager.store.modelManager.getGroupById(t)}getModelGroupByName(t){return this.manager.store.modelManager.getGroupByName(t)}getAllModelGroup(){return this.manager.store.modelManager.getAllGroup()}removeModelGroupById(t){return this.manager.store.modelManager.removeGroupById(t)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}createPoi(t){return this.manager.store.poiManager.create(t)}clonePoi(t,e,n){return this.manager.store.poiManager.clone(t,e,n)}getPoiById(t){return this.manager.store.poiManager.getById(t)}getPoiByName(t){return this.manager.store.poiManager.getByName(t)}getPoiByUserDataProperty(t,e){return this.manager.store.poiManager.getByUserDataProperty(t,e)}removePoiById(t){return this.manager.store.poiManager.removeById(t)}createGroupForPoi(t){return this.manager.store.poiManager.createGroup(t)}createPoiToGroup(t,e){return this.manager.store.poiManager.createToGroup(t,e)}addPoiForGroup(t,e){return this.manager.store.poiManager.addForGroup(t,e)}getPoiGroupById(t){return this.manager.store.poiManager.getGroupById(t)}getPoiGroupByName(t){return this.manager.store.poiManager.getGroupByName(t)}getAllPoiGroup(){return this.manager.store.poiManager.getAllGroup()}removePoiGroupById(t){return this.manager.store.poiManager.removeGroupById(t)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(t){return this.manager.store.poiNodeManager.create(t)}getPoiNodeById(t){return this.manager.store.poiNodeManager.getById(t)}getPoiNodeByName(t){return this.manager.store.poiNodeManager.getByName(t)}getPoiNodeByUserDataProperty(t,e){return this.manager.store.poiNodeManager.getByUserDataProperty(t,e)}removePoiNodeById(t){return this.manager.store.poiNodeManager.removeById(t)}createGroupForPoiNode(t){return this.manager.store.poiNodeManager.createGroup(t)}createPoiNodeToGroup(t,e){return this.manager.store.poiNodeManager.createToGroup(t,e)}addPoiNodeForGroup(t,e){return this.manager.store.poiNodeManager.addForGroup(t,e)}getPoiNodeGroupById(t){return this.manager.store.poiNodeManager.getGroupById(t)}getPoiNodeGroupByName(t){return this.manager.store.poiNodeManager.getGroupByName(t)}getAllPoiNodeGroup(){return this.manager.store.poiNodeManager.getAllGroup()}removePoiNodeGroupById(t){return this.manager.store.poiNodeManager.removeGroupById(t)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createCanvas3D(t){return this.manager.store.canvas3DManager.create(t)}getCanvas3DById(t){return this.manager.store.canvas3DManager.getById(t)}getCanvas3DByName(t){return this.manager.store.canvas3DManager.getByName(t)}getCanvas3DByUserDataProperty(t,e){return this.manager.store.canvas3DManager.getByUserDataProperty(t,e)}removeCanvas3DById(t){return this.manager.store.canvas3DManager.removeById(t)}createGroupForCanvas3D(t){return this.manager.store.canvas3DManager.createGroup(t)}createCanvas3DToGroup(t,e){return this.manager.store.canvas3DManager.createToGroup(t,e)}addCanvas3DForGroup(t,e){return this.manager.store.canvas3DManager.addForGroup(t,e)}getCanvas3DGroupById(t){return this.manager.store.canvas3DManager.getGroupById(t)}getCanvas3DGroupByName(t){return this.manager.store.canvas3DManager.getGroupByName(t)}getAllCanvas3DGroup(){return this.manager.store.canvas3DManager.getAllGroup()}removeCanvas3DGroupById(t){return this.manager.store.canvas3DManager.removeGroupById(t)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(t,e){return this.manager.store.topologyManager.getShortestPath(t,e)}getShortestPathByMultipleStartPoints(t,e){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(t,e)}getShortestPathByMultipleEndPoints(t,e){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(t,e)}createTopologyFromGml(t){return this.manager.store.topologyManager.createFromGml(t)}createTopology(t){return this.manager.store.topologyManager.create(t)}resetTopologyNodes(t,e){return this.manager.store.topologyManager.resetNodes(t,e)}getTopologyById(t){return this.manager.store.topologyManager.getById(t)}getTopologyByName(t){return this.manager.store.topologyManager.getByName(t)}getTopologyByUserDataProperty(t,e){return this.manager.store.topologyManager.getByUserDataProperty(t,e)}removeTopologyById(t){return this.manager.store.topologyManager.removeById(t)}createGroupForTopology(t){return this.manager.store.topologyManager.createGroup(t)}createTopologyToGroup(t,e){return this.manager.store.topologyManager.createToGroup(t,e)}addTopologyForGroup(t,e){return this.manager.store.topologyManager.addForGroup(t,e)}getTopologyGroupById(t){return this.manager.store.topologyManager.getGroupById(t)}getTopologyGroupByName(t){return this.manager.store.topologyManager.getGroupByName(t)}getAllTopologyGroup(){return this.manager.store.topologyManager.getAllGroup()}removeTopologyGroupById(t){return this.manager.store.topologyManager.removeGroupById(t)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(t){return this.manager.store.helperManager.addGridHelper(t)}addAxesHelper(t){return this.manager.store.helperManager.addAxesHelper(t)}addBoxHelper(t){return this.manager.store.helperManager.addBoxHelper(t)}addPlaneHelper(t){return this.manager.store.helperManager.addPlaneHelper(t)}createGround(t){return console.warn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(t)}addGroundHelper(t){return this.manager.store.helperManager.addGroundHelper(t)}addDirectionalLightHelper(t){return this.manager.store.helperManager.addDirectionalLightHelper(t)}addHemisphereLightHelper(t){return this.manager.store.helperManager.addHemisphereLightHelper(t)}addSpotLightHelper(t){return this.manager.store.helperManager.addSpotLightHelper(t)}addPointLightHelper(t){return this.manager.store.helperManager.addPointLightHelper(t)}getHelperById(t){return this.manager.store.helperManager.getById(t)}removeHelperById(t){return this.manager.store.helperManager.removeById(t)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}}export{tu as BaseMesh,eu as BaseObject3D,Ep as Canvas3D,_p as Circle,Pp as Ground,ru as Group,ch as IVector3ToEuler,lh as IVector3ToVector3,gp as Icon,Sp as Line,bp as Link,vh as MinHeap,fp as Model,xp as Node,iu as PluginObject,vp as Poi,Eu as PoiNode,yp as Point,Ap as Polygon,dp as Sbm,nu as SceneManage,wp as Topology,ph as deg2Euler,fh as euler2Deg,Dh as getAsciiString,hh as getBoundingBox,yh as getCubeTexture,mh as getSpaceAttributeFromObject,bh as hasOwn,Ph as isArray,Mh as isBoolean,Eh as isDate,Lh as isFunction,Th as isNull,Sh as isNumber,Ch as isObject,Rh as isPromise,wh as isString,Ah as isSymbol,oh as log,xh as parseSbmx,dh as rotationAFix,uh as rotationAxisFix,Fh as sleep,gh as syncSpaceAttributeToObject,Ih as typeJudge};
|