soonspacejs 2.3.8 → 2.3.9
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 +4 -4
- package/dist/index.js +4 -4
- package/package.json +2 -2
- package/types/Manager/ModelManage.d.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var SoonSpace=function(t){"use strict";var e="soonspacejs",n="2.3.
|
|
1
|
+
var SoonSpace=function(t){"use strict";var e="soonspacejs",n="2.3.9",r=!1;
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2010-2021 Three.js Authors
|
|
@@ -31,16 +31,16 @@ var SoonSpace=function(t){"use strict";var e="soonspacejs",n="2.3.8",r=!1;
|
|
|
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 Dd=function(t,e){return(Dd=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 Nd=function(){return(Nd=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 Od(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 Ud(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 Bd(t){return this instanceof Bd?(this.v=t,this):new Bd(t)}var zd=Object.freeze({__proto__:null,__extends:function(t,e){function n(){this.constructor=t}Dd(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},get __assign(){return Nd},__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:Od,__read:Ud,__spread:function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ud(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:Bd,__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 Bd?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:Bd(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=Od(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}}),kd=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}(),Hd=Object.defineProperty({SlotList:kd},"__esModule",{value:!0}),Gd=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}(),jd=Object.defineProperty({Slot:Gd},"__esModule",{value:!0}),Vd=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.slots=Hd.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=Hd.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 jd.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}(),Wd=Object.defineProperty({OnceSignal:Vd},"__esModule",{value:!0}),Xd="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Yd(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 qd(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 Qd=Yd(zd),Zd=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qd.__extends(e,t),e.prototype.add=function(t){return this.registerListener(t)},e}(Wd.OnceSignal),Jd=Object.defineProperty({Signal:Zd},"__esModule",{value:!0}),Kd=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qd.__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 jd.Slot(t,this,e,n);return this.slots=this.slots.insertWithPriority(r),r}return this.slots.find(t)},e}(Jd.Signal),$d=Object.defineProperty({PrioritySignal:Kd},"__esModule",{value:!0}),tp=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 Qd.__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}($d.PrioritySignal),ep=Object.defineProperty({DeluxeSignal:tp},"__esModule",{value:!0}),np=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}(),rp=Object.defineProperty({GenericEvent:np},"__esModule",{value:!0}),ip=Symbol("IOnceSignal"),sp=Object.defineProperty({IOnceSignal:ip},"__esModule",{value:!0}),ap=Symbol("IPrioritySignal"),op=Object.defineProperty({IPrioritySignal:ap},"__esModule",{value:!0}),lp=Symbol("ISignal"),cp=Object.defineProperty({ISignal:lp},"__esModule",{value:!0}),hp=Symbol("ISlot"),up=Object.defineProperty({ISlot:hp},"__esModule",{value:!0}),dp=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 jd.Slot(t,this,e)},t}(),pp=Object.defineProperty({MonoSignal:dp},"__esModule",{value:!0}),fp=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qd.__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}(Wd.OnceSignal),mp=Object.defineProperty({Promise:fp},"__esModule",{value:!0});ep.DeluxeSignal,rp.GenericEvent,sp.IOnceSignal,op.IPrioritySignal,cp.ISignal,up.ISlot,pp.MonoSignal,Wd.OnceSignal,$d.PrioritySignal,mp.Promise;var gp=Jd.Signal;jd.Slot,Hd.SlotList;const vp=new ia;vp.name="Scene";class yp{constructor(t){this.signals=t,this.scene=vp.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 Bl&&((e=t.map)&&e.isTexture&&e.dispose()),t.dispose()}t.traverse((t=>{if("Mesh"===t.type){const e=t;e.geometry.dispose(),Fu(e.material)?e.material.forEach((t=>n(t))):e.material instanceof Bl&&n(e.material)}t instanceof Id&&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 ra(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 Fu(t)?t.forEach((t=>r(t))):Du(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 Fu(t)?Promise.all(t.map((t=>e(t)))):Du(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 ld({id:t.sid});return t.traverse((t=>{if(t instanceof Gn&&t.geometry){const n=new wo(t.geometry.clone(),89),r=new $a(n,new Va({color:s,transparent:!0,opacity:a}));bu(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}),Fu(t)?Promise.all(t.map((t=>o(t)))):Du(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 Fu(t)?Promise.all(t.map((t=>e(t)))):Du(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 Gn&&(Fu(t.material)?t.material.forEach(((e,n)=>{t.material[n]=i(e)})):t.material instanceof qe&&(t.material=i(t.material)))})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(t)),Promise.resolve());return Fu(t)?Promise.all(t.map((t=>s(t)))):Du(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 Gn&&(Fu(t.material)?t.material.forEach(((n,r)=>{t.material[r]=e(n)})):t.material instanceof qe&&(t.material=e(t.material)))})),this.signals.materialChanged.dispatch(),n()}));return Fu(t)?Promise.all(t.map((t=>n(t)))):Du(t)?n(t):Promise.resolve()}highlightShow(t,e={}){const{color:n="red",opacity:r=1}=e;function i(t){if(t instanceof Bl||t instanceof Ol){if(t.userData.color&&t.userData.opacity)return;t.userData={color:t.color.clone(),opacity:t.opacity,transparent:t.transparent},t.color=new en(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 Gn&&(Fu(t.material)?t.material.forEach((t=>i(t))):t.material instanceof qe&&i(t.material))})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(t)),Promise.resolve());return Fu(t)?Promise.all(t.map((t=>s(t)))):Du(t)?s(t):Promise.resolve()}unHighlightShow(t){function e(t){if(t instanceof Bl||t instanceof Ol){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 Gn&&(Fu(t.material)?t.material.forEach((t=>e(t))):t.material instanceof qe&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Fu(t)?Promise.all(t.map((t=>n(t)))):Du(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 Bl||t instanceof Ol){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,id({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 Gn&&(Fu(t.material)?t.material.forEach((t=>o(t))):t.material instanceof qe&&o(t.material))})),this.selectedObjects.emissive.push(t),this.signals.materialChanged.dispatch()),Promise.resolve());return Fu(t)?Promise.all(t.map((t=>l(t)))):Du(t)?l(t):Promise.resolve()}unEmissiveShow(t){function e(t){var e;if(t instanceof Bl||t instanceof Ol){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 Gn&&(Fu(t.material)?t.material.forEach((t=>e(t))):t.material instanceof qe&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Fu(t)?Promise.all(t.map((t=>n(t)))):Du(t)?n(t):Promise.resolve()}_triggerObjectAdded(t){if(t instanceof ad)if("Sbm"===t.stype||"Model"===t.stype)t.traverse((t=>{if(t instanceof Gn){-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 Gn){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}));else if(t instanceof sd){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}}class xp{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 _p=new _r(-1,1,1,-1,0,1),bp=new Sn;bp.setAttribute("position",new mn([-1,3,0,-1,-1,0,3,-1,0],3)),bp.setAttribute("uv",new mn([0,2,0,0,2,0],2));class wp{constructor(t){this._mesh=new Gn(bp,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,_p)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}const Mp={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 vt(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new he},cameraInverseProjectionMatrix:{value:new he},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}"},Sp={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new vt(512,512)},sampleUvOffsets:{value:[new vt(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}"},Tp={createSampleWeights:function(t,e){const n=[];for(let r=0;r<=t;r++)n.push(Ap(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=Tp.createSampleOffsets(e,r),t.uniforms.sampleWeights.value=Tp.createSampleWeights(e,n),t.needsUpdate=!0}};function Ap(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}var Ep={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 Pp={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 Cp extends xp{constructor(t,e,n=!1,r=!1,i=new vt(256,256)){let o;super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=r,this.originalClearColor=new en,this._oldClearColor=new en,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 vt(i.x,i.y),this.saoRenderTarget=new Ct(this.resolution.x,this.resolution.y,{minFilter:_,magFilter:_,format:L}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new Ct(this.resolution.x,this.resolution.y,{minFilter:v,magFilter:v,format:L}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(o=new Js,o.type=S,this.beautyRenderTarget.depthTexture=o,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Hs,this.depthMaterial.depthPacking=$,this.depthMaterial.blending=0,this.normalMaterial=new kl,this.normalMaterial.blending=0,void 0===Mp&&console.error("THREE.SAOPass relies on SAOShader"),this.saoMaterial=new qn({defines:Object.assign({},Mp.defines),fragmentShader:Mp.fragmentShader,vertexShader:Mp.vertexShader,uniforms:Yn.clone(Mp.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?o: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===Sp&&console.error("THREE.SAOPass relies on DepthLimitedBlurShader"),this.vBlurMaterial=new qn({uniforms:Yn.clone(Sp.uniforms),defines:Object.assign({},Sp.defines),vertexShader:Sp.vertexShader,fragmentShader:Sp.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?o:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=0,this.hBlurMaterial=new qn({uniforms:Yn.clone(Sp.uniforms),defines:Object.assign({},Sp.defines),vertexShader:Sp.vertexShader,fragmentShader:Sp.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?o:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=0,void 0===Ep&&console.error("THREE.SAOPass relies on CopyShader"),this.materialCopy=new qn({uniforms:Yn.clone(Ep.uniforms),vertexShader:Ep.vertexShader,fragmentShader:Ep.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=a,this.materialCopy.blendEquation=s,this.materialCopy.blendSrcAlpha=206,this.materialCopy.blendDstAlpha=a,this.materialCopy.blendEquationAlpha=s,void 0===Pp&&console.error("THREE.SAOPass relies on UnpackDepthRGBAShader"),this.depthCopy=new qn({uniforms:Yn.clone(Pp.uniforms),vertexShader:Pp.vertexShader,fragmentShader:Pp.fragmentShader,blending:0}),this.fsQuad=new wp(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||(Tp.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new vt(0,1)),Tp.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new vt(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}}Cp.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};class Lp extends xp{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 en}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 Rp extends xp{constructor(t,e){super(),this.textureID=void 0!==e?e:"tDiffuse",t instanceof qn?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=Yn.clone(t.uniforms),this.material=new qn({defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new wp(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 Ip extends xp{constructor(t,e,n,r){super(),this.renderScene=e,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new en(1,1,1),this.hiddenEdgeColor=new en(.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 vt(t.x,t.y):new vt(256,256);const i={minFilter:_,magFilter:_,format:L},s=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.maskBufferMaterial=new nn({color:16777215}),this.maskBufferMaterial.side=2,this.renderTargetMaskBuffer=new Ct(this.resolution.x,this.resolution.y,i),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Hs,this.depthMaterial.side=2,this.depthMaterial.depthPacking=$,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 Ct(this.resolution.x,this.resolution.y,i),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new Ct(s,a,i),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Ct(s,a,i),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Ct(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 Ct(s,a,i),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Ct(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===Ep&&console.error("THREE.OutlinePass relies on CopyShader");const o=Ep;this.copyUniforms=Yn.clone(o.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new qn({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 en,this.oldClearAlpha=1,this.fsQuad=new wp(null),this.tempPulseColor1=new en,this.tempPulseColor2=new en,this.textureMatrix=new he}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=Ip.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=Ip.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=Ip.BlurDirectionX,t.setRenderTarget(this.renderTargetBlurBuffer2),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Ip.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 qn({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new vt(.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 qn({uniforms:{maskTexture:{value:null},texSize:{value:new vt(.5,.5)},visibleEdgeColor:{value:new Ft(1,1,1)},hiddenEdgeColor:{value:new Ft(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 qn({defines:{MAX_RADIUS:t},uniforms:{colorTexture:{value:null},texSize:{value:new vt(.5,.5)},direction:{value:new vt(.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 qn({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})}}Ip.BlurDirectionX=new vt(1,0),Ip.BlurDirectionY=new vt(0,1);class Fp extends xp{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 en,void 0===Ep&&console.error("THREE.SSAARenderPass relies on CopyShader");const i=Ep;this.copyUniforms=Yn.clone(i.uniforms),this.copyMaterial=new qn({uniforms:this.copyUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.fsQuad=new wp(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 Ct(n.width,n.height,{minFilter:_,magFilter:_,format:L}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");const r=Dp[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 Dp=[[[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]]],Np={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new en(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 Op extends xp{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 vt(t.x,t.y):new vt(256,256),this.clearColor=new en(0,0,0);const i={minFilter:_,magFilter:_,format:L};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 Ct(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 Ct(s,a,i);e.texture.name="UnrealBloomPass.h"+t,e.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e);const n=new Ct(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===Np&&console.error("THREE.UnrealBloomPass relies on LuminosityHighPassShader");const o=Np;this.highPassUniforms=Yn.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new qn({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 vt(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 Ft(1,1,1),new Ft(1,1,1),new Ft(1,1,1),new Ft(1,1,1),new Ft(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,void 0===Ep&&console.error("THREE.UnrealBloomPass relies on CopyShader");const c=Ep;this.copyUniforms=Yn.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new qn({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 en,this.oldClearAlpha=1,this.basic=new nn,this.fsQuad=new wp(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 vt(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=Op.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=Op.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 qn({defines:{KERNEL_RADIUS:t,SIGMA:t},uniforms:{colorTexture:{value:null},texSize:{value:new vt(.5,.5)},direction:{value:new vt(.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 qn({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}"})}}Op.BlurDirectionX=new vt(1,0),Op.BlurDirectionY=new vt(0,1);class Up extends xp{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 Bp extends xp{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class zp{constructor(t,e){if(this.renderer=t,void 0===e){const n={minFilter:_,magFilter:_,format:L},r=t.getSize(new vt);this._pixelRatio=t.getPixelRatio(),this._width=r.width,this._height=r.height,(e=new Ct(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===Ep&&console.error("THREE.EffectComposer relies on CopyShader"),void 0===Rp&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Rp(Ep),this.clock=new Jc}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!==Up&&(r instanceof Up?n=!0:r instanceof Bp&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new vt);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 _r(-1,1,1,-1,0,1);const kp=new Sn;kp.setAttribute("position",new mn([-1,3,0,-1,-1,0,3,-1,0],3)),kp.setAttribute("uv",new mn([0,2,0,0,2,0],2));const Hp={uniforms:{tDiffuse:{value:null},resolution:{value:new vt(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}'},Gp={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 jp{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 zp(this.renderer),this.effectComposer.addPass(new Lp(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 vt(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 ta({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=J,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 xd;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 Ed;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 Rd(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 Rp(Hp),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 Fp(this.scene,t,0,0);return e.unbiased=!0,e.sampleLevel=1,e}_initOutlinePass(t){return new Ip(new vt(window.innerWidth,window.innerHeight),this.scene,t)}_initSweepingLightShaderPass(){return new Rp(Gp)}_initUnrealBloomPass(){return new Op(new vt(this.getWidth(),this.getHeight()),0,.4,.85)}_initSAOPass(t){const e=new Cp(this.scene,t,!1,!0);return e.params.saoScale=368900,e}}const Vp=new he,Wp=(t,e)=>{const n=Vp.clone(),r=Vp.clone(),i=Vp.clone();n.makeRotationY(t),r.makeRotationX(e);const s=new _e;return i.multiplyMatrices(n,r),s.setFromRotationMatrix(i),s},Xp=Wp(-Math.PI/2,-Math.PI/4),Yp=Wp(Math.PI/2,-Math.PI/4),qp=Wp(-Math.PI/4,-Math.PI/4),Qp=Wp(Math.PI/4,-Math.PI/4),Zp=Wp(1.25*Math.PI,-Math.PI/4),Jp=Wp(.75*Math.PI,-Math.PI/4),Kp={LEFT:new _e(0,-Math.PI/2,0),RIGHT:new _e(0,Math.PI/2,0),FRONT:new _e(0,0,0),BACK:new _e(0,Math.PI,0),TOP:new _e(-Math.PI/2,0,0),BOTTOM:new _e(Math.PI/2,0,0),FRONTTOP:new _e(-Math.PI/4,0,0),BACKTOP:new _e(Math.PI/4,Math.PI,0),LEFTTOP:new _e(Xp.x,Xp.y,Xp.z),RIGHTTOP:new _e(Yp.x,Yp.y,Yp.z),LEFTFRONTTOP:new _e(qp.x,qp.y,qp.z),RIGHTFRONTTOP:new _e(Qp.x,Qp.y,Qp.z),LEFTBACKTOP:new _e(Zp.x,Zp.y,Zp.z),RIGHTBACKTOP:new _e(Jp.x,Jp.y,Jp.z)},$p=t=>Cu(t)?t:t.includes("%")?.01*Number(t.split("%")[0]):isNaN(+t)?0:Number(t),tf=new Zn(50,1,.1,5e5);tf.name="Camera",tf.position.set(500,1e3,500),tf.lookAt(new Ft);class ef{constructor(t){this.viewport=t,this.mainCamera=tf.clone(),this.currentCamera=this.mainCamera,this.cameras={}}createCamera(t){const e=tf.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 id(this.currentCamera.rotation,t,e)}moveTo(t,e){return id(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 _e;if(Eu(e)){const t=e.toLocaleUpperCase();"CURRENT"===t?i.copy(this.currentCamera.rotation):Kp[t]&&i.copy(Kp[t])}else e instanceof _e?i.copy(e):Du(e)&&i.set(e.x,e.y,e.z);return i.copy(vu(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(Eu(e)){if("CURRENT"===e.toLocaleUpperCase())return this.flyTo(this.getMovePosByBBox(t),e,n);{const r=Kp[e.toLocaleUpperCase()],i=this.getObjectLabelPos(t,r);return this.flyTo(i,e,n)}}{const r=fu(e),i=this.getObjectLabelPos(t,r);return this.flyTo(i,r,n)}}flyToObj(t,e="frontTop",n={}){if(t instanceof Mf||t instanceof Id){const{padding:r=50}=n,i=$p(r);return this.flyToBoundingBox(t.getBoundingBox(i),e,n)}{const{padding:r="30%"}=n,i=mu(t),s=i.getSize(new Ft);let a=0;if(Eu(r)){const t=Math.max(s.x,s.y,s.z);a=$p(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 Ft(o/2,l/2,o/2)),i.min.sub(new Ft(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=pu(t),a=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),o=Math.abs(r);return id({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 Ot(new Ft,new Ft).setFromObject(t).getCenter(new Ft);return this.surroundOnTarget(n,e)}getMovePosByBBox(t){const e=this.currentCamera.position,n=t.getCenter(new Ft);(new Ft).subVectors(n,e).normalize();let r=new ee;r=t.getBoundingSphere(r);let i=this.currentCamera.fov/2*Math.PI/180,s=Math.sin(i),a=r.radius/s,o=new Ft;this.currentCamera.getWorldDirection(o);let l=o.clone();return l.multiplyScalar(-a),n.clone().add(l)}getObjectLabelPos(t,e="frontTop",n={}){t instanceof ad&&(t=new Ot(new Ft,new Ft).setFromObject(t));const{extendScale:r=1.6,mode:i="scene"}=n;if("scene"===i){const n=t.getCenter(new Ft),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=Eu(e)?Kp[e.toLocaleUpperCase()]:fu(e),o(new Ft(0,0,1).applyEuler(l)),a}return"screen"===i?t.getCenter(new Ft):new Ft}}const nf=navigator.userAgent.toLowerCase().includes("mac");var rf;!function(t){t[t.NONE=-1]="NONE",t[t.ROTATE=0]="ROTATE",t[t.ZOOM=1]="ZOOM",t[t.PAN=2]="PAN"}(rf||(rf={}));const sf=new Ft,af=new vt,of=new vt,lf=[new Ft,new Ft,new Ft],cf=[new Ft,new Ft,new Ft];class hf{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=rf.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;af.set(n,r);const i=af.x-of.x,s=af.y-of.y;this.state===rf.ROTATE?this.rotate(new Ft(.00375*-i,.00375*-s,0)):this.state===rf.PAN&&this.pan(new Ft(-i,s,0)),of.set(n,r)},e=n=>{n.preventDefault(),this.domElement.removeEventListener("mousemove",t,!1),window.removeEventListener("mouseup",e,!0),this.state=rf.NONE},n=t=>{if(t.preventDefault(),!1!==this.enabled){switch(t.touches.length){case 1:lf[0].set(t.touches[0].pageX,t.touches[0].pageY,0),lf[1].set(t.touches[0].pageX,t.touches[0].pageY,0);var e=lf[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}(lf[0],cf));e.x=-e.x;const r=e.multiplyScalar(.9);this.pan(r);break;case 2:lf[0].set(t.touches[0].pageX,t.touches[0].pageY,0),lf[1].set(t.touches[1].pageX,t.touches[1].pageY,0);const i=cf[0].distanceTo(cf[1])-lf[0].distanceTo(lf[1]);this.zoom_touch(new Ft(0,0,i*this.zoomSpeed/25)),this.rotate(n(lf,cf,"x"));break;case 3:case 4:case 5:lf[0].set(t.touches[0].pageX,t.touches[0].pageY,0),lf[1].set(t.touches[2].pageX,t.touches[2].pageY,0),this.rotate(n(lf,cf,"y"))}cf[0].copy(lf[0]),cf[1].copy(lf[1])}function n(t,e,n="y"){const r=new vt(t[1].x-t[0].x,t[1].y-t[0].y),i=new vt(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 Ft(0,.005*o,0):"x"===n?new Ft(s-a,0,0):new Ft}},r=t=>{t.preventDefault(),this.state=rf.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=rf.ROTATE:1===n.button?this.state=rf.ZOOM:2===n.button&&(this.state=rf.PAN);const r=this.domElement.getBoundingClientRect(),i=n.pageX-r.left,s=n.pageY-r.top;of.set(i,s),this.state!==rf.ROTATE&&this.state!==rf.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=nf&&t.shiftKey?120*-t.deltaX:120*-t.deltaY,this.zoom_on_point(new Ft(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:lf[0].set(e[0].pageX,e[0].pageY,0),lf[1].set(e[0].pageX,e[0].pageY,0);break;case 2:lf[0].set(e[0].pageX,e[0].pageY,0),lf[1].set(e[1].pageX,e[1].pageY,0);break;case 3:case 4:case 5:lf[0].set(e[0].pageX,e[0].pageY,0),lf[1].set(e[2].pageX,e[2].pageY,0)}cf[0].copy(lf[0]),cf[1].copy(lf[1]),this.interactivePosition=this.getInteractivePosition({offsetX:(lf[0].x+lf[1].x)/2,offsetY:(lf[0].y+lf[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 Ft;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 Zn).copy(this.camera);return s.position.add(t),s.updateMatrixWorld(),s.updateProjectionMatrix(),(new or).setFromProjectionMatrix((new he).multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse)).intersectsBox(e)}caculateContainPoint(t,e){let n=(new Ft).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 Ft,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 Ft,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 Ft);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 Ft(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 Ft(0,0,0);let r;if(this.interactivePosition){const t=this.domElement.getBoundingClientRect(),e={offsetX:(cf[0].x+cf[1].x)/2,offsetY:(cf[0].y+cf[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 Ft(0,0,-1);e.applyQuaternion(this.camera.quaternion);const n=e.angleTo(new Ft(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 Ft);sf.copy(this.camera.position).sub(r);const i=new he;let s=new Ft(1,0,0);this.enableRotateX&&i.makeRotationAxis(new Ft(0,1,0),t.x);const a=new he;this.enableRotateY&&(s.applyEuler(this.camera.rotation),a.makeRotationAxis(s,t.y),i.multiply(a)),sf.applyMatrix4(i),e.applyMatrix4(i),this.camera.position.copy(r).add(sf),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 Ft(t*this.autoRotateSpeed,0,0))}update(){this.enableAutoRotate&&this.autoRotate()}getSceneBbox(){const t=this.viewport._getManagerScene("sbm"),e=this.viewport._getManagerScene("model"),n=new Ot;return t&&n.setFromObject(t),e&&n.union((new Ot).setFromObject(e)),n}}class uf{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 df={needRender:!1};let pf=0,ff=0;const mf=new Jc;class gf{constructor(t){this.options=t,this.state={useFreq:1,animationTotal:0},this.signals={windowResize:new gp,cameraObjectChange:new gp,sceneChanged:new gp,backgroundChanged:new gp,beforeRender:new gp,afterRender:new gp,sceneRendered:new gp,loadRendered:new gp,tweenUpdate:new gp,hover:new gp,click:new gp,dblClick:new gp,rightClick:new gp,mouseDown:new gp,mouseMove:new gp,mouseUp:new gp,mouseWheel:new gp,keyDown:new gp,keyUp:new gp,modelHover:new gp,modelUnHover:new gp,modelClick:new gp,modelDblClick:new gp,modelRightClick:new gp,poiHover:new gp,poiUnHover:new gp,poiClick:new gp,poiDblClick:new gp,poiRightClick:new gp,selectPosition:new gp,sceneClick:new gp,objectAdded:new gp,objectRemoved:new gp,objectChanged:new gp,geometryChanged:new gp,materialAdded:new gp,materialChanged:new gp,materialRemoved:new gp,cameraChange:new gp,outlineChange:new gp,modelAnimation:new gp,getSceneInfo:new gp},this.scener=new yp(this.signals),this.scene=this.scener.scene,this.rendererManager=new jp(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 uf(this.scene,this.signals),this.cameraManager=new ef(this),this.camera=this.cameraManager.currentCamera,this.controls=new hf(this,this.camera),this.effectComposer=this.rendererManager.initEffectComposer(this.camera),this.pass=this.rendererManager.initAllPass(this.camera),this.mixer=new Mh(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 mc).load(t,(t=>{t.mapping=h,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setSkyBackground(t,e){Mu(t,e).then((t=>{this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setBackgroundColor(t){this.renderer.setClearColor(t),this.scene.background=new en(t),this.signals.backgroundChanged.dispatch()}setBackgroundImage(t){(new mc).load(t,(t=>{t.wrapS=g,t.wrapT=g,t.encoding=J,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}playModelAnimation(t,e){let n;if(e instanceof ic?n=e:Cu(e)?n=t.animations[e]:Nu(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 ic?n=e:Cu(e)?n=t.animations[e]:Nu(e)&&(n=t.animations.find(e)),n&&(this.mixer.uncacheAction(n,t),this.state.animationTotal--)}render(t){return Fd(this,void 0,void 0,(function*(){return df.needRender=!0,yield null==t?void 0:t(),new Promise((t=>{const e=()=>{df.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&&!df.needRender)return;this.state.useFreq>0&&this.state.useFreq--,df.needRender&&(df.needRender=!1),pf=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(),ff=performance.now(),this.signals.sceneRendered.dispatch(ff-pf)}animate(t){this._loop=requestAnimationFrame((t=>{this.animate(t)}));const e=mf.getDelta();this.controls.update(),this.state.animationTotal>0&&(this.mixer.update(e),this.signals.modelAnimation.dispatch()),nd.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 Ft(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 Ft(0,0,0),r=new Ft(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 vt;r.set(n.offsetX/this.container.offsetWidth*2-1,-n.offsetY/this.container.offsetHeight*2+1);const i=new Eh;return i.setFromCamera(r,this.camera),Fu(e)?i.intersectObjects(e,!0):i.intersectObject(e,!0)}rayClash(t=this.camera.position,e=new Ft(0,-1,0),n=this.scener.intersectsList.meshOfModelList){const r=new Eh;return r.set(t,e),Fu(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((()=>{nd.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 Mf){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 Ne){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 vf={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class yf extends ad{constructor(t){super(t,"Sbm"),this.isEventPropagation=!1;const{onLoad:e,onClick:n,onDblClick:r,onRightClick:i}=Object.assign(Object.assign({},vf),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 Ot(new Ft,new Ft).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){Mu(t,e).then((t=>{this.traverse((e=>{if(e instanceof Gn&&e.material instanceof Bl){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,df.needRender=!0}}))}))}sClone(t){return new yf({id:`${this.sid}_clone`,url:""}).sCopy(this,t)}}const xf={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class _f extends ad{constructor(t){super(t,"Model");const{format:e,onLoad:n,onClick:r,onDblClick:i,onRightClick:s}=Object.assign(Object.assign({},xf),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 Ot(new Ft,new Ft).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){Mu(t,e).then((t=>{this.traverse((e=>{if(e instanceof Gn&&e.material instanceof Bl){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,df.needRender=!0}}))}))}sClone(t){return new _f({id:`${this.sid}_clone`,url:"",format:this.formatType}).sCopy(this,t)}}const bf={position:{x:0,y:0,z:0},scale:{x:16,y:16,z:1},stype:"Icon"};class wf extends wa{constructor(t,e){super(t);const{position:n,scale:r,stype:i}=Object.assign(Object.assign({},bf),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 Mf extends ad{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 Ft,n=new Ft,r=new Ft(t,t,t);return e.copy(this.position),n.copy(this.position),e.sub(r),n.add(r),new Ot(e,n)}eventPropagation(){this.isEventPropagation=!0}sClone(t){return new Mf(this.icon.material,{id:`${this.sid}_clone`,url:"",name:this.name}).sCopy(this,t)}_createIcon(t){const e=new wf(t);return this.add(e),e}_createText(t){const e=this._createCanvasText(t.name||""),n=new At(e);n.flipY=!0,n.version+=1;const r=new la({map:n,depthTest:!0});this.text=new wf(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 Sf extends sd{constructor(t,e="Point"){const{radius:n=10,color:r=255,opacity:i=1}=t;super(function(t){return new El(t,32,32)}(n),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&(this.geometry=new El(r,32,32)),i&&this.position.copy(pu(i)),s.version++,df.needRender=!0}}class Tf extends Sf{constructor(t){super(t,"Node"),this.graphs=t.graphs}}class Af extends sd{constructor(t){const{radius:e=50,color:n=65280,opacity:r=1}=t;super(function(t){return new po(t,64)}(e),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&(this.geometry=new po(r,64)),i&&this.position.copy(pu(i)),s.version++,df.needRender=!0}}class Ef extends sd{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=pu(e),u=pu(n),d=h.distanceTo(u);super(function(t,e,n,r=new Ft(0,1,0)){const i=n/2,s=new Ft,a=new Ft;s.subVectors(e,t),s.normalize(),a.crossVectors(s,r);const o=new Ft(a.x*i,a.y*i,a.z*i),l=new Ft(-a.x*i,-a.y*i,-a.z*i),c=new Ft;c.addVectors(t,o);const h=new Ft;h.addVectors(t,l);const u=new Ft;u.addVectors(e,l);const d=new Ft;d.addVectors(e,o);const p=new Sn;return p.setAttribute("position",new mn([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 mn([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 nn({color:n,side:2,transparent:!0,opacity:r});let o;return i&&(o=(new mc).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=f,o.wrapT=f,o.flipY=!0,o.matrixAutoUpdate=!0,Pu(s)&&s?id(o.offset,{y:-1,x:0},{repeat:!0,duration:500}):Du(s)&&id(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 Pf extends ad{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=Fu(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=Fu(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 Tf(Object.assign({},t));return this.add(e),e}createCircle(t){const e=new Af(Object.assign(Object.assign({},t),{rotation:{x:Math.PI/2,y:0,z:0}}));return this.add(e),e}createLink(t){const e=new Ef(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||pu(n.position).distanceTo(pu(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||pu(n.position).distanceTo(pu(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&&pu(r.position).distanceTo(pu(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&&pu(r.position).distanceTo(pu(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=Fu(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 Cf(t,e,n=new Ft(0,1,0)){const r=e/2,i=new Sn;let s=[],a=[];if(t.length<2)return i;for(let e=0;e<t.length-1;e++){const i=pu(t[e]),o=pu(t[e+1]),l=new Ft,c=new Ft;l.subVectors(o,i),l.normalize(),c.crossVectors(l,n);const h=new Ft(c.x*r,c.y*r,c.z*r),u=new Ft(-c.x*r,-c.y*r,-c.z*r),d=new Ft;d.addVectors(i,h);const p=new Ft;p.addVectors(i,u);const f=new Ft;f.addVectors(o,u);const m=new Ft;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 mn(s,3)),i.setAttribute("uv",new mn(a,2)),i}class Lf extends sd{constructor(t,e="Line"){const{points:n,width:r=20,color:i=65280,opacity:s=1}=t;super(Cf(n,r),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&i?this.geometry=Cf(r,i):r?this.geometry=Cf(r,this.params.width||20):i&&(this.geometry=Cf(this.points,i)),s.version++,df.needRender=!0}}function Rf(t){const e=[];for(let n=0;n<t.length;n++)e.push(new vt(t[n].x,t[n].z));return e.length>2?new Al(new Wo(e)):new Sn}class If extends sd{constructor(t,e="Polygon"){const{yHeight:n,points:r,color:i=16776960,opacity:s=1}=t;super(Rf(r),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&this.position.set(0,r,0),i&&(this.geometry=Rf(i)),s.version++,df.needRender=!0}}class Ff extends ad{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 Sf(t);return this.add(e),df.needRender=!0,e}getPoint(t){return this.getChildForType("Point",t)}removePoint(t){const e=this.getPoint(t);e&&this.remove(e),df.needRender=!0}createLine(t){const e=new Lf(t);return this.add(e),df.needRender=!0,e}getLine(t){return this.getChildForType("Line",t)}removeLine(t){const e=this.getLine(t);e&&this.remove(e),df.needRender=!0}createPolygon(t){const e=new If(t);return this.add(e),df.needRender=!0,e}getPolygon(t){return this.getChildForType("Polygon",t)}removePolygon(t){const e=this.getPolygon(t);e&&this.remove(e),df.needRender=!0}createCircle(t){const e=new Af(t);return this.add(e),df.needRender=!0,e}getCircle(t){return this.getChildForType("Circle",t)}removeCircle(t){const e=this.getCircle(t);e&&this.remove(e),df.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 Df extends sd{constructor(t,e,n){super(t,e,n,"Ground")}}var Nf=Object.freeze({__proto__:null,BaseObject3D:ad,BaseMesh:sd,SceneManage:od,Group:ld,PluginObject:cd,PoiNode:Id,Sbm:yf,Model:_f,Poi:Mf,Icon:wf,Topology:Pf,Point:Sf,Line:Lf,Polygon:If,Circle:Af,Node:Tf,Link:Ef,Canvas3D:Ff,Ground:Df});class Of{constructor(t,e){this.type=t,this.scene=new od({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 Id&&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 ad||t instanceof sd)&&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 ad&&Du(r)&&r.stype===this.type&&(Nu(t)&&t(r.userData)||Eu(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 ld(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 ld&&Du(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 ad||e instanceof sd)&&Du(e)&&e.stype===this.type||Du(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 ad||i instanceof sd)&&Du(i)&&i.stype===t&&i[e]===n||Du(i)&&i.userData.stype===t&&i.userData[e]===n)&&r.push(i)})),r):r}}class Uf extends Of{constructor(t){super("Light",t)}createAmbientLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1}=t,s=new Rc(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 en(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 Lc(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 en(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 vc(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 en(r),o.groundColor=new en(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=pu(a).distanceTo(pu(o)),h=new Mc(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=pu(a).distanceTo(pu(o));if(c.name=n||"",c.color=new en(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 Pc(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 en(r),o.intensity=i,o.distance=s,o.position.set(a.x,a.y,a.z),this.viewport.signals.objectChanged.dispatch(),!0)}}
|
|
34
|
+
***************************************************************************** */var Dd=function(t,e){return(Dd=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 Nd=function(){return(Nd=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 Od(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 Ud(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 Bd(t){return this instanceof Bd?(this.v=t,this):new Bd(t)}var zd=Object.freeze({__proto__:null,__extends:function(t,e){function n(){this.constructor=t}Dd(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},get __assign(){return Nd},__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:Od,__read:Ud,__spread:function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Ud(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:Bd,__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 Bd?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:Bd(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=Od(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}}),kd=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}(),Hd=Object.defineProperty({SlotList:kd},"__esModule",{value:!0}),Gd=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}(),jd=Object.defineProperty({Slot:Gd},"__esModule",{value:!0}),Vd=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.slots=Hd.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=Hd.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 jd.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}(),Wd=Object.defineProperty({OnceSignal:Vd},"__esModule",{value:!0}),Xd="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Yd(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 qd(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 Qd=Yd(zd),Zd=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qd.__extends(e,t),e.prototype.add=function(t){return this.registerListener(t)},e}(Wd.OnceSignal),Jd=Object.defineProperty({Signal:Zd},"__esModule",{value:!0}),Kd=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qd.__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 jd.Slot(t,this,e,n);return this.slots=this.slots.insertWithPriority(r),r}return this.slots.find(t)},e}(Jd.Signal),$d=Object.defineProperty({PrioritySignal:Kd},"__esModule",{value:!0}),tp=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 Qd.__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}($d.PrioritySignal),ep=Object.defineProperty({DeluxeSignal:tp},"__esModule",{value:!0}),np=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}(),rp=Object.defineProperty({GenericEvent:np},"__esModule",{value:!0}),ip=Symbol("IOnceSignal"),sp=Object.defineProperty({IOnceSignal:ip},"__esModule",{value:!0}),ap=Symbol("IPrioritySignal"),op=Object.defineProperty({IPrioritySignal:ap},"__esModule",{value:!0}),lp=Symbol("ISignal"),cp=Object.defineProperty({ISignal:lp},"__esModule",{value:!0}),hp=Symbol("ISlot"),up=Object.defineProperty({ISlot:hp},"__esModule",{value:!0}),dp=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 jd.Slot(t,this,e)},t}(),pp=Object.defineProperty({MonoSignal:dp},"__esModule",{value:!0}),fp=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Qd.__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}(Wd.OnceSignal),mp=Object.defineProperty({Promise:fp},"__esModule",{value:!0});ep.DeluxeSignal,rp.GenericEvent,sp.IOnceSignal,op.IPrioritySignal,cp.ISignal,up.ISlot,pp.MonoSignal,Wd.OnceSignal,$d.PrioritySignal,mp.Promise;var gp=Jd.Signal;jd.Slot,Hd.SlotList;const vp=new ia;vp.name="Scene";class yp{constructor(t){this.signals=t,this.scene=vp.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 Bl&&((e=t.map)&&e.isTexture&&e.dispose()),t.dispose()}t.traverse((t=>{if("Mesh"===t.type){const e=t;e.geometry.dispose(),Fu(e.material)?e.material.forEach((t=>n(t))):e.material instanceof Bl&&n(e.material)}t instanceof Id&&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 ra(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 Fu(t)?t.forEach((t=>r(t))):Du(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 Fu(t)?Promise.all(t.map((t=>e(t)))):Du(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 ld({id:t.sid});return t.traverse((t=>{if(t instanceof Gn&&t.geometry){const n=new wo(t.geometry.clone(),89),r=new $a(n,new Va({color:s,transparent:!0,opacity:a}));bu(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}),Fu(t)?Promise.all(t.map((t=>o(t)))):Du(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 Fu(t)?Promise.all(t.map((t=>e(t)))):Du(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 Gn&&(Fu(t.material)?t.material.forEach(((e,n)=>{t.material[n]=i(e)})):t.material instanceof qe&&(t.material=i(t.material)))})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(t)),Promise.resolve());return Fu(t)?Promise.all(t.map((t=>s(t)))):Du(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 Gn&&(Fu(t.material)?t.material.forEach(((n,r)=>{t.material[r]=e(n)})):t.material instanceof qe&&(t.material=e(t.material)))})),this.signals.materialChanged.dispatch(),n()}));return Fu(t)?Promise.all(t.map((t=>n(t)))):Du(t)?n(t):Promise.resolve()}highlightShow(t,e={}){const{color:n="red",opacity:r=1}=e;function i(t){if(t instanceof Bl||t instanceof Ol){if(t.userData.color&&t.userData.opacity)return;t.userData={color:t.color.clone(),opacity:t.opacity,transparent:t.transparent},t.color=new en(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 Gn&&(Fu(t.material)?t.material.forEach((t=>i(t))):t.material instanceof qe&&i(t.material))})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(t)),Promise.resolve());return Fu(t)?Promise.all(t.map((t=>s(t)))):Du(t)?s(t):Promise.resolve()}unHighlightShow(t){function e(t){if(t instanceof Bl||t instanceof Ol){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 Gn&&(Fu(t.material)?t.material.forEach((t=>e(t))):t.material instanceof qe&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Fu(t)?Promise.all(t.map((t=>n(t)))):Du(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 Bl||t instanceof Ol){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,id({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 Gn&&(Fu(t.material)?t.material.forEach((t=>o(t))):t.material instanceof qe&&o(t.material))})),this.selectedObjects.emissive.push(t),this.signals.materialChanged.dispatch()),Promise.resolve());return Fu(t)?Promise.all(t.map((t=>l(t)))):Du(t)?l(t):Promise.resolve()}unEmissiveShow(t){function e(t){var e;if(t instanceof Bl||t instanceof Ol){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 Gn&&(Fu(t.material)?t.material.forEach((t=>e(t))):t.material instanceof qe&&e(t.material))})),this.signals.materialChanged.dispatch(),n()}));return Fu(t)?Promise.all(t.map((t=>n(t)))):Du(t)?n(t):Promise.resolve()}_triggerObjectAdded(t){if(t instanceof ad)if("Sbm"===t.stype||"Model"===t.stype)t.traverse((t=>{if(t instanceof Gn){-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 Gn){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}));else if(t instanceof sd){-1===this.intersectsList.otherObjList.findIndex((e=>e.uuid===t.uuid))&&this.intersectsList.otherObjList.push(t)}}}class xp{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 _p=new _r(-1,1,1,-1,0,1),bp=new Sn;bp.setAttribute("position",new mn([-1,3,0,-1,-1,0,3,-1,0],3)),bp.setAttribute("uv",new mn([0,2,0,0,2,0],2));class wp{constructor(t){this._mesh=new Gn(bp,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,_p)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}const Mp={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 vt(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new he},cameraInverseProjectionMatrix:{value:new he},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}"},Sp={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new vt(512,512)},sampleUvOffsets:{value:[new vt(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}"},Tp={createSampleWeights:function(t,e){const n=[];for(let r=0;r<=t;r++)n.push(Ap(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=Tp.createSampleOffsets(e,r),t.uniforms.sampleWeights.value=Tp.createSampleWeights(e,n),t.needsUpdate=!0}};function Ap(t,e){return Math.exp(-t*t/(e*e*2))/(Math.sqrt(2*Math.PI)*e)}var Ep={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 Pp={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 Cp extends xp{constructor(t,e,n=!1,r=!1,i=new vt(256,256)){let o;super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=r,this.originalClearColor=new en,this._oldClearColor=new en,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 vt(i.x,i.y),this.saoRenderTarget=new Ct(this.resolution.x,this.resolution.y,{minFilter:_,magFilter:_,format:L}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new Ct(this.resolution.x,this.resolution.y,{minFilter:v,magFilter:v,format:L}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(o=new Js,o.type=S,this.beautyRenderTarget.depthTexture=o,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Hs,this.depthMaterial.depthPacking=$,this.depthMaterial.blending=0,this.normalMaterial=new kl,this.normalMaterial.blending=0,void 0===Mp&&console.error("THREE.SAOPass relies on SAOShader"),this.saoMaterial=new qn({defines:Object.assign({},Mp.defines),fragmentShader:Mp.fragmentShader,vertexShader:Mp.vertexShader,uniforms:Yn.clone(Mp.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?o: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===Sp&&console.error("THREE.SAOPass relies on DepthLimitedBlurShader"),this.vBlurMaterial=new qn({uniforms:Yn.clone(Sp.uniforms),defines:Object.assign({},Sp.defines),vertexShader:Sp.vertexShader,fragmentShader:Sp.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?o:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=0,this.hBlurMaterial=new qn({uniforms:Yn.clone(Sp.uniforms),defines:Object.assign({},Sp.defines),vertexShader:Sp.vertexShader,fragmentShader:Sp.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?o:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=0,void 0===Ep&&console.error("THREE.SAOPass relies on CopyShader"),this.materialCopy=new qn({uniforms:Yn.clone(Ep.uniforms),vertexShader:Ep.vertexShader,fragmentShader:Ep.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=a,this.materialCopy.blendEquation=s,this.materialCopy.blendSrcAlpha=206,this.materialCopy.blendDstAlpha=a,this.materialCopy.blendEquationAlpha=s,void 0===Pp&&console.error("THREE.SAOPass relies on UnpackDepthRGBAShader"),this.depthCopy=new qn({uniforms:Yn.clone(Pp.uniforms),vertexShader:Pp.vertexShader,fragmentShader:Pp.fragmentShader,blending:0}),this.fsQuad=new wp(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||(Tp.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new vt(0,1)),Tp.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new vt(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}}Cp.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};class Lp extends xp{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 en}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 Rp extends xp{constructor(t,e){super(),this.textureID=void 0!==e?e:"tDiffuse",t instanceof qn?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=Yn.clone(t.uniforms),this.material=new qn({defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new wp(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 Ip extends xp{constructor(t,e,n,r){super(),this.renderScene=e,this.renderCamera=n,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new en(1,1,1),this.hiddenEdgeColor=new en(.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 vt(t.x,t.y):new vt(256,256);const i={minFilter:_,magFilter:_,format:L},s=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.maskBufferMaterial=new nn({color:16777215}),this.maskBufferMaterial.side=2,this.renderTargetMaskBuffer=new Ct(this.resolution.x,this.resolution.y,i),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new Hs,this.depthMaterial.side=2,this.depthMaterial.depthPacking=$,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 Ct(this.resolution.x,this.resolution.y,i),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new Ct(s,a,i),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Ct(s,a,i),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Ct(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 Ct(s,a,i),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Ct(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===Ep&&console.error("THREE.OutlinePass relies on CopyShader");const o=Ep;this.copyUniforms=Yn.clone(o.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new qn({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 en,this.oldClearAlpha=1,this.fsQuad=new wp(null),this.tempPulseColor1=new en,this.tempPulseColor2=new en,this.textureMatrix=new he}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=Ip.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=Ip.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=Ip.BlurDirectionX,t.setRenderTarget(this.renderTargetBlurBuffer2),t.clear(),this.fsQuad.render(t),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Ip.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 qn({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new vt(.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 qn({uniforms:{maskTexture:{value:null},texSize:{value:new vt(.5,.5)},visibleEdgeColor:{value:new Ft(1,1,1)},hiddenEdgeColor:{value:new Ft(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 qn({defines:{MAX_RADIUS:t},uniforms:{colorTexture:{value:null},texSize:{value:new vt(.5,.5)},direction:{value:new vt(.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 qn({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})}}Ip.BlurDirectionX=new vt(1,0),Ip.BlurDirectionY=new vt(0,1);class Fp extends xp{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 en,void 0===Ep&&console.error("THREE.SSAARenderPass relies on CopyShader");const i=Ep;this.copyUniforms=Yn.clone(i.uniforms),this.copyMaterial=new qn({uniforms:this.copyUniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.fsQuad=new wp(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 Ct(n.width,n.height,{minFilter:_,magFilter:_,format:L}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");const r=Dp[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 Dp=[[[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]]],Np={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new en(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 Op extends xp{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 vt(t.x,t.y):new vt(256,256),this.clearColor=new en(0,0,0);const i={minFilter:_,magFilter:_,format:L};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 Ct(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 Ct(s,a,i);e.texture.name="UnrealBloomPass.h"+t,e.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e);const n=new Ct(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===Np&&console.error("THREE.UnrealBloomPass relies on LuminosityHighPassShader");const o=Np;this.highPassUniforms=Yn.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new qn({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 vt(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 Ft(1,1,1),new Ft(1,1,1),new Ft(1,1,1),new Ft(1,1,1),new Ft(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,void 0===Ep&&console.error("THREE.UnrealBloomPass relies on CopyShader");const c=Ep;this.copyUniforms=Yn.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new qn({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 en,this.oldClearAlpha=1,this.basic=new nn,this.fsQuad=new wp(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 vt(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=Op.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=Op.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 qn({defines:{KERNEL_RADIUS:t,SIGMA:t},uniforms:{colorTexture:{value:null},texSize:{value:new vt(.5,.5)},direction:{value:new vt(.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 qn({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}"})}}Op.BlurDirectionX=new vt(1,0),Op.BlurDirectionY=new vt(0,1);class Up extends xp{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 Bp extends xp{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class zp{constructor(t,e){if(this.renderer=t,void 0===e){const n={minFilter:_,magFilter:_,format:L},r=t.getSize(new vt);this._pixelRatio=t.getPixelRatio(),this._width=r.width,this._height=r.height,(e=new Ct(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===Ep&&console.error("THREE.EffectComposer relies on CopyShader"),void 0===Rp&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Rp(Ep),this.clock=new Jc}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!==Up&&(r instanceof Up?n=!0:r instanceof Bp&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(void 0===t){const e=this.renderer.getSize(new vt);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 _r(-1,1,1,-1,0,1);const kp=new Sn;kp.setAttribute("position",new mn([-1,3,0,-1,-1,0,3,-1,0],3)),kp.setAttribute("uv",new mn([0,2,0,0,2,0],2));const Hp={uniforms:{tDiffuse:{value:null},resolution:{value:new vt(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}'},Gp={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 jp{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 zp(this.renderer),this.effectComposer.addPass(new Lp(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 vt(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 ta({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=J,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 xd;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 Ed;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 Rd(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 Rp(Hp),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 Fp(this.scene,t,0,0);return e.unbiased=!0,e.sampleLevel=1,e}_initOutlinePass(t){return new Ip(new vt(window.innerWidth,window.innerHeight),this.scene,t)}_initSweepingLightShaderPass(){return new Rp(Gp)}_initUnrealBloomPass(){return new Op(new vt(this.getWidth(),this.getHeight()),0,.4,.85)}_initSAOPass(t){const e=new Cp(this.scene,t,!1,!0);return e.params.saoScale=368900,e}}const Vp=new he,Wp=(t,e)=>{const n=Vp.clone(),r=Vp.clone(),i=Vp.clone();n.makeRotationY(t),r.makeRotationX(e);const s=new _e;return i.multiplyMatrices(n,r),s.setFromRotationMatrix(i),s},Xp=Wp(-Math.PI/2,-Math.PI/4),Yp=Wp(Math.PI/2,-Math.PI/4),qp=Wp(-Math.PI/4,-Math.PI/4),Qp=Wp(Math.PI/4,-Math.PI/4),Zp=Wp(1.25*Math.PI,-Math.PI/4),Jp=Wp(.75*Math.PI,-Math.PI/4),Kp={LEFT:new _e(0,-Math.PI/2,0),RIGHT:new _e(0,Math.PI/2,0),FRONT:new _e(0,0,0),BACK:new _e(0,Math.PI,0),TOP:new _e(-Math.PI/2,0,0),BOTTOM:new _e(Math.PI/2,0,0),FRONTTOP:new _e(-Math.PI/4,0,0),BACKTOP:new _e(Math.PI/4,Math.PI,0),LEFTTOP:new _e(Xp.x,Xp.y,Xp.z),RIGHTTOP:new _e(Yp.x,Yp.y,Yp.z),LEFTFRONTTOP:new _e(qp.x,qp.y,qp.z),RIGHTFRONTTOP:new _e(Qp.x,Qp.y,Qp.z),LEFTBACKTOP:new _e(Zp.x,Zp.y,Zp.z),RIGHTBACKTOP:new _e(Jp.x,Jp.y,Jp.z)},$p=t=>Cu(t)?t:t.includes("%")?.01*Number(t.split("%")[0]):isNaN(+t)?0:Number(t),tf=new Zn(50,1,.1,5e5);tf.name="Camera",tf.position.set(500,1e3,500),tf.lookAt(new Ft);class ef{constructor(t){this.viewport=t,this.mainCamera=tf.clone(),this.currentCamera=this.mainCamera,this.cameras={}}createCamera(t){const e=tf.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 id(this.currentCamera.rotation,t,e)}moveTo(t,e){return id(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 _e;if(Eu(e)){const t=e.toLocaleUpperCase();"CURRENT"===t?i.copy(this.currentCamera.rotation):Kp[t]&&i.copy(Kp[t])}else e instanceof _e?i.copy(e):Du(e)&&i.set(e.x,e.y,e.z);return i.copy(vu(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(Eu(e)){if("CURRENT"===e.toLocaleUpperCase())return this.flyTo(this.getMovePosByBBox(t),e,n);{const r=Kp[e.toLocaleUpperCase()],i=this.getObjectLabelPos(t,r);return this.flyTo(i,e,n)}}{const r=fu(e),i=this.getObjectLabelPos(t,r);return this.flyTo(i,r,n)}}flyToObj(t,e="frontTop",n={}){if(t instanceof wf||t instanceof Id){const{padding:r=50}=n,i=$p(r);return this.flyToBoundingBox(t.getBoundingBox(i),e,n)}{const{padding:r="30%"}=n,i=mu(t),s=i.getSize(new Ft);let a=0;if(Eu(r)){const t=Math.max(s.x,s.y,s.z);a=$p(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 Ft(o/2,l/2,o/2)),i.min.sub(new Ft(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=pu(t),a=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),o=Math.abs(r);return id({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 Ot(new Ft,new Ft).setFromObject(t).getCenter(new Ft);return this.surroundOnTarget(n,e)}getMovePosByBBox(t){const e=this.currentCamera.position,n=t.getCenter(new Ft);(new Ft).subVectors(n,e).normalize();let r=new ee;r=t.getBoundingSphere(r);let i=this.currentCamera.fov/2*Math.PI/180,s=Math.sin(i),a=r.radius/s,o=new Ft;this.currentCamera.getWorldDirection(o);let l=o.clone();return l.multiplyScalar(-a),n.clone().add(l)}getObjectLabelPos(t,e="frontTop",n={}){t instanceof ad&&(t=new Ot(new Ft,new Ft).setFromObject(t));const{extendScale:r=1.6,mode:i="scene"}=n;if("scene"===i){const n=t.getCenter(new Ft),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=Eu(e)?Kp[e.toLocaleUpperCase()]:fu(e),o(new Ft(0,0,1).applyEuler(l)),a}return"screen"===i?t.getCenter(new Ft):new Ft}}const nf=navigator.userAgent.toLowerCase().includes("mac");var rf;!function(t){t[t.NONE=-1]="NONE",t[t.ROTATE=0]="ROTATE",t[t.ZOOM=1]="ZOOM",t[t.PAN=2]="PAN"}(rf||(rf={}));const sf=new Ft,af=[new Ft,new Ft,new Ft],of=[new Ft,new Ft,new Ft];let lf=new DOMRect;class cf{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=rf.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{movementX:e,movementY:n}=t;this.state===rf.ROTATE?this.rotate(new Ft(.00375*-e,.00375*-n,0)):this.state===rf.PAN&&this.pan(new Ft(-e,n,0))},e=n=>{n.preventDefault(),this.domElement.removeEventListener("mousemove",t,!1),window.removeEventListener("mouseup",e,!0),this.state=rf.NONE},n=t=>{if(t.preventDefault(),!1===this.enabled)return;function e(t,e,n="y"){const r=new vt(t[1].x-t[0].x,t[1].y-t[0].y),i=new vt(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 Ft(0,.005*o,0):"x"===n?new Ft(s-a,0,0):new Ft}switch(t.touches.length){case 1:af[0].set(t.touches[0].pageX-lf.x,t.touches[0].pageY-lf.y,0),af[1].set(t.touches[0].pageX-lf.x,t.touches[0].pageY-lf.y,0);var n=af[0].clone().sub(((t,e)=>{let n=e[0];for(let r in e)n.distanceTo(t)>e[r].distanceTo(t)&&(n=e[r]);return n})(af[0],of));n.x=-n.x;const r=n.multiplyScalar(.9);this.pan(r);break;case 2:af[0].set(t.touches[0].pageX-lf.x,t.touches[0].pageY-lf.y,0),af[1].set(t.touches[1].pageX-lf.x,t.touches[1].pageY-lf.y,0);const i=of[0].distanceTo(of[1])-af[0].distanceTo(af[1]);this.zoom_touch(new Ft(0,0,i*this.zoomSpeed/25)),this.rotate(e(af,of,"x"));break;case 3:case 4:case 5:af[0].set(t.touches[0].pageX-lf.x,t.touches[0].pageY-lf.y,0),af[1].set(t.touches[2].pageX-lf.x,t.touches[2].pageY-lf.y,0),this.rotate(e(af,of,"y"))}of[0].copy(af[0]),of[1].copy(af[1])},r=t=>{t.preventDefault(),this.state=rf.NONE,this.domElement.removeEventListener("touchmove",n,!1),this.domElement.removeEventListener("touchend",r,!1)};this.domElement.addEventListener("mousedown",(n=>{n.preventDefault(),!1!==this.enabled&&(0===n.button?this.state=rf.ROTATE:1===n.button?this.state=rf.ZOOM:2===n.button&&(this.state=rf.PAN),lf=this.domElement.getBoundingClientRect(),this.state!==rf.ROTATE&&this.state!==rf.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=nf&&t.shiftKey?120*-t.deltaX:120*-t.deltaY,this.zoom_on_point(new Ft(0,0,e),t)}),!1),this.domElement.addEventListener("touchstart",(t=>{if(t.preventDefault(),!1===this.enabled)return;lf=this.domElement.getBoundingClientRect();const e=t.touches;switch(e.length){case 1:af[0].set(e[0].pageX,e[0].pageY,0),af[1].set(e[0].pageX,e[0].pageY,0);break;case 2:af[0].set(e[0].pageX,e[0].pageY,0),af[1].set(e[1].pageX,e[1].pageY,0);break;case 3:case 4:case 5:af[0].set(e[0].pageX,e[0].pageY,0),af[1].set(e[2].pageX,e[2].pageY,0)}const i=new Ft(lf.x,lf.y,0);af[0].sub(i),af[1].sub(i),of[0].copy(af[0]),of[1].copy(af[1]),this.interactivePosition=this.getInteractivePosition({offsetX:(af[0].x+af[1].x)/2,offsetY:(af[0].y+af[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 Ft;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 Zn).copy(this.camera);return s.position.add(t),s.updateMatrixWorld(),s.updateProjectionMatrix(),(new or).setFromProjectionMatrix((new he).multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse)).intersectsBox(e)}caculateContainPoint(t,e){let n=(new Ft).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 Ft,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 Ft,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 Ft);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 Ft(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 Ft(0,0,0);let r;if(this.interactivePosition){const t={offsetX:(of[0].x+of[1].x)/2,offsetY:(of[0].y+of[1].y)/2};r=this.interactivePosition.distanceTo(this.camera.position),n.set(t.offsetX/lf.width*2-1,-t.offsetY/lf.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 Ft(0,0,-1);e.applyQuaternion(this.camera.quaternion);const n=e.angleTo(new Ft(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 Ft);sf.copy(this.camera.position).sub(r);const i=new he;let s=new Ft(1,0,0);this.enableRotateX&&i.makeRotationAxis(new Ft(0,1,0),t.x);const a=new he;this.enableRotateY&&(s.applyEuler(this.camera.rotation),a.makeRotationAxis(s,t.y),i.multiply(a)),sf.applyMatrix4(i),e.applyMatrix4(i),this.camera.position.copy(r).add(sf),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 Ft(t*this.autoRotateSpeed,0,0))}update(){this.enableAutoRotate&&this.autoRotate()}getSceneBbox(){const t=this.viewport._getManagerScene("sbm"),e=this.viewport._getManagerScene("model"),n=new Ot;return t&&n.setFromObject(t),e&&n.union((new Ot).setFromObject(e)),n}}class hf{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 uf={needRender:!1};let df=0,pf=0;const ff=new Jc;class mf{constructor(t){this.options=t,this.state={useFreq:1,animationTotal:0},this.signals={windowResize:new gp,cameraObjectChange:new gp,sceneChanged:new gp,backgroundChanged:new gp,beforeRender:new gp,afterRender:new gp,sceneRendered:new gp,loadRendered:new gp,tweenUpdate:new gp,hover:new gp,click:new gp,dblClick:new gp,rightClick:new gp,mouseDown:new gp,mouseMove:new gp,mouseUp:new gp,mouseWheel:new gp,keyDown:new gp,keyUp:new gp,modelHover:new gp,modelUnHover:new gp,modelClick:new gp,modelDblClick:new gp,modelRightClick:new gp,poiHover:new gp,poiUnHover:new gp,poiClick:new gp,poiDblClick:new gp,poiRightClick:new gp,selectPosition:new gp,sceneClick:new gp,objectAdded:new gp,objectRemoved:new gp,objectChanged:new gp,geometryChanged:new gp,materialAdded:new gp,materialChanged:new gp,materialRemoved:new gp,cameraChange:new gp,outlineChange:new gp,modelAnimation:new gp,getSceneInfo:new gp},this.scener=new yp(this.signals),this.scene=this.scener.scene,this.rendererManager=new jp(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 hf(this.scene,this.signals),this.cameraManager=new ef(this),this.camera=this.cameraManager.currentCamera,this.controls=new cf(this,this.camera),this.effectComposer=this.rendererManager.initEffectComposer(this.camera),this.pass=this.rendererManager.initAllPass(this.camera),this.mixer=new Mh(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 mc).load(t,(t=>{t.mapping=h,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setSkyBackground(t,e){Mu(t,e).then((t=>{this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}setBackgroundColor(t){this.renderer.setClearColor(t),this.scene.background=new en(t),this.signals.backgroundChanged.dispatch()}setBackgroundImage(t){(new mc).load(t,(t=>{t.wrapS=g,t.wrapT=g,t.encoding=J,this.scene.background=t,this.signals.backgroundChanged.dispatch()}))}playModelAnimation(t,e){let n;if(e instanceof ic?n=e:Cu(e)?n=t.animations[e]:Nu(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 ic?n=e:Cu(e)?n=t.animations[e]:Nu(e)&&(n=t.animations.find(e)),n&&(this.mixer.uncacheAction(n,t),this.state.animationTotal--)}render(t){return Fd(this,void 0,void 0,(function*(){return uf.needRender=!0,yield null==t?void 0:t(),new Promise((t=>{const e=()=>{uf.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&&!uf.needRender)return;this.state.useFreq>0&&this.state.useFreq--,uf.needRender&&(uf.needRender=!1),df=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(),pf=performance.now(),this.signals.sceneRendered.dispatch(pf-df)}animate(t){this._loop=requestAnimationFrame((t=>{this.animate(t)}));const e=ff.getDelta();this.controls.update(),this.state.animationTotal>0&&(this.mixer.update(e),this.signals.modelAnimation.dispatch()),nd.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 Ft(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 Ft(0,0,0),r=new Ft(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 vt;r.set(n.offsetX/this.container.offsetWidth*2-1,-n.offsetY/this.container.offsetHeight*2+1);const i=new Eh;return i.setFromCamera(r,this.camera),Fu(e)?i.intersectObjects(e,!0):i.intersectObject(e,!0)}rayClash(t=this.camera.position,e=new Ft(0,-1,0),n=this.scener.intersectsList.meshOfModelList){const r=new Eh;return r.set(t,e),Fu(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((()=>{nd.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 wf){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 Ne){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 gf={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class vf extends ad{constructor(t){super(t,"Sbm"),this.isEventPropagation=!1;const{onLoad:e,onClick:n,onDblClick:r,onRightClick:i}=Object.assign(Object.assign({},gf),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 Ot(new Ft,new Ft).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){Mu(t,e).then((t=>{this.traverse((e=>{if(e instanceof Gn&&e.material instanceof Bl){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,uf.needRender=!0}}))}))}sClone(t){return new vf({id:`${this.sid}_clone`,url:""}).sCopy(this,t)}}const yf={onLoad:null,onClick:null,onDblClick:null,onRightClick:null};class xf extends ad{constructor(t){super(t,"Model");const{format:e,onLoad:n,onClick:r,onDblClick:i,onRightClick:s}=Object.assign(Object.assign({},yf),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 Ot(new Ft,new Ft).setFromObject(this)}eventPropagation(){this.isEventPropagation=!0}setEnvMap(t,e,n={}){Mu(t,e).then((t=>{this.traverse((e=>{if(e instanceof Gn&&e.material instanceof Bl){const{reflectivity:r=.5}=n;e.material.envMap=t,e.material.reflectivity=r,uf.needRender=!0}}))}))}sClone(t){return new xf({id:`${this.sid}_clone`,url:"",format:this.formatType}).sCopy(this,t)}}const _f={position:{x:0,y:0,z:0},scale:{x:16,y:16,z:1},stype:"Icon"};class bf extends wa{constructor(t,e){super(t);const{position:n,scale:r,stype:i}=Object.assign(Object.assign({},_f),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 wf extends ad{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 Ft,n=new Ft,r=new Ft(t,t,t);return e.copy(this.position),n.copy(this.position),e.sub(r),n.add(r),new Ot(e,n)}eventPropagation(){this.isEventPropagation=!0}sClone(t){return new wf(this.icon.material,{id:`${this.sid}_clone`,url:"",name:this.name}).sCopy(this,t)}_createIcon(t){const e=new bf(t);return this.add(e),e}_createText(t){const e=this._createCanvasText(t.name||""),n=new At(e);n.flipY=!0,n.version+=1;const r=new la({map:n,depthTest:!0});this.text=new bf(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 Mf extends sd{constructor(t,e="Point"){const{radius:n=10,color:r=255,opacity:i=1}=t;super(function(t){return new El(t,32,32)}(n),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&(this.geometry=new El(r,32,32)),i&&this.position.copy(pu(i)),s.version++,uf.needRender=!0}}class Sf extends Mf{constructor(t){super(t,"Node"),this.graphs=t.graphs}}class Tf extends sd{constructor(t){const{radius:e=50,color:n=65280,opacity:r=1}=t;super(function(t){return new po(t,64)}(e),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&(this.geometry=new po(r,64)),i&&this.position.copy(pu(i)),s.version++,uf.needRender=!0}}class Af extends sd{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=pu(e),u=pu(n),d=h.distanceTo(u);super(function(t,e,n,r=new Ft(0,1,0)){const i=n/2,s=new Ft,a=new Ft;s.subVectors(e,t),s.normalize(),a.crossVectors(s,r);const o=new Ft(a.x*i,a.y*i,a.z*i),l=new Ft(-a.x*i,-a.y*i,-a.z*i),c=new Ft;c.addVectors(t,o);const h=new Ft;h.addVectors(t,l);const u=new Ft;u.addVectors(e,l);const d=new Ft;d.addVectors(e,o);const p=new Sn;return p.setAttribute("position",new mn([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 mn([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 nn({color:n,side:2,transparent:!0,opacity:r});let o;return i&&(o=(new mc).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=f,o.wrapT=f,o.flipY=!0,o.matrixAutoUpdate=!0,Pu(s)&&s?id(o.offset,{y:-1,x:0},{repeat:!0,duration:500}):Du(s)&&id(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 Ef extends ad{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=Fu(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=Fu(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 Sf(Object.assign({},t));return this.add(e),e}createCircle(t){const e=new Tf(Object.assign(Object.assign({},t),{rotation:{x:Math.PI/2,y:0,z:0}}));return this.add(e),e}createLink(t){const e=new Af(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||pu(n.position).distanceTo(pu(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||pu(n.position).distanceTo(pu(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&&pu(r.position).distanceTo(pu(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&&pu(r.position).distanceTo(pu(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=Fu(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 Pf(t,e,n=new Ft(0,1,0)){const r=e/2,i=new Sn;let s=[],a=[];if(t.length<2)return i;for(let e=0;e<t.length-1;e++){const i=pu(t[e]),o=pu(t[e+1]),l=new Ft,c=new Ft;l.subVectors(o,i),l.normalize(),c.crossVectors(l,n);const h=new Ft(c.x*r,c.y*r,c.z*r),u=new Ft(-c.x*r,-c.y*r,-c.z*r),d=new Ft;d.addVectors(i,h);const p=new Ft;p.addVectors(i,u);const f=new Ft;f.addVectors(o,u);const m=new Ft;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 mn(s,3)),i.setAttribute("uv",new mn(a,2)),i}class Cf extends sd{constructor(t,e="Line"){const{points:n,width:r=20,color:i=65280,opacity:s=1}=t;super(Pf(n,r),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&i?this.geometry=Pf(r,i):r?this.geometry=Pf(r,this.params.width||20):i&&(this.geometry=Pf(this.points,i)),s.version++,uf.needRender=!0}}function Lf(t){const e=[];for(let n=0;n<t.length;n++)e.push(new vt(t[n].x,t[n].z));return e.length>2?new Al(new Wo(e)):new Sn}class Rf extends sd{constructor(t,e="Polygon"){const{yHeight:n,points:r,color:i=16776960,opacity:s=1}=t;super(Lf(r),function(t,e){return new nn({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 en(e)),n&&(s.opacity=n),r&&this.position.set(0,r,0),i&&(this.geometry=Lf(i)),s.version++,uf.needRender=!0}}class If extends ad{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 Mf(t);return this.add(e),uf.needRender=!0,e}getPoint(t){return this.getChildForType("Point",t)}removePoint(t){const e=this.getPoint(t);e&&this.remove(e),uf.needRender=!0}createLine(t){const e=new Cf(t);return this.add(e),uf.needRender=!0,e}getLine(t){return this.getChildForType("Line",t)}removeLine(t){const e=this.getLine(t);e&&this.remove(e),uf.needRender=!0}createPolygon(t){const e=new Rf(t);return this.add(e),uf.needRender=!0,e}getPolygon(t){return this.getChildForType("Polygon",t)}removePolygon(t){const e=this.getPolygon(t);e&&this.remove(e),uf.needRender=!0}createCircle(t){const e=new Tf(t);return this.add(e),uf.needRender=!0,e}getCircle(t){return this.getChildForType("Circle",t)}removeCircle(t){const e=this.getCircle(t);e&&this.remove(e),uf.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 Ff extends sd{constructor(t,e,n){super(t,e,n,"Ground")}}var Df=Object.freeze({__proto__:null,BaseObject3D:ad,BaseMesh:sd,SceneManage:od,Group:ld,PluginObject:cd,PoiNode:Id,Sbm:vf,Model:xf,Poi:wf,Icon:bf,Topology:Ef,Point:Mf,Line:Cf,Polygon:Rf,Circle:Tf,Node:Sf,Link:Af,Canvas3D:If,Ground:Ff});class Nf{constructor(t,e){this.type=t,this.scene=new od({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 Id&&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 ad||t instanceof sd)&&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 ad&&Du(r)&&r.stype===this.type&&(Nu(t)&&t(r.userData)||Eu(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 ld(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 ld&&Du(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 ad||e instanceof sd)&&Du(e)&&e.stype===this.type||Du(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 ad||i instanceof sd)&&Du(i)&&i.stype===t&&i[e]===n||Du(i)&&i.userData.stype===t&&i.userData[e]===n)&&r.push(i)})),r):r}}class Of extends Nf{constructor(t){super("Light",t)}createAmbientLight(t){const{id:e,name:n,color:r=10132122,intensity:i=1}=t,s=new Rc(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 en(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 Lc(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 en(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 vc(r,i,s);return o.name=n||"",o.position.set(a.x,a.y,a.z),o.userData.sid=e,o.userData.stype="Light",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 en(r),o.groundColor=new en(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=pu(a).distanceTo(pu(o)),h=new Mc(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=pu(a).distanceTo(pu(o));if(c.name=n||"",c.color=new en(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 Pc(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 en(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
|
|
38
38
|
https://localforage.github.io/localForage
|
|
39
39
|
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
40
|
-
*/var Bf,zf=(function(t,e){t.exports=function t(e,n,r){function i(a,o){if(!n[a]){if(!e[a]){if(!o&&qd)return qd(a);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};e[a][0].call(c.exports,(function(t){var n=e[a][1][t];return i(n||t)}),c,c.exports,t,e,n,r)}return n[a].exports}for(var s=qd,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e,n){(function(t){var n,r,i=t.MutationObserver||t.WebKitMutationObserver;if(i){var s=0,a=new i(h),o=t.document.createTextNode("");a.observe(o,{characterData:!0}),n=function(){o.data=s=++s%2}}else if(t.setImmediate||void 0===t.MessageChannel)n="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){h(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(h,0)};else{var l=new t.MessageChannel;l.port1.onmessage=h,n=function(){l.port2.postMessage(0)}}var c=[];function h(){var t,e;r=!0;for(var n=c.length;n;){for(e=c,c=[],t=-1;++t<n;)e[t]();n=c.length}r=!1}function u(t){1!==c.push(t)||r||n()}e.exports=u}).call(this,void 0!==Xd?Xd:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,n){var r=t(1);function i(){}var s={},a=["REJECTED"],o=["FULFILLED"],l=["PENDING"];function c(t){if("function"!=typeof t)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,t!==i&&p(this,t)}function h(t,e,n){this.promise=t,"function"==typeof e&&(this.onFulfilled=e,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function u(t,e,n){r((function(){var r;try{r=e(n)}catch(e){return s.reject(t,e)}r===t?s.reject(t,new TypeError("Cannot resolve promise with itself")):s.resolve(t,r)}))}function d(t){var e=t&&t.then;if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof e)return function(){e.apply(t,arguments)}}function p(t,e){var n=!1;function r(e){n||(n=!0,s.reject(t,e))}function i(e){n||(n=!0,s.resolve(t,e))}function a(){e(i,r)}var o=f(a);"error"===o.status&&r(o.value)}function f(t,e){var n={};try{n.value=t(e),n.status="success"}catch(t){n.status="error",n.value=t}return n}function m(t){return t instanceof this?t:s.resolve(new this(i),t)}function g(t){var e=new this(i);return s.reject(e,t)}function v(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var n=t.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),o=0,l=-1,c=new this(i);++l<n;)h(t[l],l);return c;function h(t,i){function l(t){a[i]=t,++o!==n||r||(r=!0,s.resolve(c,a))}e.resolve(t).then(l,(function(t){r||(r=!0,s.reject(c,t))}))}}function y(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var n=t.length,r=!1;if(!n)return this.resolve([]);for(var a=-1,o=new this(i);++a<n;)l(t[a]);return o;function l(t){e.resolve(t).then((function(t){r||(r=!0,s.resolve(o,t))}),(function(t){r||(r=!0,s.reject(o,t))}))}}e.exports=c,c.prototype.catch=function(t){return this.then(null,t)},c.prototype.then=function(t,e){if("function"!=typeof t&&this.state===o||"function"!=typeof e&&this.state===a)return this;var n=new this.constructor(i);return this.state!==l?u(n,this.state===o?t:e,this.outcome):this.queue.push(new h(n,t,e)),n},h.prototype.callFulfilled=function(t){s.resolve(this.promise,t)},h.prototype.otherCallFulfilled=function(t){u(this.promise,this.onFulfilled,t)},h.prototype.callRejected=function(t){s.reject(this.promise,t)},h.prototype.otherCallRejected=function(t){u(this.promise,this.onRejected,t)},s.resolve=function(t,e){var n=f(d,e);if("error"===n.status)return s.reject(t,n.value);var r=n.value;if(r)p(t,r);else{t.state=o,t.outcome=e;for(var i=-1,a=t.queue.length;++i<a;)t.queue[i].callFulfilled(e)}return t},s.reject=function(t,e){t.state=a,t.outcome=e;for(var n=-1,r=t.queue.length;++n<r;)t.queue[n].callRejected(e);return t},c.resolve=m,c.reject=g,c.all=v,c.race=y},{1:1}],3:[function(t,e,n){(function(e){"function"!=typeof e.Promise&&(e.Promise=t(2))}).call(this,void 0!==Xd?Xd:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(t,e,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(t){return}}var a=s();function o(){try{if(!a||!a.open)return!1;var t="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),e="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!t||e)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(t){return!1}}function l(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<t.length;r+=1)n.append(t[r]);return n.getBlob(e.type)}}"undefined"==typeof Promise&&t(3);var c=Promise;function h(t,e){e&&t.then((function(t){e(null,t)}),(function(t){e(t)}))}function u(t,e,n){"function"==typeof e&&t.then(e),"function"==typeof n&&t.catch(n)}function d(t){return"string"!=typeof t&&(console.warn(t+" used as a key, but it is not a string."),t=String(t)),t}function p(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var f="local-forage-detect-blob-support",m=void 0,g={},v=Object.prototype.toString,y="readonly",x="readwrite";function _(t){for(var e=t.length,n=new ArrayBuffer(e),r=new Uint8Array(n),i=0;i<e;i++)r[i]=t.charCodeAt(i);return n}function b(t){return new c((function(e){var n=t.transaction(f,x),r=l([""]);n.objectStore(f).put(r,"key"),n.onabort=function(t){t.preventDefault(),t.stopPropagation(),e(!1)},n.oncomplete=function(){var t=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);e(n||!t||parseInt(t[1],10)>=43)}})).catch((function(){return!1}))}function w(t){return"boolean"==typeof m?c.resolve(m):b(t).then((function(t){return m=t}))}function M(t){var e=g[t.name],n={};n.promise=new c((function(t,e){n.resolve=t,n.reject=e})),e.deferredOperations.push(n),e.dbReady?e.dbReady=e.dbReady.then((function(){return n.promise})):e.dbReady=n.promise}function S(t){var e=g[t.name].deferredOperations.pop();if(e)return e.resolve(),e.promise}function T(t,e){var n=g[t.name].deferredOperations.pop();if(n)return n.reject(e),n.promise}function A(t,e){return new c((function(n,r){if(g[t.name]=g[t.name]||O(),t.db){if(!e)return n(t.db);M(t),t.db.close()}var i=[t.name];e&&i.push(t.version);var s=a.open.apply(a,i);e&&(s.onupgradeneeded=function(e){var n=s.result;try{n.createObjectStore(t.storeName),e.oldVersion<=1&&n.createObjectStore(f)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+t.name+'" has been upgraded from version '+e.oldVersion+" to version "+e.newVersion+', but the storage "'+t.storeName+'" already exists.')}}),s.onerror=function(t){t.preventDefault(),r(s.error)},s.onsuccess=function(){n(s.result),S(t)}}))}function E(t){return A(t,!1)}function P(t){return A(t,!0)}function C(t,e){if(!t.db)return!0;var n=!t.db.objectStoreNames.contains(t.storeName),r=t.version<t.db.version,i=t.version>t.db.version;if(r&&(t.version!==e&&console.warn('The database "'+t.name+"\" can't be downgraded from version "+t.db.version+" to version "+t.version+"."),t.version=t.db.version),i||n){if(n){var s=t.db.version+1;s>t.version&&(t.version=s)}return!0}return!1}function L(t){return new c((function(e,n){var r=new FileReader;r.onerror=n,r.onloadend=function(n){var r=btoa(n.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:t.type})},r.readAsBinaryString(t)}))}function R(t){return l([_(atob(t.data))],{type:t.type})}function I(t){return t&&t.__local_forage_encoded_blob}function F(t){var e=this,n=e._initReady().then((function(){var t=g[e._dbInfo.name];if(t&&t.dbReady)return t.dbReady}));return u(n,t,t),n}function D(t){M(t);for(var e=g[t.name],n=e.forages,r=0;r<n.length;r++){var i=n[r];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return t.db=null,E(t).then((function(e){return t.db=e,C(t)?P(t):e})).then((function(r){t.db=e.db=r;for(var i=0;i<n.length;i++)n[i]._dbInfo.db=r})).catch((function(e){throw T(t,e),e}))}function N(t,e,n,r){void 0===r&&(r=1);try{var i=t.db.transaction(t.storeName,e);n(null,i)}catch(i){if(r>0&&(!t.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return c.resolve().then((function(){if(!t.db||"NotFoundError"===i.name&&!t.db.objectStoreNames.contains(t.storeName)&&t.version<=t.db.version)return t.db&&(t.version=t.db.version+1),P(t)})).then((function(){return D(t).then((function(){N(t,e,n,r-1)}))})).catch(n);n(i)}}function O(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function U(t){var e=this,n={db:null};if(t)for(var r in t)n[r]=t[r];var i=g[n.name];i||(i=O(),g[n.name]=i),i.forages.push(e),e._initReady||(e._initReady=e.ready,e.ready=F);var s=[];function a(){return c.resolve()}for(var o=0;o<i.forages.length;o++){var l=i.forages[o];l!==e&&s.push(l._initReady().catch(a))}var h=i.forages.slice(0);return c.all(s).then((function(){return n.db=i.db,E(n)})).then((function(t){return n.db=t,C(n,e._defaultConfig.version)?P(n):t})).then((function(t){n.db=i.db=t,e._dbInfo=n;for(var r=0;r<h.length;r++){var s=h[r];s!==e&&(s._dbInfo.db=n.db,s._dbInfo.version=n.version)}}))}function B(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){N(n._dbInfo,y,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName).get(t);a.onsuccess=function(){var t=a.result;void 0===t&&(t=null),I(t)&&(t=R(t)),e(t)},a.onerror=function(){r(a.error)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function z(t,e){var n=this,r=new c((function(e,r){n.ready().then((function(){N(n._dbInfo,y,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName).openCursor(),o=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;I(r)&&(r=R(r));var i=t(r,n.key,o++);void 0!==i?e(i):n.continue()}else e()},a.onerror=function(){r(a.error)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function k(t,e,n){var r=this;t=d(t);var i=new c((function(n,i){var s;r.ready().then((function(){return s=r._dbInfo,"[object Blob]"===v.call(e)?w(s.db).then((function(t){return t?e:L(e)})):e})).then((function(e){N(r._dbInfo,x,(function(s,a){if(s)return i(s);try{var o=a.objectStore(r._dbInfo.storeName);null===e&&(e=void 0);var l=o.put(e,t);a.oncomplete=function(){void 0===e&&(e=null),n(e)},a.onabort=a.onerror=function(){var t=l.error?l.error:l.transaction.error;i(t)}}catch(t){i(t)}}))})).catch(i)}));return h(i,n),i}function H(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){N(n._dbInfo,x,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName).delete(t);s.oncomplete=function(){e()},s.onerror=function(){r(a.error)},s.onabort=function(){var t=a.error?a.error:a.transaction.error;r(t)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function G(t){var e=this,n=new c((function(t,n){e.ready().then((function(){N(e._dbInfo,x,(function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).clear();i.oncomplete=function(){t()},i.onabort=i.onerror=function(){var t=s.error?s.error:s.transaction.error;n(t)}}catch(t){n(t)}}))})).catch(n)}));return h(n,t),n}function j(t){var e=this,n=new c((function(t,n){e.ready().then((function(){N(e._dbInfo,y,(function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).count();s.onsuccess=function(){t(s.result)},s.onerror=function(){n(s.error)}}catch(t){n(t)}}))})).catch(n)}));return h(n,t),n}function V(t,e){var n=this,r=new c((function(e,r){t<0?e(null):n.ready().then((function(){N(n._dbInfo,y,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName),o=!1,l=a.openKeyCursor();l.onsuccess=function(){var n=l.result;n?0===t||o?e(n.key):(o=!0,n.advance(t)):e(null)},l.onerror=function(){r(l.error)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function W(t){var e=this,n=new c((function(t,n){e.ready().then((function(){N(e._dbInfo,y,(function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).openKeyCursor(),a=[];s.onsuccess=function(){var e=s.result;e?(a.push(e.key),e.continue()):t(a)},s.onerror=function(){n(s.error)}}catch(t){n(t)}}))})).catch(n)}));return h(n,t),n}function X(t,e){e=p.apply(this,arguments);var n=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||n.name,t.storeName=t.storeName||n.storeName);var r,i=this;if(t.name){var s=t.name===n.name&&i._dbInfo.db?c.resolve(i._dbInfo.db):E(t).then((function(e){var n=g[t.name],r=n.forages;n.db=e;for(var i=0;i<r.length;i++)r[i]._dbInfo.db=e;return e}));r=t.storeName?s.then((function(e){if(e.objectStoreNames.contains(t.storeName)){var n=e.version+1;M(t);var r=g[t.name],i=r.forages;e.close();for(var s=0;s<i.length;s++){var o=i[s];o._dbInfo.db=null,o._dbInfo.version=n}return new c((function(e,r){var i=a.open(t.name,n);i.onerror=function(t){i.result.close(),r(t)},i.onupgradeneeded=function(){i.result.deleteObjectStore(t.storeName)},i.onsuccess=function(){var t=i.result;t.close(),e(t)}})).then((function(t){r.db=t;for(var e=0;e<i.length;e++){var n=i[e];n._dbInfo.db=t,S(n._dbInfo)}})).catch((function(e){throw(T(t,e)||c.resolve()).catch((function(){})),e}))}})):s.then((function(e){M(t);var n=g[t.name],r=n.forages;e.close();for(var i=0;i<r.length;i++)r[i]._dbInfo.db=null;return new c((function(e,n){var r=a.deleteDatabase(t.name);r.onerror=r.onblocked=function(t){var e=r.result;e&&e.close(),n(t)},r.onsuccess=function(){var t=r.result;t&&t.close(),e(t)}})).then((function(t){n.db=t;for(var e=0;e<r.length;e++)S(r[e]._dbInfo)})).catch((function(e){throw(T(t,e)||c.resolve()).catch((function(){})),e}))}))}else r=c.reject("Invalid arguments");return h(r,e),r}var Y={_driver:"asyncStorage",_initStorage:U,_support:o(),iterate:z,getItem:B,setItem:k,removeItem:H,clear:G,length:j,key:V,keys:W,dropInstance:X};function q(){return"function"==typeof openDatabase}var Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Z="~~local_forage_type~",J=/^~~local_forage_type~([^~]+)~/,K="__lfsc__:",$=K.length,tt="arbf",et="blob",nt="si08",rt="ui08",it="uic8",st="si16",at="si32",ot="ur16",lt="ui32",ct="fl32",ht="fl64",ut=$+tt.length,dt=Object.prototype.toString;function pt(t){var e,n,r,i,s,a=.75*t.length,o=t.length,l=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var c=new ArrayBuffer(a),h=new Uint8Array(c);for(e=0;e<o;e+=4)n=Q.indexOf(t[e]),r=Q.indexOf(t[e+1]),i=Q.indexOf(t[e+2]),s=Q.indexOf(t[e+3]),h[l++]=n<<2|r>>4,h[l++]=(15&r)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return c}function ft(t){var e,n=new Uint8Array(t),r="";for(e=0;e<n.length;e+=3)r+=Q[n[e]>>2],r+=Q[(3&n[e])<<4|n[e+1]>>4],r+=Q[(15&n[e+1])<<2|n[e+2]>>6],r+=Q[63&n[e+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function mt(t,e){var n="";if(t&&(n=dt.call(t)),t&&("[object ArrayBuffer]"===n||t.buffer&&"[object ArrayBuffer]"===dt.call(t.buffer))){var r,i=K;t instanceof ArrayBuffer?(r=t,i+=tt):(r=t.buffer,"[object Int8Array]"===n?i+=nt:"[object Uint8Array]"===n?i+=rt:"[object Uint8ClampedArray]"===n?i+=it:"[object Int16Array]"===n?i+=st:"[object Uint16Array]"===n?i+=ot:"[object Int32Array]"===n?i+=at:"[object Uint32Array]"===n?i+=lt:"[object Float32Array]"===n?i+=ct:"[object Float64Array]"===n?i+=ht:e(new Error("Failed to get type for BinaryArray"))),e(i+ft(r))}else if("[object Blob]"===n){var s=new FileReader;s.onload=function(){var n=Z+t.type+"~"+ft(this.result);e(K+et+n)},s.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(n){console.error("Couldn't convert value into a JSON string: ",t),e(null,n)}}function gt(t){if(t.substring(0,$)!==K)return JSON.parse(t);var e,n=t.substring(ut),r=t.substring($,ut);if(r===et&&J.test(n)){var i=n.match(J);e=i[1],n=n.substring(i[0].length)}var s=pt(n);switch(r){case tt:return s;case et:return l([s],{type:e});case nt:return new Int8Array(s);case rt:return new Uint8Array(s);case it:return new Uint8ClampedArray(s);case st:return new Int16Array(s);case ot:return new Uint16Array(s);case at:return new Int32Array(s);case lt:return new Uint32Array(s);case ct:return new Float32Array(s);case ht:return new Float64Array(s);default:throw new Error("Unkown type: "+r)}}var vt={serialize:mt,deserialize:gt,stringToBuffer:pt,bufferToString:ft};function yt(t,e,n,r){t.executeSql("CREATE TABLE IF NOT EXISTS "+e.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function xt(t){var e=this,n={db:null};if(t)for(var r in t)n[r]="string"!=typeof t[r]?t[r].toString():t[r];var i=new c((function(t,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(t){return r(t)}n.db.transaction((function(i){yt(i,n,(function(){e._dbInfo=n,t()}),(function(t,e){r(e)}))}),r)}));return n.serializer=vt,i}function _t(t,e,n,r,i,s){t.executeSql(n,r,i,(function(t,a){a.code===a.SYNTAX_ERR?t.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[e.storeName],(function(t,o){o.rows.length?s(t,a):yt(t,e,(function(){t.executeSql(n,r,i,s)}),s)}),s):s(t,a)}),s)}function bt(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[t],(function(t,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=i.serializer.deserialize(r)),e(r)}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function wt(t,e){var n=this,r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"SELECT * FROM "+i.storeName,[],(function(n,r){for(var s=r.rows,a=s.length,o=0;o<a;o++){var l=s.item(o),c=l.value;if(c&&(c=i.serializer.deserialize(c)),void 0!==(c=t(c,l.key,o+1)))return void e(c)}e()}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function Mt(t,e,n,r){var i=this;t=d(t);var s=new c((function(s,a){i.ready().then((function(){void 0===e&&(e=null);var o=e,l=i._dbInfo;l.serializer.serialize(e,(function(e,c){c?a(c):l.db.transaction((function(n){_t(n,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[t,e],(function(){s(o)}),(function(t,e){a(e)}))}),(function(e){if(e.code===e.QUOTA_ERR){if(r>0)return void s(Mt.apply(i,[t,o,n,r-1]));a(e)}}))}))})).catch(a)}));return h(s,n),s}function St(t,e,n){return Mt.apply(this,[t,e,n,1])}function Tt(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[t],(function(){e()}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function At(t){var e=this,n=new c((function(t,n){e.ready().then((function(){var r=e._dbInfo;r.db.transaction((function(e){_t(e,r,"DELETE FROM "+r.storeName,[],(function(){t()}),(function(t,e){n(e)}))}))})).catch(n)}));return h(n,t),n}function Et(t){var e=this,n=new c((function(t,n){e.ready().then((function(){var r=e._dbInfo;r.db.transaction((function(e){_t(e,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(e,n){var r=n.rows.item(0).c;t(r)}),(function(t,e){n(e)}))}))})).catch(n)}));return h(n,t),n}function Pt(t,e){var n=this,r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[t+1],(function(t,n){var r=n.rows.length?n.rows.item(0).key:null;e(r)}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function Ct(t){var e=this,n=new c((function(t,n){e.ready().then((function(){var r=e._dbInfo;r.db.transaction((function(e){_t(e,r,"SELECT key FROM "+r.storeName,[],(function(e,n){for(var r=[],i=0;i<n.rows.length;i++)r.push(n.rows.item(i).key);t(r)}),(function(t,e){n(e)}))}))})).catch(n)}));return h(n,t),n}function Lt(t){return new c((function(e,n){t.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var i=[],s=0;s<r.rows.length;s++)i.push(r.rows.item(s).name);e({db:t,storeNames:i})}),(function(t,e){n(e)}))}),(function(t){n(t)}))}))}function Rt(t,e){e=p.apply(this,arguments);var n=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||n.name,t.storeName=t.storeName||n.storeName);var r,i=this;return h(r=t.name?new c((function(e){var r;r=t.name===n.name?i._dbInfo.db:openDatabase(t.name,"","",0),t.storeName?e({db:r,storeNames:[t.storeName]}):e(Lt(r))})).then((function(t){return new c((function(e,n){t.db.transaction((function(r){function i(t){return new c((function(e,n){r.executeSql("DROP TABLE IF EXISTS "+t,[],(function(){e()}),(function(t,e){n(e)}))}))}for(var s=[],a=0,o=t.storeNames.length;a<o;a++)s.push(i(t.storeNames[a]));c.all(s).then((function(){e()})).catch((function(t){n(t)}))}),(function(t){n(t)}))}))})):c.reject("Invalid arguments"),e),r}var It={_driver:"webSQLStorage",_initStorage:xt,_support:q(),iterate:wt,getItem:bt,setItem:St,removeItem:Tt,clear:At,length:Et,key:Pt,keys:Ct,dropInstance:Rt};function Ft(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(t){return!1}}function Dt(t,e){var n=t.name+"/";return t.storeName!==e.storeName&&(n+=t.storeName+"/"),n}function Nt(){var t="_localforage_support_test";try{return localStorage.setItem(t,!0),localStorage.removeItem(t),!1}catch(t){return!0}}function Ot(){return!Nt()||localStorage.length>0}function Ut(t){var e=this,n={};if(t)for(var r in t)n[r]=t[r];return n.keyPrefix=Dt(t,e._defaultConfig),Ot()?(e._dbInfo=n,n.serializer=vt,c.resolve()):c.reject()}function Bt(t){var e=this,n=e.ready().then((function(){for(var t=e._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(t)&&localStorage.removeItem(r)}}));return h(n,t),n}function zt(t,e){var n=this;t=d(t);var r=n.ready().then((function(){var e=n._dbInfo,r=localStorage.getItem(e.keyPrefix+t);return r&&(r=e.serializer.deserialize(r)),r}));return h(r,e),r}function kt(t,e){var n=this,r=n.ready().then((function(){for(var e=n._dbInfo,r=e.keyPrefix,i=r.length,s=localStorage.length,a=1,o=0;o<s;o++){var l=localStorage.key(o);if(0===l.indexOf(r)){var c=localStorage.getItem(l);if(c&&(c=e.serializer.deserialize(c)),void 0!==(c=t(c,l.substring(i),a++)))return c}}}));return h(r,e),r}function Ht(t,e){var n=this,r=n.ready().then((function(){var e,r=n._dbInfo;try{e=localStorage.key(t)}catch(t){e=null}return e&&(e=e.substring(r.keyPrefix.length)),e}));return h(r,e),r}function Gt(t){var e=this,n=e.ready().then((function(){for(var t=e._dbInfo,n=localStorage.length,r=[],i=0;i<n;i++){var s=localStorage.key(i);0===s.indexOf(t.keyPrefix)&&r.push(s.substring(t.keyPrefix.length))}return r}));return h(n,t),n}function jt(t){var e=this.keys().then((function(t){return t.length}));return h(e,t),e}function Vt(t,e){var n=this;t=d(t);var r=n.ready().then((function(){var e=n._dbInfo;localStorage.removeItem(e.keyPrefix+t)}));return h(r,e),r}function Wt(t,e,n){var r=this;t=d(t);var i=r.ready().then((function(){void 0===e&&(e=null);var n=e;return new c((function(i,s){var a=r._dbInfo;a.serializer.serialize(e,(function(e,r){if(r)s(r);else try{localStorage.setItem(a.keyPrefix+t,e),i(n)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||s(t),s(t)}}))}))}));return h(i,n),i}function Xt(t,e){if(e=p.apply(this,arguments),!(t="function"!=typeof t&&t||{}).name){var n=this.config();t.name=t.name||n.name,t.storeName=t.storeName||n.storeName}var r,i=this;return h(r=t.name?new c((function(e){t.storeName?e(Dt(t,i._defaultConfig)):e(t.name+"/")})).then((function(t){for(var e=localStorage.length-1;e>=0;e--){var n=localStorage.key(e);0===n.indexOf(t)&&localStorage.removeItem(n)}})):c.reject("Invalid arguments"),e),r}var Yt={_driver:"localStorageWrapper",_initStorage:Ut,_support:Ft(),iterate:kt,getItem:zt,setItem:Wt,removeItem:Vt,clear:Bt,length:jt,key:Ht,keys:Gt,dropInstance:Xt},qt=function(t,e){return t===e||"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)},Qt=function(t,e){for(var n=t.length,r=0;r<n;){if(qt(t[r],e))return!0;r++}return!1},Zt=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Jt={},Kt={},$t={INDEXEDDB:Y,WEBSQL:It,LOCALSTORAGE:Yt},te=[$t.INDEXEDDB._driver,$t.WEBSQL._driver,$t.LOCALSTORAGE._driver],ee=["dropInstance"],ne=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ee),re={description:"",driver:te.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ie(t,e){t[e]=function(){var n=arguments;return t.ready().then((function(){return t[e].apply(t,n)}))}}function se(){for(var t=1;t<arguments.length;t++){var e=arguments[t];if(e)for(var n in e)e.hasOwnProperty(n)&&(Zt(e[n])?arguments[0][n]=e[n].slice():arguments[0][n]=e[n])}return arguments[0]}var ae=new(function(){function t(e){for(var n in i(this,t),$t)if($t.hasOwnProperty(n)){var r=$t[n],s=r._driver;this[n]=s,Jt[s]||this.defineDriver(r)}this._defaultConfig=se({},re),this._config=se({},this._defaultConfig,e),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return t.prototype.config=function(t){if("object"===(void 0===t?"undefined":r(t))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var e in t){if("storeName"===e&&(t[e]=t[e].replace(/\W/g,"_")),"version"===e&&"number"!=typeof t[e])return new Error("Database version must be a number.");this._config[e]=t[e]}return!("driver"in t)||!t.driver||this.setDriver(this._config.driver)}return"string"==typeof t?this._config[t]:this._config},t.prototype.defineDriver=function(t,e,n){var r=new c((function(e,n){try{var r=t._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver)return void n(i);for(var s=ne.concat("_initStorage"),a=0,o=s.length;a<o;a++){var l=s[a];if((!Qt(ee,l)||t[l])&&"function"!=typeof t[l])return void n(i)}!function(){for(var e=function(t){return function(){var e=new Error("Method "+t+" is not implemented by the current driver"),n=c.reject(e);return h(n,arguments[arguments.length-1]),n}},n=0,r=ee.length;n<r;n++){var i=ee[n];t[i]||(t[i]=e(i))}}();var u=function(n){Jt[r]&&console.info("Redefining LocalForage driver: "+r),Jt[r]=t,Kt[r]=n,e()};"_support"in t?t._support&&"function"==typeof t._support?t._support().then(u,n):u(!!t._support):u(!0)}catch(t){n(t)}}));return u(r,e,n),r},t.prototype.driver=function(){return this._driver||null},t.prototype.getDriver=function(t,e,n){var r=Jt[t]?c.resolve(Jt[t]):c.reject(new Error("Driver not found."));return u(r,e,n),r},t.prototype.getSerializer=function(t){var e=c.resolve(vt);return u(e,t),e},t.prototype.ready=function(t){var e=this,n=e._driverSet.then((function(){return null===e._ready&&(e._ready=e._initDriver()),e._ready}));return u(n,t,t),n},t.prototype.setDriver=function(t,e,n){var r=this;Zt(t)||(t=[t]);var i=this._getSupportedDrivers(t);function s(){r._config.driver=r.driver()}function a(t){return r._extend(t),s(),r._ready=r._initStorage(r._config),r._ready}function o(t){return function(){var e=0;function n(){for(;e<t.length;){var i=t[e];return e++,r._dbInfo=null,r._ready=null,r.getDriver(i).then(a).catch(n)}s();var o=new Error("No available storage method found.");return r._driverSet=c.reject(o),r._driverSet}return n()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return c.resolve()})):c.resolve();return this._driverSet=l.then((function(){var t=i[0];return r._dbInfo=null,r._ready=null,r.getDriver(t).then((function(t){r._driver=t._driver,s(),r._wrapLibraryMethodsWithReady(),r._initDriver=o(i)}))})).catch((function(){s();var t=new Error("No available storage method found.");return r._driverSet=c.reject(t),r._driverSet})),u(this._driverSet,e,n),this._driverSet},t.prototype.supports=function(t){return!!Kt[t]},t.prototype._extend=function(t){se(this,t)},t.prototype._getSupportedDrivers=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];this.supports(i)&&e.push(i)}return e},t.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,e=ne.length;t<e;t++)ie(this,ne[t])},t.prototype.createInstance=function(e){return new t(e)},t}());e.exports=ae},{3:3}]},{},[4])(4)}(Bf={exports:{}},Bf.exports),Bf.exports);class kf extends DataView{constructor(t,e){super(t),this.isLE=!0,this.appKeys=e}byteRevers(t,e){const n=e%this.appKeys.length;return t^this.appKeys[n]}getSoonUint8(t){return this.byteRevers(this.getUint8(t),t)}getSoonUint16(t){const e=new DataView(new Uint8Array(2).buffer);for(let n=0;n<2;n++)e.setUint8(n,this.getSoonUint8(t+n));return e.getUint16(0,this.isLE)}getSoonUint32(t){const e=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)e.setUint8(n,this.getSoonUint8(t+n));return e.getUint32(0,this.isLE)}getSoonFloat32(t){const e=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)e.setUint8(n,this.getSoonUint8(t+n));return e.getFloat32(0,this.isLE)}}const Hf=new Map,Gf=t=>{if(Hf.has(t))return Hf.get(t);const e=new At;return Hf.set(t,e),(new dc).load(t,(t=>{e.image=t,e.needsUpdate=!0})),e.wrapS=f,e.wrapT=f,e.flipY=!1,e.anisotropy=16,e.mipmaps=[],e.generateMipmaps=!0,e},jf=(t,e,n)=>{const[r,i,s,a,o]=e,l=a<1;return new Bl({name:t,color:new en(r,i,s),opacity:a,transparent:l,map:n,side:o,shininess:0,specular:0})};var Vf=class{constructor(){this.materials=new Map,this.sbmInfo=null}load(t,e){return this.sbmInfo=t,fetch(t.url).then((t=>t.arrayBuffer())).then((n=>this.parseBuffer(n,t,e)))}parseBuffer(t,e,n){return Fd(this,void 0,void 0,(function*(){this.sbmInfo=e;const r=new DataView(t);let i=0;const s=[];for(let t=0;t<8;t++)s.push(r.getUint8(i)),i+=1;if("SBK-----"!==String.fromCharCode(...s))return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})格式或数据错误!`);const a=[],o=[],l=[];for(let t=0;t<32;t++)a.push(r.getUint8(i)),i+=1;const c=r.getUint8(i);i+=1;const h=r.getUint8(i);i+=1;for(let t=0;t<32;t++)o.push(r.getUint8(i)),i+=1;for(let t=0;t<64;t++)l.push(r.getUint8(i)),i+=1;const u=[...o,...l,...a],d=[];for(let t=0;t<u.length;t++)(t<=7||t>23&&t<=31||t>39&&t<=55||t>63&&t<=87||t>95&&t<=103)&&d.push(u[t]);if(64!==d.length)return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url} 数据错误!`);if(1===c){const t=r.buffer.slice(i,r.buffer.byteLength),e=new kf(t,d);return 1===h||2===h?this._parseV2(e,n):3===h?this._parseV3(e,n):Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})版本错误!`)}return new yf(this.sbmInfo)}))}_parseV2(t,e){return Fd(this,void 0,void 0,(function*(){let n=0;const r=performance.now();n+=66;const i={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const s=new yf(this.sbmInfo),a=t.getSoonUint16(n);n+=2;const o=t.getSoonUint16(n);n+=2,i.total=o;let l={};for(let e=0;e<a;++e){const e=t.getSoonUint16(n).toString();n+=2,l[e]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const r=t.getSoonFloat32(n);n+=4;const i=t.getSoonFloat32(n);n+=4;const s=t.getSoonFloat32(n);n+=4;const a=t.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=t.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const c=t.getSoonUint16(n);n+=2;let h=null;if(c>0){let r="",i="";for(let e=0;e<c;e++){const e=t.getSoonUint8(n);e>127?i=i+"%"+e.toString(16).toUpperCase():i.length>0?(r+=decodeURIComponent(i)+String.fromCharCode(e),i=""):r+=String.fromCharCode(e),n+=1}r=r.replace("\\","/");const{url:s,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(s,r,a);l[e].textureUrl=o,h=Gf(o)}if(!this.materials.has(e)){const t=[r,i,s,a,o],n=jf(e,t,h);this.materials.set(e,n),l[e].materialInfo=t}}const c={};for(let a=0;a<o;++a){const a=t.getSoonUint16(n);n+=2;const o=t.getSoonUint16(n).toString();n+=2,c[a]={materialId:o,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const l=[],h=[],u=[],d=[],p=t.getSoonUint16(n);if(n+=2,p>0)for(let e=0;e<p;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4,l.push(e)}const f=t.getSoonUint16(n);if(n+=2,f>0)for(let e=0;e<f;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4}const m=t.getSoonUint16(n);if(n+=2,m>0)for(let e=0;e<m;e++){const e=new vt;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,h.push(e)}const g=t.getSoonUint16(n);if(n+=2,g>0)for(let e=0;e<g;e++){const e=t.getSoonUint16(n);n+=2;const r=t.getSoonUint16(n);n+=2;const i=t.getSoonUint16(n);n+=2;const s=[e,r,i];u.push(s),h.length>0&&d.push([h[s[0]],h[s[1]],h[s[2]]])}const v=[],y=[];for(let t=0;t<u.length;t++){const e=u[t],n=l[e[0]],r=l[e[1]],i=l[e[2]];v.push(...n.toArray(),...r.toArray(),...i.toArray());let s=new vt,a=new vt,o=new vt;const c=d[t];void 0!==c&&(s=c[0],a=c[1],o=c[2]),y.push(...s.toArray(),...a.toArray(),...o.toArray())}const x=new Float32Array(v),_=new Float32Array(y);c[a].position=x.buffer,c[a].uv=_.buffer;const b=new Sn;x.length>0&&b.setAttribute("position",new an(x,3)),_.length>0&&b.setAttribute("uv",new an(_,2)),b.computeVertexNormals();const w=this.materials.get(o);if(w){const t=new sd(b,w,{id:a,name:a.toString()});s.add(t)}i.loaded++,i.timeStamp=performance.now()-r,e&&e(i)}const h={materialsCache:l,meshsCache:c};return Promise.resolve({sbm:s,caches:h})}))}_parseV3(t,e){let n=0;n+=66;const r=performance.now(),i={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const s=new yf(this.sbmInfo),a=t.getSoonUint16(n);n+=2;const o=t.getSoonUint16(n);n+=2,i.total=o;let l={};for(let e=0;e<a;++e){const e=t.getSoonUint16(n).toString();n+=2,l[e]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const r=t.getSoonFloat32(n);n+=4;const i=t.getSoonFloat32(n);n+=4;const s=t.getSoonFloat32(n);n+=4;const a=t.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=t.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const c=t.getSoonUint16(n);n+=2;let h=null;if(c>0){let r="",i="";for(let e=0;e<c;e++){const e=t.getSoonUint8(n);e>127?i=i+"%"+e.toString(16).toUpperCase():i.length>0?(r+=decodeURIComponent(i)+String.fromCharCode(e),i=""):r+=String.fromCharCode(e),n+=1}r=r.replace("\\","/");const{url:s,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(s,r,a);l[e].textureUrl=o,h=Gf(o)}if(!this.materials.has(e)){const t=[r,i,s,a,o],n=jf(e,t,h);this.materials.set(e,n),l[e].materialInfo=t}}const c={};for(let a=0;a<o;++a){const a=t.getSoonUint16(n).toString();n+=2;const o=t.getSoonUint16(n);if(n+=2,o>0){let e="";for(let r=0;r<o;r++){const r=t.getUint8(n);r>127?e=e+"%"+r.toString(16).toUpperCase():e.length>0&&(e=""),n+=1}}const l=t.getSoonUint16(n).toString();n+=2,c[a]={materialId:l,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const h=[],u=[],d=[],p=[],f=t.getSoonUint32(n);if(n+=4,f>0)for(let e=0;e<f;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4,h.push(e)}const m=t.getSoonUint32(n);if(n+=4,m>0)for(let e=0;e<m;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4}const g=t.getSoonUint32(n);if(n+=4,g>0)for(let e=0;e<g;e++){const e=new vt;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,u.push(e)}const v=t.getSoonUint32(n);if(n+=4,v>0)for(let e=0;e<v;e++){const e=t.getSoonUint32(n);n+=4;const r=t.getSoonUint32(n);n+=4;const i=t.getSoonUint32(n);n+=4;const s=[e,r,i];d.push(s),u.length>0&&p.push([u[s[0]],u[s[1]],u[s[2]]])}const y=[],x=[];for(let t=0;t<d.length;t++){const e=d[t],n=h[e[0]],r=h[e[1]],i=h[e[2]];y.push(...n.toArray(),...r.toArray(),...i.toArray());let s=new vt,a=new vt,o=new vt;const l=p[t];void 0!==l&&(s=l[0],a=l[1],o=l[2]),x.push(...s.toArray(),...a.toArray(),...o.toArray())}const _=new Float32Array(y),b=new Float32Array(x);c[a].position=_.buffer,c[a].uv=b.buffer;const w=new Sn;if(_.length>0&&w.setAttribute("position",new an(_,3)),b.length>0&&w.setAttribute("uv",new an(b,2)),w.computeVertexNormals(),this.materials.has(l)){const t=new sd(w,this.materials.get(l),{id:a,name:a});s.add(t)}i.loaded++,i.timeStamp=performance.now()-r,e&&e(i)}const h={materialsCache:l,meshsCache:c};return Promise.resolve({sbm:s,caches:h})}getTextureUrl(t,e,n){let r="",i=e;const s=i.lastIndexOf("/");if(-1!==s&&(i=i.substring(s+1)),r=t,n){const t=r.split("/");t.length>1&&(t.splice(t.length-3,t.length),r=t.join("/")+"/Maps/"+i)}else{const t=r.lastIndexOf("/");-1!==t&&(r=r.substring(0,t+1)+"Maps/"+i)}return r}},Wf=function(){function t(){}return t.prototype.toJson=function(t,e){var n=this.xmlStringToXmlDom(t),r=this.xmlToJson(n);return e?(e.removeLineBreaks&&this.removeLineBreaks(r),e.removeComments&&this.removeCommentProperties(r),e.transformTextOnly&&this.transformTextOnly(r),r):r},t.prototype.xmlStringToXmlDom=function(t){return(new DOMParser).parseFromString(t,"text/xml")},t.prototype.removeLineBreaks=function(t){var e=this;Object.keys(t).forEach((function(n,r){"#text"===n&&Array.isArray(t[n])&&delete t[n],"object"==typeof t[n]&&e.removeLineBreaks(t[n])}))},t.prototype.removeCommentProperties=function(t){var e=this;Object.keys(t).forEach((function(n,r){"#comment"===n&&delete t[n],"object"==typeof t[n]&&e.removeCommentProperties(t[n])}))},t.prototype.transformTextOnly=function(t){var e=this;Object.keys(t).forEach((function(n,r){var i=Object.keys(t[n]).length>1,s=Object.keys(t[n])[0];i||"object"==typeof t[n][s]?e.transformTextOnly(t[n]):"object"==typeof t[n]&&t[n]["#text"]&&(t[n]=t[n]["#text"])}))},t.prototype.xmlToJson=function(t){var e={};if(1==t.nodeType){if(t.attributes.length>0){e._attributes={};for(var n=0;n<t.attributes.length;n++){var r=t.attributes.item(n);e._attributes[r.nodeName]=r.nodeValue}}}else 3==t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes())for(var i=0;i<t.childNodes.length;i++){var s=t.childNodes.item(i),a=s.nodeName;if(void 0===e[a])e[a]=this.xmlToJson(s);else{if(void 0===e[a].push){var o=e[a];e[a]=[],e[a].push(o)}e[a].push(this.xmlToJson(s))}}return e},t}();function Xf(t){return fetch(t).then((t=>t.text())).then((t=>Promise.resolve(function(t){return(new Wf).toJson(t,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(t))))}class Yf{constructor(){this.materials=new Map}parseObject(t,e){const n=new yf(e),{materialsCache:r,meshsCache:i}=t;for(let[t,e]of Object.entries(r)){if(this.materials.has(t))continue;const{textureUrl:n,materialInfo:r}=e;let i=null;n&&(i=Gf(n));const s=jf(t,r,i);this.materials.set(t,s)}for(let[t,e]of Object.entries(i)){const{materialId:r,position:i,uv:s}=e,a=this.materials.get(r.toString());if(a){const e=new Sn,r=new Float32Array(i),o=new Float32Array(s);r.length>0&&e.setAttribute("position",new an(r,3)),o.length>0&&e.setAttribute("uv",new an(o,2)),e.computeVertexNormals();const l=new sd(e,a,{id:t,name:t});n.add(l)}}return n}}class qf extends Of{constructor(t){super("Sbm",t),this.viewport=t,this.modelMaps=new Map,this.store=zf.createInstance({name:"soonspace",version:2,storeName:"sbmData"})}load(t,e){return this._loadItem(t,e)}parse(t,e,n){return Fd(this,void 0,void 0,(function*(){const r=t=>{var n;if(!this.modelMaps.get(e.url)){const n=t.sClone();this.modelMaps.set(e.url,n)}return null===(n=t.onLoad)||void 0===n||n.call(t,t),t};if(t instanceof ArrayBuffer)return(new Vf).parseBuffer(t,e,n).then((t=>{let n;if(t instanceof yf)n=t;else{const{sbm:r,caches:i}=t;n=r;const s=()=>{i&&this.viewport.options.useIndexedDB&&this.store.setItem(`${e.url}_object`,i)};"function"==typeof requestIdleCallback?requestIdleCallback(s):setTimeout(s)}return r(n)}));const i=(new Yf).parseObject(t,e);return r(i)}))}clone(t,e,n){return new Promise(((r,i)=>{"Sbm"!==t.stype&&i("In soonspacejs: 方法 cloneSbm 参入对象类型错误!");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,v=t.sClone();s&&(v.sid=s),a&&(v.name=a),o&&(v.level=o),Pu(l)&&(v.visible=l),c&&v.position.set(c.x,c.y,c.z),h&&v.rotation.set(h.x,h.y,h.z),u&&v.scale.set(u.x,u.y,u.z),v.onClick=d?d.bind(v):null,v.onDblClick=p?p.bind(v):null,v.onRightClick=f?f.bind(v):null,v.onLoad=m?m.bind(v):null,v.onLoad&&v.onLoad(v),g&&(v.userData=g),null!==n&&this.viewport.scener.addObject(v,n||this.scene||t.parent),r(v)}))}loadToGroup(t,e,n){return new Promise((r=>Fd(this,void 0,void 0,(function*(){const i=new ld(t);for(let t=0;t<e.length;t++){const r=yield this._loadItem(e[t],(r=>{n&&n({modelTotal:e.length,loadingModelIndex:t+1,current:r})}),null);i.add(r)}this.viewport.scener.addObject(i,this.scene),r(i)}))))}addForGroup(t,e,n){return new Promise((r=>Fd(this,void 0,void 0,(function*(){const i=this.getGroupById(t);if(i)for(let t=0;t<e.length;t++){const r=yield this._loadItem(e[t],(r=>{n&&n({modelTotal:e.length,loadingModelIndex:t+1,current:r})}),null);this.viewport.scener.addObject(r,i)}r(i)}))))}createGroupFromXml(t,e){return new Promise((n=>Fd(this,void 0,void 0,(function*(){let r=!1;const i=yield Xf(e),s=new ld(t),{ProjectInfo:a,Building:o}=i.Project,l=t=>Fd(this,void 0,void 0,(function*(){const i=e.split(a.Title+".xml")[0],{id:l,name:c}=t._attributes,{name:h}=t.FileSource._attributes,u=a.Title+c,d=yield this._loadItem({id:l,name:u,url:i+h.replace("\\","/")},void 0,null);let p;if(s.add(d),p=Fu(o.ObjectHierarchy.Entity)?o.ObjectHierarchy.Entity.find((t=>t._attributes.id===l)):o.ObjectHierarchy.Entity,!p)return;const f=p.Entity.filter((t=>"FACILITY"===t._attributes.type)),m=f.length;if(0===m&&r)this.viewport.scener.addObject(s,this.scene),n(s);else for(let t=0;t<m;t++){const{id:e,name:a,longname:o,position:l,scale:c,orient:h}=f[t]._attributes,u=l.split(","),p=c.split(","),g=h.split(","),v=yield this._loadItem({id:e,name:a,url:i+o+".sbm",position:{x:10*Number(u[0].trim()),y:10*Number(u[1].trim()),z:10*Number(u[2].trim())},scale:{x:10*Number(p[0].trim()),y:10*Number(p[1].trim()),z:10*Number(p[2].trim())}},void 0,null);v.quaternion.set(Number(g[1].trim()),Number(g[2].trim()),Number(g[3].trim()),Number(g[0].trim())),d.add(v),r&&t===m-1&&(this.viewport.scener.addObject(s,this.scene),n(s))}})),{Floor:c}=o.Floors;Fu(c)?c.forEach(((t,e)=>{e===c.length-1&&(r=!0),l(t)})):Du(c)&&(r=!0,l(c))}))))}clearIdb(){return this.store.clear()}_loadItem(t,e,n=this.scene){return Fd(this,void 0,void 0,(function*(){const{url:r}=t,{useIndexedDB:i}=this.viewport.options,s=this.modelMaps.get(r);if(s)return this.clone(s,t,n);let a=null,o=null,l=null;return i&&(o=yield this.store.getItem(`${r}_object`),o?l=yield this.parse(o,t,e):a=yield this.store.getItem(r)),l||(a||(a=yield this._fetchBuffer(t)),l=yield this.parse(a,t,e)),null!==n&&this.viewport.scener.addObject(l,n||this.scene),l}))}_fetchBuffer(t){const{url:e}=t,{useIndexedDB:n}=this.viewport.options;return fetch(e).then((t=>t.arrayBuffer())).then((t=>(n&&r&&this.store.setItem(e,t),Promise.resolve(t))))}}
|
|
40
|
+
*/var Uf,Bf=(function(t,e){t.exports=function t(e,n,r){function i(a,o){if(!n[a]){if(!e[a]){if(!o&&qd)return qd(a);if(s)return s(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[a]={exports:{}};e[a][0].call(c.exports,(function(t){var n=e[a][1][t];return i(n||t)}),c,c.exports,t,e,n,r)}return n[a].exports}for(var s=qd,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e,n){(function(t){var n,r,i=t.MutationObserver||t.WebKitMutationObserver;if(i){var s=0,a=new i(h),o=t.document.createTextNode("");a.observe(o,{characterData:!0}),n=function(){o.data=s=++s%2}}else if(t.setImmediate||void 0===t.MessageChannel)n="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){h(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(h,0)};else{var l=new t.MessageChannel;l.port1.onmessage=h,n=function(){l.port2.postMessage(0)}}var c=[];function h(){var t,e;r=!0;for(var n=c.length;n;){for(e=c,c=[],t=-1;++t<n;)e[t]();n=c.length}r=!1}function u(t){1!==c.push(t)||r||n()}e.exports=u}).call(this,void 0!==Xd?Xd:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(t,e,n){var r=t(1);function i(){}var s={},a=["REJECTED"],o=["FULFILLED"],l=["PENDING"];function c(t){if("function"!=typeof t)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,t!==i&&p(this,t)}function h(t,e,n){this.promise=t,"function"==typeof e&&(this.onFulfilled=e,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function u(t,e,n){r((function(){var r;try{r=e(n)}catch(e){return s.reject(t,e)}r===t?s.reject(t,new TypeError("Cannot resolve promise with itself")):s.resolve(t,r)}))}function d(t){var e=t&&t.then;if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof e)return function(){e.apply(t,arguments)}}function p(t,e){var n=!1;function r(e){n||(n=!0,s.reject(t,e))}function i(e){n||(n=!0,s.resolve(t,e))}function a(){e(i,r)}var o=f(a);"error"===o.status&&r(o.value)}function f(t,e){var n={};try{n.value=t(e),n.status="success"}catch(t){n.status="error",n.value=t}return n}function m(t){return t instanceof this?t:s.resolve(new this(i),t)}function g(t){var e=new this(i);return s.reject(e,t)}function v(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var n=t.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),o=0,l=-1,c=new this(i);++l<n;)h(t[l],l);return c;function h(t,i){function l(t){a[i]=t,++o!==n||r||(r=!0,s.resolve(c,a))}e.resolve(t).then(l,(function(t){r||(r=!0,s.reject(c,t))}))}}function y(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var n=t.length,r=!1;if(!n)return this.resolve([]);for(var a=-1,o=new this(i);++a<n;)l(t[a]);return o;function l(t){e.resolve(t).then((function(t){r||(r=!0,s.resolve(o,t))}),(function(t){r||(r=!0,s.reject(o,t))}))}}e.exports=c,c.prototype.catch=function(t){return this.then(null,t)},c.prototype.then=function(t,e){if("function"!=typeof t&&this.state===o||"function"!=typeof e&&this.state===a)return this;var n=new this.constructor(i);return this.state!==l?u(n,this.state===o?t:e,this.outcome):this.queue.push(new h(n,t,e)),n},h.prototype.callFulfilled=function(t){s.resolve(this.promise,t)},h.prototype.otherCallFulfilled=function(t){u(this.promise,this.onFulfilled,t)},h.prototype.callRejected=function(t){s.reject(this.promise,t)},h.prototype.otherCallRejected=function(t){u(this.promise,this.onRejected,t)},s.resolve=function(t,e){var n=f(d,e);if("error"===n.status)return s.reject(t,n.value);var r=n.value;if(r)p(t,r);else{t.state=o,t.outcome=e;for(var i=-1,a=t.queue.length;++i<a;)t.queue[i].callFulfilled(e)}return t},s.reject=function(t,e){t.state=a,t.outcome=e;for(var n=-1,r=t.queue.length;++n<r;)t.queue[n].callRejected(e);return t},c.resolve=m,c.reject=g,c.all=v,c.race=y},{1:1}],3:[function(t,e,n){(function(e){"function"!=typeof e.Promise&&(e.Promise=t(2))}).call(this,void 0!==Xd?Xd:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(t,e,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(t){return}}var a=s();function o(){try{if(!a||!a.open)return!1;var t="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),e="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!t||e)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(t){return!1}}function l(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<t.length;r+=1)n.append(t[r]);return n.getBlob(e.type)}}"undefined"==typeof Promise&&t(3);var c=Promise;function h(t,e){e&&t.then((function(t){e(null,t)}),(function(t){e(t)}))}function u(t,e,n){"function"==typeof e&&t.then(e),"function"==typeof n&&t.catch(n)}function d(t){return"string"!=typeof t&&(console.warn(t+" used as a key, but it is not a string."),t=String(t)),t}function p(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var f="local-forage-detect-blob-support",m=void 0,g={},v=Object.prototype.toString,y="readonly",x="readwrite";function _(t){for(var e=t.length,n=new ArrayBuffer(e),r=new Uint8Array(n),i=0;i<e;i++)r[i]=t.charCodeAt(i);return n}function b(t){return new c((function(e){var n=t.transaction(f,x),r=l([""]);n.objectStore(f).put(r,"key"),n.onabort=function(t){t.preventDefault(),t.stopPropagation(),e(!1)},n.oncomplete=function(){var t=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);e(n||!t||parseInt(t[1],10)>=43)}})).catch((function(){return!1}))}function w(t){return"boolean"==typeof m?c.resolve(m):b(t).then((function(t){return m=t}))}function M(t){var e=g[t.name],n={};n.promise=new c((function(t,e){n.resolve=t,n.reject=e})),e.deferredOperations.push(n),e.dbReady?e.dbReady=e.dbReady.then((function(){return n.promise})):e.dbReady=n.promise}function S(t){var e=g[t.name].deferredOperations.pop();if(e)return e.resolve(),e.promise}function T(t,e){var n=g[t.name].deferredOperations.pop();if(n)return n.reject(e),n.promise}function A(t,e){return new c((function(n,r){if(g[t.name]=g[t.name]||O(),t.db){if(!e)return n(t.db);M(t),t.db.close()}var i=[t.name];e&&i.push(t.version);var s=a.open.apply(a,i);e&&(s.onupgradeneeded=function(e){var n=s.result;try{n.createObjectStore(t.storeName),e.oldVersion<=1&&n.createObjectStore(f)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+t.name+'" has been upgraded from version '+e.oldVersion+" to version "+e.newVersion+', but the storage "'+t.storeName+'" already exists.')}}),s.onerror=function(t){t.preventDefault(),r(s.error)},s.onsuccess=function(){n(s.result),S(t)}}))}function E(t){return A(t,!1)}function P(t){return A(t,!0)}function C(t,e){if(!t.db)return!0;var n=!t.db.objectStoreNames.contains(t.storeName),r=t.version<t.db.version,i=t.version>t.db.version;if(r&&(t.version!==e&&console.warn('The database "'+t.name+"\" can't be downgraded from version "+t.db.version+" to version "+t.version+"."),t.version=t.db.version),i||n){if(n){var s=t.db.version+1;s>t.version&&(t.version=s)}return!0}return!1}function L(t){return new c((function(e,n){var r=new FileReader;r.onerror=n,r.onloadend=function(n){var r=btoa(n.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:t.type})},r.readAsBinaryString(t)}))}function R(t){return l([_(atob(t.data))],{type:t.type})}function I(t){return t&&t.__local_forage_encoded_blob}function F(t){var e=this,n=e._initReady().then((function(){var t=g[e._dbInfo.name];if(t&&t.dbReady)return t.dbReady}));return u(n,t,t),n}function D(t){M(t);for(var e=g[t.name],n=e.forages,r=0;r<n.length;r++){var i=n[r];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return t.db=null,E(t).then((function(e){return t.db=e,C(t)?P(t):e})).then((function(r){t.db=e.db=r;for(var i=0;i<n.length;i++)n[i]._dbInfo.db=r})).catch((function(e){throw T(t,e),e}))}function N(t,e,n,r){void 0===r&&(r=1);try{var i=t.db.transaction(t.storeName,e);n(null,i)}catch(i){if(r>0&&(!t.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return c.resolve().then((function(){if(!t.db||"NotFoundError"===i.name&&!t.db.objectStoreNames.contains(t.storeName)&&t.version<=t.db.version)return t.db&&(t.version=t.db.version+1),P(t)})).then((function(){return D(t).then((function(){N(t,e,n,r-1)}))})).catch(n);n(i)}}function O(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function U(t){var e=this,n={db:null};if(t)for(var r in t)n[r]=t[r];var i=g[n.name];i||(i=O(),g[n.name]=i),i.forages.push(e),e._initReady||(e._initReady=e.ready,e.ready=F);var s=[];function a(){return c.resolve()}for(var o=0;o<i.forages.length;o++){var l=i.forages[o];l!==e&&s.push(l._initReady().catch(a))}var h=i.forages.slice(0);return c.all(s).then((function(){return n.db=i.db,E(n)})).then((function(t){return n.db=t,C(n,e._defaultConfig.version)?P(n):t})).then((function(t){n.db=i.db=t,e._dbInfo=n;for(var r=0;r<h.length;r++){var s=h[r];s!==e&&(s._dbInfo.db=n.db,s._dbInfo.version=n.version)}}))}function B(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){N(n._dbInfo,y,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName).get(t);a.onsuccess=function(){var t=a.result;void 0===t&&(t=null),I(t)&&(t=R(t)),e(t)},a.onerror=function(){r(a.error)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function z(t,e){var n=this,r=new c((function(e,r){n.ready().then((function(){N(n._dbInfo,y,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName).openCursor(),o=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;I(r)&&(r=R(r));var i=t(r,n.key,o++);void 0!==i?e(i):n.continue()}else e()},a.onerror=function(){r(a.error)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function k(t,e,n){var r=this;t=d(t);var i=new c((function(n,i){var s;r.ready().then((function(){return s=r._dbInfo,"[object Blob]"===v.call(e)?w(s.db).then((function(t){return t?e:L(e)})):e})).then((function(e){N(r._dbInfo,x,(function(s,a){if(s)return i(s);try{var o=a.objectStore(r._dbInfo.storeName);null===e&&(e=void 0);var l=o.put(e,t);a.oncomplete=function(){void 0===e&&(e=null),n(e)},a.onabort=a.onerror=function(){var t=l.error?l.error:l.transaction.error;i(t)}}catch(t){i(t)}}))})).catch(i)}));return h(i,n),i}function H(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){N(n._dbInfo,x,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName).delete(t);s.oncomplete=function(){e()},s.onerror=function(){r(a.error)},s.onabort=function(){var t=a.error?a.error:a.transaction.error;r(t)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function G(t){var e=this,n=new c((function(t,n){e.ready().then((function(){N(e._dbInfo,x,(function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).clear();i.oncomplete=function(){t()},i.onabort=i.onerror=function(){var t=s.error?s.error:s.transaction.error;n(t)}}catch(t){n(t)}}))})).catch(n)}));return h(n,t),n}function j(t){var e=this,n=new c((function(t,n){e.ready().then((function(){N(e._dbInfo,y,(function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).count();s.onsuccess=function(){t(s.result)},s.onerror=function(){n(s.error)}}catch(t){n(t)}}))})).catch(n)}));return h(n,t),n}function V(t,e){var n=this,r=new c((function(e,r){t<0?e(null):n.ready().then((function(){N(n._dbInfo,y,(function(i,s){if(i)return r(i);try{var a=s.objectStore(n._dbInfo.storeName),o=!1,l=a.openKeyCursor();l.onsuccess=function(){var n=l.result;n?0===t||o?e(n.key):(o=!0,n.advance(t)):e(null)},l.onerror=function(){r(l.error)}}catch(t){r(t)}}))})).catch(r)}));return h(r,e),r}function W(t){var e=this,n=new c((function(t,n){e.ready().then((function(){N(e._dbInfo,y,(function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).openKeyCursor(),a=[];s.onsuccess=function(){var e=s.result;e?(a.push(e.key),e.continue()):t(a)},s.onerror=function(){n(s.error)}}catch(t){n(t)}}))})).catch(n)}));return h(n,t),n}function X(t,e){e=p.apply(this,arguments);var n=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||n.name,t.storeName=t.storeName||n.storeName);var r,i=this;if(t.name){var s=t.name===n.name&&i._dbInfo.db?c.resolve(i._dbInfo.db):E(t).then((function(e){var n=g[t.name],r=n.forages;n.db=e;for(var i=0;i<r.length;i++)r[i]._dbInfo.db=e;return e}));r=t.storeName?s.then((function(e){if(e.objectStoreNames.contains(t.storeName)){var n=e.version+1;M(t);var r=g[t.name],i=r.forages;e.close();for(var s=0;s<i.length;s++){var o=i[s];o._dbInfo.db=null,o._dbInfo.version=n}return new c((function(e,r){var i=a.open(t.name,n);i.onerror=function(t){i.result.close(),r(t)},i.onupgradeneeded=function(){i.result.deleteObjectStore(t.storeName)},i.onsuccess=function(){var t=i.result;t.close(),e(t)}})).then((function(t){r.db=t;for(var e=0;e<i.length;e++){var n=i[e];n._dbInfo.db=t,S(n._dbInfo)}})).catch((function(e){throw(T(t,e)||c.resolve()).catch((function(){})),e}))}})):s.then((function(e){M(t);var n=g[t.name],r=n.forages;e.close();for(var i=0;i<r.length;i++)r[i]._dbInfo.db=null;return new c((function(e,n){var r=a.deleteDatabase(t.name);r.onerror=r.onblocked=function(t){var e=r.result;e&&e.close(),n(t)},r.onsuccess=function(){var t=r.result;t&&t.close(),e(t)}})).then((function(t){n.db=t;for(var e=0;e<r.length;e++)S(r[e]._dbInfo)})).catch((function(e){throw(T(t,e)||c.resolve()).catch((function(){})),e}))}))}else r=c.reject("Invalid arguments");return h(r,e),r}var Y={_driver:"asyncStorage",_initStorage:U,_support:o(),iterate:z,getItem:B,setItem:k,removeItem:H,clear:G,length:j,key:V,keys:W,dropInstance:X};function q(){return"function"==typeof openDatabase}var Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Z="~~local_forage_type~",J=/^~~local_forage_type~([^~]+)~/,K="__lfsc__:",$=K.length,tt="arbf",et="blob",nt="si08",rt="ui08",it="uic8",st="si16",at="si32",ot="ur16",lt="ui32",ct="fl32",ht="fl64",ut=$+tt.length,dt=Object.prototype.toString;function pt(t){var e,n,r,i,s,a=.75*t.length,o=t.length,l=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var c=new ArrayBuffer(a),h=new Uint8Array(c);for(e=0;e<o;e+=4)n=Q.indexOf(t[e]),r=Q.indexOf(t[e+1]),i=Q.indexOf(t[e+2]),s=Q.indexOf(t[e+3]),h[l++]=n<<2|r>>4,h[l++]=(15&r)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return c}function ft(t){var e,n=new Uint8Array(t),r="";for(e=0;e<n.length;e+=3)r+=Q[n[e]>>2],r+=Q[(3&n[e])<<4|n[e+1]>>4],r+=Q[(15&n[e+1])<<2|n[e+2]>>6],r+=Q[63&n[e+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}function mt(t,e){var n="";if(t&&(n=dt.call(t)),t&&("[object ArrayBuffer]"===n||t.buffer&&"[object ArrayBuffer]"===dt.call(t.buffer))){var r,i=K;t instanceof ArrayBuffer?(r=t,i+=tt):(r=t.buffer,"[object Int8Array]"===n?i+=nt:"[object Uint8Array]"===n?i+=rt:"[object Uint8ClampedArray]"===n?i+=it:"[object Int16Array]"===n?i+=st:"[object Uint16Array]"===n?i+=ot:"[object Int32Array]"===n?i+=at:"[object Uint32Array]"===n?i+=lt:"[object Float32Array]"===n?i+=ct:"[object Float64Array]"===n?i+=ht:e(new Error("Failed to get type for BinaryArray"))),e(i+ft(r))}else if("[object Blob]"===n){var s=new FileReader;s.onload=function(){var n=Z+t.type+"~"+ft(this.result);e(K+et+n)},s.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(n){console.error("Couldn't convert value into a JSON string: ",t),e(null,n)}}function gt(t){if(t.substring(0,$)!==K)return JSON.parse(t);var e,n=t.substring(ut),r=t.substring($,ut);if(r===et&&J.test(n)){var i=n.match(J);e=i[1],n=n.substring(i[0].length)}var s=pt(n);switch(r){case tt:return s;case et:return l([s],{type:e});case nt:return new Int8Array(s);case rt:return new Uint8Array(s);case it:return new Uint8ClampedArray(s);case st:return new Int16Array(s);case ot:return new Uint16Array(s);case at:return new Int32Array(s);case lt:return new Uint32Array(s);case ct:return new Float32Array(s);case ht:return new Float64Array(s);default:throw new Error("Unkown type: "+r)}}var vt={serialize:mt,deserialize:gt,stringToBuffer:pt,bufferToString:ft};function yt(t,e,n,r){t.executeSql("CREATE TABLE IF NOT EXISTS "+e.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function xt(t){var e=this,n={db:null};if(t)for(var r in t)n[r]="string"!=typeof t[r]?t[r].toString():t[r];var i=new c((function(t,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(t){return r(t)}n.db.transaction((function(i){yt(i,n,(function(){e._dbInfo=n,t()}),(function(t,e){r(e)}))}),r)}));return n.serializer=vt,i}function _t(t,e,n,r,i,s){t.executeSql(n,r,i,(function(t,a){a.code===a.SYNTAX_ERR?t.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[e.storeName],(function(t,o){o.rows.length?s(t,a):yt(t,e,(function(){t.executeSql(n,r,i,s)}),s)}),s):s(t,a)}),s)}function bt(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[t],(function(t,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=i.serializer.deserialize(r)),e(r)}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function wt(t,e){var n=this,r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"SELECT * FROM "+i.storeName,[],(function(n,r){for(var s=r.rows,a=s.length,o=0;o<a;o++){var l=s.item(o),c=l.value;if(c&&(c=i.serializer.deserialize(c)),void 0!==(c=t(c,l.key,o+1)))return void e(c)}e()}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function Mt(t,e,n,r){var i=this;t=d(t);var s=new c((function(s,a){i.ready().then((function(){void 0===e&&(e=null);var o=e,l=i._dbInfo;l.serializer.serialize(e,(function(e,c){c?a(c):l.db.transaction((function(n){_t(n,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[t,e],(function(){s(o)}),(function(t,e){a(e)}))}),(function(e){if(e.code===e.QUOTA_ERR){if(r>0)return void s(Mt.apply(i,[t,o,n,r-1]));a(e)}}))}))})).catch(a)}));return h(s,n),s}function St(t,e,n){return Mt.apply(this,[t,e,n,1])}function Tt(t,e){var n=this;t=d(t);var r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[t],(function(){e()}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function At(t){var e=this,n=new c((function(t,n){e.ready().then((function(){var r=e._dbInfo;r.db.transaction((function(e){_t(e,r,"DELETE FROM "+r.storeName,[],(function(){t()}),(function(t,e){n(e)}))}))})).catch(n)}));return h(n,t),n}function Et(t){var e=this,n=new c((function(t,n){e.ready().then((function(){var r=e._dbInfo;r.db.transaction((function(e){_t(e,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(e,n){var r=n.rows.item(0).c;t(r)}),(function(t,e){n(e)}))}))})).catch(n)}));return h(n,t),n}function Pt(t,e){var n=this,r=new c((function(e,r){n.ready().then((function(){var i=n._dbInfo;i.db.transaction((function(n){_t(n,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[t+1],(function(t,n){var r=n.rows.length?n.rows.item(0).key:null;e(r)}),(function(t,e){r(e)}))}))})).catch(r)}));return h(r,e),r}function Ct(t){var e=this,n=new c((function(t,n){e.ready().then((function(){var r=e._dbInfo;r.db.transaction((function(e){_t(e,r,"SELECT key FROM "+r.storeName,[],(function(e,n){for(var r=[],i=0;i<n.rows.length;i++)r.push(n.rows.item(i).key);t(r)}),(function(t,e){n(e)}))}))})).catch(n)}));return h(n,t),n}function Lt(t){return new c((function(e,n){t.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var i=[],s=0;s<r.rows.length;s++)i.push(r.rows.item(s).name);e({db:t,storeNames:i})}),(function(t,e){n(e)}))}),(function(t){n(t)}))}))}function Rt(t,e){e=p.apply(this,arguments);var n=this.config();(t="function"!=typeof t&&t||{}).name||(t.name=t.name||n.name,t.storeName=t.storeName||n.storeName);var r,i=this;return h(r=t.name?new c((function(e){var r;r=t.name===n.name?i._dbInfo.db:openDatabase(t.name,"","",0),t.storeName?e({db:r,storeNames:[t.storeName]}):e(Lt(r))})).then((function(t){return new c((function(e,n){t.db.transaction((function(r){function i(t){return new c((function(e,n){r.executeSql("DROP TABLE IF EXISTS "+t,[],(function(){e()}),(function(t,e){n(e)}))}))}for(var s=[],a=0,o=t.storeNames.length;a<o;a++)s.push(i(t.storeNames[a]));c.all(s).then((function(){e()})).catch((function(t){n(t)}))}),(function(t){n(t)}))}))})):c.reject("Invalid arguments"),e),r}var It={_driver:"webSQLStorage",_initStorage:xt,_support:q(),iterate:wt,getItem:bt,setItem:St,removeItem:Tt,clear:At,length:Et,key:Pt,keys:Ct,dropInstance:Rt};function Ft(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(t){return!1}}function Dt(t,e){var n=t.name+"/";return t.storeName!==e.storeName&&(n+=t.storeName+"/"),n}function Nt(){var t="_localforage_support_test";try{return localStorage.setItem(t,!0),localStorage.removeItem(t),!1}catch(t){return!0}}function Ot(){return!Nt()||localStorage.length>0}function Ut(t){var e=this,n={};if(t)for(var r in t)n[r]=t[r];return n.keyPrefix=Dt(t,e._defaultConfig),Ot()?(e._dbInfo=n,n.serializer=vt,c.resolve()):c.reject()}function Bt(t){var e=this,n=e.ready().then((function(){for(var t=e._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(t)&&localStorage.removeItem(r)}}));return h(n,t),n}function zt(t,e){var n=this;t=d(t);var r=n.ready().then((function(){var e=n._dbInfo,r=localStorage.getItem(e.keyPrefix+t);return r&&(r=e.serializer.deserialize(r)),r}));return h(r,e),r}function kt(t,e){var n=this,r=n.ready().then((function(){for(var e=n._dbInfo,r=e.keyPrefix,i=r.length,s=localStorage.length,a=1,o=0;o<s;o++){var l=localStorage.key(o);if(0===l.indexOf(r)){var c=localStorage.getItem(l);if(c&&(c=e.serializer.deserialize(c)),void 0!==(c=t(c,l.substring(i),a++)))return c}}}));return h(r,e),r}function Ht(t,e){var n=this,r=n.ready().then((function(){var e,r=n._dbInfo;try{e=localStorage.key(t)}catch(t){e=null}return e&&(e=e.substring(r.keyPrefix.length)),e}));return h(r,e),r}function Gt(t){var e=this,n=e.ready().then((function(){for(var t=e._dbInfo,n=localStorage.length,r=[],i=0;i<n;i++){var s=localStorage.key(i);0===s.indexOf(t.keyPrefix)&&r.push(s.substring(t.keyPrefix.length))}return r}));return h(n,t),n}function jt(t){var e=this.keys().then((function(t){return t.length}));return h(e,t),e}function Vt(t,e){var n=this;t=d(t);var r=n.ready().then((function(){var e=n._dbInfo;localStorage.removeItem(e.keyPrefix+t)}));return h(r,e),r}function Wt(t,e,n){var r=this;t=d(t);var i=r.ready().then((function(){void 0===e&&(e=null);var n=e;return new c((function(i,s){var a=r._dbInfo;a.serializer.serialize(e,(function(e,r){if(r)s(r);else try{localStorage.setItem(a.keyPrefix+t,e),i(n)}catch(t){"QuotaExceededError"!==t.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==t.name||s(t),s(t)}}))}))}));return h(i,n),i}function Xt(t,e){if(e=p.apply(this,arguments),!(t="function"!=typeof t&&t||{}).name){var n=this.config();t.name=t.name||n.name,t.storeName=t.storeName||n.storeName}var r,i=this;return h(r=t.name?new c((function(e){t.storeName?e(Dt(t,i._defaultConfig)):e(t.name+"/")})).then((function(t){for(var e=localStorage.length-1;e>=0;e--){var n=localStorage.key(e);0===n.indexOf(t)&&localStorage.removeItem(n)}})):c.reject("Invalid arguments"),e),r}var Yt={_driver:"localStorageWrapper",_initStorage:Ut,_support:Ft(),iterate:kt,getItem:zt,setItem:Wt,removeItem:Vt,clear:Bt,length:jt,key:Ht,keys:Gt,dropInstance:Xt},qt=function(t,e){return t===e||"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)},Qt=function(t,e){for(var n=t.length,r=0;r<n;){if(qt(t[r],e))return!0;r++}return!1},Zt=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Jt={},Kt={},$t={INDEXEDDB:Y,WEBSQL:It,LOCALSTORAGE:Yt},te=[$t.INDEXEDDB._driver,$t.WEBSQL._driver,$t.LOCALSTORAGE._driver],ee=["dropInstance"],ne=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ee),re={description:"",driver:te.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ie(t,e){t[e]=function(){var n=arguments;return t.ready().then((function(){return t[e].apply(t,n)}))}}function se(){for(var t=1;t<arguments.length;t++){var e=arguments[t];if(e)for(var n in e)e.hasOwnProperty(n)&&(Zt(e[n])?arguments[0][n]=e[n].slice():arguments[0][n]=e[n])}return arguments[0]}var ae=new(function(){function t(e){for(var n in i(this,t),$t)if($t.hasOwnProperty(n)){var r=$t[n],s=r._driver;this[n]=s,Jt[s]||this.defineDriver(r)}this._defaultConfig=se({},re),this._config=se({},this._defaultConfig,e),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return t.prototype.config=function(t){if("object"===(void 0===t?"undefined":r(t))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var e in t){if("storeName"===e&&(t[e]=t[e].replace(/\W/g,"_")),"version"===e&&"number"!=typeof t[e])return new Error("Database version must be a number.");this._config[e]=t[e]}return!("driver"in t)||!t.driver||this.setDriver(this._config.driver)}return"string"==typeof t?this._config[t]:this._config},t.prototype.defineDriver=function(t,e,n){var r=new c((function(e,n){try{var r=t._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver)return void n(i);for(var s=ne.concat("_initStorage"),a=0,o=s.length;a<o;a++){var l=s[a];if((!Qt(ee,l)||t[l])&&"function"!=typeof t[l])return void n(i)}!function(){for(var e=function(t){return function(){var e=new Error("Method "+t+" is not implemented by the current driver"),n=c.reject(e);return h(n,arguments[arguments.length-1]),n}},n=0,r=ee.length;n<r;n++){var i=ee[n];t[i]||(t[i]=e(i))}}();var u=function(n){Jt[r]&&console.info("Redefining LocalForage driver: "+r),Jt[r]=t,Kt[r]=n,e()};"_support"in t?t._support&&"function"==typeof t._support?t._support().then(u,n):u(!!t._support):u(!0)}catch(t){n(t)}}));return u(r,e,n),r},t.prototype.driver=function(){return this._driver||null},t.prototype.getDriver=function(t,e,n){var r=Jt[t]?c.resolve(Jt[t]):c.reject(new Error("Driver not found."));return u(r,e,n),r},t.prototype.getSerializer=function(t){var e=c.resolve(vt);return u(e,t),e},t.prototype.ready=function(t){var e=this,n=e._driverSet.then((function(){return null===e._ready&&(e._ready=e._initDriver()),e._ready}));return u(n,t,t),n},t.prototype.setDriver=function(t,e,n){var r=this;Zt(t)||(t=[t]);var i=this._getSupportedDrivers(t);function s(){r._config.driver=r.driver()}function a(t){return r._extend(t),s(),r._ready=r._initStorage(r._config),r._ready}function o(t){return function(){var e=0;function n(){for(;e<t.length;){var i=t[e];return e++,r._dbInfo=null,r._ready=null,r.getDriver(i).then(a).catch(n)}s();var o=new Error("No available storage method found.");return r._driverSet=c.reject(o),r._driverSet}return n()}}var l=null!==this._driverSet?this._driverSet.catch((function(){return c.resolve()})):c.resolve();return this._driverSet=l.then((function(){var t=i[0];return r._dbInfo=null,r._ready=null,r.getDriver(t).then((function(t){r._driver=t._driver,s(),r._wrapLibraryMethodsWithReady(),r._initDriver=o(i)}))})).catch((function(){s();var t=new Error("No available storage method found.");return r._driverSet=c.reject(t),r._driverSet})),u(this._driverSet,e,n),this._driverSet},t.prototype.supports=function(t){return!!Kt[t]},t.prototype._extend=function(t){se(this,t)},t.prototype._getSupportedDrivers=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];this.supports(i)&&e.push(i)}return e},t.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,e=ne.length;t<e;t++)ie(this,ne[t])},t.prototype.createInstance=function(e){return new t(e)},t}());e.exports=ae},{3:3}]},{},[4])(4)}(Uf={exports:{}},Uf.exports),Uf.exports);class zf extends DataView{constructor(t,e){super(t),this.isLE=!0,this.appKeys=e}byteRevers(t,e){const n=e%this.appKeys.length;return t^this.appKeys[n]}getSoonUint8(t){return this.byteRevers(this.getUint8(t),t)}getSoonUint16(t){const e=new DataView(new Uint8Array(2).buffer);for(let n=0;n<2;n++)e.setUint8(n,this.getSoonUint8(t+n));return e.getUint16(0,this.isLE)}getSoonUint32(t){const e=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)e.setUint8(n,this.getSoonUint8(t+n));return e.getUint32(0,this.isLE)}getSoonFloat32(t){const e=new DataView(new Uint8Array(4).buffer);for(let n=0;n<4;n++)e.setUint8(n,this.getSoonUint8(t+n));return e.getFloat32(0,this.isLE)}}const kf=new Map,Hf=t=>{if(kf.has(t))return kf.get(t);const e=new At;return kf.set(t,e),(new dc).load(t,(t=>{e.image=t,e.needsUpdate=!0})),e.wrapS=f,e.wrapT=f,e.flipY=!1,e.anisotropy=16,e.mipmaps=[],e.generateMipmaps=!0,e},Gf=(t,e,n)=>{const[r,i,s,a,o]=e,l=a<1;return new Bl({name:t,color:new en(r,i,s),opacity:a,transparent:l,map:n,side:o,shininess:0,specular:0})};var jf=class{constructor(){this.materials=new Map,this.sbmInfo=null}load(t,e){return this.sbmInfo=t,fetch(t.url).then((t=>t.arrayBuffer())).then((n=>this.parseBuffer(n,t,e)))}parseBuffer(t,e,n){return Fd(this,void 0,void 0,(function*(){this.sbmInfo=e;const r=new DataView(t);let i=0;const s=[];for(let t=0;t<8;t++)s.push(r.getUint8(i)),i+=1;if("SBK-----"!==String.fromCharCode(...s))return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})格式或数据错误!`);const a=[],o=[],l=[];for(let t=0;t<32;t++)a.push(r.getUint8(i)),i+=1;const c=r.getUint8(i);i+=1;const h=r.getUint8(i);i+=1;for(let t=0;t<32;t++)o.push(r.getUint8(i)),i+=1;for(let t=0;t<64;t++)l.push(r.getUint8(i)),i+=1;const u=[...o,...l,...a],d=[];for(let t=0;t<u.length;t++)(t<=7||t>23&&t<=31||t>39&&t<=55||t>63&&t<=87||t>95&&t<=103)&&d.push(u[t]);if(64!==d.length)return Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url} 数据错误!`);if(1===c){const t=r.buffer.slice(i,r.buffer.byteLength),e=new zf(t,d);return 1===h||2===h?this._parseV2(e,n):3===h?this._parseV3(e,n):Promise.reject(`In soonspacejs: sbm 资源模型(${this.sbmInfo.url})版本错误!`)}return new vf(this.sbmInfo)}))}_parseV2(t,e){return Fd(this,void 0,void 0,(function*(){let n=0;const r=performance.now();n+=66;const i={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const s=new vf(this.sbmInfo),a=t.getSoonUint16(n);n+=2;const o=t.getSoonUint16(n);n+=2,i.total=o;let l={};for(let e=0;e<a;++e){const e=t.getSoonUint16(n).toString();n+=2,l[e]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const r=t.getSoonFloat32(n);n+=4;const i=t.getSoonFloat32(n);n+=4;const s=t.getSoonFloat32(n);n+=4;const a=t.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=t.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const c=t.getSoonUint16(n);n+=2;let h=null;if(c>0){let r="",i="";for(let e=0;e<c;e++){const e=t.getSoonUint8(n);e>127?i=i+"%"+e.toString(16).toUpperCase():i.length>0?(r+=decodeURIComponent(i)+String.fromCharCode(e),i=""):r+=String.fromCharCode(e),n+=1}r=r.replace("\\","/");const{url:s,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(s,r,a);l[e].textureUrl=o,h=Hf(o)}if(!this.materials.has(e)){const t=[r,i,s,a,o],n=Gf(e,t,h);this.materials.set(e,n),l[e].materialInfo=t}}const c={};for(let a=0;a<o;++a){const a=t.getSoonUint16(n);n+=2;const o=t.getSoonUint16(n).toString();n+=2,c[a]={materialId:o,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const l=[],h=[],u=[],d=[],p=t.getSoonUint16(n);if(n+=2,p>0)for(let e=0;e<p;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4,l.push(e)}const f=t.getSoonUint16(n);if(n+=2,f>0)for(let e=0;e<f;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4}const m=t.getSoonUint16(n);if(n+=2,m>0)for(let e=0;e<m;e++){const e=new vt;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,h.push(e)}const g=t.getSoonUint16(n);if(n+=2,g>0)for(let e=0;e<g;e++){const e=t.getSoonUint16(n);n+=2;const r=t.getSoonUint16(n);n+=2;const i=t.getSoonUint16(n);n+=2;const s=[e,r,i];u.push(s),h.length>0&&d.push([h[s[0]],h[s[1]],h[s[2]]])}const v=[],y=[];for(let t=0;t<u.length;t++){const e=u[t],n=l[e[0]],r=l[e[1]],i=l[e[2]];v.push(...n.toArray(),...r.toArray(),...i.toArray());let s=new vt,a=new vt,o=new vt;const c=d[t];void 0!==c&&(s=c[0],a=c[1],o=c[2]),y.push(...s.toArray(),...a.toArray(),...o.toArray())}const x=new Float32Array(v),_=new Float32Array(y);c[a].position=x.buffer,c[a].uv=_.buffer;const b=new Sn;x.length>0&&b.setAttribute("position",new an(x,3)),_.length>0&&b.setAttribute("uv",new an(_,2)),b.computeVertexNormals();const w=this.materials.get(o);if(w){const t=new sd(b,w,{id:a,name:a.toString()});s.add(t)}i.loaded++,i.timeStamp=performance.now()-r,e&&e(i)}const h={materialsCache:l,meshsCache:c};return Promise.resolve({sbm:s,caches:h})}))}_parseV3(t,e){let n=0;n+=66;const r=performance.now(),i={total:0,loaded:0,timeStamp:0};if(!this.sbmInfo)return Promise.reject("In soonspacejs: sbm 模型资源解析时 'sbmInfo' 缺失!");const s=new vf(this.sbmInfo),a=t.getSoonUint16(n);n+=2;const o=t.getSoonUint16(n);n+=2,i.total=o;let l={};for(let e=0;e<a;++e){const e=t.getSoonUint16(n).toString();n+=2,l[e]={materialInfo:[]},n+=4,n+=4,n+=4,n+=4;const r=t.getSoonFloat32(n);n+=4;const i=t.getSoonFloat32(n);n+=4;const s=t.getSoonFloat32(n);n+=4;const a=t.getSoonFloat32(n);n+=4,n+=4,n+=4,n+=4,n+=4;let o=t.getSoonUint8(n);n+=1,0===o?o=0:1===o?o=1:2===o&&(o=2);const c=t.getSoonUint16(n);n+=2;let h=null;if(c>0){let r="",i="";for(let e=0;e<c;e++){const e=t.getSoonUint8(n);e>127?i=i+"%"+e.toString(16).toUpperCase():i.length>0?(r+=decodeURIComponent(i)+String.fromCharCode(e),i=""):r+=String.fromCharCode(e),n+=1}r=r.replace("\\","/");const{url:s,isPlatform:a}=this.sbmInfo,o=this.getTextureUrl(s,r,a);l[e].textureUrl=o,h=Hf(o)}if(!this.materials.has(e)){const t=[r,i,s,a,o],n=Gf(e,t,h);this.materials.set(e,n),l[e].materialInfo=t}}const c={};for(let a=0;a<o;++a){const a=t.getSoonUint16(n).toString();n+=2;const o=t.getSoonUint16(n);if(n+=2,o>0){let e="";for(let r=0;r<o;r++){const r=t.getUint8(n);r>127?e=e+"%"+r.toString(16).toUpperCase():e.length>0&&(e=""),n+=1}}const l=t.getSoonUint16(n).toString();n+=2,c[a]={materialId:l,position:new ArrayBuffer(0),uv:new ArrayBuffer(0)};const h=[],u=[],d=[],p=[],f=t.getSoonUint32(n);if(n+=4,f>0)for(let e=0;e<f;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4,h.push(e)}const m=t.getSoonUint32(n);if(n+=4,m>0)for(let e=0;e<m;e++){const e=new Ft;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,e.setZ(t.getSoonFloat32(n)),n+=4}const g=t.getSoonUint32(n);if(n+=4,g>0)for(let e=0;e<g;e++){const e=new vt;e.setX(t.getSoonFloat32(n)),n+=4,e.setY(t.getSoonFloat32(n)),n+=4,u.push(e)}const v=t.getSoonUint32(n);if(n+=4,v>0)for(let e=0;e<v;e++){const e=t.getSoonUint32(n);n+=4;const r=t.getSoonUint32(n);n+=4;const i=t.getSoonUint32(n);n+=4;const s=[e,r,i];d.push(s),u.length>0&&p.push([u[s[0]],u[s[1]],u[s[2]]])}const y=[],x=[];for(let t=0;t<d.length;t++){const e=d[t],n=h[e[0]],r=h[e[1]],i=h[e[2]];y.push(...n.toArray(),...r.toArray(),...i.toArray());let s=new vt,a=new vt,o=new vt;const l=p[t];void 0!==l&&(s=l[0],a=l[1],o=l[2]),x.push(...s.toArray(),...a.toArray(),...o.toArray())}const _=new Float32Array(y),b=new Float32Array(x);c[a].position=_.buffer,c[a].uv=b.buffer;const w=new Sn;if(_.length>0&&w.setAttribute("position",new an(_,3)),b.length>0&&w.setAttribute("uv",new an(b,2)),w.computeVertexNormals(),this.materials.has(l)){const t=new sd(w,this.materials.get(l),{id:a,name:a});s.add(t)}i.loaded++,i.timeStamp=performance.now()-r,e&&e(i)}const h={materialsCache:l,meshsCache:c};return Promise.resolve({sbm:s,caches:h})}getTextureUrl(t,e,n){let r="",i=e;const s=i.lastIndexOf("/");if(-1!==s&&(i=i.substring(s+1)),r=t,n){const t=r.split("/");t.length>1&&(t.splice(t.length-3,t.length),r=t.join("/")+"/Maps/"+i)}else{const t=r.lastIndexOf("/");-1!==t&&(r=r.substring(0,t+1)+"Maps/"+i)}return r}},Vf=function(){function t(){}return t.prototype.toJson=function(t,e){var n=this.xmlStringToXmlDom(t),r=this.xmlToJson(n);return e?(e.removeLineBreaks&&this.removeLineBreaks(r),e.removeComments&&this.removeCommentProperties(r),e.transformTextOnly&&this.transformTextOnly(r),r):r},t.prototype.xmlStringToXmlDom=function(t){return(new DOMParser).parseFromString(t,"text/xml")},t.prototype.removeLineBreaks=function(t){var e=this;Object.keys(t).forEach((function(n,r){"#text"===n&&Array.isArray(t[n])&&delete t[n],"object"==typeof t[n]&&e.removeLineBreaks(t[n])}))},t.prototype.removeCommentProperties=function(t){var e=this;Object.keys(t).forEach((function(n,r){"#comment"===n&&delete t[n],"object"==typeof t[n]&&e.removeCommentProperties(t[n])}))},t.prototype.transformTextOnly=function(t){var e=this;Object.keys(t).forEach((function(n,r){var i=Object.keys(t[n]).length>1,s=Object.keys(t[n])[0];i||"object"==typeof t[n][s]?e.transformTextOnly(t[n]):"object"==typeof t[n]&&t[n]["#text"]&&(t[n]=t[n]["#text"])}))},t.prototype.xmlToJson=function(t){var e={};if(1==t.nodeType){if(t.attributes.length>0){e._attributes={};for(var n=0;n<t.attributes.length;n++){var r=t.attributes.item(n);e._attributes[r.nodeName]=r.nodeValue}}}else 3==t.nodeType&&(e=t.nodeValue);if(t.hasChildNodes())for(var i=0;i<t.childNodes.length;i++){var s=t.childNodes.item(i),a=s.nodeName;if(void 0===e[a])e[a]=this.xmlToJson(s);else{if(void 0===e[a].push){var o=e[a];e[a]=[],e[a].push(o)}e[a].push(this.xmlToJson(s))}}return e},t}();function Wf(t){return fetch(t).then((t=>t.text())).then((t=>Promise.resolve(function(t){return(new Vf).toJson(t,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(t))))}class Xf{constructor(){this.materials=new Map}parseObject(t,e){const n=new vf(e),{materialsCache:r,meshsCache:i}=t;for(let[t,e]of Object.entries(r)){if(this.materials.has(t))continue;const{textureUrl:n,materialInfo:r}=e;let i=null;n&&(i=Hf(n));const s=Gf(t,r,i);this.materials.set(t,s)}for(let[t,e]of Object.entries(i)){const{materialId:r,position:i,uv:s}=e,a=this.materials.get(r.toString());if(a){const e=new Sn,r=new Float32Array(i),o=new Float32Array(s);r.length>0&&e.setAttribute("position",new an(r,3)),o.length>0&&e.setAttribute("uv",new an(o,2)),e.computeVertexNormals();const l=new sd(e,a,{id:t,name:t});n.add(l)}}return n}}class Yf extends Nf{constructor(t){super("Sbm",t),this.viewport=t,this.modelMaps=new Map,this.store=Bf.createInstance({name:"soonspace",version:2,storeName:"sbmData"})}load(t,e){return this._loadItem(t,e)}parse(t,e,n){return Fd(this,void 0,void 0,(function*(){const r=t=>{var n;if(!this.modelMaps.get(e.url)){const n=t.sClone();this.modelMaps.set(e.url,n)}return null===(n=t.onLoad)||void 0===n||n.call(t,t),t};if(t instanceof ArrayBuffer)return(new jf).parseBuffer(t,e,n).then((t=>{let n;if(t instanceof vf)n=t;else{const{sbm:r,caches:i}=t;n=r;const s=()=>{i&&this.viewport.options.useIndexedDB&&this.store.setItem(`${e.url}_object`,i)};"function"==typeof requestIdleCallback?requestIdleCallback(s):setTimeout(s)}return r(n)}));const i=(new Xf).parseObject(t,e);return r(i)}))}clone(t,e,n){return new Promise(((r,i)=>{"Sbm"!==t.stype&&i("In soonspacejs: 方法 cloneSbm 参入对象类型错误!");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,v=t.sClone();s&&(v.sid=s),a&&(v.name=a),o&&(v.level=o),Pu(l)&&(v.visible=l),c&&v.position.set(c.x,c.y,c.z),h&&v.rotation.set(h.x,h.y,h.z),u&&v.scale.set(u.x,u.y,u.z),v.onClick=d?d.bind(v):null,v.onDblClick=p?p.bind(v):null,v.onRightClick=f?f.bind(v):null,v.onLoad=m?m.bind(v):null,v.onLoad&&v.onLoad(v),g&&(v.userData=g),null!==n&&this.viewport.scener.addObject(v,n||this.scene||t.parent),r(v)}))}loadToGroup(t,e,n){return new Promise((r=>Fd(this,void 0,void 0,(function*(){const i=new ld(t);for(let t=0;t<e.length;t++){const r=yield this._loadItem(e[t],(r=>{n&&n({modelTotal:e.length,loadingModelIndex:t+1,current:r})}),null);i.add(r)}this.viewport.scener.addObject(i,this.scene),r(i)}))))}addForGroup(t,e,n){return new Promise((r=>Fd(this,void 0,void 0,(function*(){const i=this.getGroupById(t);if(i)for(let t=0;t<e.length;t++){const r=yield this._loadItem(e[t],(r=>{n&&n({modelTotal:e.length,loadingModelIndex:t+1,current:r})}),null);this.viewport.scener.addObject(r,i)}r(i)}))))}createGroupFromXml(t,e){return new Promise((n=>Fd(this,void 0,void 0,(function*(){let r=!1;const i=yield Wf(e),s=new ld(t),{ProjectInfo:a,Building:o}=i.Project,l=t=>Fd(this,void 0,void 0,(function*(){const i=e.split(a.Title+".xml")[0],{id:l,name:c}=t._attributes,{name:h}=t.FileSource._attributes,u=a.Title+c,d=yield this._loadItem({id:l,name:u,url:i+h.replace("\\","/")},void 0,null);let p;if(s.add(d),p=Fu(o.ObjectHierarchy.Entity)?o.ObjectHierarchy.Entity.find((t=>t._attributes.id===l)):o.ObjectHierarchy.Entity,!p)return;const f=p.Entity.filter((t=>"FACILITY"===t._attributes.type)),m=f.length;if(0===m&&r)this.viewport.scener.addObject(s,this.scene),n(s);else for(let t=0;t<m;t++){const{id:e,name:a,longname:o,position:l,scale:c,orient:h}=f[t]._attributes,u=l.split(","),p=c.split(","),g=h.split(","),v=yield this._loadItem({id:e,name:a,url:i+o+".sbm",position:{x:10*Number(u[0].trim()),y:10*Number(u[1].trim()),z:10*Number(u[2].trim())},scale:{x:10*Number(p[0].trim()),y:10*Number(p[1].trim()),z:10*Number(p[2].trim())}},void 0,null);v.quaternion.set(Number(g[1].trim()),Number(g[2].trim()),Number(g[3].trim()),Number(g[0].trim())),d.add(v),r&&t===m-1&&(this.viewport.scener.addObject(s,this.scene),n(s))}})),{Floor:c}=o.Floors;Fu(c)?c.forEach(((t,e)=>{e===c.length-1&&(r=!0),l(t)})):Du(c)&&(r=!0,l(c))}))))}clearIdb(){return this.store.clear()}_loadItem(t,e,n=this.scene){return Fd(this,void 0,void 0,(function*(){const{url:r}=t,{useIndexedDB:i}=this.viewport.options,s=this.modelMaps.get(r);if(s)return this.clone(s,t,n);let a=null,o=null,l=null;return i&&(o=yield this.store.getItem(`${r}_object`),o?l=yield this.parse(o,t,e):a=yield this.store.getItem(r)),l||(a||(a=yield this._fetchBuffer(t)),l=yield this.parse(a,t,e)),null!==n&&this.viewport.scener.addObject(l,n||this.scene),l}))}_fetchBuffer(t){const{url:e}=t,{useIndexedDB:n}=this.viewport.options;return fetch(e).then((t=>t.arrayBuffer())).then((t=>(n&&r&&this.store.setItem(e,t),Promise.resolve(t))))}}
|
|
41
41
|
/*!
|
|
42
42
|
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 Qf={},Zf=function(t){return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))},Jf=function(t){return new Worker(t)};try{URL.revokeObjectURL(Zf(""))}catch(Wf){Zf=function(t){return"data:application/javascript;charset=UTF-8,"+encodeURI(t)},Jf=function(t){return new Worker(t,{type:"module"})}}var Kf=Uint8Array,$f=Uint16Array,tm=Uint32Array,em=new Kf([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]),nm=new Kf([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]),rm=new Kf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),im=function(t,e){for(var n=new $f(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var i=new tm(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]},sm=im(em,2),am=sm[0],om=sm[1];am[28]=258,om[258]=28;for(var lm=im(nm,0),cm=lm[0],hm=lm[1],um=new $f(32768),dm=0;dm<32768;++dm){var pm=(43690&dm)>>>1|(21845&dm)<<1;pm=(61680&(pm=(52428&pm)>>>2|(13107&pm)<<2))>>>4|(3855&pm)<<4,um[dm]=((65280&pm)>>>8|(255&pm)<<8)>>>1}var fm=function(t,e,n){for(var r=t.length,i=0,s=new $f(e);i<r;++i)++s[t[i]-1];var a,o=new $f(e);for(i=0;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;if(n){a=new $f(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[um[u]>>>l]=c}else for(a=new $f(r),i=0;i<r;++i)t[i]&&(a[i]=um[o[t[i]-1]++]>>>15-t[i]);return a},mm=new Kf(288);for(dm=0;dm<144;++dm)mm[dm]=8;for(dm=144;dm<256;++dm)mm[dm]=9;for(dm=256;dm<280;++dm)mm[dm]=7;for(dm=280;dm<288;++dm)mm[dm]=8;var gm=new Kf(32);for(dm=0;dm<32;++dm)gm[dm]=5;var vm=fm(mm,9,0),ym=fm(mm,9,1),xm=fm(gm,5,0),_m=fm(gm,5,1),bm=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},wm=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&n},Mm=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Sm=function(t){return(t/8|0)+(7&t&&1)},Tm=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var r=new(t instanceof $f?$f:t instanceof tm?tm:Kf)(n-e);return r.set(t.subarray(e,n)),r},Am=function(t,e,n){var r=t.length;if(!r||n&&!n.l&&r<5)return e||new Kf(0);var i=!e||n,s=!n||n.i;n||(n={}),e||(e=new Kf(3*r));var a=function(t){var n=e.length;if(t>n){var r=new Kf(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=wm(t,l,1);var m=wm(t,l+1,3);if(l+=3,!m){var g=t[(E=Sm(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=ym,u=_m,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=wm(t,l,31)+257,x=wm(t,l+10,15)+4,_=y+wm(t,l+5,31)+1;l+=14;for(var b=new Kf(_),w=new Kf(19),M=0;M<x;++M)w[rm[M]]=wm(t,l+3*M,7);l+=3*x;var S=bm(w),T=(1<<S)-1,A=fm(w,S,1);for(M=0;M<_;){var E,P=A[wm(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+wm(t,l,3),l+=2,C=b[M-1]):17==E?(L=3+wm(t,l,7),l+=3):18==E&&(L=11+wm(t,l,127),l+=7);L--;)b[M++]=C}}var R=b.subarray(0,y),I=b.subarray(y);d=bm(R),p=bm(I),h=fm(R,d,1),u=fm(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[Mm(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=em[M=O-257];U=wm(t,l,(1<<B)-1)+am[M],l+=B}var z=u[Mm(t,l)&D],k=z>>>4;if(!z)throw"invalid distance";l+=15&z;I=cm[k];if(k>3){B=nm[k];I+=Mm(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:Tm(e,0,c)},Em=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>>8},Pm=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},Cm=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[Om,0];if(1==i){var a=new Kf(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 $f(d+1),f=Lm(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 Kf(p),f]},Lm=function(t,e,n){return-1==t.s?Math.max(Lm(t.l,e,n+1),Lm(t.r,e,n+1)):e[t.s]=n},Rm=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new $f(++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]},Im=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},Fm=function(t,e,n){var r=n.length,i=Sm(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)},Dm=function(t,e,n,r,i,s,a,o,l,c,h){Em(e,h++,n),++i[256];for(var u=Cm(i,15),d=u[0],p=u[1],f=Cm(s,15),m=f[0],g=f[1],v=Rm(d),y=v[0],x=v[1],_=Rm(m),b=_[0],w=_[1],M=new $f(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=Cm(M,7),A=T[0],E=T[1],P=19;P>4&&!A[rm[P-1]];--P);var C,L,R,I,F=c+5<<3,D=Im(i,mm)+Im(s,gm)+a,N=Im(i,d)+Im(s,m)+a+14+3*P+Im(M,A)+(2*M[16]+3*M[17]+7*M[18]);if(F<=D&&F<=N)return Fm(e,h,t.subarray(l,l+c));if(Em(e,h,1+(N<D)),h+=2,N<D){C=fm(d,p,0),L=d,R=fm(m,g,0),I=m;var O=fm(A,E,0);Em(e,h,x-257),Em(e,h+5,w-1),Em(e,h+10,P-4),h+=14;for(S=0;S<P;++S)Em(e,h+3*S,A[rm[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];Em(e,h,O[k]),h+=A[k],k>15&&(Em(e,h,z[S]>>>5&127),h+=z[S]>>>12)}}}else C=vm,L=mm,R=xm,I=gm;for(S=0;S<o;++S)if(r[S]>255){k=r[S]>>>18&31;Pm(e,h,C[k+257]),h+=L[k+257],k>7&&(Em(e,h,r[S]>>>23&31),h+=em[k]);var H=31&r[S];Pm(e,h,R[H]),h+=I[H],H>3&&(Pm(e,h,r[S]>>>5&8191),h+=nm[H])}else Pm(e,h,C[r[S]]),h+=L[r[S]];return Pm(e,h,C[256]),h+L[256]},Nm=new tm([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Om=new Kf(0),Um=function(t,e,n,r,i,s){var a=t.length,o=new Kf(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=Fm(l,c,t.subarray(h,u)):(l[h]=s,c=Fm(l,c,t.subarray(h,a)))}else{for(var d=Nm[e-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new $f(32768),v=new $f(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 tm(25e3),w=new $f(288),M=new $f(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=Dm(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|om[D]<<18|hm[N];var X=31&om[D],Y=31&hm[N];T+=em[X]+nm[Y],++w[257+X],++M[Y],E=h+D,++S}else b[A++]=t[h],++w[t[h]]}}c=Dm(t,l,s,b,w,M,T,A,P,h-P,c),!s&&7&c&&(c=Fm(l,c+1,Om))}return Tm(o,0,r+Sm(c)+i)},Bm=function(){for(var t=new tm(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),zm=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=Bm[255&n^e[r]]^n>>>8;t=n},d:function(){return~t}}},km=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}}},Hm=function(t,e,n,r,i){return Um(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)},Gm=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},jm=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]},Vm=[],Wm=function(t,e,n,r){var i;if(!Vm[n]){for(var s="",a={},o=t.length-1,l=0;l<o;++l)s=(i=jm(t[l],s,a))[0],a=i[1];Vm[n]=jm(t[o],s,a)}var c=Gm({},Vm[n][1]);return function(t,e,n,r,i){var s=Jf(Qf[e]||(Qf[e]=Zf(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}(Vm[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 Kf||t[n]instanceof $f||t[n]instanceof tm)&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e}(c),r)},Xm=function(){return[Kf,$f,tm,em,nm,rm,am,cm,ym,_m,um,fm,bm,wm,Mm,Sm,Tm,Am,bg,Km,$m]},Ym=function(){return[Kf,$f,tm,em,nm,rm,om,hm,vm,mm,xm,gm,um,Nm,Om,fm,Em,Pm,Cm,Lm,Rm,Im,Fm,Dm,Sm,Tm,Um,Hm,vg,Km]},qm=function(){return[og,hg,ag,zm,Bm]},Qm=function(){return[lg,cg]},Zm=function(){return[ug,ag,km]},Jm=function(){return[dg]},Km=function(t){return postMessage(t,[t.buffer])},$m=function(t){return t&&t.size&&new Kf(t.size)},tg=function(t,e,n,r,i,s){var a=Wm(n,r,i,(function(t,e){a.terminate(),s(t,e)}));return a.postMessage([t,e],e.consume?[t.buffer]:[]),function(){a.terminate()}},eg=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])}},ng=function(t,e,n,r,i){var s,a=Wm(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()}},rg=function(t,e){return t[e]|t[e+1]<<8},ig=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},sg=function(t,e){return ig(t,e)+4294967296*ig(t,e+4)},ag=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},og=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&&ag(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)}},lg=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)},cg=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},hg=function(t){return 10+(t.filename&&t.filename.length+1||0)},ug=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)},dg=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 pg(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var fg=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(Hm(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}(),mg=function(){return function(t,e){ng([Ym,function(){return[eg,fg]}],this,pg.call(this,t,e),(function(t){var e=new fg(t.data);onmessage=eg(e)}),6)}}();function gg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return tg(t,e,[Ym],(function(t){return Km(vg(t.data[0],t.data[1]))}),0,n)}function vg(t,e){return Hm(t,e||{},0,0)}var yg=function(){function t(t){this.s={},this.p=new Kf(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 Kf(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=Am(this.p,this.o,this.s);this.ondata(Tm(n,e,this.s.b),this.d),this.o=Tm(n,this.s.b-32768),this.s.b=this.o.length,this.p=Tm(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),xg=function(){return function(t){this.ondata=t,ng([Xm,function(){return[eg,yg]}],this,0,(function(){var t=new yg;onmessage=eg(t)}),7)}}();function _g(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return tg(t,e,[Xm],(function(t){return Km(bg(t.data[0],$m(t.data[1])))}),1,n)}function bg(t,e){return Am(t,e)}var wg=function(){function t(t,e){this.c=zm(),this.l=0,this.v=1,fg.call(this,t,e)}return t.prototype.push=function(t,e){fg.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=Hm(t,this.o,this.v&&hg(this.o),e&&8,!e);this.v&&(og(n,this.o),this.v=0),e&&(ag(n,n.length-8,this.c.d()),ag(n,n.length-4,this.l)),this.ondata(n,e)},t}(),Mg=function(){return function(t,e){ng([Ym,qm,function(){return[eg,fg,wg]}],this,pg.call(this,t,e),(function(t){var e=new wg(t.data);onmessage=eg(e)}),8)}}();function Sg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return tg(t,e,[Ym,qm,function(){return[Tg]}],(function(t){return Km(Tg(t.data[0],t.data[1]))}),2,n)}function Tg(t,e){e||(e={});var n=zm(),r=t.length;n.p(t);var i=Hm(t,e,hg(e),8),s=i.length;return og(i,e),ag(i,s-8,n.d()),ag(i,s-4,r),i}var Ag=function(){function t(t){this.v=1,yg.call(this,t)}return t.prototype.push=function(t,e){if(yg.prototype.e.call(this,t),this.v){var n=this.p.length>3?lg(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)}yg.prototype.c.call(this,e)},t}(),Eg=function(){return function(t){this.ondata=t,ng([Xm,Qm,function(){return[eg,yg,Ag]}],this,0,(function(){var t=new Ag;onmessage=eg(t)}),9)}}();function Pg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return tg(t,e,[Xm,Qm,function(){return[Cg]}],(function(t){return Km(Cg(t.data[0]))}),3,n)}function Cg(t,e){return Am(t.subarray(lg(t),-8),e||new Kf(cg(t)))}var Lg=function(){function t(t,e){this.c=km(),this.v=1,fg.call(this,t,e)}return t.prototype.push=function(t,e){fg.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var n=Hm(t,this.o,this.v&&2,e&&4,!e);this.v&&(ug(n,this.o),this.v=0),e&&ag(n,n.length-4,this.c.d()),this.ondata(n,e)},t}(),Rg=function(){return function(t,e){ng([Ym,Zm,function(){return[eg,fg,Lg]}],this,pg.call(this,t,e),(function(t){var e=new Lg(t.data);onmessage=eg(e)}),10)}}();function Ig(t,e){e||(e={});var n=km();n.p(t);var r=Hm(t,e,2,4);return ug(r,e),ag(r,r.length-4,n.d()),r}var Fg=function(){function t(t){this.v=1,yg.call(this,t)}return t.prototype.push=function(t,e){if(yg.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)}yg.prototype.c.call(this,e)},t}(),Dg=function(){return function(t){this.ondata=t,ng([Xm,Jm,function(){return[eg,yg,Fg]}],this,0,(function(){var t=new Fg;onmessage=eg(t)}),11)}}();function Ng(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return tg(t,e,[Xm,Jm,function(){return[Og]}],(function(t){return Km(Og(t.data[0],$m(t.data[1])))}),5,n)}function Og(t,e){return Am((dg(t),t.subarray(2,-4)),e)}var Ug=function(){function t(t){this.G=Ag,this.I=yg,this.Z=Fg,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 Kf(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}(),Bg=function(){function t(t){this.G=Eg,this.I=xg,this.Z=Dg,this.ondata=t}return t.prototype.push=function(t,e){Ug.prototype.push.call(this,t,e)},t}();var zg=function(t,e,n,r){for(var i in t){var s=t[i],a=e+i;s instanceof Kf?n[a]=[s,r]:Array.isArray(s)?n[a]=[s[0],Gm(r,s[1])]:zg(s,a+"/",n,r)}},kg="undefined"!=typeof TextEncoder&&new TextEncoder,Hg="undefined"!=typeof TextDecoder&&new TextDecoder,Gg=0;try{Hg.decode(Om,{stream:!0}),Gg=1}catch(Wf){}var jg=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,Tm(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)}},Vg=function(){function t(t){this.ondata=t,Gg?this.t=new TextDecoder:this.p=Om}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 Kf(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var r=jg(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}(),Wg=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(Xg(t),this.d=e||!1)},t}();function Xg(t,e){if(e){for(var n=new Kf(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}if(kg)return kg.encode(t);var i=t.length,s=new Kf(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 Kf(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 Tm(s,0,a)}function Yg(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(Hg)return Hg.decode(t);var i=jg(t),s=i[0];if(i[1].length)throw"invalid utf-8 data";return s}var qg=function(t){return 1==t?3:t<6?2:9==t?1:0},Qg=function(t,e){return e+30+rg(t,e+26)+rg(t,e+28)},Zg=function(t,e,n){var r=rg(t,e+28),i=Yg(t.subarray(e+46,e+46+r),!(2048&rg(t,e+8))),s=e+46+r,a=ig(t,e+20),o=n&&4294967295==a?Jg(t,s):[a,ig(t,e+24),ig(t,e+42)],l=o[0],c=o[1],h=o[2];return[rg(t,e+10),l,c,i,s+rg(t,e+30)+rg(t,e+32),h]},Jg=function(t,e){for(;1!=rg(t,e);e+=4+rg(t,e+2));return[sg(t,e+12),sg(t,e+4),sg(t,e+20)]},Kg=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},$g=function(t,e,n,r,i,s,a,o){var l=r.length,c=n.extra,h=o&&o.length,u=Kg(c);ag(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(ag(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),e+=4,null!=s&&(ag(t,e,n.crc),ag(t,e+4,s),ag(t,e+8,n.size)),ag(t,e+12,l),ag(t,e+14,u),e+=16,null!=a&&(ag(t,e,h),ag(t,e+6,n.attrs),ag(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;ag(t,e,+f),ag(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e},tv=function(t,e,n,r,i){ag(t,e,101010256),ag(t,e+8,n),ag(t,e+10,n),ag(t,e+12,r),ag(t,e+16,i)},ev=function(){function t(t){this.filename=t,this.c=zm(),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}(),nv=function(){function t(t,e){var n=this;e||(e={}),ev.call(this,t),this.d=new fg(e,(function(t,e){n.ondata(null,t,e)})),this.compression=8,this.flag=qg(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){ev.prototype.push.call(this,t,e)},t}(),rv=function(){function t(t,e){var n=this;e||(e={}),ev.call(this,t),this.d=new mg(e,(function(t,e,r){n.ondata(t,e,r)})),this.compression=8,this.flag=qg(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){ev.prototype.push.call(this,t,e)},t}(),iv=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=Xg(t.filename),r=n.length,i=t.comment,s=i&&Xg(i),a=r!=t.filename.length||s&&i.length!=s.length,o=r+Kg(t.extra)+30;if(r>65535)throw"filename too long";var l=new Kf(o);$g(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=Gm(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 Kf(16);ag(s,0,134695760),ag(s,4,t.crc),ag(s,8,f),ag(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+Kg(l.extra)+(l.o?l.o.length:0)}for(var s=new Kf(n+22),a=0,o=this.u;a<o.length;a++){var l=o[a];$g(s,t,l,l.f,l.u,l.c,e,l.o),t+=46+l.f.length+Kg(l.extra)+(l.o?l.o.length:0),e+=l.b}tv(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 sv=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}(),av=function(){function t(){var t=this;this.i=new yg((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}(),ov=function(){function t(t,e){var n=this;e<32e4?this.i=new yg((function(t,e){n.ondata(null,t,e)})):(this.i=new xg((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=Tm(t,0)),this.i.push(t,e)},t.compression=8,t}(),lv=function(){function t(t){this.onfile=t,this.k=[],this.o={0:sv},this.p=Om}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 Kf(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=ig(l,a);if(67324752==e){s=1,o=a,p.d=null,p.c=0;var r=rg(l,a+6),i=rg(l,a+8),u=2048&r,d=8&r,f=rg(l,a+26),m=rg(l,a+28);if(c>a+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=ig(l,a+18),x=ig(l,a+22),_=Yg(l.subarray(a+30,a+=30+f),!u);4294967295==y?(t=d?[-2]:Jg(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(Om,!0)}else b.ondata(null,Om,!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=Om,h<0){var f=s?l.subarray(0,o-12-(-2==h&&8)-(134695760==ig(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 cv=Object.freeze({__proto__:null,Deflate:fg,AsyncDeflate:mg,deflate:gg,deflateSync:vg,Inflate:yg,AsyncInflate:xg,inflate:_g,inflateSync:bg,Gzip:wg,AsyncGzip:Mg,gzip:Sg,gzipSync:Tg,Gunzip:Ag,AsyncGunzip:Eg,gunzip:Pg,gunzipSync:Cg,Zlib:Lg,AsyncZlib:Rg,zlib:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return tg(t,e,[Ym,Zm,function(){return[Ig]}],(function(t){return Km(Ig(t.data[0],t.data[1]))}),4,n)},zlibSync:Ig,Unzlib:Fg,AsyncUnzlib:Dg,unzlib:Ng,unzlibSync:Og,compress:Sg,AsyncCompress:Mg,compressSync:Tg,Compress:wg,Decompress:Ug,AsyncDecompress:Bg,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]?Pg(t,e,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?_g(t,e,n):Ng(t,e,n)},decompressSync:function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?Cg(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?bg(t,e):Og(t,e)},DecodeUTF8:Vg,EncodeUTF8:Wg,strToU8:Xg,strFromU8:Yg,ZipPassThrough:ev,ZipDeflate:nv,AsyncZipDeflate:rv,Zip:iv,zip:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";var r={};zg(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 Kf(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;$g(t,o,s,s.f,s.u,h);var u=30+s.f.length+Kg(s.extra),d=o+u;t.set(s.c,d),$g(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)}}tv(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=zm(),g=p.length;m.p(p);var v=Xg(e),y=v.length,x=f.comment,_=x&&Xg(x),b=_&&_.length,w=Kg(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]=Gm(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,vg(p,f))}catch(t){S(t,null)}else h.push(gg(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=[];zg(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=Xg(a)).length,d=c.comment,p=d&&Xg(d),f=p&&p.length,m=Kg(c.extra);if(u>65535)throw"filename too long";var g=h?vg(l,c):l,v=g.length,y=zm();y.p(l),r.push(Gm(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 Kf(s+22),_=i,b=s-i,w=0;w<r.length;++w){var M=r[w];$g(x,M.o,M,M.f,M.u,M.c.length);var S=30+M.f.length+Kg(M.extra);x.set(M.c,M.o+S),$g(x,i,M,M.f,M.u,M.c.length,M.o,M.m),i+=16+S+(M.m?M.m.length:0)}return tv(x,i,r.length,b,_),x},UnzipPassThrough:sv,UnzipInflate:av,AsyncUnzipInflate:ov,Unzip:lv,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!=ig(t,s);--s)if(!s||t.length-s>65558)return void e("invalid zip file",null);var a=rg(t,s+8);a||e(null,{});var o=a,l=ig(t,s+16),c=4294967295==l;if(c){if(s=ig(t,s-12),101075792!=ig(t,s))return void e("invalid zip file",null);o=a=ig(t,s+32),l=ig(t,s+48)}for(var h=function(s){var o=Zg(t,l,c),h=o[0],u=o[1],d=o[2],p=o[3],f=o[4],m=o[5],g=Qg(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,bg(y,new Kf(d)))}catch(t){v(t,null)}else n.push(_g(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,Tm(t,g,g+u))},u=0;u<o;++u)h();return r},unzipSync:function(t){for(var e={},n=t.length-22;101010256!=ig(t,n);--n)if(!n||t.length-n>65558)throw"invalid zip file";var r=rg(t,n+8);if(!r)return{};var i=ig(t,n+16),s=4294967295==i;if(s){if(n=ig(t,n-12),101075792!=ig(t,n))throw"invalid zip file";r=ig(t,n+32),i=ig(t,n+48)}for(var a=0;a<r;++a){var o=Zg(t,i,s),l=o[0],c=o[1],h=o[2],u=o[3],d=o[4],p=o[5],f=Qg(t,p);if(i=d,l){if(8!=l)throw"unknown compression type "+l;e[u]=bg(t.subarray(f,f+c),new Kf(h))}else e[u]=Tm(t,f,f+c)}return e}});function hv(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 uv(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 dv(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 Ft(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(uv(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=hv(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 Pt(0,0,0);return a}(t,e,n,r,i))}class pv extends Mo{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 Pt(e.x,e.y,e.z,e.w)}}getPoint(t,e=new Ft){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=hv(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 Pt(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 Ft){const n=e,r=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),i=dv(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}}let fv,mv,gv;class vv extends cc{constructor(t){super(t)}load(t,e,n,r){const i=this,s=""===i.path?Oc.extractUrlBase(t):i.path,a=new uc(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===Dv(t,0,e.length)}(t))fv=(new wv).parse(t);else{const e=Dv(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(Tv(e)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Tv(e));fv=(new bv).parse(e)}const n=new mc(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new yv(n,this.manager).parse(fv)}}class yv{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){mv=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),n=this.parseMaterials(e),r=this.parseDeformers(),i=(new xv).parse(r);return this.parseScene(r,i,n),gv}parseConnections(){const t=new Map;if("Connections"in fv){fv.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 fv.Objects){const n=fv.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 fv.Objects){const n=fv.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?f:m,n.wrapT=0===a?f:m,"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=mv.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 At):(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 At):s=this.textureLoader.load(n);return this.textureLoader.setPath(r),s}parseMaterials(t){const e=new Map;if("Material"in fv.Objects){const n=fv.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),!mv.has(n))return null;const s=this.parseParameters(t,e,n);let a;switch(i.toLowerCase()){case"phong":a=new Bl;break;case"lambert":a=new Hl;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),a=new Bl}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 en).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(r.color=(new en).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(r.displacementScale=t.DisplacementFactor.value),t.Emissive?r.emissive=(new en).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(r.emissive=(new en).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 en).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(r.specular=(new en).fromArray(t.SpecularColor.value));const i=this;return mv.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=K);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=K);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=h,r.envMap.encoding=K);break;case"SpecularColor":r.specularMap=i.getTexture(e,t.ID),void 0!==r.specularMap&&(r.specularMap.encoding=K);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 fv.Objects&&e in fv.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=mv.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in fv.Objects){const n=fv.Objects.Deformer;for(const r in n){const i=n[r],s=mv.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 he).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=mv.get(parseInt(i.ID)).children.filter((function(t){return void 0===t.relationship}))[0].ID,n.push(a)}return n}parseScene(t,e,n){gv=new qs;const r=this.parseModels(t.skeletons,e,n),i=fv.Objects.Model,s=this;r.forEach((function(t){const e=i[t.ID];s.setLookAtProperties(t,e);mv.get(t.ID).parents.forEach((function(e){const n=r.get(e.ID);void 0!==n&&n.add(t)})),null===t.parent&&gv.add(t)})),this.bindSkeleton(t.skeletons,e,r),this.createAmbientLight(),gv.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=Rv(t.userData.transformData);t.applyMatrix4(e),t.updateWorldMatrix()}}));const a=(new _v).parse();1===gv.children.length&&gv.children[0].isGroup&&(gv.children[0].animations=a,gv=gv.children[0]),gv.animations=a}parseModels(t,e,n){const r=new Map,i=fv.Objects.Model;for(const s in i){const a=parseInt(s),o=i[s],l=mv.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 Fa;break;case"Null":default:c=new qs}c.name=o.attrName?_h.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 Fa,i.matrixWorld.copy(e.transformLink),i.name=r?_h.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=fv.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Ne;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 Zn(l,o,r,i),null!==c&&e.setFocalLength(c);break;case 1:e=new _r(-s/2,s/2,a/2,-a/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+t+"."),e=new Ne}}return e}createLight(t){let e,n;if(t.children.forEach((function(t){const e=fv.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Ne;else{let t;t=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=(new en).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 Pc(r,i,s,a);break;case 1:e=new Lc(r,i);break;case 2:let t=Math.PI/3;void 0!==n.InnerAngle&&(t=gt.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=gt.degToRad(n.OuterAngle.value),o=Math.max(o,1)),e=new Mc(r,i,s,t,o,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),e=new Pc(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 Bl({color:13421772}),a.push(s)),"color"in i.attributes&&a.forEach((function(t){t.vertexColors=!0})),i.FBX_Deformer?(r=new Ia(i,s),r.normalizeSkinWeights()):r=new Gn(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 Va({color:3342591,linewidth:1});return new Za(n,r)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),n.eulerOrder="RotationOrder"in e?Iv(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){mv.get(t.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const n=fv.Objects.Model[e.ID];if("Lcl_Translation"in n){const e=n.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(e),gv.add(t.target)):t.lookAt((new Ft).fromArray(e))}}}))}}bindSkeleton(t,e,n){const r=this.parsePoseNodes();for(const i in t){const s=t[i];mv.get(parseInt(s.ID)).parents.forEach((function(t){if(e.has(t.ID)){const e=t.ID;mv.get(e).parents.forEach((function(t){if(n.has(t.ID)){n.get(t.ID).bind(new Ua(s.bones),r[t.ID])}}))}}))}}parsePoseNodes(){const t={};if("Pose"in fv.Objects){const e=fv.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 he).fromArray(e.Matrix.a)})):t[r.Node]=(new he).fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in fv&&"AmbientColor"in fv.GlobalSettings){const t=fv.GlobalSettings.AmbientColor.value,e=t[0],n=t[1],r=t[2];if(0!==e||0!==n||0!==r){const t=new en(e,n,r);gv.add(new Rc(t,1))}}}}class xv{parse(t){const e=new Map;if("Geometry"in fv.Objects){const n=fv.Objects.Geometry;for(const r in n){const i=mv.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 fv.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=Iv(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=Rv(l);return this.genGeometry(e,a,i,c)}genGeometry(t,e,n,r){const i=new Sn;t.attrName&&(i.name=t.attrName);const s=this.parseGeoNode(t,e),a=this.genBuffers(s),o=new mn(a.vertex,3);if(o.applyMatrix4(r),i.setAttribute("position",o),a.colors.length>0&&i.setAttribute("color",new mn(a.colors,3)),e&&(i.setAttribute("skinIndex",new un(a.weightsIndices,4)),i.setAttribute("skinWeight",new mn(a.vertexWeights,4)),i.FBX_Deformer=e),a.normal.length>0){const t=(new yt).getNormalMatrix(r),e=new mn(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 mn(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=Pv(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=Pv(p,n,d,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(f=Pv(p,n,d,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=Pv(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=fv.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 mn(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===pv)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 Sn;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 Sn;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 Pt).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 pv(n,r,i,a,o).getPoints(12*i.length);return(new Sn).setFromPoints(l)}}class _v{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===fv.Objects.AnimationCurve)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=fv.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=fv.Objects.AnimationCurve;for(const n in e){const r={id:e[n].id,times:e[n].KeyTime.a.map(Av),values:e[n].KeyValueFloat.a},i=mv.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=fv.Objects.AnimationLayer,n=new Map;for(const r in e){const e=[],i=mv.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=mv.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID;if(void 0!==t){const i=fv.Objects.Model[t.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:i.attrName?_h.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};gv.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 he),"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=mv.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID,i=mv.get(t).parents[0].ID,s=mv.get(i).parents[0].ID,a=mv.get(s).parents[0].ID,o=fv.Objects.Model[a],l={modelName:o.attrName?_h.sanitizeNodeName(o.attrName):"",morphName:fv.Objects.Deformer[t].attrName};e[r]=l}e[r][i.attr]=i}}})),n.set(parseInt(r),e)}}return n}parseAnimStacks(t){const e=fv.Objects.AnimationStack,n={};for(const r in e){const i=mv.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 ic(t.name,-1,e)}generateTracks(t){const e=[];let n=new Ft,r=new It,i=new Ft;if(t.transform&&t.transform.decompose(n,r,i),n=n.toArray(),r=(new _e).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 rc(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(gt.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(gt.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(gt.degToRad));const a=this.getTimesForAllAxes(e),o=this.getKeyframeTrackValues(a,e,n);void 0!==r&&((r=r.map(gt.degToRad)).push(s),r=(new _e).fromArray(r),r=(new It).setFromEuler(r)),void 0!==i&&((i=i.map(gt.degToRad)).push(s),i=(new _e).fromArray(i),i=(new It).setFromEuler(i).invert());const l=new It,c=new _e,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 ec(t+".quaternion",a,h)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,n=e.values.map((function(t){return t/100})),r=gv.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new $l(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=Nv(t.times,e,u),t.values=Nv(t.values,e,d)}}}}class bv{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 Sv,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=Fv(i))}else this.parseNodeSpecialProperty(t,r,i)}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,","!==t.slice(-1)&&(e.a=Fv(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=Fv(l)}this.getPrevNode()[i]={type:s,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class wv{parse(t){const e=new Mv(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 Sv;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===cv&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=Og(new Uint8Array(t.getArrayBuffer(s))),o=new Mv(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 Mv{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)),Oc.decodeText(new Uint8Array(e))}}class Sv{add(t,e){this[t]=e}}function Tv(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 Av(t){return t/46186158e3}const Ev=[];function Pv(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}(Ev,r.buffer,s,a)}const Cv=new _e,Lv=new Ft;function Rv(t){const e=new he,n=new he,r=new he,i=new he,s=new he,a=new he,o=new he,l=new he,c=new he,h=new he,u=new he,d=new he,p=t.inheritType?t.inheritType:0;if(t.translation&&e.setPosition(Lv.fromArray(t.translation)),t.preRotation){const e=t.preRotation.map(gt.degToRad);e.push(t.eulerOrder),n.makeRotationFromEuler(Cv.fromArray(e))}if(t.rotation){const e=t.rotation.map(gt.degToRad);e.push(t.eulerOrder),r.makeRotationFromEuler(Cv.fromArray(e))}if(t.postRotation){const e=t.postRotation.map(gt.degToRad);e.push(t.eulerOrder),i.makeRotationFromEuler(Cv.fromArray(e)),i.invert()}t.scale&&s.scale(Lv.fromArray(t.scale)),t.scalingOffset&&o.setPosition(Lv.fromArray(t.scalingOffset)),t.scalingPivot&&a.setPosition(Lv.fromArray(t.scalingPivot)),t.rotationOffset&&l.setPosition(Lv.fromArray(t.rotationOffset)),t.rotationPivot&&c.setPosition(Lv.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(u.copy(t.parentMatrix),h.copy(t.parentMatrixWorld));const f=n.clone().multiply(r).multiply(i),m=new he;m.extractRotation(h);const g=new he;g.copyPosition(h);const v=g.clone().invert().multiply(h),y=m.clone().invert().multiply(v),x=s,_=new he;if(0===p)_.copy(m).multiply(f).multiply(y).multiply(x);else if(1===p)_.copy(m).multiply(y).multiply(f).multiply(x);else{const t=(new he).scale((new Ft).setFromMatrixScale(u)).clone().invert(),e=y.clone().multiply(t);_.copy(m).multiply(f).multiply(e).multiply(x)}const b=c.clone().invert(),w=a.clone().invert();let M=e.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(b).multiply(o).multiply(a).multiply(s).multiply(w);const S=(new he).copyPosition(M),T=h.clone().multiply(S);return d.copyPosition(T),M=d.clone().multiply(_),M.premultiply(h.invert()),M}function Iv(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 Fv(t){return t.split(",").map((function(t){return parseFloat(t)}))}function Dv(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=t.byteLength),Oc.decodeText(new Uint8Array(t,e,n))}function Nv(t,e,n){return t.slice(0,e).concat(n).concat(t.slice(e))}class Ov extends cc{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new Hv(t)})),this.register((function(t){return new Yv(t)})),this.register((function(t){return new qv(t)})),this.register((function(t){return new Gv(t)})),this.register((function(t){return new jv(t)})),this.register((function(t){return new Vv(t)})),this.register((function(t){return new Wv(t)})),this.register((function(t){return new Xv(t)})),this.register((function(t){return new zv(t)})),this.register((function(t){return new Qv(t)}))}load(t,e,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Oc.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 uc(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(Oc.decodeText(new Uint8Array(t,0,4))===Zv){try{s[Bv.KHR_BINARY_GLTF]=new $v(t)}catch(t){return void(r&&r(t))}i=s[Bv.KHR_BINARY_GLTF].content}else i=Oc.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 Iy(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 Bv.KHR_MATERIALS_UNLIT:s[e]=new kv;break;case Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[e]=new ry;break;case Bv.KHR_DRACO_MESH_COMPRESSION:s[e]=new ty(o,this.dracoLoader);break;case Bv.KHR_TEXTURE_TRANSFORM:s[e]=new ey;break;case Bv.KHR_MESH_QUANTIZATION:s[e]=new iy;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 Uv(){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 Bv={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 zv{constructor(t){this.parser=t,this.name=Bv.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 en(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 Lc(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Pc(o),a.distance=l;break;case"spot":a=new Mc(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 kv{constructor(){this.name=Bv.KHR_MATERIALS_UNLIT}getMaterialType(){return nn}extendParams(t,e,n){const r=[];t.color=new en(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 Hv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 vt(t,t)}return Promise.all(i)}}class Gv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 en(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 jv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 Vv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 en(a[0],a[1],a[2]),Promise.all(i)}}class Wv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 Xv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 en(a[0],a[1],a[2]),void 0!==s.specularColorTexture&&i.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture).then((function(t){t.encoding=K}))),Promise.all(i)}}class Yv{constructor(t){this.parser=t,this.name=Bv.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 qv{constructor(t){this.parser=t,this.name=Bv.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 Qv{constructor(t){this.name=Bv.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 Zv="glTF",Jv=1313821514,Kv=5130562;class $v{constructor(t){this.name=Bv.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:Oc.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Zv)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===Jv){const n=new Uint8Array(t,12+i,e);this.content=Oc.decodeText(n)}else if(n===Kv){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 ty{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Bv.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=xy[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const r=xy[e]||e.toLowerCase();if(void 0!==s[e]){const i=n.accessors[t.attributes[e]],s=my[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 ey{constructor(){this.name=Bv.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 ny extends Ol{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 en).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 ry{constructor(){this.name=Bv.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 ny}extendParams(t,e,n){const r=e.extensions[this.name];t.color=new en(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 en(0,0,0),t.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,t.specular=new en(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 ny(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 iy{constructor(){this.name=Bv.KHR_MESH_QUANTIZATION}}class sy extends Xl{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}}sy.prototype.beforeStart_=sy.prototype.copySampleValue_,sy.prototype.afterEnd_=sy.prototype.copySampleValue_,sy.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 ay=new It;class oy extends sy{interpolate_(t,e,n,r){const i=super.interpolate_(t,e,n,r);return ay.fromArray(i).normalize().toArray(i),i}}const ly=0,cy=1,hy=2,uy=3,dy=4,py=5,fy=6,my={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},gy={9728:v,9729:_,9984:y,9985:b,9986:x,9987:w},vy={33071:m,33648:g,10497:f},yy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xy={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_y={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},by={CUBICSPLINE:void 0,LINEAR:V,STEP:j},wy="OPAQUE",My="MASK",Sy="BLEND";function Ty(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new Ol({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),t.DefaultMaterial}function Ay(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 Ey(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 Py(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 Cy(t){const e=t.extensions&&t.extensions[Bv.KHR_DRACO_MESH_COMPRESSION];let n;return n=e?"draco:"+e.bufferView+":"+e.indices+":"+Ly(e.attributes):t.indices+":"+Ly(t.attributes)+":"+t.mode,n}function Ly(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 Ry(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 Iy{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Uv,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 Gc(this.options.manager):this.textureLoader=new mc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new uc(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:{}};Ay(i,s,r),Ey(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[Bv.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(t,i){n.load(Oc.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=yy[r.type],a=my[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 sa(d,h/o),e.cache.add(n,l)),p=new oa(l,s,c%h/o,u)}else d=null===i?new a(r.count*s):new a(i,c,r.count*s),p=new an(d,s,u);if(void 0!==r.sparse){const e=yy.SCALAR,n=my[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 an(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 At(t);n.needsUpdate=!0,e(n)}),n.load(Oc.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=gy[n.magFilter]||_,e.minFilter=gy[n.minFilter]||w,e.wrapS=vy[n.wrapS]||f,e.wrapT=vy[n.wrapT]||f,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[Bv.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Bv.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(i);i=r.extensions[Bv.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 eo,qe.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 Va,qe.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 Ol}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[Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=r[Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else if(o[Bv.KHR_MATERIALS_UNLIT]){const t=r[Bv.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new en(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||wy;if(c===Sy?(a.transparent=!0,a.depthWrite=!1):(a.format=C,a.transparent=!1,c===My&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==nn&&(l.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new vt(1,1),void 0!==i.normalTexture.scale)){const t=i.normalTexture.scale;a.normalScale.set(t,t)}return void 0!==i.occlusionTexture&&s!==nn&&(l.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==nn&&(a.emissive=(new en).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&s!==nn&&l.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){let n;return n=s===ny?r[Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new s(a),i.name&&(n.name=i.name),n.map&&(n.map.encoding=K),n.emissiveMap&&(n.emissiveMap.encoding=K),Ey(n,i),e.associations.set(n,{materials:t}),i.extensions&&Ay(r,n,i),n}))}createUniqueName(t){const e=_h.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[Bv.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return Dy(n,t,e)}))}const s=[];for(let n=0,a=t.length;n<a;n++){const a=t[n],o=Cy(a),l=r[o];if(l)s.push(l.promise);else{let t;t=a.extensions&&a.extensions[Bv.KHR_DRACO_MESH_COMPRESSION]?i(a):Dy(new Sn,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?Ty(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===dy||h.mode===py||h.mode===fy||void 0===h.mode)u=!0===i.isSkinnedMesh?new Ia(c,d):new Gn(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===py?u.geometry=Ny(u.geometry,1):h.mode===fy&&(u.geometry=Ny(u.geometry,2));else if(h.mode===cy)u=new $a(c,d);else if(h.mode===uy)u=new Za(c,d);else if(h.mode===hy)u=new to(c,d);else{if(h.mode!==ly)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new ao(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&Py(u,i),u.name=e.createUniqueName(i.name||"mesh_"+t),Ey(u,i),h.extensions&&Ay(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 qs;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 Zn(gt.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(e=new _r(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),Ey(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,_y[u.path]){case _y.weights:d=$l;break;case _y.rotation:d=ec;break;case _y.position:case _y.scale:default:d=rc}const p=e.name?e.name:e.uuid,f=void 0!==h.interpolation?by[h.interpolation]:V,m=[];_y[u.path]===_y.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=Ry(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]+"."+_y[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(e.createInterpolant=function(t){return new(this instanceof ec?oy:sy)(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 ic(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 Fa:e.length>1?new qs:1===e.length?e[0]:new Ne,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),Ey(a,i),i.extensions&&Ay(n,a,i),void 0!==i.matrix){const t=new he;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 qs;r.name&&(s.name=i.createUniqueName(r.name)),Ey(s,r),r.extensions&&Ay(n,s,r);const a=r.nodes||[],o=[];for(let t=0,n=a.length;t<n;t++)o.push(Fy(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 qe||t instanceof At)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(s),s}))}}function Fy(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 he;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 Ua(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(Fy(a,t,n,r))}}return Promise.all(s)}))}function Dy(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=xy[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 Ey(t,e),function(t,e,n){const r=e.attributes,i=new Ot;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 Ft(e[0],e[1],e[2]),new Ft(s[0],s[1],s[2])),t.normalized){const e=Ry(my[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new Ft,e=new Ft;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=Ry(my[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 ee;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 Ny(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 Oy=new WeakMap;class Uy extends cc{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 uc(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(Oy.has(t)){const e=Oy.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)})),Oy.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new Sn;t.index&&e.setIndex(new an(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 an(s,a))}return e}_loadLibrary(t,e){const n=new uc(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=By.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 By(){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 zy extends Of{constructor(t){super("Model",t),this.viewport=t,this.gltfLoader=null,this.fbxLoader=null,this.modelMaps=new Map,this.store=zf.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 _f(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 Ov),this.dracoDecoderPath&&!this.gltfLoader.dracoLoader){const t=new Uy;t.setDecoderPath(this.dracoDecoderPath),this.gltfLoader.setDRACOLoader(t)}c&&(e=Su(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 vv);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)=>Fd(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 ad||t instanceof sd?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 Ia){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=>Fd(this,void 0,void 0,(function*(){const r=new ld(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=>Fd(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 Fd(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 Gn&&(Fu(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof qe&&(t.material=t.material.clone()))}))}}class ky extends Of{constructor(t){super("Poi",t),this.materials=new Map}create(t){const e=this._createMaterial(t.url),n=new Mf(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),Pu(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 ld(t);return e.forEach((t=>{const e=this._createMaterial(t.url),r=new Mf(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 Mf(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 mc).load(t);e.flipY=!0;const n=new la({map:e,color:16777215});return this.materials.set(t,n),n}return e}_copyMaterial(t){t.traverse((t=>{(t instanceof Gn||t instanceof wa)&&(Fu(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof qe&&(t.material=t.material.clone()))}))}}class Hy extends Of{constructor(t){super("PoiNode",t)}create(t){this._openEnableRenderCss(t);const e=new Id(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ld(t);return e.forEach((t=>{this._openEnableRenderCss(t);const e=new Id(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 Id(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 Gy extends Of{constructor(t){super("Canvas3D",t)}create(t){const e=new Ff(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ld(t);return e.forEach((t=>{const e=new Ff(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 Ff(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene)),n}}class jy{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(t){if(!Fu(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 wu,this.queue.add(t,0),this.previous[t]=null;n=this.queue.shift();){if(n===e){const t=[];for(;Cu(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 Vy extends Of{constructor(t){super("Topology",t),this.dijkstra=new jy}createFromGml(t){const{url:e,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255}=t;return Xf(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;Fu(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:Eu(n)?n:"",name:Eu(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 Pf(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 Pf(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 ld(t);return e.forEach((t=>{const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const r=new Pf(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 Pf(e);n.add(r)})),n}getShortestPath(t,e){const{nodes:n}=t.info,r=pu(e.start),i=pu(e.end);let s=null,a=1/0,o=null,l=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=pu(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 Pf(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=pu(t),s=pu(e.end);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=pu(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?pu(s.position).distanceTo(i):pu(s.position).distanceTo(pu(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(pu(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 Ft),rotation:(new _e).setFromQuaternion(t.getWorldQuaternion(new It)),scale:t.getWorldScale(new Ft)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Pf(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=pu(e.start),s=pu(t);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=pu(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?pu(s.position).distanceTo(i):pu(s.position).distanceTo(pu(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(pu(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 Ft),rotation:(new _e).setFromQuaternion(t.getWorldQuaternion(new It)),scale:t.getWorldScale(new Ft)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Pf(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||pu(n.position).distanceTo(pu(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:pu(t.nodes[e].position).distanceTo(pu(r.position)),restrict:0,passable:0}]}return t}}class Wy extends Of{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 Yh(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 ou(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 ru(n,new en(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 sd(new hr(n,r),new nn({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 mc).load(e),u=new hr(r,i);u.computeBoundingBox();const d=new Ol({side:2,map:h,transparent:!0,opacity:s,roughness:.8});d.map&&(d.map.repeat.set(c.x,c.x),d.map.wrapS=f,d.map.wrapT=f,d.map.version++),o.x-=Math.PI/2,d.version++;const p=new Df(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 Jh(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 Xh(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 Oh(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 Gh(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}}class Xy extends Of{constructor(t){super("PluginObject",t)}createObject(t,e){const n=new cd(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 Yy{constructor(t){this.viewport=t,this.needUpdate=!1,this.store={LightManager:new Uf(t),sbmManager:new qf(t),modelManager:new zy(t),poiManager:new ky(t),poiNodeManager:new Hy(t),canvas3DManager:new Gy(t),topologyManager:new Vy(t),helperManager:new Wy(t),pluginObjectManager:new Xy(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()}}return t.BaseMesh=sd,t.BaseObject3D=ad,t.Canvas3D=Ff,t.Circle=Af,t.Ground=Df,t.Group=ld,t.IVector3ToEuler=fu,t.IVector3ToVector3=pu,t.Icon=wf,t.Line=Lf,t.Link=Ef,t.MinHeap=wu,t.Model=_f,t.Node=Tf,t.PluginObject=cd,t.Poi=Mf,t.PoiNode=Id,t.Point=Sf,t.Polygon=If,t.Sbm=yf,t.SceneManage=od,t.Topology=Pf,t.default=class{constructor(t){this.THREE=uu,this.version=n,this.animation=id,this.library=Nf,this.utils=Hu,this.plugins={};const{el:e,options:r={},events:i={}}=t;if(this.domElement=document.querySelector(e),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 gf(this.options),this.signals=this.viewport.signals,this.manager=new Yy(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${e}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(i),this._initDefaultLight()}_init(){const{showGrid:t,background:n,fog:r,controls:i,closeInfoLog:s,closeWarnLog:a,useIndexedDB:o}=this.options;if(!s){du(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),du(e,{color:"#3eaf7c","font-size":"24px"}),du(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),du("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),du("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),du("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?Eu(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):Du(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()}},t.deg2Euler=yu,t.euler2Deg=xu,t.getAsciiString=zu,t.getBoundingBox=mu,t.getCubeTexture=Mu,t.getSpaceAttributeFromObject=_u,t.hasOwn=Au,t.isArray=Fu,t.isBoolean=Pu,t.isDate=Iu,t.isFunction=Nu,t.isNull=Lu,t.isNumber=Cu,t.isObject=Du,t.isPromise=Ou,t.isString=Eu,t.isSymbol=Ru,t.log=du,t.parseSbmx=Su,t.rotationAFix=vu,t.rotationAxisFix=gu,t.sleep=Bu,t.syncSpaceAttributeToObject=bu,t.typeJudge=Uu,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|
|
46
|
+
*/var qf={},Qf=function(t){return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))},Zf=function(t){return new Worker(t)};try{URL.revokeObjectURL(Qf(""))}catch(Vf){Qf=function(t){return"data:application/javascript;charset=UTF-8,"+encodeURI(t)},Zf=function(t){return new Worker(t,{type:"module"})}}var Jf=Uint8Array,Kf=Uint16Array,$f=Uint32Array,tm=new Jf([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]),em=new Jf([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]),nm=new Jf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rm=function(t,e){for(var n=new Kf(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var i=new $f(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]},im=rm(tm,2),sm=im[0],am=im[1];sm[28]=258,am[258]=28;for(var om=rm(em,0),lm=om[0],cm=om[1],hm=new Kf(32768),um=0;um<32768;++um){var dm=(43690&um)>>>1|(21845&um)<<1;dm=(61680&(dm=(52428&dm)>>>2|(13107&dm)<<2))>>>4|(3855&dm)<<4,hm[um]=((65280&dm)>>>8|(255&dm)<<8)>>>1}var pm=function(t,e,n){for(var r=t.length,i=0,s=new Kf(e);i<r;++i)++s[t[i]-1];var a,o=new Kf(e);for(i=0;i<e;++i)o[i]=o[i-1]+s[i-1]<<1;if(n){a=new Kf(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[hm[u]>>>l]=c}else for(a=new Kf(r),i=0;i<r;++i)t[i]&&(a[i]=hm[o[t[i]-1]++]>>>15-t[i]);return a},fm=new Jf(288);for(um=0;um<144;++um)fm[um]=8;for(um=144;um<256;++um)fm[um]=9;for(um=256;um<280;++um)fm[um]=7;for(um=280;um<288;++um)fm[um]=8;var mm=new Jf(32);for(um=0;um<32;++um)mm[um]=5;var gm=pm(fm,9,0),vm=pm(fm,9,1),ym=pm(mm,5,0),xm=pm(mm,5,1),_m=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},bm=function(t,e,n){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(7&e)&n},wm=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},Mm=function(t){return(t/8|0)+(7&t&&1)},Sm=function(t,e,n){(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length);var r=new(t instanceof Kf?Kf:t instanceof $f?$f:Jf)(n-e);return r.set(t.subarray(e,n)),r},Tm=function(t,e,n){var r=t.length;if(!r||n&&!n.l&&r<5)return e||new Jf(0);var i=!e||n,s=!n||n.i;n||(n={}),e||(e=new Jf(3*r));var a=function(t){var n=e.length;if(t>n){var r=new Jf(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=bm(t,l,1);var m=bm(t,l+1,3);if(l+=3,!m){var g=t[(E=Mm(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=vm,u=xm,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=bm(t,l,31)+257,x=bm(t,l+10,15)+4,_=y+bm(t,l+5,31)+1;l+=14;for(var b=new Jf(_),w=new Jf(19),M=0;M<x;++M)w[nm[M]]=bm(t,l+3*M,7);l+=3*x;var S=_m(w),T=(1<<S)-1,A=pm(w,S,1);for(M=0;M<_;){var E,P=A[bm(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+bm(t,l,3),l+=2,C=b[M-1]):17==E?(L=3+bm(t,l,7),l+=3):18==E&&(L=11+bm(t,l,127),l+=7);L--;)b[M++]=C}}var R=b.subarray(0,y),I=b.subarray(y);d=_m(R),p=_m(I),h=pm(R,d,1),u=pm(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[wm(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=tm[M=O-257];U=bm(t,l,(1<<B)-1)+sm[M],l+=B}var z=u[wm(t,l)&D],k=z>>>4;if(!z)throw"invalid distance";l+=15&z;I=lm[k];if(k>3){B=em[k];I+=wm(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:Sm(e,0,c)},Am=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>>8},Em=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},Pm=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[Nm,0];if(1==i){var a=new Jf(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 Kf(d+1),f=Cm(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 Jf(p),f]},Cm=function(t,e,n){return-1==t.s?Math.max(Cm(t.l,e,n+1),Cm(t.r,e,n+1)):e[t.s]=n},Lm=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Kf(++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]},Rm=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},Im=function(t,e,n){var r=n.length,i=Mm(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)},Fm=function(t,e,n,r,i,s,a,o,l,c,h){Am(e,h++,n),++i[256];for(var u=Pm(i,15),d=u[0],p=u[1],f=Pm(s,15),m=f[0],g=f[1],v=Lm(d),y=v[0],x=v[1],_=Lm(m),b=_[0],w=_[1],M=new Kf(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=Pm(M,7),A=T[0],E=T[1],P=19;P>4&&!A[nm[P-1]];--P);var C,L,R,I,F=c+5<<3,D=Rm(i,fm)+Rm(s,mm)+a,N=Rm(i,d)+Rm(s,m)+a+14+3*P+Rm(M,A)+(2*M[16]+3*M[17]+7*M[18]);if(F<=D&&F<=N)return Im(e,h,t.subarray(l,l+c));if(Am(e,h,1+(N<D)),h+=2,N<D){C=pm(d,p,0),L=d,R=pm(m,g,0),I=m;var O=pm(A,E,0);Am(e,h,x-257),Am(e,h+5,w-1),Am(e,h+10,P-4),h+=14;for(S=0;S<P;++S)Am(e,h+3*S,A[nm[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];Am(e,h,O[k]),h+=A[k],k>15&&(Am(e,h,z[S]>>>5&127),h+=z[S]>>>12)}}}else C=gm,L=fm,R=ym,I=mm;for(S=0;S<o;++S)if(r[S]>255){k=r[S]>>>18&31;Em(e,h,C[k+257]),h+=L[k+257],k>7&&(Am(e,h,r[S]>>>23&31),h+=tm[k]);var H=31&r[S];Em(e,h,R[H]),h+=I[H],H>3&&(Em(e,h,r[S]>>>5&8191),h+=em[H])}else Em(e,h,C[r[S]]),h+=L[r[S]];return Em(e,h,C[256]),h+L[256]},Dm=new $f([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Nm=new Jf(0),Om=function(t,e,n,r,i,s){var a=t.length,o=new Jf(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=Im(l,c,t.subarray(h,u)):(l[h]=s,c=Im(l,c,t.subarray(h,a)))}else{for(var d=Dm[e-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new Kf(32768),v=new Kf(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 $f(25e3),w=new Kf(288),M=new Kf(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=Fm(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|am[D]<<18|cm[N];var X=31&am[D],Y=31&cm[N];T+=tm[X]+em[Y],++w[257+X],++M[Y],E=h+D,++S}else b[A++]=t[h],++w[t[h]]}}c=Fm(t,l,s,b,w,M,T,A,P,h-P,c),!s&&7&c&&(c=Im(l,c+1,Nm))}return Sm(o,0,r+Mm(c)+i)},Um=function(){for(var t=new $f(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),Bm=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=Um[255&n^e[r]]^n>>>8;t=n},d:function(){return~t}}},zm=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}}},km=function(t,e,n,r,i){return Om(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)},Hm=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},Gm=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]},jm=[],Vm=function(t,e,n,r){var i;if(!jm[n]){for(var s="",a={},o=t.length-1,l=0;l<o;++l)s=(i=Gm(t[l],s,a))[0],a=i[1];jm[n]=Gm(t[o],s,a)}var c=Hm({},jm[n][1]);return function(t,e,n,r,i){var s=Zf(qf[e]||(qf[e]=Qf(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}(jm[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 Jf||t[n]instanceof Kf||t[n]instanceof $f)&&e.push((t[n]=new t[n].constructor(t[n])).buffer);return e}(c),r)},Wm=function(){return[Jf,Kf,$f,tm,em,nm,sm,lm,vm,xm,hm,pm,_m,bm,wm,Mm,Sm,Tm,_g,Jm,Km]},Xm=function(){return[Jf,Kf,$f,tm,em,nm,am,cm,gm,fm,ym,mm,hm,Dm,Nm,pm,Am,Em,Pm,Cm,Lm,Rm,Im,Fm,Mm,Sm,Om,km,gg,Jm]},Ym=function(){return[ag,cg,sg,Bm,Um]},qm=function(){return[og,lg]},Qm=function(){return[hg,sg,zm]},Zm=function(){return[ug]},Jm=function(t){return postMessage(t,[t.buffer])},Km=function(t){return t&&t.size&&new Jf(t.size)},$m=function(t,e,n,r,i,s){var a=Vm(n,r,i,(function(t,e){a.terminate(),s(t,e)}));return a.postMessage([t,e],e.consume?[t.buffer]:[]),function(){a.terminate()}},tg=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])}},eg=function(t,e,n,r,i){var s,a=Vm(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()}},ng=function(t,e){return t[e]|t[e+1]<<8},rg=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},ig=function(t,e){return rg(t,e)+4294967296*rg(t,e+4)},sg=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},ag=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&&sg(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)}},og=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)},lg=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},cg=function(t){return 10+(t.filename&&t.filename.length+1||0)},hg=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)},ug=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 dg(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var pg=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(km(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}(),fg=function(){return function(t,e){eg([Xm,function(){return[tg,pg]}],this,dg.call(this,t,e),(function(t){var e=new pg(t.data);onmessage=tg(e)}),6)}}();function mg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return $m(t,e,[Xm],(function(t){return Jm(gg(t.data[0],t.data[1]))}),0,n)}function gg(t,e){return km(t,e||{},0,0)}var vg=function(){function t(t){this.s={},this.p=new Jf(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 Jf(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=Tm(this.p,this.o,this.s);this.ondata(Sm(n,e,this.s.b),this.d),this.o=Sm(n,this.s.b-32768),this.s.b=this.o.length,this.p=Sm(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}(),yg=function(){return function(t){this.ondata=t,eg([Wm,function(){return[tg,vg]}],this,0,(function(){var t=new vg;onmessage=tg(t)}),7)}}();function xg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return $m(t,e,[Wm],(function(t){return Jm(_g(t.data[0],Km(t.data[1])))}),1,n)}function _g(t,e){return Tm(t,e)}var bg=function(){function t(t,e){this.c=Bm(),this.l=0,this.v=1,pg.call(this,t,e)}return t.prototype.push=function(t,e){pg.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var n=km(t,this.o,this.v&&cg(this.o),e&&8,!e);this.v&&(ag(n,this.o),this.v=0),e&&(sg(n,n.length-8,this.c.d()),sg(n,n.length-4,this.l)),this.ondata(n,e)},t}(),wg=function(){return function(t,e){eg([Xm,Ym,function(){return[tg,pg,bg]}],this,dg.call(this,t,e),(function(t){var e=new bg(t.data);onmessage=tg(e)}),8)}}();function Mg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return $m(t,e,[Xm,Ym,function(){return[Sg]}],(function(t){return Jm(Sg(t.data[0],t.data[1]))}),2,n)}function Sg(t,e){e||(e={});var n=Bm(),r=t.length;n.p(t);var i=km(t,e,cg(e),8),s=i.length;return ag(i,e),sg(i,s-8,n.d()),sg(i,s-4,r),i}var Tg=function(){function t(t){this.v=1,vg.call(this,t)}return t.prototype.push=function(t,e){if(vg.prototype.e.call(this,t),this.v){var n=this.p.length>3?og(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)}vg.prototype.c.call(this,e)},t}(),Ag=function(){return function(t){this.ondata=t,eg([Wm,qm,function(){return[tg,vg,Tg]}],this,0,(function(){var t=new Tg;onmessage=tg(t)}),9)}}();function Eg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return $m(t,e,[Wm,qm,function(){return[Pg]}],(function(t){return Jm(Pg(t.data[0]))}),3,n)}function Pg(t,e){return Tm(t.subarray(og(t),-8),e||new Jf(lg(t)))}var Cg=function(){function t(t,e){this.c=zm(),this.v=1,pg.call(this,t,e)}return t.prototype.push=function(t,e){pg.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var n=km(t,this.o,this.v&&2,e&&4,!e);this.v&&(hg(n,this.o),this.v=0),e&&sg(n,n.length-4,this.c.d()),this.ondata(n,e)},t}(),Lg=function(){return function(t,e){eg([Xm,Qm,function(){return[tg,pg,Cg]}],this,dg.call(this,t,e),(function(t){var e=new Cg(t.data);onmessage=tg(e)}),10)}}();function Rg(t,e){e||(e={});var n=zm();n.p(t);var r=km(t,e,2,4);return hg(r,e),sg(r,r.length-4,n.d()),r}var Ig=function(){function t(t){this.v=1,vg.call(this,t)}return t.prototype.push=function(t,e){if(vg.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)}vg.prototype.c.call(this,e)},t}(),Fg=function(){return function(t){this.ondata=t,eg([Wm,Zm,function(){return[tg,vg,Ig]}],this,0,(function(){var t=new Ig;onmessage=tg(t)}),11)}}();function Dg(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return $m(t,e,[Wm,Zm,function(){return[Ng]}],(function(t){return Jm(Ng(t.data[0],Km(t.data[1])))}),5,n)}function Ng(t,e){return Tm((ug(t),t.subarray(2,-4)),e)}var Og=function(){function t(t){this.G=Tg,this.I=vg,this.Z=Ig,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 Jf(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}(),Ug=function(){function t(t){this.G=Ag,this.I=yg,this.Z=Fg,this.ondata=t}return t.prototype.push=function(t,e){Og.prototype.push.call(this,t,e)},t}();var Bg=function(t,e,n,r){for(var i in t){var s=t[i],a=e+i;s instanceof Jf?n[a]=[s,r]:Array.isArray(s)?n[a]=[s[0],Hm(r,s[1])]:Bg(s,a+"/",n,r)}},zg="undefined"!=typeof TextEncoder&&new TextEncoder,kg="undefined"!=typeof TextDecoder&&new TextDecoder,Hg=0;try{kg.decode(Nm,{stream:!0}),Hg=1}catch(Vf){}var Gg=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,Sm(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)}},jg=function(){function t(t){this.ondata=t,Hg?this.t=new TextDecoder:this.p=Nm}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 Jf(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length);var r=Gg(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}(),Vg=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(Wg(t),this.d=e||!1)},t}();function Wg(t,e){if(e){for(var n=new Jf(t.length),r=0;r<t.length;++r)n[r]=t.charCodeAt(r);return n}if(zg)return zg.encode(t);var i=t.length,s=new Jf(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 Jf(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 Sm(s,0,a)}function Xg(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(kg)return kg.decode(t);var i=Gg(t),s=i[0];if(i[1].length)throw"invalid utf-8 data";return s}var Yg=function(t){return 1==t?3:t<6?2:9==t?1:0},qg=function(t,e){return e+30+ng(t,e+26)+ng(t,e+28)},Qg=function(t,e,n){var r=ng(t,e+28),i=Xg(t.subarray(e+46,e+46+r),!(2048&ng(t,e+8))),s=e+46+r,a=rg(t,e+20),o=n&&4294967295==a?Zg(t,s):[a,rg(t,e+24),rg(t,e+42)],l=o[0],c=o[1],h=o[2];return[ng(t,e+10),l,c,i,s+ng(t,e+30)+ng(t,e+32),h]},Zg=function(t,e){for(;1!=ng(t,e);e+=4+ng(t,e+2));return[ig(t,e+12),ig(t,e+4),ig(t,e+20)]},Jg=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},Kg=function(t,e,n,r,i,s,a,o){var l=r.length,c=n.extra,h=o&&o.length,u=Jg(c);sg(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(sg(t,e,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),e+=4,null!=s&&(sg(t,e,n.crc),sg(t,e+4,s),sg(t,e+8,n.size)),sg(t,e+12,l),sg(t,e+14,u),e+=16,null!=a&&(sg(t,e,h),sg(t,e+6,n.attrs),sg(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;sg(t,e,+f),sg(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e},$g=function(t,e,n,r,i){sg(t,e,101010256),sg(t,e+8,n),sg(t,e+10,n),sg(t,e+12,r),sg(t,e+16,i)},tv=function(){function t(t){this.filename=t,this.c=Bm(),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}(),ev=function(){function t(t,e){var n=this;e||(e={}),tv.call(this,t),this.d=new pg(e,(function(t,e){n.ondata(null,t,e)})),this.compression=8,this.flag=Yg(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){tv.prototype.push.call(this,t,e)},t}(),nv=function(){function t(t,e){var n=this;e||(e={}),tv.call(this,t),this.d=new fg(e,(function(t,e,r){n.ondata(t,e,r)})),this.compression=8,this.flag=Yg(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){tv.prototype.push.call(this,t,e)},t}(),rv=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=Wg(t.filename),r=n.length,i=t.comment,s=i&&Wg(i),a=r!=t.filename.length||s&&i.length!=s.length,o=r+Jg(t.extra)+30;if(r>65535)throw"filename too long";var l=new Jf(o);Kg(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=Hm(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 Jf(16);sg(s,0,134695760),sg(s,4,t.crc),sg(s,8,f),sg(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+Jg(l.extra)+(l.o?l.o.length:0)}for(var s=new Jf(n+22),a=0,o=this.u;a<o.length;a++){var l=o[a];Kg(s,t,l,l.f,l.u,l.c,e,l.o),t+=46+l.f.length+Jg(l.extra)+(l.o?l.o.length:0),e+=l.b}$g(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 iv=function(){function t(){}return t.prototype.push=function(t,e){this.ondata(null,t,e)},t.compression=0,t}(),sv=function(){function t(){var t=this;this.i=new vg((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}(),av=function(){function t(t,e){var n=this;e<32e4?this.i=new vg((function(t,e){n.ondata(null,t,e)})):(this.i=new yg((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=Sm(t,0)),this.i.push(t,e)},t.compression=8,t}(),ov=function(){function t(t){this.onfile=t,this.k=[],this.o={0:iv},this.p=Nm}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 Jf(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=rg(l,a);if(67324752==e){s=1,o=a,p.d=null,p.c=0;var r=ng(l,a+6),i=ng(l,a+8),u=2048&r,d=8&r,f=ng(l,a+26),m=ng(l,a+28);if(c>a+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=rg(l,a+18),x=rg(l,a+22),_=Xg(l.subarray(a+30,a+=30+f),!u);4294967295==y?(t=d?[-2]:Zg(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(Nm,!0)}else b.ondata(null,Nm,!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=Nm,h<0){var f=s?l.subarray(0,o-12-(-2==h&&8)-(134695760==rg(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 lv=Object.freeze({__proto__:null,Deflate:pg,AsyncDeflate:fg,deflate:mg,deflateSync:gg,Inflate:vg,AsyncInflate:yg,inflate:xg,inflateSync:_g,Gzip:bg,AsyncGzip:wg,gzip:Mg,gzipSync:Sg,Gunzip:Tg,AsyncGunzip:Ag,gunzip:Eg,gunzipSync:Pg,Zlib:Cg,AsyncZlib:Lg,zlib:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";return $m(t,e,[Xm,Qm,function(){return[Rg]}],(function(t){return Jm(Rg(t.data[0],t.data[1]))}),4,n)},zlibSync:Rg,Unzlib:Ig,AsyncUnzlib:Fg,unzlib:Dg,unzlibSync:Ng,compress:Mg,AsyncCompress:wg,compressSync:Sg,Compress:bg,Decompress:Og,AsyncDecompress:Ug,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]?Eg(t,e,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?xg(t,e,n):Dg(t,e,n)},decompressSync:function(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?Pg(t,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?_g(t,e):Ng(t,e)},DecodeUTF8:jg,EncodeUTF8:Vg,strToU8:Wg,strFromU8:Xg,ZipPassThrough:tv,ZipDeflate:ev,AsyncZipDeflate:nv,Zip:rv,zip:function(t,e,n){if(n||(n=e,e={}),"function"!=typeof n)throw"no callback";var r={};Bg(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 Jf(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;Kg(t,o,s,s.f,s.u,h);var u=30+s.f.length+Jg(s.extra),d=o+u;t.set(s.c,d),Kg(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)}}$g(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=Bm(),g=p.length;m.p(p);var v=Wg(e),y=v.length,x=f.comment,_=x&&Wg(x),b=_&&_.length,w=Jg(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]=Hm(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,gg(p,f))}catch(t){S(t,null)}else h.push(mg(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=[];Bg(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=Wg(a)).length,d=c.comment,p=d&&Wg(d),f=p&&p.length,m=Jg(c.extra);if(u>65535)throw"filename too long";var g=h?gg(l,c):l,v=g.length,y=Bm();y.p(l),r.push(Hm(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 Jf(s+22),_=i,b=s-i,w=0;w<r.length;++w){var M=r[w];Kg(x,M.o,M,M.f,M.u,M.c.length);var S=30+M.f.length+Jg(M.extra);x.set(M.c,M.o+S),Kg(x,i,M,M.f,M.u,M.c.length,M.o,M.m),i+=16+S+(M.m?M.m.length:0)}return $g(x,i,r.length,b,_),x},UnzipPassThrough:iv,UnzipInflate:sv,AsyncUnzipInflate:av,Unzip:ov,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!=rg(t,s);--s)if(!s||t.length-s>65558)return void e("invalid zip file",null);var a=ng(t,s+8);a||e(null,{});var o=a,l=rg(t,s+16),c=4294967295==l;if(c){if(s=rg(t,s-12),101075792!=rg(t,s))return void e("invalid zip file",null);o=a=rg(t,s+32),l=rg(t,s+48)}for(var h=function(s){var o=Qg(t,l,c),h=o[0],u=o[1],d=o[2],p=o[3],f=o[4],m=o[5],g=qg(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,_g(y,new Jf(d)))}catch(t){v(t,null)}else n.push(xg(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,Sm(t,g,g+u))},u=0;u<o;++u)h();return r},unzipSync:function(t){for(var e={},n=t.length-22;101010256!=rg(t,n);--n)if(!n||t.length-n>65558)throw"invalid zip file";var r=ng(t,n+8);if(!r)return{};var i=rg(t,n+16),s=4294967295==i;if(s){if(n=rg(t,n-12),101075792!=rg(t,n))throw"invalid zip file";r=rg(t,n+32),i=rg(t,n+48)}for(var a=0;a<r;++a){var o=Qg(t,i,s),l=o[0],c=o[1],h=o[2],u=o[3],d=o[4],p=o[5],f=qg(t,p);if(i=d,l){if(8!=l)throw"unknown compression type "+l;e[u]=_g(t.subarray(f,f+c),new Jf(h))}else e[u]=Sm(t,f,f+c)}return e}});function cv(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 hv(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 uv(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 Ft(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(hv(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=cv(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 Pt(0,0,0);return a}(t,e,n,r,i))}class dv extends Mo{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 Pt(e.x,e.y,e.z,e.w)}}getPoint(t,e=new Ft){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=cv(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 Pt(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 Ft){const n=e,r=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),i=uv(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}}let pv,fv,mv;class gv extends cc{constructor(t){super(t)}load(t,e,n,r){const i=this,s=""===i.path?Oc.extractUrlBase(t):i.path,a=new uc(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===Fv(t,0,e.length)}(t))pv=(new bv).parse(t);else{const e=Fv(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(Sv(e)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Sv(e));pv=(new _v).parse(e)}const n=new mc(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new vv(n,this.manager).parse(pv)}}class vv{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){fv=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),n=this.parseMaterials(e),r=this.parseDeformers(),i=(new yv).parse(r);return this.parseScene(r,i,n),mv}parseConnections(){const t=new Map;if("Connections"in pv){pv.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 pv.Objects){const n=pv.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 pv.Objects){const n=pv.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?f:m,n.wrapT=0===a?f:m,"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=fv.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 At):(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 At):s=this.textureLoader.load(n);return this.textureLoader.setPath(r),s}parseMaterials(t){const e=new Map;if("Material"in pv.Objects){const n=pv.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),!fv.has(n))return null;const s=this.parseParameters(t,e,n);let a;switch(i.toLowerCase()){case"phong":a=new Bl;break;case"lambert":a=new Hl;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),a=new Bl}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 en).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(r.color=(new en).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(r.displacementScale=t.DisplacementFactor.value),t.Emissive?r.emissive=(new en).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(r.emissive=(new en).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 en).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(r.specular=(new en).fromArray(t.SpecularColor.value));const i=this;return fv.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=K);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=K);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=h,r.envMap.encoding=K);break;case"SpecularColor":r.specularMap=i.getTexture(e,t.ID),void 0!==r.specularMap&&(r.specularMap.encoding=K);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 pv.Objects&&e in pv.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=fv.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in pv.Objects){const n=pv.Objects.Deformer;for(const r in n){const i=n[r],s=fv.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 he).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=fv.get(parseInt(i.ID)).children.filter((function(t){return void 0===t.relationship}))[0].ID,n.push(a)}return n}parseScene(t,e,n){mv=new qs;const r=this.parseModels(t.skeletons,e,n),i=pv.Objects.Model,s=this;r.forEach((function(t){const e=i[t.ID];s.setLookAtProperties(t,e);fv.get(t.ID).parents.forEach((function(e){const n=r.get(e.ID);void 0!==n&&n.add(t)})),null===t.parent&&mv.add(t)})),this.bindSkeleton(t.skeletons,e,r),this.createAmbientLight(),mv.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=Lv(t.userData.transformData);t.applyMatrix4(e),t.updateWorldMatrix()}}));const a=(new xv).parse();1===mv.children.length&&mv.children[0].isGroup&&(mv.children[0].animations=a,mv=mv.children[0]),mv.animations=a}parseModels(t,e,n){const r=new Map,i=pv.Objects.Model;for(const s in i){const a=parseInt(s),o=i[s],l=fv.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 Fa;break;case"Null":default:c=new qs}c.name=o.attrName?_h.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 Fa,i.matrixWorld.copy(e.transformLink),i.name=r?_h.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=pv.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Ne;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 Zn(l,o,r,i),null!==c&&e.setFocalLength(c);break;case 1:e=new _r(-s/2,s/2,a/2,-a/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+t+"."),e=new Ne}}return e}createLight(t){let e,n;if(t.children.forEach((function(t){const e=pv.Objects.NodeAttribute[t.ID];void 0!==e&&(n=e)})),void 0===n)e=new Ne;else{let t;t=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=(new en).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 Pc(r,i,s,a);break;case 1:e=new Lc(r,i);break;case 2:let t=Math.PI/3;void 0!==n.InnerAngle&&(t=gt.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=gt.degToRad(n.OuterAngle.value),o=Math.max(o,1)),e=new Mc(r,i,s,t,o,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),e=new Pc(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 Bl({color:13421772}),a.push(s)),"color"in i.attributes&&a.forEach((function(t){t.vertexColors=!0})),i.FBX_Deformer?(r=new Ia(i,s),r.normalizeSkinWeights()):r=new Gn(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 Va({color:3342591,linewidth:1});return new Za(n,r)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),n.eulerOrder="RotationOrder"in e?Rv(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){fv.get(t.ID).children.forEach((function(e){if("LookAtProperty"===e.relationship){const n=pv.Objects.Model[e.ID];if("Lcl_Translation"in n){const e=n.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(e),mv.add(t.target)):t.lookAt((new Ft).fromArray(e))}}}))}}bindSkeleton(t,e,n){const r=this.parsePoseNodes();for(const i in t){const s=t[i];fv.get(parseInt(s.ID)).parents.forEach((function(t){if(e.has(t.ID)){const e=t.ID;fv.get(e).parents.forEach((function(t){if(n.has(t.ID)){n.get(t.ID).bind(new Ua(s.bones),r[t.ID])}}))}}))}}parsePoseNodes(){const t={};if("Pose"in pv.Objects){const e=pv.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 he).fromArray(e.Matrix.a)})):t[r.Node]=(new he).fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in pv&&"AmbientColor"in pv.GlobalSettings){const t=pv.GlobalSettings.AmbientColor.value,e=t[0],n=t[1],r=t[2];if(0!==e||0!==n||0!==r){const t=new en(e,n,r);mv.add(new Rc(t,1))}}}}class yv{parse(t){const e=new Map;if("Geometry"in pv.Objects){const n=pv.Objects.Geometry;for(const r in n){const i=fv.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 pv.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=Rv(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=Lv(l);return this.genGeometry(e,a,i,c)}genGeometry(t,e,n,r){const i=new Sn;t.attrName&&(i.name=t.attrName);const s=this.parseGeoNode(t,e),a=this.genBuffers(s),o=new mn(a.vertex,3);if(o.applyMatrix4(r),i.setAttribute("position",o),a.colors.length>0&&i.setAttribute("color",new mn(a.colors,3)),e&&(i.setAttribute("skinIndex",new un(a.weightsIndices,4)),i.setAttribute("skinWeight",new mn(a.vertexWeights,4)),i.FBX_Deformer=e),a.normal.length>0){const t=(new yt).getNormalMatrix(r),e=new mn(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 mn(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=Ev(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=Ev(p,n,d,t.normal);a.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(f=Ev(p,n,d,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const r=Ev(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=pv.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 mn(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===dv)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 Sn;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 Sn;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 Pt).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 dv(n,r,i,a,o).getPoints(12*i.length);return(new Sn).setFromPoints(l)}}class xv{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===pv.Objects.AnimationCurve)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=pv.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=pv.Objects.AnimationCurve;for(const n in e){const r={id:e[n].id,times:e[n].KeyTime.a.map(Tv),values:e[n].KeyValueFloat.a},i=fv.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=pv.Objects.AnimationLayer,n=new Map;for(const r in e){const e=[],i=fv.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=fv.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID;if(void 0!==t){const i=pv.Objects.Model[t.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:i.attrName?_h.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};mv.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 he),"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=fv.get(n.ID).parents.filter((function(t){return void 0!==t.relationship}))[0].ID,i=fv.get(t).parents[0].ID,s=fv.get(i).parents[0].ID,a=fv.get(s).parents[0].ID,o=pv.Objects.Model[a],l={modelName:o.attrName?_h.sanitizeNodeName(o.attrName):"",morphName:pv.Objects.Deformer[t].attrName};e[r]=l}e[r][i.attr]=i}}})),n.set(parseInt(r),e)}}return n}parseAnimStacks(t){const e=pv.Objects.AnimationStack,n={};for(const r in e){const i=fv.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 ic(t.name,-1,e)}generateTracks(t){const e=[];let n=new Ft,r=new It,i=new Ft;if(t.transform&&t.transform.decompose(n,r,i),n=n.toArray(),r=(new _e).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 rc(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(gt.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(gt.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(gt.degToRad));const a=this.getTimesForAllAxes(e),o=this.getKeyframeTrackValues(a,e,n);void 0!==r&&((r=r.map(gt.degToRad)).push(s),r=(new _e).fromArray(r),r=(new It).setFromEuler(r)),void 0!==i&&((i=i.map(gt.degToRad)).push(s),i=(new _e).fromArray(i),i=(new It).setFromEuler(i).invert());const l=new It,c=new _e,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 ec(t+".quaternion",a,h)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,n=e.values.map((function(t){return t/100})),r=mv.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new $l(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=Dv(t.times,e,u),t.values=Dv(t.values,e,d)}}}}class _v{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 Mv,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=Iv(i))}else this.parseNodeSpecialProperty(t,r,i)}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,","!==t.slice(-1)&&(e.a=Iv(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=Iv(l)}this.getPrevNode()[i]={type:s,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class bv{parse(t){const e=new wv(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 Mv;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===lv&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=Ng(new Uint8Array(t.getArrayBuffer(s))),o=new wv(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 wv{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)),Oc.decodeText(new Uint8Array(e))}}class Mv{add(t,e){this[t]=e}}function Sv(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 Tv(t){return t/46186158e3}const Av=[];function Ev(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}(Av,r.buffer,s,a)}const Pv=new _e,Cv=new Ft;function Lv(t){const e=new he,n=new he,r=new he,i=new he,s=new he,a=new he,o=new he,l=new he,c=new he,h=new he,u=new he,d=new he,p=t.inheritType?t.inheritType:0;if(t.translation&&e.setPosition(Cv.fromArray(t.translation)),t.preRotation){const e=t.preRotation.map(gt.degToRad);e.push(t.eulerOrder),n.makeRotationFromEuler(Pv.fromArray(e))}if(t.rotation){const e=t.rotation.map(gt.degToRad);e.push(t.eulerOrder),r.makeRotationFromEuler(Pv.fromArray(e))}if(t.postRotation){const e=t.postRotation.map(gt.degToRad);e.push(t.eulerOrder),i.makeRotationFromEuler(Pv.fromArray(e)),i.invert()}t.scale&&s.scale(Cv.fromArray(t.scale)),t.scalingOffset&&o.setPosition(Cv.fromArray(t.scalingOffset)),t.scalingPivot&&a.setPosition(Cv.fromArray(t.scalingPivot)),t.rotationOffset&&l.setPosition(Cv.fromArray(t.rotationOffset)),t.rotationPivot&&c.setPosition(Cv.fromArray(t.rotationPivot)),t.parentMatrixWorld&&(u.copy(t.parentMatrix),h.copy(t.parentMatrixWorld));const f=n.clone().multiply(r).multiply(i),m=new he;m.extractRotation(h);const g=new he;g.copyPosition(h);const v=g.clone().invert().multiply(h),y=m.clone().invert().multiply(v),x=s,_=new he;if(0===p)_.copy(m).multiply(f).multiply(y).multiply(x);else if(1===p)_.copy(m).multiply(y).multiply(f).multiply(x);else{const t=(new he).scale((new Ft).setFromMatrixScale(u)).clone().invert(),e=y.clone().multiply(t);_.copy(m).multiply(f).multiply(e).multiply(x)}const b=c.clone().invert(),w=a.clone().invert();let M=e.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(b).multiply(o).multiply(a).multiply(s).multiply(w);const S=(new he).copyPosition(M),T=h.clone().multiply(S);return d.copyPosition(T),M=d.clone().multiply(_),M.premultiply(h.invert()),M}function Rv(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 Iv(t){return t.split(",").map((function(t){return parseFloat(t)}))}function Fv(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=t.byteLength),Oc.decodeText(new Uint8Array(t,e,n))}function Dv(t,e,n){return t.slice(0,e).concat(n).concat(t.slice(e))}class Nv extends fc{constructor(t){super(t)}parse(t){const e=0,n=1,r=2,i=3,s=9,a=10,o=11,l=48,c=4,h=0,u=1,d=2,p=3;t.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let f=0;const m=new Uint8Array(t),g={id_length:m[f++],colormap_type:m[f++],image_type:m[f++],colormap_index:m[f++]|m[f++]<<8,colormap_length:m[f++]|m[f++]<<8,colormap_size:m[f++],origin:[m[f++]|m[f++]<<8,m[f++]|m[f++]<<8],width:m[f++]|m[f++]<<8,height:m[f++]|m[f++]<<8,pixel_size:m[f++],flags:m[f++]};!function(t){switch(t.image_type){case n:case s:(t.colormap_length>256||24!==t.colormap_size||1!==t.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case r:case i:case a:case o:t.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case e:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',t.image_type)}(t.width<=0||t.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==t.pixel_size&&16!==t.pixel_size&&24!==t.pixel_size&&32!==t.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',t.pixel_size)}(g),g.id_length+f>t.length&&console.error("THREE.TGALoader: No data."),f+=g.id_length;let v=!1,y=!1,x=!1;switch(g.image_type){case s:v=!0,y=!0;break;case n:y=!0;break;case a:v=!0;break;case r:break;case o:v=!0,x=!0;break;case i:x=!0}const _=new Uint8Array(g.width*g.height*4),b=function(t,e,n,r,i){let s,a;const o=n.pixel_size>>3,l=n.width*n.height*o;if(e&&(a=i.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),t){let t,e,n;s=new Uint8Array(l);let a=0;const c=new Uint8Array(o);for(;a<l;)if(t=i[r++],e=1+(127&t),128&t){for(n=0;n<o;++n)c[n]=i[r++];for(n=0;n<e;++n)s.set(c,a+n*o);a+=o*e}else{for(e*=o,n=0;n<e;++n)s[a+n]=i[r++];a+=e}}else s=i.subarray(r,r+=e?n.width*n.height:l);return{pixel_data:s,palettes:a}}(v,y,g,f,m);return function(t,e,n,r,i){let s,a,o,f,m,v;switch((g.flags&l)>>c){default:case d:s=0,o=1,m=e,a=0,f=1,v=n;break;case h:s=0,o=1,m=e,a=n-1,f=-1,v=-1;break;case p:s=e-1,o=-1,m=-1,a=0,f=1,v=n;break;case u:s=e-1,o=-1,m=-1,a=n-1,f=-1,v=-1}if(x)switch(g.pixel_size){case 8:!function(t,e,n,r,i,s,a,o){let l,c,h,u=0;const d=g.width;for(h=e;h!==r;h+=n)for(c=i;c!==a;c+=s,u++)l=o[u],t[4*(c+d*h)+0]=l,t[4*(c+d*h)+1]=l,t[4*(c+d*h)+2]=l,t[4*(c+d*h)+3]=255}(t,a,f,v,s,o,m,r);break;case 16:!function(t,e,n,r,i,s,a,o){let l,c,h=0;const u=g.width;for(c=e;c!==r;c+=n)for(l=i;l!==a;l+=s,h+=2)t[4*(l+u*c)+0]=o[h+0],t[4*(l+u*c)+1]=o[h+0],t[4*(l+u*c)+2]=o[h+0],t[4*(l+u*c)+3]=o[h+1]}(t,a,f,v,s,o,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(t,e,n,r,i,s,a,o,l){const c=l;let h,u,d,p=0;const f=g.width;for(d=e;d!==r;d+=n)for(u=i;u!==a;u+=s,p++)h=o[p],t[4*(u+f*d)+3]=255,t[4*(u+f*d)+2]=c[3*h+0],t[4*(u+f*d)+1]=c[3*h+1],t[4*(u+f*d)+0]=c[3*h+2]}(t,a,f,v,s,o,m,r,i);break;case 16:!function(t,e,n,r,i,s,a,o){let l,c,h,u=0;const d=g.width;for(h=e;h!==r;h+=n)for(c=i;c!==a;c+=s,u+=2)l=o[u+0]+(o[u+1]<<8),t[4*(c+d*h)+0]=(31744&l)>>7,t[4*(c+d*h)+1]=(992&l)>>2,t[4*(c+d*h)+2]=(31&l)<<3,t[4*(c+d*h)+3]=32768&l?0:255}(t,a,f,v,s,o,m,r);break;case 24:!function(t,e,n,r,i,s,a,o){let l,c,h=0;const u=g.width;for(c=e;c!==r;c+=n)for(l=i;l!==a;l+=s,h+=3)t[4*(l+u*c)+3]=255,t[4*(l+u*c)+2]=o[h+0],t[4*(l+u*c)+1]=o[h+1],t[4*(l+u*c)+0]=o[h+2]}(t,a,f,v,s,o,m,r);break;case 32:!function(t,e,n,r,i,s,a,o){let l,c,h=0;const u=g.width;for(c=e;c!==r;c+=n)for(l=i;l!==a;l+=s,h+=4)t[4*(l+u*c)+2]=o[h+0],t[4*(l+u*c)+1]=o[h+1],t[4*(l+u*c)+0]=o[h+2],t[4*(l+u*c)+3]=o[h+3]}(t,a,f,v,s,o,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}}(_,g.width,g.height,b.pixel_data,b.palettes),{data:_,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:w}}}class Ov extends cc{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(t){return new Hv(t)})),this.register((function(t){return new Yv(t)})),this.register((function(t){return new qv(t)})),this.register((function(t){return new Gv(t)})),this.register((function(t){return new jv(t)})),this.register((function(t){return new Vv(t)})),this.register((function(t){return new Wv(t)})),this.register((function(t){return new Xv(t)})),this.register((function(t){return new zv(t)})),this.register((function(t){return new Qv(t)}))}load(t,e,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Oc.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 uc(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(Oc.decodeText(new Uint8Array(t,0,4))===Zv){try{s[Bv.KHR_BINARY_GLTF]=new $v(t)}catch(t){return void(r&&r(t))}i=s[Bv.KHR_BINARY_GLTF].content}else i=Oc.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 Iy(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 Bv.KHR_MATERIALS_UNLIT:s[e]=new kv;break;case Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[e]=new ry;break;case Bv.KHR_DRACO_MESH_COMPRESSION:s[e]=new ty(o,this.dracoLoader);break;case Bv.KHR_TEXTURE_TRANSFORM:s[e]=new ey;break;case Bv.KHR_MESH_QUANTIZATION:s[e]=new iy;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 Uv(){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 Bv={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 zv{constructor(t){this.parser=t,this.name=Bv.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 en(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 Lc(o),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new Pc(o),a.distance=l;break;case"spot":a=new Mc(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 kv{constructor(){this.name=Bv.KHR_MATERIALS_UNLIT}getMaterialType(){return nn}extendParams(t,e,n){const r=[];t.color=new en(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 Hv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 vt(t,t)}return Promise.all(i)}}class Gv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 en(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 jv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 Vv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 en(a[0],a[1],a[2]),Promise.all(i)}}class Wv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 Xv{constructor(t){this.parser=t,this.name=Bv.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?Ul: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 en(a[0],a[1],a[2]),void 0!==s.specularColorTexture&&i.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture).then((function(t){t.encoding=K}))),Promise.all(i)}}class Yv{constructor(t){this.parser=t,this.name=Bv.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 qv{constructor(t){this.parser=t,this.name=Bv.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 Qv{constructor(t){this.name=Bv.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 Zv="glTF",Jv=1313821514,Kv=5130562;class $v{constructor(t){this.name=Bv.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:Oc.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Zv)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===Jv){const n=new Uint8Array(t,12+i,e);this.content=Oc.decodeText(n)}else if(n===Kv){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 ty{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Bv.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=xy[t]||t.toLowerCase();a[e]=s[t]}for(const e in t.attributes){const r=xy[e]||e.toLowerCase();if(void 0!==s[e]){const i=n.accessors[t.attributes[e]],s=my[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 ey{constructor(){this.name=Bv.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 ny extends Ol{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 en).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 ry{constructor(){this.name=Bv.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 ny}extendParams(t,e,n){const r=e.extensions[this.name];t.color=new en(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 en(0,0,0),t.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,t.specular=new en(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 ny(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 iy{constructor(){this.name=Bv.KHR_MESH_QUANTIZATION}}class sy extends Xl{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}}sy.prototype.beforeStart_=sy.prototype.copySampleValue_,sy.prototype.afterEnd_=sy.prototype.copySampleValue_,sy.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 ay=new It;class oy extends sy{interpolate_(t,e,n,r){const i=super.interpolate_(t,e,n,r);return ay.fromArray(i).normalize().toArray(i),i}}const ly=0,cy=1,hy=2,uy=3,dy=4,py=5,fy=6,my={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},gy={9728:v,9729:_,9984:y,9985:b,9986:x,9987:w},vy={33071:m,33648:g,10497:f},yy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xy={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_y={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},by={CUBICSPLINE:void 0,LINEAR:V,STEP:j},wy="OPAQUE",My="MASK",Sy="BLEND";function Ty(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new Ol({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),t.DefaultMaterial}function Ay(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 Ey(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 Py(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 Cy(t){const e=t.extensions&&t.extensions[Bv.KHR_DRACO_MESH_COMPRESSION];let n;return n=e?"draco:"+e.bufferView+":"+e.indices+":"+Ly(e.attributes):t.indices+":"+Ly(t.attributes)+":"+t.mode,n}function Ly(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 Ry(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 Iy{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Uv,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 Gc(this.options.manager):this.textureLoader=new mc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new uc(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:{}};Ay(i,s,r),Ey(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[Bv.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(t,i){n.load(Oc.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=yy[r.type],a=my[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 sa(d,h/o),e.cache.add(n,l)),p=new oa(l,s,c%h/o,u)}else d=null===i?new a(r.count*s):new a(i,c,r.count*s),p=new an(d,s,u);if(void 0!==r.sparse){const e=yy.SCALAR,n=my[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 an(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 At(t);n.needsUpdate=!0,e(n)}),n.load(Oc.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=gy[n.magFilter]||_,e.minFilter=gy[n.minFilter]||w,e.wrapS=vy[n.wrapS]||f,e.wrapT=vy[n.wrapT]||f,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[Bv.KHR_TEXTURE_TRANSFORM]){const t=void 0!==n.extensions?n.extensions[Bv.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(i);i=r.extensions[Bv.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 eo,qe.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 Va,qe.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 Ol}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[Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=r[Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else if(o[Bv.KHR_MATERIALS_UNLIT]){const t=r[Bv.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),l.push(t.extendParams(a,i,e))}else{const n=i.pbrMetallicRoughness||{};if(a.color=new en(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||wy;if(c===Sy?(a.transparent=!0,a.depthWrite=!1):(a.format=C,a.transparent=!1,c===My&&(a.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==nn&&(l.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new vt(1,1),void 0!==i.normalTexture.scale)){const t=i.normalTexture.scale;a.normalScale.set(t,t)}return void 0!==i.occlusionTexture&&s!==nn&&(l.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(a.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==nn&&(a.emissive=(new en).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&s!==nn&&l.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture)),Promise.all(l).then((function(){let n;return n=s===ny?r[Bv.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new s(a),i.name&&(n.name=i.name),n.map&&(n.map.encoding=K),n.emissiveMap&&(n.emissiveMap.encoding=K),Ey(n,i),e.associations.set(n,{materials:t}),i.extensions&&Ay(r,n,i),n}))}createUniqueName(t){const e=_h.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[Bv.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(n){return Dy(n,t,e)}))}const s=[];for(let n=0,a=t.length;n<a;n++){const a=t[n],o=Cy(a),l=r[o];if(l)s.push(l.promise);else{let t;t=a.extensions&&a.extensions[Bv.KHR_DRACO_MESH_COMPRESSION]?i(a):Dy(new Sn,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?Ty(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===dy||h.mode===py||h.mode===fy||void 0===h.mode)u=!0===i.isSkinnedMesh?new Ia(c,d):new Gn(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===py?u.geometry=Ny(u.geometry,1):h.mode===fy&&(u.geometry=Ny(u.geometry,2));else if(h.mode===cy)u=new $a(c,d);else if(h.mode===uy)u=new Za(c,d);else if(h.mode===hy)u=new to(c,d);else{if(h.mode!==ly)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new ao(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&Py(u,i),u.name=e.createUniqueName(i.name||"mesh_"+t),Ey(u,i),h.extensions&&Ay(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 qs;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 Zn(gt.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(e=new _r(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),Ey(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,_y[u.path]){case _y.weights:d=$l;break;case _y.rotation:d=ec;break;case _y.position:case _y.scale:default:d=rc}const p=e.name?e.name:e.uuid,f=void 0!==h.interpolation?by[h.interpolation]:V,m=[];_y[u.path]===_y.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=Ry(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]+"."+_y[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(e.createInterpolant=function(t){return new(this instanceof ec?oy:sy)(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 ic(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 Fa:e.length>1?new qs:1===e.length?e[0]:new Ne,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),Ey(a,i),i.extensions&&Ay(n,a,i),void 0!==i.matrix){const t=new he;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 qs;r.name&&(s.name=i.createUniqueName(r.name)),Ey(s,r),r.extensions&&Ay(n,s,r);const a=r.nodes||[],o=[];for(let t=0,n=a.length;t<n;t++)o.push(Fy(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 qe||t instanceof At)&&e.set(t,n);return t.traverse((t=>{const n=i.associations.get(t);null!=n&&e.set(t,n)})),e})(s),s}))}}function Fy(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 he;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 Ua(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(Fy(a,t,n,r))}}return Promise.all(s)}))}function Dy(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=xy[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 Ey(t,e),function(t,e,n){const r=e.attributes,i=new Ot;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 Ft(e[0],e[1],e[2]),new Ft(s[0],s[1],s[2])),t.normalized){const e=Ry(my[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const s=e.targets;if(void 0!==s){const t=new Ft,e=new Ft;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=Ry(my[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 ee;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 Ny(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 Oy=new WeakMap;class Uy extends cc{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 uc(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(Oy.has(t)){const e=Oy.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)})),Oy.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new Sn;t.index&&e.setIndex(new an(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 an(s,a))}return e}_loadLibrary(t,e){const n=new uc(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=By.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 By(){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 zy extends Nf{constructor(t){super("Model",t),this.viewport=t,this.gltfLoader=null,this.fbxLoader=null,this.modelMaps=new Map,this.store=Bf.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 xf(Object.assign({format:t},n)),a=new oc;a.addHandler(/\.tga$/i,new Nv);const{url:o}=n,l=t.toLocaleUpperCase(),c=o.substring(0,o.lastIndexOf("/")+1),h="SBMX"===l;if("GLTF"===l||"GLB"===l||h){if(this.gltfLoader||(this.gltfLoader=new Ov(a)),this.dracoDecoderPath&&!this.gltfLoader.dracoLoader){const t=new Uy;t.setDecoderPath(this.dracoDecoderPath),this.gltfLoader.setDRACOLoader(t)}h&&(e=Su(e)),this.gltfLoader.parse(e,c,(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(o)){const t=s.sClone();this.modelMaps.set(o,t)}r(s)}),(t=>{i(t)}))}else if("FBX"===l){this.fbxLoader||(this.fbxLoader=new gv(a));const t=this.fbxLoader.parse(e,c),{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(o)){const t=s.sClone();this.modelMaps.set(o,t)}r(s)}else i(`In soonspacejs: 加载通用模型资源(${o})格式错误,当前支持 fbx、gltf、glb !`)}))}clone(t,e,n){return new Promise(((r,i)=>Fd(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 ad||t instanceof sd?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 Ia){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=>Fd(this,void 0,void 0,(function*(){const r=new ld(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=>Fd(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 Fd(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 Gn&&(Fu(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof qe&&(t.material=t.material.clone()))}))}}class ky extends Nf{constructor(t){super("Poi",t),this.materials=new Map}create(t){const e=this._createMaterial(t.url),n=new wf(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),Pu(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 ld(t);return e.forEach((t=>{const e=this._createMaterial(t.url),r=new wf(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 wf(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 mc).load(t);e.flipY=!0;const n=new la({map:e,color:16777215});return this.materials.set(t,n),n}return e}_copyMaterial(t){t.traverse((t=>{(t instanceof Gn||t instanceof wa)&&(Fu(t.material)?t.material=t.material.map((t=>t.clone())):t.material instanceof qe&&(t.material=t.material.clone()))}))}}class Hy extends Nf{constructor(t){super("PoiNode",t)}create(t){this._openEnableRenderCss(t);const e=new Id(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ld(t);return e.forEach((t=>{this._openEnableRenderCss(t);const e=new Id(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 Id(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 Gy extends Nf{constructor(t){super("Canvas3D",t)}create(t){const e=new If(t);return this.viewport.scener.addObject(e,this.scene),e}createToGroup(t,e){const n=new ld(t);return e.forEach((t=>{const e=new If(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 If(t);n.add(e)})),this.viewport.scener.addObject(n,this.scene)),n}}class jy{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(t){if(!Fu(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 wu,this.queue.add(t,0),this.previous[t]=null;n=this.queue.shift();){if(n===e){const t=[];for(;Cu(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 Vy extends Nf{constructor(t){super("Topology",t),this.dijkstra=new jy}createFromGml(t){const{url:e,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255}=t;return Wf(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;Fu(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:Eu(n)?n:"",name:Eu(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 Ef(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 Ef(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 ld(t);return e.forEach((t=>{const e=this.generateLineTopologyInfoNodeGraphs(t);this.setDijkstraGraph(e.nodes);const r=new Ef(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 Ef(e);n.add(r)})),n}getShortestPath(t,e){const{nodes:n}=t.info,r=pu(e.start),i=pu(e.end);let s=null,a=1/0,o=null,l=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=pu(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 Ef(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=pu(t),s=pu(e.end);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=pu(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?pu(s.position).distanceTo(i):pu(s.position).distanceTo(pu(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(pu(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 Ft),rotation:(new _e).setFromQuaternion(t.getWorldQuaternion(new It)),scale:t.getWorldScale(new Ft)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Ef(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=pu(e.start),s=pu(t);let a=null,o=1/0,l=null,c=1/0;if(n.forEach((t=>{if(t.graphs.length>0){const e=pu(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?pu(s.position).distanceTo(i):pu(s.position).distanceTo(pu(a[a.length-1].position)),a.push(s))})),a.push({id:"endPoint",position:s,graphs:[]}),t+=s.distanceTo(pu(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 Ft),rotation:(new _e).setFromQuaternion(t.getWorldQuaternion(new It)),scale:t.getWorldScale(new Ft)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Ef(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||pu(n.position).distanceTo(pu(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:pu(t.nodes[e].position).distanceTo(pu(r.position)),restrict:0,passable:0}]}return t}}class Wy extends Nf{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 Yh(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 ou(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 ru(n,new en(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 sd(new hr(n,r),new nn({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 mc).load(e),u=new hr(r,i);u.computeBoundingBox();const d=new Ol({side:2,map:h,transparent:!0,opacity:s,roughness:.8});d.map&&(d.map.repeat.set(c.x,c.x),d.map.wrapS=f,d.map.wrapT=f,d.map.version++),o.x-=Math.PI/2,d.version++;const p=new Ff(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 Jh(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 Xh(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 Oh(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 Gh(n,i,r);return s.userData.sid=e,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}}class Xy extends Nf{constructor(t){super("PluginObject",t)}createObject(t,e){const n=new cd(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 Yy{constructor(t){this.viewport=t,this.needUpdate=!1,this.store={LightManager:new Of(t),sbmManager:new Yf(t),modelManager:new zy(t),poiManager:new ky(t),poiNodeManager:new Hy(t),canvas3DManager:new Gy(t),topologyManager:new Vy(t),helperManager:new Wy(t),pluginObjectManager:new Xy(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()}}return t.BaseMesh=sd,t.BaseObject3D=ad,t.Canvas3D=If,t.Circle=Tf,t.Ground=Ff,t.Group=ld,t.IVector3ToEuler=fu,t.IVector3ToVector3=pu,t.Icon=bf,t.Line=Cf,t.Link=Af,t.MinHeap=wu,t.Model=xf,t.Node=Sf,t.PluginObject=cd,t.Poi=wf,t.PoiNode=Id,t.Point=Mf,t.Polygon=Rf,t.Sbm=vf,t.SceneManage=od,t.Topology=Ef,t.default=class{constructor(t){this.THREE=uu,this.version=n,this.animation=id,this.library=Df,this.utils=Hu,this.plugins={};const{el:e,options:r={},events:i={}}=t;if(this.domElement=document.querySelector(e),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 mf(this.options),this.signals=this.viewport.signals,this.manager=new Yy(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${e}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(i),this._initDefaultLight()}_init(){const{showGrid:t,background:n,fog:r,controls:i,closeInfoLog:s,closeWarnLog:a,useIndexedDB:o}=this.options;if(!s){du(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),du(e,{color:"#3eaf7c","font-size":"24px"}),du(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),du("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),du("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),du("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?Eu(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):Du(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()}},t.deg2Euler=yu,t.euler2Deg=xu,t.getAsciiString=zu,t.getBoundingBox=mu,t.getCubeTexture=Mu,t.getSpaceAttributeFromObject=_u,t.hasOwn=Au,t.isArray=Fu,t.isBoolean=Pu,t.isDate=Iu,t.isFunction=Nu,t.isNull=Lu,t.isNumber=Cu,t.isObject=Du,t.isPromise=Ou,t.isString=Eu,t.isSymbol=Ru,t.log=du,t.parseSbmx=Su,t.rotationAFix=vu,t.rotationAxisFix=gu,t.sleep=Bu,t.syncSpaceAttributeToObject=bu,t.typeJudge=Uu,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
|